Class: Capacity
- Inherits:
-
CloudstackCli::Base
- Object
- Thor
- CloudstackCli::Base
- Capacity
- 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
Instance Method Summary collapse
Methods inherited from CloudstackCli::Base
Methods included from CloudstackCli::OptionResolver
#resolve_account, #resolve_cluster, #resolve_compute_offering, #resolve_disk_offering, #resolve_domain, #resolve_host, #resolve_ip_network_list, #resolve_iso, #resolve_iso_for_vm_deployment, #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, #pf_rule_to_object, #print_job_status, #print_options, #run_background_jobs, #update_job_status, #update_jobs, #watch_jobs
Methods inherited from Thor
banner, basename2, old_subcommand, subcommand
Instance Method Details
#list ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cloudstack-cli/commands/capacity.rb', line 19 def list resolve_zone resolve_cluster capacities = client.list_capacity() table = [] header = ["Zone", "Type", "Capacity Used", "Capacity Total", "Used"] header[0] = "Cluster" if [:cluster_id] capacities.each do |c| if CAPACITY_TYPES.include? c['type'] table << [ c['clustername'] || c['zonename'], CAPACITY_TYPES[c['type']][:name], capacity_to_s(c, 'capacityused'), capacity_to_s(c, 'capacitytotal'), "#{c['percentused']}%" ] end end table = table.sort {|a, b| [a[0], a[1]] <=> [b[0], b[1]]} print_table table.insert(0, header) end |
#types ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/cloudstack-cli/commands/capacity.rb', line 42 def types table = [['type', 'name']] CAPACITY_TYPES.each_pair do |type, data| table << [type, data[:name]] end print_table table end |