/[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 162 by dpavlin, Thu Aug 6 18:10:31 2009 UTC revision 181 by dpavlin, Sun Aug 9 19:00:52 2009 UTC
# Line 52  use progress_bar; Line 52  use progress_bar;
52  use config;  use config;
53  use client;  use client;
54  use log;  use log;
55    use x11;
56    use amt;
57    
58  sub static {  sub static {
59          my ($client,$path) = @_;          my ($client,$path) = @_;
# Line 135  sub start_stop { Line 137  sub start_stop {
137                          if ( $daemon =~ m{dhcpd|tftpd|dnsd} ) {                          if ( $daemon =~ m{dhcpd|tftpd|dnsd} ) {
138                                  my $exec = "perl -I$server::base_dir/lib -I$server::base_dir/lib/PXElator -M$daemon -e ${daemon}::${invoke}";                                  my $exec = "perl -I$server::base_dir/lib -I$server::base_dir/lib/PXElator -M$daemon -e ${daemon}::${invoke}";
139                                  warn "exec $exec";                                  warn "exec $exec";
140                                  exec "xterm -T $daemon -n $daemon -e $exec";                                  x11::xterm( $daemon => $exec );
141                          } else {                          } else {
142                                  my $eval = $daemon . '::' . $invoke . '(' . ( @_ ? dump(@_) : '' ) . ')';                                  my $eval = $daemon . '::' . $invoke . '(' . ( @_ ? dump(@_) : '' ) . ')';
143                                  warn "eval $eval";                                  warn "eval $eval";
# Line 173  sub get_request { Line 175  sub get_request {
175                  foreach my $name ( sort keys %$pids ) {                  foreach my $name ( sort keys %$pids ) {
176                          my $pid = $pids->{$name} || next;                          my $pid = $pids->{$name} || next;
177    
178                          my $html = qq|<a href=/start_stop/$name>$pid</a>|;                          my $html;
179    
180                          my $proc = "/proc/$pid/status";                          my $proc = "/proc/$pid/status";
181    
182                          if ( -e $proc ) {                          if ( -e $proc ) {
183                                    $html .= qq|<a href=/start_stop/$name>$pid</a>|;
184                                  if ( $debug ) {                                  if ( $debug ) {
185                                          $html .= qq| <a name=$pid href=#proc-$pid>?</a>|;                                          $html .= qq| <a name=$pid href=#proc-$pid>?</a>|;
186    
# Line 195  sub get_request { Line 198  sub get_request {
198                                  if ( $name->can('actions') ) {                                  if ( $name->can('actions') ) {
199                                          $html .= qq| <a href=/action/kvm/$_>$_</a>| foreach $name->actions;                                          $html .= qq| <a href=/action/kvm/$_>$_</a>| foreach $name->actions;
200                                  }                                  }
201                            } else {
202                                    $html .= qq|<a href=/start_stop/$name>restart</a> $pid exited|;
203                          }                          }
204    
205                          push @rows, ( $name => $html );                          push @rows, ( $name => $html );
# Line 235  sub get_request { Line 240  sub get_request {
240                                  , qq|<form method=get>|                                  , qq|<form method=get>|
241                                  , html::table( 2,                                  , html::table( 2,
242                                          'ip' => $ip,                                          'ip' => $ip,
243                                            'mac' => client::mac( $ip ),
244                                          'hostname' => qq|<input type=text name=hostname value=$hostname>|,                                          'hostname' => qq|<input type=text name=hostname value=$hostname>|,
245                                          'deploy' => html::select( 'deploy', $deploy, config::available ),                                          'deploy' => html::select( 'deploy', $deploy, config::available ),
246                                  )                                  )
# Line 243  sub get_request { Line 249  sub get_request {
249                                  , config::for_ip( $ip )                                  , config::for_ip( $ip )
250                                  , qq|</pre>|                                  , qq|</pre>|
251                                  ;                                  ;
252    
253                            if ( my $amt = client::conf( $ip, 'amt' ) ) {
254                                    print $client amt::info( $amt );
255                            }
256                  } else {                  } else {
257                          print $client $ok                          print $client $ok
258                                  , qq|<h2>Clients on $server::ip</h2>|                                  , qq|<h2>Clients on $server::ip</h2>|
259                                  , qq|<ul>|                                  , html::table( -4,
260                                  , join("\n",                                          'ip', 'mac', 'hostname', 'deploy',
261                                          map {                                          map {
262                                                  my $ip = $_;                                                  my $ip = $_;
263                                                  $ip =~ s{^.+/ip/}{};                                                  $ip =~ s{^.+/ip/}{};
264                                                  qq|<li><a href=/client/$ip>$ip</a></li>|                                                  ( qq|<a href=/client/$ip>$ip</a>|, client::mac($ip), client::conf( $ip, 'hostname' ), client::conf( $ip, 'deploy' ) );
265                                          }                                          }
266                                          glob("$server::conf/ip/*")                                          glob("$server::conf/ip/*")
267                                  )                                  )
                                 , qq|</ul>|  
268                                  ;                                  ;
269                  }                  }
270          } elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {          } elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {
# Line 298  sub start { Line 307  sub start {
307          start_stop 'dhcpd';          start_stop 'dhcpd';
308          start_stop 'tftpd';          start_stop 'tftpd';
309          start_stop 'dnsd';          start_stop 'dnsd';
310          start_stop 'kvm';          start_stop 'kvm' unless $ENV{DEV}; # skip kvm statup when running on real device
311    
312          while (1) {          while (1) {
313                  my $client = $server->accept() || next; # ALARM trickle us                  my $client = $server->accept() || next; # ALARM trickle us

Legend:
Removed from v.162  
changed lines
  Added in v.181

  ViewVC Help
Powered by ViewVC 1.1.26