VMware

This Question is Answered

1 "correct" answer available (10 pts) 1 "helpful" answer available (6 pts)
6 Replies Last post: Nov 5, 2009 7:33 AM by DroppedAtBirth  

Setup Network/Vlan during CloneVM in .net posted: Nov 3, 2009 1:53 PM

Click to view DroppedAtBirth's profile Enthusiast 47 posts since
Jul 15, 2008
I currently have a process to clone a vm but can't seem to find a way to set the Network/Vlan on the network adapter at the time it is cloned. Have found a few partial examples of it being done after a clone is complete, but would prefer it to be done all in one step if possible. If anyone has a .net example or can point me in the write direction i would be greatly appricated.
Click to view lamw's profile Champion 2,803 posts since
Nov 27, 2007
This can definitely be done in 1 step during the clone process, when you clone a VM, you're making a call to CloneVM_Task which accepts a clone spec, all you need to do is get a reference to the network device and from there specify the network in which you want to connect to and set that in the configuration spec. This clone spec allows you to change pretty much any of the settings prior to the clone and you can take a look at this vSphere SDK for Perl to give you an idea on how: updateVMPortgroup.pl

=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
VMware Code Central - Scripts/Sample code for Developers and Administrators
VMware Developer Comuunity
Getting Started with the vMA (tips/tricks)
Getting Started with the vSphere SDK for Perl
Twitter: @lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

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

Click to view lamw's profile Champion 2,803 posts since
Nov 27, 2007
Have you tried looking in code central for some sample code? VMware Code Central

=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
VMware Code Central - Scripts/Sample code for Developers and Administrators
VMware Developer Comuunity
Getting Started with the vMA (tips/tricks)
Getting Started with the vSphere SDK for Perl
Twitter: @lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

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

Re: Setup Network/Vlan during CloneVM in .net

4. Nov 4, 2009 10:20 AM in response to: DroppedAtBirth
Click to view AngelaS's profile Enthusiast 43 posts since
Sep 28, 2009

Are you trying to change the network link for an existing virtual nic?

If you are trying to do the above, thenbelow steps might be helpful for you:

1. Create a virtualdeviceconfigspec data object and assign the device property of this object to the virtual device of which you are trying to change the virtual nic. You can retreive the required network device from the vm.config.hardware.device property which consists an array of virtual devices.

2. In VirtualDeviceConfigSpecOperation, you need to use edit operation as you are trying to change the network.

3. Set the the device.backing property of the VirtualDeviceConfigSpec to the type of backing you want to use, like , VirtualEthernetCardNetworkBackingInfo nic = new VirtualEthernetCardNetworkBackingInfo()

and set the deviceName property of this nic to the name of the network to which you want to connect your device to.

4. Pass this virtualdeviceconfigspec in the deviceChange property of virtualmachineconfigspec.

Developer Social Media

Communities