--- lib/PXElator/client.pm 2009/08/10 00:07:38 190 +++ lib/PXElator/client.pm 2009/08/10 17:30:01 194 @@ -71,4 +71,30 @@ } +sub ip_from_mac { + my $mac = shift; + + $mac = lc $mac; + $mac =~ s{:}{}g; + + my $mac_path = "$server::conf/mac/$mac"; + return unless -e $mac_path; + + my $ip; + + if ( -f $mac_path ) { + $ip = read_file $mac_path; + unlink $mac_path; + symlink "$server::conf/ip/$ip", $mac_path; + warn "I: upgrade to mac symlink $mac_path\n"; + } elsif ( -l $mac_path ) { + $ip = readlink $mac_path; + $ip =~ s{^.+/([^/]+)$}{$1}; + } else { + die "$mac_path not file or symlink"; + } + + return $ip; +} + 1;