VMware {code} Community
Ashwin89
Contributor
Contributor

clonevm_task() issue

I am trying to clone the virtual machine in a particular ESX server.

  • Can I use this API for both the virtual center as well as ESX server?

I am trying for ESX server and I am getting error as : "The operation is not supported on the object".

ManagedObjectReference hostComputeResMoref = (ManagedObjectReference)vmUtils._GetPropFromMoref(hostMoref, "parent");

ManagedObjectReference HostFolderMoref = (ManagedObjectReference)vmUtils._GetPropFromMoref(hostComputeResMoref, "parent");

ManagedObjectReference dcmor = (ManagedObjectReference)vmUtils._GetPropFromMoref(HostFolderMoref,parent");

ManagedObjectReference vmFoldermore = (ManagedObjectReference)vmUtils._GetPropFromMoref(dcmor, "vmFolder");

ManagedObjectReference rp = (ManagedObjectReference)vmUtils._GetPropFromMoref(hostComputeResMoref, "resourcePool");

ManagedObjectReference vmMoref = GetMorefFromVMName(vmName);

ManagedObjectReference dsMoref = GetDatastoreMoref("NETAPP_FC", "");

VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec();

VirtualMachineRelocateSpec relocateSpec = new VirtualMachineRelocateSpec();

relocateSpec.datastore = dsMoref;

relocateSpec.pool = rp;

relocateSpec.host = hostMoref;

cloneSpec.location = relocateSpec;

cloneSpec.powerOn = false;

cloneSpec.template = false;

ManagedObjectReference taskRef = mconnection.Service.CloneVMTask(vmMoref, vmFoldermore, "clone_vm", cloneSpec);

Can someone help on this?

-AsHwIN

0 Kudos
3 Replies
rkamal
VMware Employee
VMware Employee

Templates, cloning and migrations (VMotion

Migration and Cold Migration) are features of VMware

VirtualCenter. Therefore, if you are connected directly to an ESX host,

these features are unavailable.

http://kb.vmware.com/kb/1004000

Rajesh Kamal

0 Kudos
storm27
Enthusiast
Enthusiast

Hi Ashwin,

You can also verify which direct operations are possible on a managed object by connecting directly to an ESX host through VI Client. This helps to compare the possible operations available when we directly connect to a VC or an ESX host.

-Angela

0 Kudos
helpmeforvmware
Contributor
Contributor

hi ashwin you can check which methods are allowed and which method are not by viewing Managed Object Browser.

You can see by typing following in your browser,

https://your-esx/i-ip/mob

There is one property in VirtualMachine called disabledMethod Propertied in MOB which will tell you about disabled method, which you can not implement directly on VM.

Whe you type above as URL in browser you will get a page where you can traverse through all VM on partucular host.

clieck follwing in MOB,

content->ha-folder-root->ha-datacenter->ha-folder-vm,

here you will get vm id in childEntity property, just select any child and see the disabledMethod property for that VM.

0 Kudos