When I try to create a vm using VC:HostFolder.createVM_Task() I get an error "The operation is not supported on the object". I've only been successful when using VC:VmFolder.createVM_Task(). Can anyone confirm using the methods on the host folder of other folder types works from vRO? All the canned examples also always use a VmFolder for the task creation. I have a situation where VmFolders are not always specified so I'd like to simply deploy to the host. I'd like to at least know this works for someone else out there before I spend too many more hours troubleshooting the issue.
Paul.
As Ilian mentioned, this is by design (not vRO, but vCenter). Every VM needs to be placed in a VmFolder (shown in the "VMs and Templates" view in vCenter).
If you don't have an explicit folder structure for the VM folders, you can pick the "root" one of a datacenter.
datacenter.vmFolder gives you that, it's always named "vm", and this one is not visible in the vSphere Client.
If you just have a HostSystem (or any other managed Entity btw.), use the com.vmware.library.vc.basic.getDataCenterForVimObject Action of the vCenter Library to the the datacenter its in.
Regards,
Joerg
Hi Paul,
Excerpt from Folder documentation at https://code.vmware.com/apis/358/vsphere#/doc/vim.Folder.html#createVm
This operation only works if the folder's childType includes VirtualMachine
Also, here is the documentation for the childType property that shows how to check if you can create a vm inside a given folder:
Specifies the object types a folder may contain. When you create a folder, it inherits its childType from the parent folder in which it is created. childType is an array of strings. Each array entry identifies a set of object types - Folder and one or more managed object types. The following list shows childType values for the different folders:
As Ilian mentioned, this is by design (not vRO, but vCenter). Every VM needs to be placed in a VmFolder (shown in the "VMs and Templates" view in vCenter).
If you don't have an explicit folder structure for the VM folders, you can pick the "root" one of a datacenter.
datacenter.vmFolder gives you that, it's always named "vm", and this one is not visible in the vSphere Client.
If you just have a HostSystem (or any other managed Entity btw.), use the com.vmware.library.vc.basic.getDataCenterForVimObject Action of the vCenter Library to the the datacenter its in.
Regards,
Joerg
Thanks! That all makes sense and I'll traverse to the root folder to create the vm. Why does this method exist then VC:HostFolder.createVM_Task() . I would expect it to just select the root folder on its own maybe? Or does this work if the host is not in a cluster?