Class: Chef::Knife::XenserverVmPoweroff
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::XenserverVmPoweroff
- Includes:
- XenserverBase
- Defined in:
- lib/chef/knife/xenserver_vm_poweroff.rb
Instance Method Summary collapse
Methods included from XenserverBase
#bytes_to_megabytes, #connection, included, #locate_config_value
Instance Method Details
#run ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/chef/knife/xenserver_vm_poweroff.rb', line 36 def run powered_off = [] connection.servers.each do |vm| @name_args.each do |vm_name| if (vm_name == vm.name) or (vm_name == vm.uuid) confirm("Do you really want to #{'poweroff'.bold.red} this virtual machine #{vm.name.bold.red}") if config[:hard] vm.stop 'hard' else vm.stop 'clean' end powered_off << vm_name ui.info("#{'Powered off'.yellow} virtual machine #{vm.name.yellow} [uuid: #{vm.uuid}]") end end end @name_args.each do |vm_name| ui.warn "Virtual Machine #{vm_name} not found" if not powered_off.include?(vm_name) end end |