Class: Capacity

Inherits:
CloudstackCli::Base show all
Defined in:
lib/cloudstack-cli/commands/capacity.rb

Constant Summary collapse

CAPACITY_TYPES =
{
  0 => {name: "Memory", unit: "GB", divider: 1024.0**3},
  1 => {name: "CPU", unit: "GHz", divider: 1000.0},
  2 => {name: "Storage", unit: "TB", divider: 1024.0**4},
  3 => {name: "Primary Storage", unit: "TB", divider: 1024.0**4},
  4 => {name: "Public IP's"},
  5 => {name: "Private IP's"},
  6 => {name: "Secondary Storage", unit: "TB", divider: 1024.0**4},
  7 => {name: "VLAN"},
  8 => {name: "Direct Attached Public IP's"},
  9 => {name: "Local Storage", unit: "TB", divider: 1024.0**4}
}

Constants included from CloudstackCli::Helper

CloudstackCli::Helper::ASYNC_STATES

Instance Attribute Summary

Attributes inherited from CloudstackCli::Base

#config

Instance Method Summary collapse

Methods inherited from CloudstackCli::Base

exit_on_failure?

Methods included from CloudstackCli::Helper

#ask_number, #bootstrap_server, #bootstrap_server_interactive, #create_port_rules, #create_server, #print_job_status, #print_options, #update_job_status, #watch_jobs

Instance Method Details

#listObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cloudstack-cli/commands/capacity.rb', line 17

def list
  capacities = client.list_capacity
  table = []
  header = ["Zone", "Type", "Capacity Used", "Capacity Total", "Used"]
  capacities.each do |c|
    table << [
      c['zonename'],
       CAPACITY_TYPES[c['type']][:name],
       capacity_to_s(c, 'capacityused'),
       capacity_to_s(c, 'capacitytotal'),
       "#{c['percentused']}%"
    ]
  end
  table = table.sort {|a, b|  [a[0], a[1]] <=> [b[0], b[1]]}.insert(0, header)
  print_table table
end