add site summary table
smbaker [Tue, 20 Nov 2012 05:29:40 +0000 (21:29 -0800)]
apps/gacksadmin/user_nodelist.php

index 90667f3..77ae304 100644 (file)
@@ -54,20 +54,56 @@ if ($account_name != NULL) {
         }
 
         $slice = $slices[0];
-        $slice_nodes=$api->GetNodes(array('node_id'=>$slice['node_ids']),array("hostname"));
+        $slice_nodes=$api->GetNodes(array('node_id'=>$slice['node_ids']),array("hostname","site_id"));
+
+        $site_ids = array();
+        $site_count = array();
+        foreach ($slice_nodes as $node) {
+            $site_id = $node["site_id"];
+            if (!in_array($site_id, $site_ids)) {
+                $site_ids []= $site_id;
+                $site_count[$site_id] = 0;
+            }
+            $site_count[$site_id] = $site_count[$site_id] + 1;
+        }
+
+        $sites = $api->GetSites(array('site_id'=>$site_ids), array("site_id", "name"));
+        $site_names = array();
+        foreach ($sites as $site) {
+            $site_names[$site["site_id"]] = $site["name"];
+        }
+
+        $headers=array();
+        $headers["Site Name"] = "string";
+        $headers["Sliver Count"] = "int";
+
+        $table = new PlekitTable("sites", $headers, 0);
+        $table->start();
+        foreach ($site_names as $site_id=>$site_name) {
+            $table->row_start();
+            $table->cell($site_name);
+            $table->cell($site_count[$site_id]);
+            $table->row_end();
+        }
+        $table->end();
 
         print "<br><center>";
-        print href(l_gacks_nodelist_download($account_name), "Export as CSV");
+        print href(l_gacks_nodelist_download($account_name), "Export Node List as CSV");
         print "</center>";
 
         $headers=array();
         $headers["Hostname"] = "string";
+        $headers["Site"] = "string";
 
-        $table = new PlekitTable("accounts", $headers, 0);
+        $table = new PlekitTable("slivers", $headers, 0);
         $table->start();
         foreach ($slice_nodes as $node) {
             $table->row_start();
             $table->cell($node["hostname"]);
+
+            $site_name = $site_names[$node["site_id"]];
+            $table->cell($site_name);
+
             $table->row_end();
         }
         $table->end();