/[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 164 by dpavlin, Thu Aug 6 18:43:55 2009 UTC revision 188 by dpavlin, Sun Aug 9 22:05:09 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 39  sub conf { Line 40  sub conf {
40          return $value;          return $value;
41  }  }
42    
43    sub mac {
44            my $ip = shift;
45            my $mac = client::conf( $ip, 'mac' );
46            return '' unless $mac;
47            $mac =~ s{(..)}{$1:}g;
48            $mac =~ s{:$}{};
49            $mac = qq|<tt>$mac</tt>| if (caller(1))[3] =~ m{^httpd};
50            return uc($mac);
51    }
52    
53    sub next_ip {
54    
55            my $p = Net::Ping->new;
56    
57            my $prefix = $server::ip;
58            $prefix =~ s{\.\d+$}{.};
59            my $addr = $server::ip_from || die;
60            my $ip = $prefix . $addr;
61    
62            while ( -e "$server::conf/ip/$ip" || $p->ping( $ip, 0.7 ) ) {
63                    $ip = $prefix . $addr++;
64                    die "all addresses allocated!" if $addr == $server::ip_to;
65                    warn "skip $ip\n";
66            }
67    
68            warn "next_ip $ip\n";
69            return $ip;
70    
71    }
72    
73  1;  1;

Legend:
Removed from v.164  
changed lines
  Added in v.188

  ViewVC Help
Powered by ViewVC 1.1.26