Sha256: 7028546e85596291ee5bec2a7306e0395eb023dd3ce0517e896a26c86555e70a
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
class SystemVm < CloudstackCli::Base desc 'list', 'list system VMs' option :zone, desc: "the name of the availability zone" option :state, desc: "state of the system VM" option :type, desc: "the system VM type.", enum: %w(consoleproxy secondarystoragevm) def list vms = client.list_system_vms(options) if vms.size < 1 say "No system VM's found." else table = [%w(Name Zone State Type)] vms.each do |vm| table << [ vm['name'], vm['zonename'], vm['state'], vm['systemvmtype'] ] end print_table table say "Total number of system VM's: #{vms.size}" end end desc 'show NAME', 'show system VM' def show(name) vms = client.list_system_vms unless vm = filter_by(vms, 'name', name).first 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 desc "start NAME", "start a system VM" def start(name) vms = client.list_system_vms unless vm = filter_by(vms, 'name', name).first say "No system vm with name #{name} found." else say("Starting system VM #{name}", :magenta) client.start_system_vm(vm['id']) puts end end desc "stop NAME", "stop a system VM" def stop(name) vms = client.list_system_vms(options) unless vm = filter_by(vms, 'name', name).first say "No system vm with name #{name} found." else exit unless options[:force] || yes?("Stop system VM #{name}? [y/N]:", :magenta) client.stop_system_vm(vm['id']) puts end end desc "reboot NAME", "reboot a system VM" def reboot(name) vms = client.list_system_vms(options) unless vm = filter_by(vms, 'name', name).first say "No system vm with name #{name} found." else exit unless options[:force] || yes?("Reboot system VM #{name}? [y/N]:", :magenta) client.reboot_system_vm(vm['id']) puts end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cloudstack-cli-0.15.1 | lib/cloudstack-cli/commands/system_vm.rb |
cloudstack-cli-0.15.0 | lib/cloudstack-cli/commands/system_vm.rb |