VM MAC Address Blocklist Management in vCenter Server
In my previous blog posts (here and here), I discussed the built-in mechanism for managing VM MAC addresses in vCenter Server, where the original VM has been migrated to a different vCenter Server using a VM MAC address blocklist. The blocklist is managed through private APIs, and the only way to find out what VM MAC addresses are currently in the list is by interactively using the vSphere MOB and the fetchRelocatedMACAddress API.
Recently, I had a question from a customer who was looking to clear the VM MAC address blocklist and was wondering if that was possible and whether there was an API to perform this operation. The good news is that not only is it possible to clear the blocklist, but there is also an API available to do so.
Clearing the VM MAC Address Blocklist
To clear the VM MAC address blocklist, we can use the reclaimMac private API. This API will reclaim all VM MAC addresses within the blocklist, and it is available through the vSphere MOB just like the fetchRelocatedMACAddress API. To demonstrate the retrieval of the VM MAC address blocklist and its clearing, I have created two scripts: fetch-vc-mac-address-blocklist-via-mob.ps1 and reclaim-vc-mac-address-blocklist-via-mob.ps1.
The first script, fetch-vc-mac-address-blocklist-via-mob.ps1, retrieves the VM MAC address blocklist from the vCenter Server. You will need to update three variables in the script with your vCenter Server FQDN/IP address and credentials. If no VMs have been migrated to another vCenter Server, the results will be empty.
The second script, reclaim-vc-mac-address-blocklist-via-mob.ps1, clears the VM MAC address blocklist on the vCenter Server. You will need to update the variables for your vCenter Server FQDN/IP address, credentials, and its Instance UUID. The easiest way to find your vCenter Server Instance UUID is to connect using PowerCLI and run the following snippet: $global:DefaultVIServer.ExtensionData.Content.About.InstanceUuid
To use these scripts, simply update the variables with your vCenter Server details, and then run the scripts in your PowerCLI environment.
Note that the reclaimMAC private API will remove all VM MAC address entries from the vCenter Server VM MAC address blocklist, so there is no way to reclaim a specific VM MAC address.
Conclusion
In this blog post, I have demonstrated how to manage the VM MAC address blocklist in vCenter Server, including how to retrieve the list of blocked VM MAC addresses and how to clear the blocklist using private APIs through the vSphere MOB. These scripts can be useful for automating the management of VM MAC addresses in your vCenter Server environment.