/[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 165 by dpavlin, Thu Aug 6 18:51:57 2009 UTC revision 190 by dpavlin, Mon Aug 10 00:07:38 2009 UTC
# Line 6  use autodie; Line 6  use autodie;
6    
7  use server;  use server;
8  use File::Slurp;  use File::Slurp;
9    use Net::Ping;
10    
11  sub conf {  sub conf {
12          my $ip  = shift;          my $ip  = shift;
# Line 40  sub conf { Line 41  sub conf {
41  }  }
42    
43  sub mac {  sub mac {
44          my $ip = shift;          my ( $ip, $op ) = @_;
45            $op ||= 'html';
46          my $mac = client::conf( $ip, 'mac' );          my $mac = client::conf( $ip, 'mac' );
47            return '' unless $mac;
48          $mac =~ s{(..)}{$1:}g;          $mac =~ s{(..)}{$1:}g;
49          $mac =~ s{:$}{};          $mac =~ s{:$}{};
50          $mac = qq|<tt>$mac</tt>| if (caller(1))[3] =~ m{^httpd};          $mac = qq|<tt>$mac</tt>| if (caller(1))[3] =~ m{^httpd} && $op ne 'clean';
51          return uc($mac);          return uc($mac);
52  }  }
53    
54    sub next_ip {
55    
56            my $p = Net::Ping->new;
57    
58            my $prefix = $server::ip;
59            $prefix =~ s{\.\d+$}{.};
60            my $addr = $server::ip_from || die;
61            my $ip = $prefix . $addr;
62    
63            while ( -e "$server::conf/ip/$ip" || $p->ping( $ip, 0.7 ) ) {
64                    $ip = $prefix . $addr++;
65                    die "all addresses allocated!" if $addr == $server::ip_to;
66                    warn "skip $ip\n";
67            }
68    
69            warn "next_ip $ip\n";
70            return $ip;
71    
72    }
73    
74  1;  1;

Legend:
Removed from v.165  
changed lines
  Added in v.190

  ViewVC Help
Powered by ViewVC 1.1.26