Class: SystemVm

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

Constant Summary

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



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cloudstack-cli/commands/system_vm.rb', line 5

def list
  vms = client.list_system_vms(options)
  if vms.size < 1
    say "No system vms found."
  else
    table = [["Zone", "State", "Type", "Name"]]
    vms.each do |vm|
      table << [
        vm['zonename'], vm['state'], vm['systemvmtype'], vm['name']
      ]
    end
    print_table table
    say "Total number of system vms: #{vms.size}"
  end
end

#show(name) ⇒ Object



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

def show(name)
  vms = client.list_system_vms(options)
  vms = filter_by(vms, 'name', name)
  vm = vms.first
  unless vm
    say "No system vm with name #{name} found."
  else
    table = vm.map do |key, value|
      [ set_color("#{key}:", :yellow), "#{value}" ]
    end
    print_table table
  end
end