Hi all,
Am trying to launch from a template, but i keep getting an error. Kindly see if you can help.
#########################################################################################
[root@localhost ansible_playbooks]# ruby193-ruby vsphere_template.rb
Connected to vsphere.internal as root (API version 4.1)
Deploying new VM from template. This may take a few minutes...
/opt/rh/ruby193/root/usr/share/gems/gems/rbvmomi-1.8.2/lib/rbvmomi/connection.rb:61:in `parse_response': InvalidRequest: (RbVmomi::Fault)
Required property key is missing from data object of type VirtualE1000
while parsing serialized DataObject of type vim.vm.device.VirtualE1000
at line 1, column 727
while parsing property "device" of static type VirtualDevice
while parsing serialized DataObject of type vim.vm.device.VirtualDeviceSpec
at line 1, column 651
while parsing property "deviceChange" of static type ArrayOfVirtualDeviceConfigSpec
while parsing serialized DataObject of type vim.vm.ConfigSpec
at line 1, column 562
while parsing property "config" of static type VirtualMachineConfigSpec
while parsing serialized DataObject of type vim.vm.CloneSpec
at line 1, column 314
while parsing call information for method CloneVM_Task
at line 1, column 177
while parsing SOAP body
at line 1, column 167
while parsing SOAP envelope
at line 1, column 0
while parsing HTTP request for method clone
on object of type vim.VirtualMachine
at line 1, column 0
from /opt/rh/ruby193/root/usr/share/gems/gems/rbvmomi-1.8.2/lib/rbvmomi/connection.rb:90:in `call'
from /opt/rh/ruby193/root/usr/share/gems/gems/rbvmomi-1.8.2/lib/rbvmomi/basic_types.rb:205:in `_call'
from /opt/rh/ruby193/root/usr/share/gems/gems/rbvmomi-1.8.2/lib/rbvmomi/basic_types.rb:74:in `block (2 levels) in init'
from /opt/rh/ruby193/root/usr/share/gems/gems/fog-1.29.0/lib/fog/vsphere/requests/compute/vm_clone.rb:251:in `vm_clone'
from vsphere_template.rb:41:in `<main>'
##############################################################
This is what my ruby code looks like:#!/usr/bin/ruby
require 'rubygems'
require 'fog'
require 'pp'
credentials = {
:provider => "vsphere",
:vsphere_username => "root",
:vsphere_password => "password",
:vsphere_server => "vsphere.internal",
:vsphere_ssl => "true",
:vsphere_expected_pubkey_hash => "<hash>"
}
connection = Fog::Compute.new(credentials)
puts "Connected to #{connection.vsphere_server} as #{connection.vsphere_username} (API version #{connection.vsphere_rev})"
options = {
'datacenter' => 'Datacenter',
'template_path' => ubuntu_14.04-v0.4',
'power_on' => true,
'memoryMB' => '1024',
'network_label' => 'Internal',
'numCPUs' => 2,
'datastore' => 'fra1esx02',
'wait' => true,
'hostname' => 'test2',
'name' => 'test2',
'customization_spec' => {
'domain' => '
example.com',
'ipsettings' => {
'ip' => '10.19.19.18',
'gateway' => ['10.1.1.1'],
'subnetMask' => '255.0.0.0',
},
},
}
puts "Deploying new VM from template. This may take a few minutes..."
new_vm=connection.vm_clone(options)
pp new_vm
###############################################