/[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 200 by dpavlin, Tue Aug 11 15:55:26 2009 UTC revision 217 by dpavlin, Thu Aug 13 13:32:19 2009 UTC
# Line 7  use autodie; Line 7  use autodie;
7  use server;  use server;
8  use File::Slurp;  use File::Slurp;
9  use Net::Ping;  use Net::Ping;
10    use format;
11    
12  sub mac_path { $server::conf . '/mac/' . $_[0] }  sub mac_path { $server::conf . '/mac/' . $_[0] }
13  sub  ip_path { $server::conf . '/ip/'  . join('/', @_) }  sub  ip_path { $server::conf . '/ip/'  . join('/', @_) }
# Line 43  sub conf { Line 44  sub conf {
44          return $value;          return $value;
45  }  }
46    
 sub mac {  
         my ( $ip, $op ) = @_;  
         $op ||= 'html';  
         my $mac = client::conf( $ip, 'mac' );  
         return '' unless $mac;  
         $mac =~ s{(..)}{$1:}g;  
         $mac =~ s{:$}{};  
         $mac = qq|<tt>$mac</tt>| if (caller(1))[3] =~ m{^httpd} && $op ne 'clean';  
         return uc($mac);  
 }  
   
47  sub next_ip($) {  sub next_ip($) {
48          my $mac = shift;          my $mac = shift;
49    
# Line 74  sub next_ip($) { Line 64  sub next_ip($) {
64    
65          mkdir ip_path($ip);          mkdir ip_path($ip);
66    
67          symlink ip_path($ip), mac_path($mac);          my $mac_path = mac_path($mac);
68            unlink $mac_path if -e $mac_path;       # XXX audit?
69            symlink ip_path($ip), $mac_path;
70          write_file ip_path($ip,'mac'), $mac;          write_file ip_path($ip,'mac'), $mac;
71    
72          return $ip;          return $ip;

Legend:
Removed from v.200  
changed lines
  Added in v.217

  ViewVC Help
Powered by ViewVC 1.1.26