Class: Chef::Knife::NcServerList
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::NcServerList
- Includes:
- NcBase
- Defined in:
- lib/chef/knife/nc_server_list.rb
Instance Method Summary collapse
Methods included from NcBase
#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 68 69 70 71 |
# File 'lib/chef/knife/nc_server_list.rb', line 29 def run $stdout.sync = true validate! server_list = [ ui.color('Instance ID', :bold), ui.color('Public IP', :bold), ui.color('Private IP', :bold), ui.color('Flavor', :bold), ui.color('Image', :bold), ui.color('SSH Key', :bold), ui.color('Security Group', :bold), ui.color('State', :bold) ] set = connection.describe_instances.reservationSet if set set.item.each do |instance| server = instance.instancesSet.item.first group = instance.groupSet server_list << server.instanceId server_list << server.ipAddress.to_s server_list << server.privateIpAddress.to_s server_list << server.instanceType server_list << server.imageId server_list << server.keyName server_list << (group ? group.item.first.groupId : '') server_list << begin state = server.instanceState.name case state when 'sotopped', 'warning', 'waiting', 'creating', 'suspending', 'uploading', 'import_error' ui.color(state, :red) when 'pending' ui.color(state, :yellow) else ui.color(state, :green) end end end end puts ui.list(server_list, :columns_across, 8) end |