use x11::xterm, detect existed processes, show clients in table
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 6 Aug 2009 22:29:58 +0000 (22:29 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 6 Aug 2009 22:29:58 +0000 (22:29 +0000)
lib/PXElator/httpd.pm

index 20870f7..ca4610d 100644 (file)
@@ -52,6 +52,7 @@ use progress_bar;
 use config;
 use client;
 use log;
+use x11;
 
 sub static {
        my ($client,$path) = @_;
@@ -106,7 +107,6 @@ sub static {
 use boolean;
 
 use kvm;
-use qemu; $pids->{qemu} = 'stopped';
 
 $SIG{CHLD} = 'IGNORE';
 
@@ -136,7 +136,7 @@ sub start_stop {
                        if ( $daemon =~ m{dhcpd|tftpd|dnsd} ) {
                                my $exec = "perl -I$server::base_dir/lib -I$server::base_dir/lib/PXElator -M$daemon -e ${daemon}::${invoke}";
                                warn "exec $exec";
-                               exec "xterm -T $daemon -n $daemon -e $exec";
+                               x11::xterm( $daemon => $exec );
                        } else {
                                my $eval = $daemon . '::' . $invoke . '(' . ( @_ ? dump(@_) : '' ) . ')';
                                warn "eval $eval";
@@ -174,11 +174,12 @@ sub get_request {
                foreach my $name ( sort keys %$pids ) {
                        my $pid = $pids->{$name} || next;
 
-                       my $html = qq|<a href=/start_stop/$name>$pid</a>|;
+                       my $html;
 
                        my $proc = "/proc/$pid/status";
 
                        if ( -e $proc ) {
+                               $html .= qq|<a href=/start_stop/$name>$pid</a>|;
                                if ( $debug ) {
                                        $html .= qq| <a name=$pid href=#proc-$pid>?</a>|;
 
@@ -196,6 +197,8 @@ sub get_request {
                                if ( $name->can('actions') ) {
                                        $html .= qq| <a href=/action/kvm/$_>$_</a>| foreach $name->actions;
                                }
+                       } else {
+                               $html .= qq|<a href=/start_stop/$name>restart</a> $pid exited|;
                        }
 
                        push @rows, ( $name => $html );
@@ -248,16 +251,15 @@ sub get_request {
                } else {
                        print $client $ok
                                , qq|<h2>Clients on $server::ip</h2>|
-                               , qq|<ul>|
-                               , join("\n",
+                               , html::table( -4,
+                                       'ip', 'mac', 'hostname', 'deploy',
                                        map {
                                                my $ip = $_;
                                                $ip =~ s{^.+/ip/}{};
-                                               qq|<li><a href=/client/$ip>$ip</a> |, client::mac($ip), ' ', client::conf( $ip, 'hostname' ), qq|</li>|;
+                                               ( qq|<a href=/client/$ip>$ip</a>|, client::mac($ip), client::conf( $ip, 'hostname' ), client::conf( $ip, 'deploy' ) );
                                        }
                                        glob("$server::conf/ip/*") 
                                )
-                               , qq|</ul>|
                                ;
                }
        } elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {