/[pxelator]/lib/PXElator/httpd.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/httpd.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 185 by dpavlin, Sun Aug 9 21:13:36 2009 UTC revision 193 by dpavlin, Mon Aug 10 16:36:16 2009 UTC
# Line 184  sub get_request { Line 184  sub get_request {
184                  my $ip = $1 || $client->peerhost;                  my $ip = $1 || $client->peerhost;
185                  if ( $ip ne $server::ip ) {                  if ( $ip ne $server::ip ) {
186                          my $hostname = client::conf( $ip, 'hostname' => $param->{hostname} );                          my $hostname = client::conf( $ip, 'hostname' => $param->{hostname} );
187                          my $deploy   = client::conf( $ip, 'deploy'   => $param->{deploy}   );  
188                            my @table = (
189                                    'ip' => $ip,
190                                    'hostname' => qq|<input type=text name=hostname value=$hostname>|,
191                            );
192    
193                            my $deploy;
194    
195                            if ( my $mac = client::mac( $ip ) ) {
196                                    $deploy = client::conf( $ip, 'deploy' => $param->{deploy} );
197                                    push @table, (
198                                            'mac' => $mac,
199                                            'deploy' => html::select( 'deploy', $deploy, config::available )
200                                    );
201                                    $deploy = qq|<h2>PXElinux</h2>| . html::pre( config::for_ip( $ip ) );
202                            }
203    
204                          print $client $ok                          print $client $ok
205                                  , qq|<form method=get>|                                  , qq|<form method=get>|
206                                  , html::table( 2,                                  , html::table( 2, @table ),
                                         'ip' => $ip,  
                                         'mac' => client::mac( $ip ),  
                                         'hostname' => qq|<input type=text name=hostname value=$hostname>|,  
                                         'deploy' => html::select( 'deploy', $deploy, config::available ),  
                                 )  
207                                  , qq|<input type=submit value=change></form>|                                  , qq|<input type=submit value=change></form>|
208                                  , qq|<h2>PXElinux $deploy</h2><pre>|                                  , $deploy
                                 , config::for_ip( $ip )  
                                 , qq|</pre>|  
209                                  ;                                  ;
210    
211                          if ( my $amt = client::conf( $ip, 'amt' ) ) {                          if ( my $amt = client::conf( $ip, 'amt' ) ) {
212                                  print $client amt::info( $amt );                                  print $client qq|<h2>AMT</h2>|, amt::info( $amt );
213                          }                          }
214                  } else {                  } else {
215    
216                            my $arp = {
217                                    map {
218                                            my @c = split(/\s+/,$_);
219                                            if ( $#c == 5 ) {
220                                                    ( uc $c[3] => [ $c[0] , $c[5] ] )
221                                            } else {
222                                            }
223                                    } read_file('/proc/net/arp')
224                            };
225    
226                            warn "# arp ",dump( $arp );
227    
228                          print $client $ok                          print $client $ok
229                                  , qq|<h2>Clients on $server::ip</h2>|                                  , qq|<h2>Clients on $server::ip</h2>|
230                                  , html::table( -4,                                  , html::table( -5,
231                                          'ip', 'mac', 'hostname', 'deploy',                                          'ip', 'hostname', 'mac', 'deploy', 'arp',
232                                          map {                                          map {
233                                                  my $ip = $_;                                                  my $ip = $_;
234                                                  $ip =~ s{^.+/ip/}{};                                                  $ip =~ s{^.+/ip/}{};
235                                                  ( qq|<a href=/client/$ip>$ip</a>|, client::mac($ip), client::conf( $ip, 'hostname' ), html::tt client::conf( $ip, 'deploy' ) );                                                  my $arp = $arp->{ client::mac $ip, 'clean' };
236                                                    $arp = $arp ? $arp->[1] : '';
237                                                    $arp =~ s{$ip}{};
238                                                    (
239                                                            qq|<a href=/client/$ip>$ip</a>|
240                                                            , client::conf( $ip, 'hostname' )
241                                                            , client::mac( $ip )
242                                                            , html::tt( client::conf( $ip, 'deploy' ) )
243                                                            , $arp
244                                                    );
245                                          }                                          }
246                                          glob("$server::conf/ip/*")                                          glob("$server::conf/ip/*")
247                                  )                                  )
248                                    , qq|<h2>ARP</h2>|
249                                    , html::table( -3, 'mac', 'dev', 'ip',
250                                            map {
251                                                    my $c = $arp->{$_};
252                                                    ( html::tt( $_ ), $c->[1], $c->[0] )
253                                            } sort keys %$arp
254                                    )
255                                  ;                                  ;
256                  }                  }
257          } elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {          } elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {
# Line 240  sub start { Line 278  sub start {
278    
279          warn 'tap ', network::tap();          warn 'tap ', network::tap();
280    
281            daemons::start_stop 'browser', $url;
282            daemons::start_stop $_ foreach ( qw/dhcpd tftpd dnsd/ );
283            daemons::start_stop 'kvm' unless $ENV{DEV}; # skip kvm statup when running on real device
284    
285          my $server = IO::Socket::INET->new(          my $server = IO::Socket::INET->new(
286                          Proto     => 'tcp',                          Proto     => 'tcp',
287                          LocalAddr => $server::ip,                          LocalAddr => $server::ip,
# Line 250  sub start { Line 292  sub start {
292    
293          print "url $url\n";          print "url $url\n";
294    
         daemons::start_stop 'browser', $url;  
         daemons::start_stop $_ foreach ( qw/dhcpd tftpd dnsd/ );  
         daemons::start_stop 'kvm' unless $ENV{DEV}; # skip kvm statup when running on real device  
   
295          while (1) {          while (1) {
296                  my $client = $server->accept() || next; # ALARM trickle us                  my $client = $server->accept() || next; # ALARM trickle us
297                  my $request = <$client>;                  my $request = <$client>;

Legend:
Removed from v.185  
changed lines
  Added in v.193

  ViewVC Help
Powered by ViewVC 1.1.26