X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=machines.cgi;h=72f729bae8844a5b205486eed268dc15f92d9764;hb=d242cbc0a1f1bf7e36ec02464fb33d0ad234cd8d;hp=1bca7f8b2608f1d20eb104cfde0e196be3e67964;hpb=e2cbab82299c7896e668e575c91551d6a5c81fb8;p=mirror%2Fuserdir-ldap-cgi.git diff --git a/machines.cgi b/machines.cgi index 1bca7f8..72f729b 100755 --- a/machines.cgi +++ b/machines.cgi @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: machines.cgi,v 1.5 2000/01/23 05:36:58 tausq Exp $ +# $Id: machines.cgi,v 1.7 2000/08/19 02:53:56 tausq Exp $ # (c) 1999 Randolph Chung. Licensed under the GPL. @@ -25,6 +25,7 @@ my (%attrs, @attrorder, %summaryattrs, @summaryorder); 'memory' => 'Memory', 'disk' => 'Disk space', 'bandwidth' => 'Bandwidth', + 'status' => 'Status', 'notes' => 'Notes', 'createtimestamp' => 'Entry created', 'modifytimestamp' => 'Entry modified' @@ -33,15 +34,17 @@ my (%attrs, @attrorder, %summaryattrs, @summaryorder); # This defines what fields are displayed, and in what order @attrorder = ('hostname', 'admin', 'architecture', 'distribution', 'access', 'sponsor', 'sponsor-admin', 'location', 'machine', 'memory', - 'disk', 'bandwidth', 'notes', 'createtimestamp', 'modifytimestamp'); + 'disk', 'bandwidth', 'status', 'notes', 'createtimestamp', 'modifytimestamp'); # ditto for summary %summaryattrs = ('hostname' => 'Host name', 'host' => 'just for a link', 'architecture' => 'Architecture', + 'distribution' => 'Distribution', + 'status' => 'Status', 'access' => 'Access'); -@summaryorder = ('hostname', 'architecture', 'access'); +@summaryorder = ('hostname', 'architecture', 'distribution', 'status', 'access'); # Global settings... my %config = &Util::ReadConfigFile; @@ -65,7 +68,7 @@ $mesg = $ldap->search(base => $config{hostbasedn}, filter => 'host=*'); $mesg->code && &Util::HTMLError($mesg->error); $entries = $mesg->as_struct; -foreach $dn (sort {$entries->{$a}->{host}->[0] <=> $entries->{$b}->{host}->[0]} keys(%$entries)) { +foreach $dn (sort {$entries->{$a}->{host}->[0] cmp $entries->{$b}->{host}->[0]} keys(%$entries)) { $data = $entries->{$dn}; my $thishost = $data->{host}->[0]; @@ -77,6 +80,11 @@ foreach $dn (sort {$entries->{$a}->{host}->[0] <=> $entries->{$b}->{host}->[0]} foreach $key (keys(%attrs)) { $output{$key} = $data->{$key}->[0]; } + + $output{hostname} = undef; + foreach my $hostname (@{$data->{hostname}}) { + $output{hostname} .= sprintf("%s%s", ($output{hostname} ? ', ' : ''), $hostname); + } # Modified/created time. TODO: maybe add is the name of the creator/modifier $output{modifytimestamp} = &Util::FormatTimestamp($output{modifytimestamp}); @@ -111,8 +119,10 @@ foreach $dn (sort {$entries->{$a}->{host}->[0] <=> $entries->{$b}->{host}->[0]} $summary{$thishost}{$key} = $data->{$key}->[0]; } - $summary{$thishost}{hostname} = sprintf("%s", - $summary{$thishost}{host}, $summary{$thishost}{hostname}); + $summary{$thishost}{hostname} = undef; + foreach my $hostname (@{$data->{hostname}}) { + $summary{$thishost}{hostname} .= sprintf("%s%s", ($summary{$thishost}{hostname} ? '
' : ''), $summary{$thishost}{host}, $hostname); + } } $ldap->unbind;