Class: Chef::Knife::HpServerList
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::HpServerList
- Includes:
- HpBase
- Defined in:
- lib/chef/knife/hp_server_list.rb
Instance Method Summary collapse
Methods included from HpBase
#connection, included, #locate_config_value, #msg_pair, #validate!
Instance Method Details
#run ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/chef/knife/hp_server_list.rb', line 29 def run $stdout.sync = true validate! server_list = [ ui.color('Instance ID', :bold), ui.color('Name', :bold), ui.color('Public IP', :bold), ui.color('Private IP', :bold), ui.color('Flavor', :bold), ui.color('Image', :bold), ui.color('Key Pair', :bold), ui.color('State', :bold) ] connection.servers.all.sort_by(&:id).each do |server| Chef::Log.debug("Server: #{server.to_yaml}") server_list << server.id.to_s server_list << server.name server_list << (server.public_ip_address or "") server_list << (server.private_ip_address or "") server_list << server.flavor['id'].to_s server_list << server.image['id'].to_s server_list << (server.key_name or "") server_list << begin state = server.state.to_s.downcase case state when 'shutting-down','terminated','stopping','stopped','active(deleting)','build(deleting)' ui.color(state, :red) when 'pending','build(scheduling)','build(spawning)','build(networking)' ui.color(state, :yellow) else ui.color(state, :green) end end end puts ui.list(server_list, :uneven_columns_across, 8) end |