hi experts,
These days I want to write a workflow in VCO to auto change port group of NIC.(AS attachment pic shows)
For two given VM: SampleVM and DestVM. If they are in different port groups, I want to allocate DestVM to the port group of SampleVM automatically through workflow.
Scripts can be seen as follows:
var SampleDevs = SampleVM.config.Hardware.Device;
var DestDevs = DestVM.config.Hardware.Device;
var SampleNic = null;
var DestNic = null;
for (var i in SampleDevs)
{
if( SampleDevs[i].deviceInfo.Label == "Network adapter 1" )
SampleNic = SampleDevs[i]; //return sampleVM's network adapter
}
for (var i in DestDevs)
{
if( DestDevs[i].deviceInfo.Label == "Network adapter 1" )
DestNic = DestDevs[i]; //return DestVM's network adapter
}
var spec = new VcVirtualMachineConfigSpec();
//spec.changeVersion = DestVM.config.changeVersion;
spec.Version = DestVM.config.Version;
var nicDev = new VcVirtualDeviceConfigSpec();
nicDev.operation = "edit";
nicDev.device = DestNic;
nicDev.device.backing = SampleNic.backing;
nicDev.device.deviceInfo.summary = SampleNic.deviceInfo.sumarry;
spec.deviceChange += nivDev;
But it can not work. Who can tell me how to modify the script? Thanks sincerely.
Martin Ding from EMC
I have not tried your code - which part is not working? The connection to the distributed virtual portgroup? Rather than coding the connection yourself, have you looked at the library action "connectVmNicNumberToVirtualDistributedPortgroup" - this action is called by a library workflow Connect virtual machine NIC number to distributed virtual port group. Once you've determined the destination portgroup and the destination VM NIC number, this action can be used to connect the vm to that portgroup.
Perfect
Thanks