Class: Capacity

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

Constant Summary collapse

TYPES =
{
	0 => "Memory",
	1 => "CPU",
	2 => "Storage",
	3 => "Storage Allocated",
	4 => "Public IP's",
	5 => "Private IP's",
	6 => "Secondary Storage",
	7 => "VLAN",
	8 => "Direct Attached Public IP's",
	9 => "Local Storage"
}

Instance Attribute Summary

Attributes inherited from CloudstackCli::Base

#config

Instance Method Summary collapse

Methods inherited from CloudstackCli::Base

exit_on_failure?

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'],
  	 	TYPES[c['type']],
  	 	c['capacityused'],
  	 	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