Class: Chef::Knife::Cloud::VcenterClusterList

Inherits:
ResourceListCommand
  • Object
show all
Includes:
VcenterServiceHelpers, VcenterServiceOptions
Defined in:
lib/chef/knife/vcenter_cluster_list.rb

Overview

Extends ResourceListcommand to talk to vCenter

Instance Method Summary collapse

Methods included from VcenterServiceOptions

included

Methods included from VcenterServiceHelpers

#check_for_missing_config_values!, #create_service_instance, #validate!, #verify_ssl?

Instance Method Details

#before_exec_commandObject

Creates the columns and how to sort the columns



38
39
40
41
42
43
44
45
46
47
# File 'lib/chef/knife/vcenter_cluster_list.rb', line 38

def before_exec_command
  @columns_with_info = [
    { label: "ID",    key: "cluster" },
    { label: "Name",  key: "name" },
    { label: "DRS?", key: "drs_enabled", value_callback: method(:format_boolean) },
    { label: "HA?", key: "ha_enabled", value_callback: method(:format_boolean) },
  ]

  @sort_by_field = "name"
end

#format_boolean(status) ⇒ Object

How to set the color of the text



57
58
59
60
# File 'lib/chef/knife/vcenter_cluster_list.rb', line 57

def format_boolean(status)
  status_color = status ? :green : :red
  ui.color(status ? "True" : "False", status_color)
end

#query_resourceObject

Call service to get the list of hosts from vcenter



51
52
53
# File 'lib/chef/knife/vcenter_cluster_list.rb', line 51

def query_resource
  service.list_clusters
end