lib/cloudstack-cli/commands/capacity.rb in cloudstack-cli-0.4.0 vs lib/cloudstack-cli/commands/capacity.rb in cloudstack-cli-0.4.1

- old
+ new

@@ -12,12 +12,13 @@ 9 => {name: "Local Storage", unit: "TB", divider: 1024.0**4} } desc "capacity list", "list system capacity" option :zone + option :type, desc: "specify type, see types for a list of types" def list - capacities = client.list_capacity + capacities = client.list_capacity(options) table = [] header = ["Zone", "Type", "Capacity Used", "Capacity Total", "Used"] capacities.each do |c| table << [ c['zonename'], @@ -29,17 +30,26 @@ end table = table.sort {|a, b| [a[0], a[1]] <=> [b[0], b[1]]}.insert(0, header) print_table table end + desc "capacity types", "show capacity types" + def types + table = [['type', 'name']] + CAPACITY_TYPES.each_pair do |type, data| + table << [type, data[:name]] + end + print_table table + end + no_commands do def capacity_to_s(capacity, entity) value = CAPACITY_TYPES[capacity['type']][:divider] ? (capacity[entity] / CAPACITY_TYPES[capacity['type']][:divider]).round(1) : capacity[entity] CAPACITY_TYPES[capacity['type']][:unit] ? - "#{value}#{CAPACITY_TYPES[capacity['type']][:unit]}" : + "#{value} #{CAPACITY_TYPES[capacity['type']][:unit]}" : value.to_s end end \ No newline at end of file