From 625def6a2bace40057723611177335790714db4a Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 29 Aug 2009 16:51:07 +0000 Subject: [PATCH] make selected configuration options for clients editable or returned in table format --- lib/PXElator/html.pm | 34 ++++++++++++++++++++++++++++++++++ lib/PXElator/httpd.pm | 42 ++++++++++++++++++------------------------ lib/PXElator/t/html.t | 12 +++++++++++- 3 files changed, 63 insertions(+), 25 deletions(-) diff --git a/lib/PXElator/html.pm b/lib/PXElator/html.pm index 80a3de5..a6af381 100644 --- a/lib/PXElator/html.pm +++ b/lib/PXElator/html.pm @@ -66,6 +66,40 @@ sub pre_dump { qq|
$dump
|; } +sub conf { + my ($ip,$conf,$format) = @_; + my @editable = splice(@_,3); + + warn "# conf ",dump( $ip, $conf, $format, [ @editable ] ); + + $format ||= 'inline'; + + my @opts = map { + my $name = $_; + my $html = $conf->{$name}; + + if ( $format eq 'edit' && grep { m/^$name$/ } @editable ) { + $size = length($html); + ( $name, qq|| ) + } else { + if ( $name eq 'amt' ) { + $html = qq|logon|; + } + $html = qq|
$html
| + unless + $html =~ s{\b(\S+)\t(\S+)\t(\S+)\b}{$3 }gs; + + if ( $format =~ /edit|table/ ) { + ( $name, $html ); + } else { + qq|$name $html
| + } + } + } keys %$conf; + + $format eq 'inline' ? join("\n", @opts) : @opts; +} + warn "loaded"; 1; diff --git a/lib/PXElator/httpd.pm b/lib/PXElator/httpd.pm index 5084eed..cf1edc3 100644 --- a/lib/PXElator/httpd.pm +++ b/lib/PXElator/httpd.pm @@ -239,24 +239,29 @@ warn "XXX pids = ", dump( $daemons::pids ); } if ( $ip && $ip ne $server::ip ) { - my $hostname = client::conf( $ip, 'hostname' => $param->{hostname} ); - my $nmap = qq|nmap|; + my @editable = ( qw/hostname deploy homepage/ ); + + client::conf( $ip, $_ => $param->{$_} ) foreach @editable; + + my $conf = client::all_conf( $ip ); + my $deploy = delete $conf->{deploy}; + my $nmap = qq|nmap|; my @table = ( 'ip' => qq|