Skip to content

Instantly share code, notes, and snippets.

@styblope
Created October 4, 2018 08:10
Show Gist options
  • Save styblope/a6c57f8f071d3ce32477fc3b7758655a to your computer and use it in GitHub Desktop.
Save styblope/a6c57f8f071d3ce32477fc3b7758655a to your computer and use it in GitHub Desktop.
VMWare vCenter network adapter name detection fix
sub GetInterfaceByMacAddress
{
# This function is same as GetInterfaceByMacAddress but uses
# '/sbin/ip addr show' instead of/sbin/ifconfig
my ($self, $macAddress, $ipAddrResult) = @_;
my $result = undef;
if (! defined $ipAddrResult) {
my $ipPath = Utils::GetIpPath();
if ( defined $ipPath){
$ipAddrResult = Utils::ExecuteCommand("$ipPath addr show");
} else {
WARN("Path to 'ip addr' not found.");
}
}
my $macAddressValid = ($macAddress =~ /^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i);
if ($macAddressValid && ($ipAddrResult =~
/^\d+:\s([^\s.:]+):\s[^\n]+[^\n]+\s+link\/\w+\s+$macAddress/mi)) {
$result = $1;
}
return $result;
}
@styblope
Copy link
Author

styblope commented Oct 4, 2018

Replace the function in /usr/lib/vmware-vpx/imgcust/linux/imgcust-scripts/Customization.pm or in C:\Program Files\VMware\vCenter Server\vpxd\imgcust\linux\imgcust-scripts\Customization.pm

Based on vmware/open-vm-tools#130 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment