Method: DiskOffer#list

Defined in:
lib/cloudstack-cli/commands/disk_offer.rb

#listObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cloudstack-cli/commands/disk_offer.rb', line 9

def list
  resolve_domain
  add_filters_to_options("listDiskOfferings") if options[:filter]
  offerings = client.list_disk_offerings(options)
  offerings = filter_objects(offerings) if options[:filter]
  if offerings.size < 1
    puts "No offerings found."
  else
    case options[:format].to_sym
    when :yaml
      puts({disk_offers: offerings}.to_yaml)
    when :json
      puts JSON.pretty_generate(disk_offers: offerings)
    else
      table = [["Name", "Displaytext", "Domain", "ID"]]
      offerings.each do |offering|
        table << [
          offering["name"],
          offering["displaytext"],
          offering["domain"],
          offering["id"]
        ]
      end
      print_table table
      say "Total number of offerings: #{offerings.size}"
    end
  end
end