Class: Chef::Knife::CloudstackServiceofferingList

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

Instance Method Summary collapse

Methods included from CloudstackBase

#connection, included, #locate_config_value, #msg_pair, #validate!

Instance Method Details

#runObject



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
# File 'lib/chef/knife/cloudstack_serviceoffering_list.rb', line 29

def run
  $stdout.sync = true

  validate!

  serviceoffering_list = [
    ui.color('ID', :bold),
    ui.color('Name', :bold),
    ui.color('Description', :bold),
    ui.color('Number of CPUs', :bold),
    ui.color('CPU Speed', :bold),
    ui.color('Memory (in MB)', :bold),
    ui.color('Network Speed', :bold)
  ]
  response = connection.list_service_offerings['listserviceofferingsresponse']
    if serviceofferings = response['serviceoffering']
      serviceofferings.each do |serviceoffering|
        serviceoffering_list << serviceoffering['id'].to_s
        serviceoffering_list << serviceoffering['name'].to_s
        serviceoffering_list << serviceoffering['displaytext'].to_s
        serviceoffering_list << serviceoffering['cpunumber'].to_s
        serviceoffering_list << serviceoffering['cpuspeed'].to_s
        serviceoffering_list << serviceoffering['memory'].to_s
        serviceoffering_list << serviceoffering['networkrate'].to_s
      end
    end
  puts ui.list(serviceoffering_list, :uneven_columns_across, 7)

end