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?, start

Methods included from CloudstackCli::OptionResolver

#resolve_account, #resolve_compute_offering, #resolve_disk_offering, #resolve_domain, #resolve_host, #resolve_iso, #resolve_networks, #resolve_project, #resolve_snapshot, #resolve_template, #resolve_virtual_machine, #resolve_zone, #vm_options_to_params

Methods included from CloudstackCli::Helper

#ask_number, #bootstrap_server, #bootstrap_server_interactive, #create_port_rules, #create_server, #get_server_default_nic, #get_server_fqdn, #get_server_public_ip, #get_ssh_port_forwarding_rule, #print_job_status, #print_options, #run_background_jobs, #update_job_status, #update_jobs, #watch_jobs

Instance Method Details

#listObject



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

def list
  resolve_zone if options[:zone]
  capacities = client.list_capacity(options)
  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

#typesObject



37
38
39
40
41
42
43
# File 'lib/cloudstack-cli/commands/capacity.rb', line 37

def types
  table = [['type', 'name']]
  CAPACITY_TYPES.each_pair do |type, data|
    table << [type, data[:name]]
  end
  print_table table
end