Class: Chef::Knife::CloudstackDiskofferingList

Inherits:
Chef::Knife
  • Object
show all
Includes:
CloudstackBase
Defined in:
lib/chef/knife/cloudstack_diskoffering_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
# File 'lib/chef/knife/cloudstack_diskoffering_list.rb', line 29

def run
  $stdout.sync = true

  validate!

  diskoffering_list = [
    ui.color('ID', :bold),
    ui.color('Name', :bold),
    ui.color('Description', :bold),
    ui.color('Disk Size (in GB)', :bold)
  ]
  response = connection.list_disk_offerings['listdiskofferingsresponse']
    if diskofferings = response['diskoffering']
      diskofferings.each do |diskoffering|
        diskoffering_list << diskoffering['id'].to_s
        diskoffering_list << diskoffering['name'].to_s
        diskoffering_list << diskoffering['displaytext'].to_s
        disk_size = diskoffering['disksize']
        diskoffering_list << disk_size.to_s

      end
    end
  puts ui.list(diskoffering_list, :columns_across, 4)

end