class Chef::Knife::Cloud::VcenterClusterList
Extends ResourceListcommand to talk to vCenter
Public Instance Methods
before_exec_command()
click to toggle source
Creates the columns and how to sort the columns
# File lib/chef/knife/vcenter_cluster_list.rb, line 41 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)
click to toggle source
How to set the color of the text
# File lib/chef/knife/vcenter_cluster_list.rb, line 60 def format_boolean(status) status_color = status ? :green : :red ui.color(status ? "True" : "False", status_color) end
query_resource()
click to toggle source
Call service to get the list of hosts from vcenter
# File lib/chef/knife/vcenter_cluster_list.rb, line 54 def query_resource service.list_clusters end