/[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 167 by dpavlin, Thu Aug 6 18:51:57 2009 UTC revision 168 by dpavlin, Thu Aug 6 21:31:10 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 48  sub mac { Line 49  sub mac {
49          return uc($mac);          return uc($mac);
50  }  }
51    
52    sub next_ip {
53    
54            my $p = Net::Ping->new;
55    
56            my $prefix = $server::ip;
57            $prefix =~ s{\.\d+$}{.};
58            my $addr = $server::ip_from || die;
59            my $ip = $prefix . $addr;
60    
61            while ( -e "$server::conf/ip/$ip" || $p->ping( $ip, 0.7 ) ) {
62                    $ip = $prefix . $addr++;
63                    die "all addresses allocated!" if $addr == $server::ip_to;
64                    warn "skip $ip\n";
65            }
66    
67            warn "next_ip $ip\n";
68            return $ip;
69    
70    }
71    
72  1;  1;

Legend:
Removed from v.167  
changed lines
  Added in v.168

  ViewVC Help
Powered by ViewVC 1.1.26