lib/esx.rb in esx-0.2 vs lib/esx.rb in esx-0.2.1
- old
+ new
@@ -4,11 +4,11 @@
require 'net/scp'
require 'net/ssh'
module ESX
- VERSION = '0.2'
+ VERSION = '0.2.1'
class Host
attr_reader :address, :user, :password
@@ -122,20 +122,11 @@
:busNumber => 0,
:sharedBus => :noSharing)
},
{
:operation => :add,
- :device => RbVmomi::VIM.VirtualE1000(
- :key => 0,
- :deviceInfo => {
- :label => 'Network Adapter 1',
- :summary => 'VM Network'
- },
- :backing => RbVmomi::VIM.VirtualEthernetCardNetworkBackingInfo(
- :deviceName => 'VM Network'
- ),
- :addressType => 'generated')
+ :device => RbVmomi::VIM.VirtualE1000(create_net_dev(specification))
}
],
:extraConfig => [
{
:key => 'bios.bootOrder',
@@ -146,9 +137,29 @@
vm_cfg[:deviceChange].push(create_disk_spec(:disk_file => spec[:disk_file],
:disk_type => spec[:disk_type],
:disk_size => spec[:disk_size],
:datastore => spec[:datastore]))
VM.wrap(@_datacenter.vmFolder.CreateVM_Task(:config => vm_cfg, :pool => @_datacenter.hostFolder.children.first.resourcePool).wait_for_completion)
+ end
+
+ def create_net_dev(spec)
+ h = {
+ :key => 0,
+ :deviceInfo => {
+ :label => 'Network Adapter 1',
+ :summary => 'VM Network'
+ },
+ :backing => RbVmomi::VIM.VirtualEthernetCardNetworkBackingInfo(
+ :deviceName => 'VM Network'
+ )
+ }
+ if spec[:mac_address]
+ h[:macAddress] = spec[:mac_address]
+ h[:addressType] = 'manual'
+ else
+ h[:addressType] = 'generated'
+ end
+ h
end
# Return product info as an array of strings containing
#
# fullName, apiType, apiVersion, osType, productLineId, vendor, version