Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

Set vm network to a distributed port group

$
0
0

Trying to set the network for a VM to a distributed port group.  There doesn't appear to be an easy straight forward way to do this - does someone have a small snippet of code that does it?

 

I was thinking something like this (u_vm is a Vc:VirtualMachine)

 

 

var nic = new VcVirtualEthernetCardNetworkBackingInfo();

nic.deviceName = "dvpg-myportgroup";

var spec = new VcVirtualDeviceConfigSpec();

 

 

for each (var device in u_vm.config.hardware.device)

{

  if (device.deviceInfo.label == "Network adapter 1")

  {

  spec.device = device;

  spec.operation = VcVirtualDeviceConfigSpecOperation.edit;

  spec.device.backing = nic;

  }

}

 

 

u_vm.reconfigVM_Task(spec);

 

But that bombs out with this error:

[2015-06-23 13:20:42.303] [I] Cannot convert com.vmware.vim.vi4.VirtualDeviceConfigSpec@ffb8e5cd to com.vmware.vim.vi4.VirtualMachineConfigSpec (Workflow:meh / Scriptable task (item1)#17)


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>