Class: KnifeCloudstack::CsZoneList

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

Instance Method Summary collapse

Instance Method Details

#locate_config_value(key) ⇒ Object



72
73
74
75
# File 'lib/chef/knife/cs_zone_list.rb', line 72

def locate_config_value(key)
  key = key.to_sym
  Chef::Config[:knife][key] || config[key]
end

#runObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/chef/knife/cs_zone_list.rb', line 48

def run

  connection = CloudstackClient::Connection.new(
      locate_config_value(:cloudstack_url),
      locate_config_value(:cloudstack_api_key),
      locate_config_value(:cloudstack_secret_key)
  )

  zone_list = [
      ui.color('Name', :bold),
      ui.color('Network Type', :bold),
      ui.color('Security Groups', :bold)
  ]

  zones = connection.list_zones
  zones.each do |z|
    zone_list << z['name']
    zone_list << z['networktype']
    zone_list << z['securitygroupsenabled'].to_s
  end
  puts ui.list(zone_list, :columns_across, 3)

end