VMware Cloud Community
WinStime
Enthusiast
Enthusiast
Jump to solution

How to change a dvportgroup for a VM with vRO ?

Hi everybody,

I'm looking for a way to change a network binding for VM.

After a cluster migration done with vRO, i want to change the backing to map dvportgroup on the new cluster in the new datacenter (so another VDS)

I am able to change a network with standard switch, but not with vDS.

I can retrieve the portgroup, but how to assign to existing ethernet adapter ?

Here is the script for standard switch :

var existNetwork = eth1.name

var newNetwork = neweth1.name

var vmspec = new VcVirtualMachineConfigSpec();

var device = new VcVirtualPCNet32();

var devicearr = new Array();

var nic = new VcVirtualEthernetCardNetworkBackingInfo();

nic.deviceName = newNetwork;

var devicespec = new VcVirtualDeviceConfigSpec();

var devices = host.config.hardware.device;

for( var i in devices)

{

System.log("dans la boucle")

    if(devices[i] instanceof VcVirtualPCNet32)

        {

        System.log("liste device pcnet")

            if (devices[i].deviceInfo.summary == existNetwork)

            {

            System.log("trouvé")

                devicespec.device = devices[i];

                devicespec.operation = VcVirtualDeviceConfigSpecOperation.edit;

                devicespec.device.backing = nic;

                devicearr[0] = devicespec;

            }

        }

}

vmspec.deviceChange = devicearr;

task = host.reconfigVM_Task(vmspec);

Reply
0 Kudos
1 Solution

Accepted Solutions
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Here is an action I threw together a long time ago... just hacked the standard connection action.

View solution in original post

Reply
0 Kudos
1 Reply
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Here is an action I threw together a long time ago... just hacked the standard connection action.

Reply
0 Kudos