I am using the SDK and VIJava with Jruby to access a vCenter and trying to create a VM in a ResourcePool.
It is failing with "The operation is not supported on the object". The vCenter logs show "[2011-02-15 11:30:00.991 01880 error 'App' opID=270500b0] [VpxdVAppUtil] Cannot create a vm inside a resource pool with no folder."
But I'm not quite sure how to set the folder. On what object do I set this?
My code is as follows:
nicInfo.setSummary("VLAN_700")
nic.setDeviceInfo(nicInfo)
nic.setAddressType("generated")
nic.setBacking(nicBacking)
nic.setKey(0)
nicSpec.setDevice(nic)
vdcsarray = Vim::VirtualMachineConfigSpec.new
shitty = Array[scsiSpec, diskSpec, nicSpec]
vmspec.setDeviceChange(shitty)
vmfi = Vim::VirtualMachineFileInfo.new
vmfi.setVmPathName("[aligntempvol]")
vmspec.setFiles(vmfi)
qarp.create_child_vm_task(vmspec, nil)
si.getServerConnection().logout()
I should say that this code is adapted from Steve Jin's very good "VMware VI and vSphere SDK" book.
Hi Complex,
Thanks for supporting my book VMware VI and vSphere SDK!
According to the API reference of create_child_vm_task() method on ResourcePool type, "This method supports creating a virtual machine directly in a vApp. A virtual machine in a vApp is not associated with a VM folder and therefore cannot be created using the method on a Folder. This method can only be called directly on a vApp or on a resource pool that is a child of a vApp."
Now back to your code, I think qarp is a top ResourcePool, not a child ResoucePool of a vApp. You may want to change your code accordingly.
Hope it helps.
Steve Jin (http://www.doublecloud.org)
You are correct, the qarp Resource Pool is at the root of a cluster, not in a vApp. OK, I understand that. However, in my Windows VI Client I can right-click on this Resource Pool and create a VM. Is there a way to accomplish the same thing using vijava/jruby?
When you right-click on a ResourcePool to create a VM, though, the first thing it asks for you is a Folder. I don't know this for sure, but I suspect it's calling the Folder method CreateVM_Task, just as if you'd right-clicked on a Folder to create the VM (though there the wizard would prompt you for a resource pool).
Since you have a folder (vmfolder), why not call that method (dunno what the Ruby name is), passing qarp as the pool argument?
Ah, Steve, you are correct. I should have examined the documentation closer to see the vApp restrictions on the ResourcePool object.
And Ben, your plan of attack seems sound. Yes, in Ruby they are called methods. I will attack the problem by specifying the Folder and then CreateVM_Task on that object.
Thanks to you both.