/[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 399 by dpavlin, Tue Sep 8 18:09:01 2009 UTC revision 412 by dpavlin, Wed Sep 9 13:40:45 2009 UTC
# Line 12  use server; Line 12  use server;
12  use format;  use format;
13  use ip;  use ip;
14  use ping;  use ping;
15    use kvm;
16    
17  our $debug = $server::debug;  our $debug = $server::debug;
18    
# Line 84  sub next_ip($) { Line 85  sub next_ip($) {
85          my $mac = shift;          my $mac = shift;
86          $mac = format::mac($mac);          $mac = format::mac($mac);
87    
88          if ( $server::new_clients-- ) {          if ( $server::new_clients > 0 ) {
89                  warn "# clients left: $server::new_clients\n";                  warn "# clients left: ", --$server::new_clients;
90          } else {          } else {
91                  warn "W: no new clients accepted";                  warn "W: no new clients accepted";
92                  return '0.0.0.0';                  return '0.0.0.0';
# Line 112  sub next_ip($) { Line 113  sub next_ip($) {
113  sub save_ip_mac {  sub save_ip_mac {
114          my ($ip,$mac) = @_;          my ($ip,$mac) = @_;
115          $mac = format::mac($mac);          $mac = format::mac($mac);
116          return if $mac eq '00:00:00:00:00:00';          return if $mac eq '00:00:00:00:00:00' || $ip eq '0.0.0.0';
117    
118          mkdir ip_path($ip) unless -e ip_path($ip);          mkdir ip_path($ip) unless -e ip_path($ip);
119    
# Line 165  sub all_ips { Line 166  sub all_ips {
166          map {          map {
167                  my $ip = $_;                  my $ip = $_;
168                  $ip =~ s{^.+/ip/}{};                  $ip =~ s{^.+/ip/}{};
169                    autocreate_params( $ip );
170                  $ip;                  $ip;
171          } glob("$server::conf/ip/*")          } glob("$server::conf/ip/*")
172  }  }
# Line 194  sub arp_mac_dev { Line 196  sub arp_mac_dev {
196          return $arp;          return $arp;
197  }  }
198    
199    sub rebuild_mac_links {
200            warn "# rebuild mac links";
201            foreach my $ip ( all_ips ) {
202                    my $mac = ip_path $ip, 'mac';
203                    if ( -e $mac ) {
204                            $mac = read_file $mac;
205                            save_ip_mac( $ip, $mac );
206                            warn "## $ip $mac\n";
207                    }
208            }
209    }
210    
211    sub autocreate_params {
212            my $ip = shift;
213            my $mac = mac_from_ip $ip;
214            if ( $mac =~ m{^AC:DE:48:00:00} && ! defined conf( $ip, 'kvm' ) ) {
215                    conf( $ip, 'kvm', default => kvm::nr_from_mac( $mac ) );
216                    warn "# create kvm for $ip";
217            }
218    }
219    
220  1;  1;

Legend:
Removed from v.399  
changed lines
  Added in v.412

  ViewVC Help
Powered by ViewVC 1.1.26