Class: Chef::Knife::Cloud::VcenterHostList
- Inherits:
-
ResourceListCommand
- Object
- ResourceListCommand
- Chef::Knife::Cloud::VcenterHostList
- Includes:
- VcenterServiceOptions
- Defined in:
- lib/chef/knife/vcenter_host_list.rb
Overview
Extends the ResourceListcommand for specific vCenter
Instance Method Summary collapse
-
#before_exec_command ⇒ Object
Sets up the columns for listing out and sorts by name.
-
#format_power_status(status) ⇒ Object
Formats the power status.
-
#query_resource ⇒ Object
Call service to get the list of hosts from vCenter.
Methods included from VcenterServiceOptions
Instance Method Details
#before_exec_command ⇒ Object
Sets up the columns for listing out and sorts by name
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/chef/knife/vcenter_host_list.rb', line 43 def before_exec_command @columns_with_info = [ { label: "ID", key: "host" }, { label: "Name", key: "name" }, { label: "Power State", key: "power_state", value_callback: method(:format_power_status) }, { label: "Connection State", key: "connection_state" }, ] @sort_by_field = "name" end |
#format_power_status(status) ⇒ Object
Formats the power status
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/chef/knife/vcenter_host_list.rb', line 63 def format_power_status(status) status_color = case status when "POWERED_OFF" :red when "POWERED_ON" :green when "SUSPENDED" :yellow end ui.color(status, status_color) end |
#query_resource ⇒ Object
Call service to get the list of hosts from vCenter
56 57 58 |
# File 'lib/chef/knife/vcenter_host_list.rb', line 56 def query_resource service.list_hosts end |