Created
October 4, 2018 08:10
Star
You must be signed in to star a gist
VMWare vCenter network adapter name detection fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace the function in
/usr/lib/vmware-vpx/imgcust/linux/imgcust-scripts/Customization.pm
or inC:\Program Files\VMware\vCenter Server\vpxd\imgcust\linux\imgcust-scripts\Customization.pm
Based on vmware/open-vm-tools#130 (comment)