class SystemVm

Public Instance Methods

list() click to toggle source
   # File lib/cloudstack-cli/commands/system_vm.rb
10 def list
11   resolve_zone
12   vms = client.list_system_vms(options)
13   if vms.size < 1
14     say "No system VM's found."
15   else
16     case options[:format].to_sym
17     when :yaml
18       puts({system_vms: vms}.to_yaml)
19     when :json
20       puts JSON.pretty_generate(system_vms: vms)
21     else
22       table = [%w(Name Zone State Type)]
23       vms.each do |vm|
24         table << [
25           vm['name'], vm['zonename'], vm['state'], vm['systemvmtype']
26         ]
27       end
28       print_table table
29       say "Total number of system VM's: #{vms.size}"
30     end
31   end
32 end
reboot(name) click to toggle source
   # File lib/cloudstack-cli/commands/system_vm.rb
69 def reboot(name)
70   unless vm = client.list_system_vms(name: name).first
71     say "No system vm with name #{name} found."
72   else
73     exit unless options[:force] || yes?("Reboot system VM #{name}? [y/N]:", :magenta)
74     client.reboot_system_vm(id: vm['id'])
75     say " OK.", :green
76   end
77 end
show(name) click to toggle source
   # File lib/cloudstack-cli/commands/system_vm.rb
35 def show(name)
36   unless vm = client.list_system_vms(name: name).first
37     say "No system vm with name #{name} found."
38   else
39     table = vm.map do |key, value|
40       [ set_color("#{key}:", :yellow), "#{value}" ]
41     end
42     print_table table
43   end
44 end
start(name) click to toggle source
   # File lib/cloudstack-cli/commands/system_vm.rb
47 def start(name)
48   unless vm = client.list_system_vms(name: name).first
49     say "No system vm with name #{name} found."
50   else
51     say("Starting system VM #{name}", :magenta)
52     client.start_system_vm(id: vm['id'])
53     say " OK.", :green
54   end
55 end
stop(name) click to toggle source
   # File lib/cloudstack-cli/commands/system_vm.rb
58 def stop(name)
59   unless vm = client.list_system_vms(name: name).first
60     say "No system vm with name #{name} found."
61   else
62     exit unless options[:force] || yes?("Stop system VM #{name}? [y/N]:", :magenta)
63     client.stop_system_vm(id: vm['id'])
64     say " OK.", :green
65   end
66 end