VMware {code} Community
sahmed24
Contributor
Contributor

how can i create linked clone while using vSphere web services sdk

Hi

i want to create linked clone using vSphere web services SDK. but i dont know how to do it. i found a documents (attached with this post) that explains it, according to the document i can create linked clone as below

-


relSpec = new VirtualMachineRelocateSpec()

relSpec.diskMoveType = VirtualMachineRelocateDiskMoveOptions.createNewChildDiskBacking

cloneSpec = new VirtualMachineCloneSpec()

cloneSpec.powerOn = False

cloneSpec.template = False

cloneSpec.location = relSpec

cloneSpec.snapshot = myVm.snapshot.currentSnapshot

myVm.Clone(myVm.parent, myVm.name + "-clone", cloneSpec)

-


but the problem is that i can not find VirtualMachineRelocateDiskMoveOptions Class in vSphere web services SDK 4.0

//Rizwan

Reply
0 Kudos
14 Replies
lamw
Community Manager
Community Manager

It's a property you need to set as part of CloneVM_Task - http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.CloneSpec.html

Within the VirtualMachineRelocateSpec, you'll set the diskMoveType as createNewChildDiskBacking as you've referenced from the VMware WP on Linked Clones with vSphere 4.0 API

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
sahmed24
Contributor
Contributor

i think i didnt make myself clear.

i want to say that in the vSphere web services sdk 4.0 i do not find anything VirtualMachineRelocateMoveOptions and diskMoveType. please see attached images i.e. image1 and image2. The property and the class doesnt show up in the menu.

r//Rizwa

Reply
0 Kudos
lamw
Community Manager
Community Manager

Unless there is a bug in there, this property value should exists. All the various SDKs out there are based on the vSphere API, if you have VMware support, you may want to file a support request to confirm this or if you're just missing something.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
sahmed24
Contributor
Contributor

i forgot to mention that i am using C# as the development environment, not Java. and i am currently using trial version of vSphere, but this all shouldnt have anything to do with this issue, i hope

What i need to do to create linked clone in C#

Reply
0 Kudos
stumpr
Virtuoso
Virtuoso

VirtualMachineRelocateDiskMoveOptions is just an enum.

That value was added in vSphere 4.0, any chance you are using an older WSDL file?

I do recall that if you were running unlicensed, there were some SDK features that were disabled. Or so I think I remember. I never run without a license, so I never verified it myself. However, this wouldn't stop you from seeing VirtualMachineRelocateDiskMoveOptions in your IDE. You'd just get a SoapFault with some SDK calls.

Reuben Stump | http://www.virtuin.com | @ReubenStump
Reply
0 Kudos
sahmed24
Contributor
Contributor

thanks Stumpr

i have attached the wsdl files i have. i am new to it. can you please verify that is the right file?

besides this could provide some clue too

namespace VimApi

{

...............

Generate Code "wsdl", "2.0.50727.42"

..............

public class VirtualMachineRelocateSpec : DynamicData

{

....................

}

}

Reply
0 Kudos
stumpr
Virtuoso
Virtuoso

I don't think you do have the right WSDL file, I couldn't find the * VirtualMachineRelocateDiskMoveOptions* string in the files you linked.

Download the latest SDK. For MS C# environment, you run the batch file. Make sure you set your WSDLFILE environment variable to the path of the latest SDK download after you unzip it.

It should just be \SDK\wsdl.

Unfortunately, I don't think there is anyway to really be sure your WSDL files are current by the file contents (unless you search on property strings you know are only in vSphere 4.0). The development team opted to keep the vim25 namespace when they went to vSphere 4.

I'm not really into MS/C#, so if anyone else has any good tips for checking the environment when building feel free to add to this thread.

Reuben Stump | http://www.virtuin.com | @ReubenStump
sahmed24
Contributor
Contributor

thanks Stumpr

i am using vsphere web services sdk 4 that was released on 29th May 2009. i download it from this location

http://www.vmware.com/support/developer/vc-sdk/

i am extracting it and running build2005 script as mentioned in the documentation

i have looked in to my wsdl file i.e. vim25.wsdl and it does contain VirtualMachineRelocateDiskMoveOptions. But when i look in to the object browser of the reference to Vim25Service2005.dll, i dont see VirtualMachineRelocateDiskMoveOptions there.

Reply
0 Kudos
stumpr
Virtuoso
Virtuoso

These are from the wsdl\vim25\ directory.

You can see the enum type in the file contents:

egrep -r "VirtualMachineRelocateDiskMoveOptions" ./
./vim25/vim.wsdl:         <simpleType name="VirtualMachineRelocateDiskMoveOptions">

Perhaps you are incorrectly using the wsdl\vim WSDL files?

Reuben Stump | http://www.virtuin.com | @ReubenStump
Reply
0 Kudos
sahmed24
Contributor
Contributor

the files you have sent me are exactly the same as mine. I am now clue less on this issue.

Can you please send me the dll files generated by build2005.cmd. May be i can use them directly.

Reply
0 Kudos
stumpr
Virtuoso
Virtuoso

Unfortunately I don't have a VIsual Studio environment ready at the moment. I'll see what I can get together to help.

Reuben Stump | http://www.virtuin.com | @ReubenStump
Reply
0 Kudos
sahmed24
Contributor
Contributor

would be a great favor since this issue is becoming very frustrating now

thanks in advance

Reply
0 Kudos
sahmed24
Contributor
Contributor

ok, i have found the way. i succeeded in creating the linked clone from the snapshot. though it failed when i did it from the current state.

Reply
0 Kudos
RenateKa
VMware Employee
VMware Employee

We also have a tech note about linked clones (renamed to linked virtual machines, sorry) here:

http://www.vmware.com/support/developer/vc-sdk/linked_vms_note.pdf

Reply
0 Kudos