VMware {code} Community
fherbert
Contributor
Contributor

Label ignored for vmxnet3 virtualdevice

I'm trying to set the label for a vmxnet3 virtual device, the information is passed to vsphere, but vsphere ignores the label (customlabel) and just calls the network interface 'Network Adapter 1'.

Data passed to Vsphere (Using Fog.io):

(vim.vm.device.VirtualDeviceSpec) {

-->             dynamicType = <unset>,

-->             operation = "add",

-->             fileOperation = <unset>,

-->             device = (vim.vm.device.VirtualVmxnet3) {

-->                dynamicType = <unset>,

-->                key = 0,

-->                deviceInfo = (vim.Description) {

-->                   dynamicType = <unset>,

-->                   label = "customlabel",

-->                   summary = "VM Network",

-->                },

-->                backing = (vim.vm.device.VirtualEthernetCard.DistributedVirtualPortBackingInfo) {

-->                   dynamicType = <unset>,

-->                   port = (vim.dvs.PortConnection) {

-->                      dynamicType = <unset>,

-->                      switchUuid = "be 0c 1a 50 3a 62 17 09-ba a4 0a 88 ad a6 96 a0",

-->                      portgroupKey = "dvportgroup-87",

-->                      portKey = <unset>,

-->                      connectionCookie = <unset>,

-->                   },

-->                },

-->                connectable = (vim.vm.device.VirtualDevice.ConnectInfo) null,

-->                slotInfo = (vim.vm.device.VirtualDevice.BusSlotInfo) null,

-->                controllerKey = <unset>,

-->                unitNumber = <unset>,

-->                addressType = "generated",

-->                macAddress = <unset>,

-->                wakeOnLanEnabled = <unset>,

-->                resourceAllocation = (vim.vm.device.VirtualEthernetCard.ResourceAllocation) null,

-->             },

-->          },

But when I read the device info back it comes back as 'Network Adapter 1'.

Is it possible to set a label on a network adapter?

0 Kudos
3 Replies
stumpr
Virtuoso
Virtuoso

Don't think so, that ties into the device label in vSphere.  What's your ultimate goal?  There are other places you can store arbitrary values if you need to provide some custom strings.

Reuben Stump | http://www.virtuin.com | @ReubenStump
fherbert
Contributor
Contributor

I'm using a third party tool (theforeman) to create vm's. The mapping of the interfaces used to occur based on network name but since we started using distrubted port groups in vsphere, the network now returns as the portgroup name instead of the network name. So we need to find another way of identifying the interface (since we don't know the mac address when it's initially created).

What other fields are available to add custom labels to?

0 Kudos
stumpr
Virtuoso
Virtuoso

You'll need to tap the API twice to get what you want when working with DVPGs.  You can get the backing.port (which is the DVPG key), then look that up in the DVPG list to get the network name.

Basically you need logic to check the backing type:

VirtualEthernetCardNetworkBackingInfo = standard switch portgroup

VirtualEthernetCardDistributedVirtualPortBackingInfo = distributed virtual portgroup

If it's a DVPG backing, then you need to cross-reference it with the DVPG object based on the key property.  I usually pre-load all the DVPGs into a dictionary or hash, get the backing.port key value (if it's a DVPG) and then loop through the DVPG dictionary until the key matches.  From there you can get the DVPG display name (as seen in the vCenter UI).

If your tooling is using the deviceInfo (Description) field as a way to track VM->networking mapping, then that tooling will need to be updated. 

Reuben Stump | http://www.virtuin.com | @ReubenStump