VMware Cloud Community
Jock8186
Enthusiast
Enthusiast

Change VM Port Group Assignment

Hey Guys. I pretty new to orchestrator. I have managed to put together a workflow which will clone from template, power on and customise the ip and join the domain. The problem I am having is that the templates are assigned to a specific VLAN and I will be looking for this workflow to assign to various other VLANs at the point of the clone completion.

Does anyone have scriptable task/workflow which will allow me to change the Network Label assignment for a specified VM??

Thanks

Reply
0 Kudos
1 Reply
Jock8186
Enthusiast
Enthusiast

UPDATE - I have managed to get the port group assignment to change as per script:

System.log("vm name =" + vm);

System.log("new VLAN Name" + newNetwork);   

   

    var existNetwork = existNetwork;

  var newNetwork = newNetwork;

  var vmspec = new VcVirtualMachineConfigSpec();

  var devicearr = new Array();

  var nic = new VcVirtualEthernetCardNetworkBackingInfo();

  nic.deviceName = newNetwork;

  var devicespec = new VcVirtualDeviceConfigSpec();

  var devices = vm.config.hardware.device;

  for( var i in devices){

  if(devices[i] instanceof VcVirtualE1000 || devices[i] instanceof VcVirtualPCNet32 || devices[i] instanceof VcVirtualVmxnet || devices[i] instanceof VcVirtualVmxnet2 || devices[i] instanceof VcVirtualVmxnet3) {

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

  System.log("devices.deviceInfo.summary: '"+devices[i].deviceInfo.summary+"'");

     devicespec.device = devices[i];

  devicespec.operation = VcVirtualDeviceConfigSpecOperation.edit;

  devicespec.device.backing = nic;

  devicearr[0] = devicespec;

     }

   }

  }

  vmspec.deviceChange = devicearr;

  task = vm.reconfigVM_Task(vmspec);

Problem I have now is the nic is being disconnected when the configuration change takes place. I'm sure its something fairly simple to run a cmd to check that "connect at power on" is selected. Any ideas???

Reply
0 Kudos