VMware {code} Community
jrhodes
Contributor
Contributor
Jump to solution

specifying the vmpath for cloning a VM with the SDK vmClone sample

Does anyone know the syntax on how the vmpath should be passed.

I have tried many of the examples:

--vmpath datacenter/folder/vmname

I can not get theis to work

0 Kudos
1 Solution

Accepted Solutions
Steve_Jin
Expert
Expert
Jump to solution

Hi Jim,

It should be "Princeton/vm/VM/vm1". The vm inside the string is a little tricky.

The managed object browser is the best tool to find out the inventory path to a specific managed entity. To get it, just point it using a browser with the following url:

https://<target_name_or_ip_address>/mob

-Steve

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org

View solution in original post

0 Kudos
5 Replies
Steve_Jin
Expert
Expert
Jump to solution

The vmpath parameter is used by the SearchIndex to locate the virtual machine as shown in the code:

ManagedObjectReference vmRef

= S1.getService().findByInventoryPath(content.getSearchIndex(), vmPath);

Now the question becomes what format is expected by the findByInventoryPath(). According to the API reference, it should be:

"My Folder/My Datacenter/vm/Discovered VM/VM1"

Not quite clear yet. Let me to give it a try here:

"[My Folder]/<My Datacenter>/vm/[Discovered VM]/<VM1>"

A string in ESX server would be. The winxp is your virtual machine name and you can change to your virtual machine name. The rest of the path is fixed on ESX server.

"ha-datacenter/vm/winxp"

Things are different at VirtualCenter path. To find out more, just try the ManagedObject Browser.

Note: the vmpath is the path in the system, not the path you see in the VI Client.

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
jrhodes
Contributor
Contributor
Jump to solution

Thanks Steve. I am still a little confused though.

If my datacenter nme is: "Princeton" a I have a VM named "vm1" in a folder called "VM".

Would it be something like" VM/Princeton/VM/vm1

Where would I find the exact path?

We are not tlaking about the ESX server path to where the files reside on the VMFS volume are we?

Thanks

Jim

0 Kudos
Steve_Jin
Expert
Expert
Jump to solution

Hi Jim,

It should be "Princeton/vm/VM/vm1". The vm inside the string is a little tricky.

The managed object browser is the best tool to find out the inventory path to a specific managed entity. To get it, just point it using a browser with the following url:

https://<target_name_or_ip_address>/mob

-Steve

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
0 Kudos
jrhodes
Contributor
Contributor
Jump to solution

Thanks Steve!!!!

That was it!

Now I understand at little better.

If it were a host I was referencing it would have looked something like:

Princeton/hosts/cluster1/host1

Thanks for your help, and especially the quick responses!

Jim

0 Kudos
agnihotrit
Contributor
Contributor
Jump to solution

way of passing vmpath in java sample to clone a virtual machine will be as shown below-

datacenter/vmfolder/vm1

where-

datacenter is datacenter name.

vmfolder is virtual machine folder name.

vm1 is name of the virtual machine to be cloned.

0 Kudos