Class: Chef::Knife::SoftlayerGlobalIpList

Inherits:
Chef::Knife
  • Object
show all
Includes:
SoftlayerBase
Defined in:
lib/chef/knife/softlayer_global_ip_list.rb

Constant Summary

Constants included from SoftlayerBase

Chef::Knife::SoftlayerBase::USER_AGENT

Instance Method Summary collapse

Methods included from SoftlayerBase

#compute, #connection, included, #locate_config_value, #msg_pair, #network

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/chef/knife/softlayer_global_ip_list.rb', line 18

def run
  $stdout.sync = true

  if connection(:network).get_global_ip_records.body.empty?
    puts ui.color("No global ip addresses found.", :green)
  else
    puts ui.color("This operation can take several minutes.  ", :yellow)
    table_data = connection(:network).ips.map do |ip|
      {:address => ip.address, :destination => ip.destination_ip.respond_to?(:address) ? ip.destination_ip.address : 'NOT ROUTED'} if ip.global?
    end.compact
    puts Formatador.display_table(table_data, [:address, :destination])
  end
end