VMware Cloud Community
shekhar_puranik
Contributor
Contributor
Jump to solution

Code to get mac address and network lable for multiple network card in VM using VRO

My VM has multiple NIC and I want to fetch details by having network label and Mac address for each network card of VM

Eg.

Network Adapter 1 : 00:50:63:aa:0C:01

Network Adapter 2 : 00:50:63:aa:24:D5

Network Adapter 3 : 00:50:63:aa:3F:23

All this is to be fetched using VRO and VM properties vm.config.hardware.device

1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Try this:

var modnet = System.getModule("com.vmware.library.vc.vm.network");

for each (var device in vm.config.hardware.device) {

    if (!modnet.isSupportedNic(device)) {

        // device is not a network card; skip it

        continue;

    }

    System.log("Label: '" + device.deviceInfo.label + "'   MAC Address: " + device.macAddress);

}

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.

View solution in original post

2 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Try this:

var modnet = System.getModule("com.vmware.library.vc.vm.network");

for each (var device in vm.config.hardware.device) {

    if (!modnet.isSupportedNic(device)) {

        // device is not a network card; skip it

        continue;

    }

    System.log("Label: '" + device.deviceInfo.label + "'   MAC Address: " + device.macAddress);

}

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.

shekhar_puranik
Contributor
Contributor
Jump to solution

Smiley Happy

Appreciate it !!!

Thanks for your input. it was really helpful.

Reply
0 Kudos