use check-sigs instead of list-sigs
[mirror/userdir-ldap-cgi.git] / machines.cgi
index 61e50cd..92deede 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# $Id: machines.cgi,v 1.4 1999/10/01 03:44:20 tausq Exp $
+# $Id: machines.cgi,v 1.9 2001/01/08 07:03:23 tausq Exp $
 
 # (c) 1999 Randolph Chung. Licensed under the GPL. <tausq@debian.org>
 
@@ -25,23 +25,30 @@ my (%attrs, @attrorder, %summaryattrs, @summaryorder);
          'memory' => 'Memory',
          'disk' => 'Disk space',
          'bandwidth' => 'Bandwidth',
+         'status' => 'Status',
          'notes' => 'Notes',
+         'sshrsahostkey' => 'SSH host key (RSA)',
+         'sshdsahostkey' => 'SSH host key (DSA)',
+         'description' => 'Description',
          'createtimestamp' => 'Entry created',
          'modifytimestamp' => 'Entry modified'
         );
 
 # 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');
+@attrorder = qw(hostname admin architecture distribution access
+                sponsor sponsor-admin location machine memory
+               disk bandwidth status notes sshrsahostkey sshdsahostkey
+               description 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 +72,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 +84,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 +123,10 @@ foreach $dn (sort {$entries->{$a}->{host}->[0] <=> $entries->{$b}->{host}->[0]}
     $summary{$thishost}{$key} = $data->{$key}->[0];
   }
   
-  $summary{$thishost}{hostname} = sprintf("<a href=\"machines.cgi?host=%s\">%s</a>",
-                                          $summary{$thishost}{host}, $summary{$thishost}{hostname});
+  $summary{$thishost}{hostname} = undef;
+  foreach my $hostname (@{$data->{hostname}}) {
+    $summary{$thishost}{hostname} .= sprintf("%s<a href=\"machines.cgi?host=%s\">%s</a>", ($summary{$thishost}{hostname} ? '<br>' : ''), $summary{$thishost}{host}, $hostname);
+  }
 }
 $ldap->unbind;
 
@@ -128,11 +142,11 @@ if ($output{havehostdata}) {
 } else {
   # display summary info
   $hostdetails = "<h1>Summary</h1>\n";
-  $hostdetails .= "<table border=1 width=90%>\n<th>";
+  $hostdetails .= "<table border=1 width=90%>\n<tr>";
   foreach $key (@summaryorder) {
-    $hostdetails .= "<td>$summaryattrs{$key}</td>";
+    $hostdetails .= "<th>$summaryattrs{$key}</th>";
   }
-  $hostdetails .= "</th>\n";
+  $hostdetails .= "</tr>\n";
   
   foreach $host (sort(keys(%summary))) {
     $hostdetails .= "<tr>";