--- lib/PXElator/client.pm 2009/08/28 16:41:46 322 +++ lib/PXElator/client.pm 2009/08/28 18:51:43 323 @@ -111,7 +111,7 @@ my $mac_path = mac_path($mac); unlink $mac_path if -l $mac_path; # XXX audit? symlink ip_path($ip), $mac_path; - write_file ip_path($ip,'mac'), $mac; + write_file( ip_path($ip,'mac'), $mac ); } sub ip_from_mac($) { @@ -144,10 +144,12 @@ sub change_ip($$) { my ($old, $new) = @_; - my $mac = mac_from_ip($old); + return if $old eq $new; + my $mac = mac_from_ip($old) || die "no mac for $old"; rename ip_path($old), ip_path($new); unlink mac_path($mac); symlink ip_path($new), mac_path($mac); + return $new; } sub all_ips { @@ -159,4 +161,13 @@ } glob("$server::conf/ip/*") } +sub remove { + my $ip = shift; + unlink $_ foreach grep { -e $_ } ( glob "$server::conf/ip/$ip/*" ); + if ( my $mac = mac_from_ip $ip ) { + unlink "$server::conf/mac/$mac"; + } + rmdir "$server::conf/ip/$ip"; +} + 1;