pomattic
Contributor
Contributor

Thanks for the response.

I am still extremely lost and confused. : (

My inventory (as in the Inventory->Datatstores view in the Virtual Infrastructure client) looks like such:

| Datastores

|-> folderName

|--> datastore1

|--> datastore2

Now when I click on a datastore (all have same structure) I see a hierarchy like this:

| /

|->myVirtualMachineFolder

|--> baseMachines

|---> machineBase

|--> liveMachines

|---> machineLive1

|---> machineLive2

When I look at the childEntities of rootFolder I only have "folderName" as a child.

What I want to be able to do is clone say "\[datastore1\] myVirtualMachineFolder/baseMachines/machineBase" to "\[datastore2\] myVirtualMachineFolder/liveMachines/machineLive3"

So this is what I have:

VirtualMachineCloneSpec vmcs = new VirtualMachineCloneSpec();

VirtualMachineRelocateSpec vmrs = new VirtualMachineRelocateSpec();

vmrs.setDatastore(dataStore); //mor to datastore

vmcs.setLocation(vmrs);

vmcs.setPowerOn(false);

vmcs.setTemplate(false);

ManagedObjectReference ref = connexion.cloneVM_Task(baseRef, vmFolder, clone, vmcs);

// vmFolder is a ref to the rootFolder

// clone is a String for clone name

// baseRef is mor to base machine

Do I want the Folder to be something else? I am confused as to what this folder is used for. (Ref says "The location of the new virtual machine." but how deep is that?)

My use of the VirtualMachineRelocateSpec is wrong. I am not sure which values are needed...

I have a sketchy method of getting the HostSystem, but cannot seem to find any way to get a ResourcePool (well I can get this info for a VM that already exists (what Pool it belongs to), but I do not want to relly on that)

What I really need to get working is to clone from a datastore to another datastore, the folder thing can be left on the back burner till that works.

Any further help in these areas would be greatly appreciated.

M@

Message was edited by: pomattic (added: "(well I can get this info for a VM that already exists (what Pool it belongs to), but I do not want to relly on that)")

Reply
0 Kudos