Class: Knifecosmic::CosmicHosts

Inherits:
Chef::Knife show all
Includes:
Chef::Knife::KnifecosmicBase, Chef::Knife::KnifecosmicBaseList
Defined in:
lib/chef/knife/cosmic_hosts.rb

Constant Summary collapse

MEGABYTES =
1024 * 1024

Instance Method Summary collapse

Methods included from Chef::Knife::KnifecosmicBaseList

included, #list_object, #list_object_fields, #output_format

Methods included from Chef::Knife::KnifecosmicBase

included

Instance Method Details

#runObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/chef/knife/cosmic_hosts.rb', line 38

def run
  validate_base_options

  host_list = [
      ui.color('#Public IP', :bold),
      ui.color('Host', :bold),
      ui.color('FQDN', :bold)
  ]

  servers = connection.list_servers
  pf_rules = connection.list_port_forwarding_rules
  servers.each do |s|
    host_list << (connection.get_server_public_ip(s, pf_rules) || '#')
    host_list << (s['name'] || '')
    host_list << (connection.get_server_fqdn(s) || '')
  end
  puts ui.list(host_list, :columns_across, 3)

end