handling multiple IP/mac addresses for a hostname
Opened this issue · 0 comments
da- commented
A host may have multiple ipv4addrs() - and each may have a MAC address - following is simple code to turn them into a comma-separated list stored in $ipv4addr and $mac:
return unless defined($obj_host->ipv4addrs());
my @ipv4addrs = @{ $obj_host->ipv4addrs() };
foreach my $ip (@ipv4addrs) {
my $iptype = blessed($ip) || "";
if ( $iptype eq 'Infoblox::DHCP::FixedAddr') {
$ipv4addr .= ($ip->ipv4addr()) . ',';
$mac .= $ip->mac . ',';
} else {
$ipv4addr .= $ip . ',';
}
}
chop $ipv4addr;
chop $mac;
Code from "my $iptype" onward through the end of the loop was lifted directly from jbg's exportHostnamesNetworks.pl