VMware {code} Community
sahmed24
Contributor
Contributor

What is the "DatacenterName" and "vmPath" in VCenter

Hi

i am using VSphere SDK 4. i want to use CloneVM_Task() in VMCLone Class in Sample projects. I am unable to understand two arguments i.e. "DatacenterName" and "vmPath". i have attached the image of my VCenter. can somebody please tell me the values of those two arguments in my attached image context.

//Rizwan

0 Kudos
7 Replies
admin
Immortal
Immortal

Hi Rizwan,

In the screenshot shared by you, the datacenter name would be the name of the datacenter in your vCenter Server which would be "CZDC001".

Regarding the vmPath parameter, it is the inventory path to the VM. By default, every datacenter has a vmFolder with name "vm" under which all the virtual machines exists. You can pass this inventory path as "CZDC001/vm/WinXP".

I hope this answers your query.

Cheers,

Angela

sahmed24
Contributor
Contributor

Hi

i got the datacenter name right, but i cant get vmPath right. i have tried what you mentioned i.e. "CZDC001/vm/WinXP". but this doesnt work, however i can get the refrerence to the machine by using this method FindByDatastorePath( xxx, xxx, "[datastore1] WinXP/WinXP.vmx")

i have attached another image to show my datastores. Can you please help me further in getting "vmPath" right.

//Rizwan

0 Kudos
admin
Immortal
Immortal

If you are getting the reference of the VM using findByDatastorePath API, then you can proceed further with the CloneVM_Task API.

However, I would like to share that the inventory path of the VM can be crosschecked using the findByInventoryPath API. The path would be:

Now, you can verify your datacenter and vm name using the MOB and verifying the name property of the datacenter and VM, if it is the same. You can directly invoke the findByInventoryPath API using MOB as well.

I have tried and I am successfully able to retrieve the VM reference.

I would suggest you to crosscheck if you are passing the right name, verifying the same using Managed object browser.

sahmed24
Contributor
Contributor

I can go forward using FindByDatastorePath but i think in longer run inventory path will be easy to use.

"datacenter/vm/vmname" works for some images and for some it doesnt, strange, i dont know why

0 Kudos
admin
Immortal
Immortal

It might be possible that for some VMs, for which you unable to retrieve the reference, the VM(s) are containing inside another vm folder, which is created inside "vm" vmFolder. You can crosscheck the same using the MOB to verify in which folder the VM exists.

sahmed24
Contributor
Contributor

thanks AngelaS

after a bit of browsing in MOB, i found the machine i was looking for.

But there is another way to find the inventory path of the machines.

1. Login to VSphere Client,

2. go to Home

3. go to VMs and Templates

4. browse folder and find the virtual machine,

5. the inventory path would be DataCenter/vm/folder structure inside DataCenter e.g. if the path in the inventory is DataCenter/folder1/folder2/machine, then it the inventory path would be DataCenter/vm/folder1/folder2/machine

0 Kudos
albecool
Contributor
Contributor

The folder names are case-sensitive

0 Kudos