51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/chef/knife/cs_hosts.rb', line 51
def run
connection = CloudstackClient::Connection.new(
locate_config_value(:cloudstack_url),
locate_config_value(:cloudstack_api_key),
locate_config_value(:cloudstack_secret_key)
)
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
|