Class: ResourceLimit

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

Constant Summary collapse

RESOURCE_TYPES =
{
  0  => {name: "Instances"},
  1  => {name: "IP Addresses"},
  2  => {name: "Volumes"},
  3  => {name: "Snapshots"},
  4  => {name: "Templates"},
  5  => {name: "Projects"},
  6  => {name: "Networks"},
  7  => {name: "VPC's"},
  8  => {name: "CPU's"},
  9  => {name: "Memory", unit: "GB", divider: 1024.0},
  10 => {name: "Primary Storage", unit: "TB", divider: 1024.0},
  11 => {name: "Secondary Storage", unit: "TB", divider: 1024.0}
}

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



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cloudstack-cli/commands/resource_limit.rb', line 21

def list
  limits = client.list_resource_limits(options)
  table = []
  header = options[:project] ? ["Project"] : ["Account"]
  header += ["Type", "Resource Name", "Max"]
  limits.each do |limit|
    limit['resourcetype'] = limit['resourcetype'].to_i
    table << [
      options[:project] ? limit['project'] : limit['account'],
      limit['resourcetype'],
      RESOURCE_TYPES[limit['resourcetype']][:name],
      resource_to_s(limit, 'max')
    ]
  end
  table = table.insert(0, header)
  print_table table
end

#typesObject



40
41
42
43
44
45
46
# File 'lib/cloudstack-cli/commands/resource_limit.rb', line 40

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