/[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 325 by dpavlin, Fri Aug 28 19:36:36 2009 UTC
# Line 105  sub next_ip($) { Line 105  sub next_ip($) {
105  sub save_ip_mac {  sub save_ip_mac {
106          my ($ip,$mac) = @_;          my ($ip,$mac) = @_;
107          $mac = format::mac($mac);          $mac = format::mac($mac);
108            return if $mac eq '00:00:00:00:00:00';
109    
110          mkdir ip_path($ip) unless -e ip_path($ip);          mkdir ip_path($ip) unless -e ip_path($ip);
111    
112          my $mac_path = mac_path($mac);          my $mac_path = mac_path($mac);
113          unlink $mac_path if -l $mac_path;       # XXX audit?          unlink $mac_path if -l $mac_path;       # XXX audit?
114          symlink ip_path($ip), $mac_path;          symlink ip_path($ip), $mac_path;
115          write_file ip_path($ip,'mac'), $mac;          write_file( ip_path($ip,'mac'), $mac );
116  }  }
117    
118  sub ip_from_mac($) {  sub ip_from_mac($) {
# Line 144  sub mac_from_ip($) { Line 145  sub mac_from_ip($) {
145    
146  sub change_ip($$) {  sub change_ip($$) {
147          my ($old, $new) = @_;          my ($old, $new) = @_;
148          my $mac = mac_from_ip($old);          return if $old eq $new;
149            my $mac = mac_from_ip($old) || die "no mac for $old";
150          rename ip_path($old), ip_path($new);          rename ip_path($old), ip_path($new);
151          unlink mac_path($mac);          unlink mac_path($mac);
152          symlink ip_path($new), mac_path($mac);          symlink ip_path($new), mac_path($mac);
153            return $new;
154  }  }
155    
156  sub all_ips {  sub all_ips {
# Line 159  sub all_ips { Line 162  sub all_ips {
162          } glob("$server::conf/ip/*")          } glob("$server::conf/ip/*")
163  }  }
164    
165    sub remove {
166            my $ip = shift;
167            unlink $_ foreach grep { -e $_ } ( glob "$server::conf/ip/$ip/*" );
168            if ( my $mac = mac_from_ip $ip ) {
169                    unlink "$server::conf/mac/$mac";
170            }
171            rmdir "$server::conf/ip/$ip";
172    }
173    
174  1;  1;

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

  ViewVC Help
Powered by ViewVC 1.1.26