class VMWizard::MagicWand
Attributes
dhcp_host[R]
esx_host[R]
Public Class Methods
new(esx_host, dhcp_host)
click to toggle source
# File lib/esxmagicwand.rb, line 22 def initialize(esx_host, dhcp_host) @esx_host = esx_host @dhcp_host = dhcp_host end
Public Instance Methods
deploy(vm, datastore)
click to toggle source
# File lib/esxmagicwand.rb, line 27 def deploy(vm, datastore) vm = @esx_host.create_vm( :vm_name => vm.name, :datastore => datastore, :disk_type => :thin, :disk_size => vm.disk_size, :memory => vm.ram, :cpus => vm.cpus, :guest_id => vm.guest, :nics => vm.nics ) return vm end
undeploy(vm_name)
click to toggle source
# File lib/esxmagicwand.rb, line 42 def undeploy(vm_name) vm = nil esx_host.virtual_machines.each do |x| if x.name == vm_name vm = x break end end if not vm raise "VM with name #{vm_name} not found" end if vm.power_state == "poweredOn" vm.power_off end vm.destroy end