Sha256: 99c7df12ca878fe6c388fb8fd1a62cf9604260ee68ca536344c59f41a4fdd62a
Contents?: true
Size: 1.93 KB
Versions: 27
Compression:
Stored size: 1.93 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 resolve_zone 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) unless vm = client.list_system_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) unless vm = client.list_system_vms(name: name).first say "No system vm with name #{name} found." else say("Starting system VM #{name}", :magenta) client.start_system_vm(id: vm['id']) say " OK.", :green end end desc "stop NAME", "stop a system VM" def stop(name) unless vm = client.list_system_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(id: vm['id']) say " OK.", :green end end desc "reboot NAME", "reboot a system VM" def reboot(name) unless vm = client.list_system_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(id: vm['id']) say " OK.", :green end end end
Version data entries
27 entries across 27 versions & 1 rubygems