VMware Cloud Community
FTVDaniel
Contributor
Contributor

modify standard portgroup of a vm network card

Hello,

I have a dificulty trying to modify the portgroup affected to a network card after having created a VM

in my workflow I have firstable created a network card,  the card type is created according to the OS type using the action createVirtualEthernetCardNetworkConfigSpec (the nic type is given by a configuration element attribute linked to the OS to deploy

after I need to reaffect the network card to the production network portgroup but that is very difficult cause when I get the device it does not tells me if it is type vmxnet3 or E1000 or something else

as I can see I need to do a reconfiguration of all network parameters not only "backing.network"

is the only solution to do a "case select" to get the device type of the existing card?

or is there a best way to have this information from the device itself?

or is it possible to reuse the deviceConfigSpec variable (result of the createVirtualEthernetCardNetworkConfigSpec action to reconfigure the network card? (I am on the same workflow )

I hope my question is clear Smiley Happy

thanks

Reply
0 Kudos
3 Replies
FTVDaniel
Contributor
Contributor

I have found a simple way to do this by affecting the device informations to the ni spec

nicChangeSpec.device = device

and it seems to work but I am not sure that this methode is sure

cause one information for example is a bad information

the device.deviceInfo.summary is still the old portgroup name

var devices = vm.config.hardware.device;

var spec = new VcVirtualMachineConfigSpec();

var myDeviceChange = new Array();

for each (device in devices){

  if (device.backing instanceof VcVirtualEthernetCardNetworkBackingInfo){

  System.log(device.deviceInfo.summary);

  var nicChangeSpec = new VcVirtualDeviceConfigSpec();

  nicChangeSpec.operation = VcVirtualDeviceConfigSpecOperation.edit;

  nicChangeSpec.device = device

  nicChangeSpec.device.backing.deviceName = reseaudest.name;

  myDeviceChange.push(nicChangeSpec);

  }

  }

spec.deviceChange = myDeviceChange;

vm.reconfigVM_Task(spec);

var devices = vm.config.hardware.device;

for each (device in devices){

  if (device.backing instanceof VcVirtualEthernetCardNetworkBackingInfo){

  System.log(device.deviceInfo.summary);

  }

}

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

vm.reconfigVM_Task() returns a task object that you can use to monitor the operation. Perhaps this operation takes some time to fully complete and then your queries will return an up-to-date information, but in your scripting code you don't wait for task to complete.

Reply
0 Kudos
FTVDaniel
Contributor
Contributor

thanks for this  suggestion

I haded the line

before to read the device.deviceInfo.summary value and it is still the old vlan name

System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,true,1) ;

no matter as it seems to be only an information and I can change it too

but I would like to check all parameters of the new device object

is it possible to export this final object to xml or json to be able to control all of  his properties ?

or is it possible to log all the device properties without having to know the property name?

Reply
0 Kudos