provide interface to all methods which are defined inside start_options
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 31 Jul 2009 16:47:52 +0000 (16:47 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 31 Jul 2009 16:47:52 +0000 (16:47 +0000)
lib/PXElator/httpd.pm

index 2affd63..de24be0 100644 (file)
@@ -111,7 +111,9 @@ sub start_stop {
                        return qq|$daemon pid $pid started|;
                } elsif ( defined $pid ) {
                        # child
-                       my $eval = $daemon . '::start(' . ( @_ ? dump(@_) : '' ) . ')';
+                       my $invoke = 'start';
+                       $invoke = $1 if $daemon =~ s{/(.+)}{};
+                       my $eval = $daemon . '::' . $invoke . '(' . ( @_ ? dump(@_) : '' ) . ')';
                        warn "eval $eval";
                        eval $eval;
                        warn "can't start $daemon: $@" if $@;
@@ -153,15 +155,22 @@ sub get_request {
 
                        my $html = qq|<a href=/$name>$pid</a>|;
 
-                       if ( $debug ) {
-                               $html .= qq| <a name=$pid href=#proc-$pid>?</a>|;
+                       my $proc = "/proc/$pid/status";
 
-                               my $proc = "/proc/$pid/status";
-                               $debug_proc
-                                       .= qq|<a name=proc-$pid href=#$pid>$proc</a><pre style="font-size: 10%">|
-                                       .  read_file($proc)
-                                       .  qq|</pre>|
-                                       if -e $proc;
+                       if ( -e $proc ) {
+                               if ( $debug ) {
+                                       $html .= qq| <a name=$pid href=#proc-$pid>?</a>|;
+
+                                       $debug_proc
+                                               .= qq|<a name=proc-$pid href=#$pid>$proc</a><pre style="font-size: 10%">|
+                                               .  read_file($proc)
+                                               .  qq|</pre>|
+                                               ;
+                               }
+
+                               if ( $name->can('start_options') ) {
+                                       $html .= qq| <a href=/kvm/$_>$_</a>| foreach $name->start_options;
+                               }
                        }
 
                        push @rows, ( $name => $html );
@@ -188,7 +197,7 @@ sub get_request {
                warn $@ if $@;
                print $client $redirect, qq|<big>$1 = $2</big><br>Location: <a href="$url">$url</a>|;
                server::debug( $debug ) if $1 eq 'debug';
-       } elsif ( $path =~ m{^/(screen|kvm)} ) {
+       } elsif ( $path =~ m{^/((?:screen|kvm).*)} ) {
                print $client $redirect, start_stop($1);
        } elsif ( $path =~ m{^/kill/static/(\d+)} ) {
                print $client $redirect;