/[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 334 by dpavlin, Fri Aug 28 23:30:38 2009 UTC revision 346 by dpavlin, Sat Aug 29 16:51:07 2009 UTC
# Line 56  use ip; Line 56  use ip;
56  use wireshark;  use wireshark;
57  use syslogd;  use syslogd;
58  use nmap;  use nmap;
59    use ping;
60    use wol;
61    
62  use CouchDB;  use CouchDB;
63    
# Line 237  warn "XXX pids = ", dump( $daemons::pids Line 239  warn "XXX pids = ", dump( $daemons::pids
239                  }                  }
240    
241                  if ( $ip && $ip ne $server::ip ) {                  if ( $ip && $ip ne $server::ip ) {
                         my $hostname = client::conf( $ip, 'hostname' => $param->{hostname} );  
242    
243                            my @editable = ( qw/hostname deploy homepage/ );
244    
245                            client::conf( $ip, $_ => $param->{$_} ) foreach @editable;
246    
247                            my $conf = client::all_conf( $ip );
248                            my $deploy = delete $conf->{deploy};
249    
250                            my $nmap = qq|<a href=/nmap?scan=$ip>nmap</a>|;
251                          my @table = (                          my @table = (
252                                  'ip' => qq|<input type=text name=change_ip value="$ip" onChange="document.getElementById('old_ip').style.display = '';"><span id=old_ip style="display: none; color: #888;">old: $ip<span>|,                                  'ip' => qq|<input type=text name=change_ip value="$ip" onChange="document.getElementById('old_ip').style.display = '';"><span id=old_ip style="display: none; color: #888;">old: $ip<span>|,
253                                  'hostname' => qq|<input type=text name=hostname value="$hostname">|,                                  'mac' => format::mac( delete $conf->{mac}, 'html' ),
254                                    'hostname' => qq|<input type=text name=hostname value="| . delete($conf->{hostname}) . qq|">|,
255                                    'ping' => ping::host($ip) ? qq|<span style="color:green">up</span> $nmap| : qq|<span style="color: red">down</span> <a href=/wol/$ip>wol</a> $nmap|,
256                                    'deploy' => html::select( 'deploy', $deploy, config::available ),
257                                    html::conf( $ip, $conf, 'edit', @editable )
258                          );                          );
259    
260                          my $deploy;  warn "XX conf ",dump( $conf );
261    
262                            my $config = '';
263    
264                          if ( my $mac = client::mac_from_ip( $ip ) ) {                          if ( $deploy ) {
265                                  $deploy = client::conf( $ip, 'deploy' => $param->{deploy} );                                  if ( $config = config::for_ip( $ip ) ) {
266                                  push @table, (                                          $config = qq|<h2>config</h2>| . html::pre( $config );
                                         'mac' => format::mac( $mac => 'html' ),  
                                         'deploy' => html::select( 'deploy', $deploy, config::available )  
                                 );  
                                 if ( my $pxelinux = config::for_ip( $ip ) ) {  
                                         $deploy = qq|<h2>PXElinux</h2>| . html::pre( $pxelinux );  
267                                  }                                  }
268                          }                          }
269    
# Line 264  warn "XXX pids = ", dump( $daemons::pids Line 274  warn "XXX pids = ", dump( $daemons::pids
274                                          <input type=submit name=action value=change>                                          <input type=submit name=action value=change>
275                                          <input type=submit name=action value=remove style="color: red">                                          <input type=submit name=action value=remove style="color: red">
276                                          </form>|                                          </form>|
277                                  , $deploy                                  , $config
278                                  ;                                  ;
279    
280                          if ( my $amt = client::conf( $ip, 'amt' ) ) {                          if ( my $amt = client::conf( $ip, 'amt' ) ) {
# Line 285  warn "XXX pids = ", dump( $daemons::pids Line 295  warn "XXX pids = ", dump( $daemons::pids
295    
296                          print $client ok                          print $client ok
297                                  , qq|<h2>Clients on $server::ip</h2>|                                  , qq|<h2>Clients on $server::ip</h2>|
298                                  , html::table( -6,                                  , html::table( -5,
299                                          'ip', 'mac', 'dev', 'hostname', 'deploy', 'conf',                                          'ip', 'mac', 'dev', 'hostname', 'conf',
300                                          map {                                          map {
301                                                  my $ip = $_;                                                  my $ip = $_;
302                                                  my $conf = client::all_conf( $ip );                                                  my $conf = client::all_conf( $ip );
# Line 303  warn "XXX pids = ", dump( $daemons::pids Line 313  warn "XXX pids = ", dump( $daemons::pids
313                                                          , format::mac( $mac => 'html' )                                                          , format::mac( $mac => 'html' )
314                                                          , $arp->{$mac}                                                          , $arp->{$mac}
315                                                          , delete $conf->{hostname}                                                          , delete $conf->{hostname}
316                                                          , delete $conf->{deploy}                                                          , html::conf( $ip, $conf, 'inline' )
317                                                          , ( %$conf ? html::pre_dump( $conf ) : qq|<a href=/nmap?scan=$ip>nmap</a>| )                                                  )
                                                 );  
318                                          } client::all_ips                                          } client::all_ips
319                                  )                                  )
320                                  ;                                  ;
# Line 344  warn "XXX pids = ", dump( $daemons::pids Line 353  warn "XXX pids = ", dump( $daemons::pids
353                                  </form>                                  </form>
354                          |;                          |;
355                  }                  }
356            } elsif ( $path =~ m{^/wol/(\S+)} ) {
357                    print $client redirect( "$url/client/$1" ), wol::power_on($1);
358          } elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {          } elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {
359                  eval 'our $' . $1 . ' = ' . $2;                  eval 'our $' . $1 . ' = ' . $2;
360                  warn $@ if $@;                  warn $@ if $@;

Legend:
Removed from v.334  
changed lines
  Added in v.346

  ViewVC Help
Powered by ViewVC 1.1.26