Class: Chef::Knife::XenserverVmPoweron

Inherits:
Chef::Knife show all
Includes:
XenserverBase
Defined in:
lib/chef/knife/xenserver_vm_poweron.rb

Instance Method Summary collapse

Methods included from XenserverBase

#bytes_to_megabytes, #connection, included, #locate_config_value

Instance Method Details

#runObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/chef/knife/xenserver_vm_poweron.rb', line 29

def run
  powered_on = []
  connection.servers.each do |vm|
    @name_args.each do |vm_name|
      if (vm_name == vm.name) or (vm_name == vm.uuid)
        vm.start
        powered_on << vm_name
        ui.info("#{'Powered on'.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_on.include?(vm_name)
  end
end