vRealize Orchestrator : Find network card by MAC

0 Flares Filament.io 0 Flares ×

In this post I’ll focus mostly on code for creating simple vRO action to find a virtual machine network card by its MAC address. A use case for me was to set and IP address on VM with multiple network cards or delete a network card with specific MAC address. So instead of creating a new workflow I decided to create an action.

As input for the action I’m gonna take :

  • virtual machine of type VC:VirtualMachine
  • macAddress of type string

Output from action will be type “Any” as on screenshot below

The code of action goes like that.

As you can see it’s a simple loop on all devices and if it finds backing which is not NULL and of type VcVirtualEthernetCardNetworkBackingInfo and MAC address matches provided MAC address, action is finished and object is returned.

In the code I’ve made some limitations and assumtions :

  • I’m not checking if MAC address is correct, but it can be simply done with regex
  • I’m finishing the search when first network card with the provided MAC address is found, however it’s possible that someone has created more than one network card with same MAC – stupid but still possible 🙂

I hope this simple code will be helpful for you. In one of future post I’ll show you how to use this action to create a vRO workflow to remove network card with specific MAC address.

0 Flares LinkedIn 0 Google+ 0 Facebook 0 Twitter 0 Filament.io 0 Flares ×

Leave a Reply

Your email address will not be published. Required fields are marked *