/[pxelator]/lib/PXElator/client.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/client.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 322 by dpavlin, Fri Aug 28 16:41:46 2009 UTC revision 323 by dpavlin, Fri Aug 28 18:51:43 2009 UTC
# Line 111  sub save_ip_mac { Line 111  sub save_ip_mac {
111          my $mac_path = mac_path($mac);          my $mac_path = mac_path($mac);
112          unlink $mac_path if -l $mac_path;       # XXX audit?          unlink $mac_path if -l $mac_path;       # XXX audit?
113          symlink ip_path($ip), $mac_path;          symlink ip_path($ip), $mac_path;
114          write_file ip_path($ip,'mac'), $mac;          write_file( ip_path($ip,'mac'), $mac );
115  }  }
116    
117  sub ip_from_mac($) {  sub ip_from_mac($) {
# Line 144  sub mac_from_ip($) { Line 144  sub mac_from_ip($) {
144    
145  sub change_ip($$) {  sub change_ip($$) {
146          my ($old, $new) = @_;          my ($old, $new) = @_;
147          my $mac = mac_from_ip($old);          return if $old eq $new;
148            my $mac = mac_from_ip($old) || die "no mac for $old";
149          rename ip_path($old), ip_path($new);          rename ip_path($old), ip_path($new);
150          unlink mac_path($mac);          unlink mac_path($mac);
151          symlink ip_path($new), mac_path($mac);          symlink ip_path($new), mac_path($mac);
152            return $new;
153  }  }
154    
155  sub all_ips {  sub all_ips {
# Line 159  sub all_ips { Line 161  sub all_ips {
161          } glob("$server::conf/ip/*")          } glob("$server::conf/ip/*")
162  }  }
163    
164    sub remove {
165            my $ip = shift;
166            unlink $_ foreach grep { -e $_ } ( glob "$server::conf/ip/$ip/*" );
167            if ( my $mac = mac_from_ip $ip ) {
168                    unlink "$server::conf/mac/$mac";
169            }
170            rmdir "$server::conf/ip/$ip";
171    }
172    
173  1;  1;

Legend:
Removed from v.322  
changed lines
  Added in v.323

  ViewVC Help
Powered by ViewVC 1.1.26