VMware {code} Community
fredoenglish
Contributor
Contributor
Jump to solution

Change Virtual Machine DistributedVirtualPortgroup

Hello,

I would like to change the VC :DistributedVirtualPortgroup of a VcVirtualVmxnet3 card already created on a VM. We can consider that there’s only one NIC card on the VM.

I’ve scripted the following using the DeviceBackingInfo.

IN-paramter : VC:VirtualMachine (vm)

macAddresses = new Array();
var deviceArray = vm.config.hardware.device;
if (!deviceArray) throw "Error getting hardware config array of VM";
    System.debug("deviceArray: " + deviceArray);
for (var i in deviceArray) {
    var currentDevice = deviceArray.pop();
    if (currentDevice) {
        if (currentDevice instanceof VcVirtualVmxnet3) {
                System.debug("found network card on " + currentDevice);
System.debug("PortGroup " + currentDevice.backing.port.portGroupKey);
        }
    }
}

Log :

[D] found network card on DynamicWrapper (Instance) : [VcVirtualVmxnet3]-[class com.vmware.vim.vi4.VirtualVmxnet3]

-- VALUE : com.vmware.vim.vi4.VirtualVmxnet3@fac8f915

[D] PortGroup : dvportgroup-42367

42367 is correct, it’s the actual dvport Id… How could I change this value on adding an in-parameter "VC:DistributedVirtualPortGroup" set with the correct DvPort.


In advance, thank you for your help.

Regards,


Fred

0 Kudos
1 Solution

Accepted Solutions
robrtb12
Enthusiast
Enthusiast
Jump to solution

Take a look at this thread, it helped me when needing to change to a DV Portgroup.

http://communities.vmware.com/message/1731492

View solution in original post

0 Kudos
2 Replies
robrtb12
Enthusiast
Enthusiast
Jump to solution

Take a look at this thread, it helped me when needing to change to a DV Portgroup.

http://communities.vmware.com/message/1731492

0 Kudos
fredoenglish
Contributor
Contributor
Jump to solution

Thank you...! I've founded the answer in the package.

Regards,

Fred

0 Kudos