23259a50d455be5dd61705ecd004f43f141b79c3
[plewww.git] / planetlab / tags / nodegroups.php
1 <?php
2
3 // $Id$
4
5 // Require login
6 require_once 'plc_login.php';
7
8 // Get session and API handles
9 require_once 'plc_session.php';
10 global $plc, $api;
11
12 // Print header
13 require_once 'plc_drupal.php';
14 include 'plc_header.php';
15
16 // Common functions
17 require_once 'plc_functions.php';
18 require_once 'plc_minitabs.php';
19 require_once 'plc_tables.php';
20
21 // -------------------- 
22 // recognized URL arguments
23 $pattern=$_GET['pattern'];
24
25 // --- decoration
26 $title="Nodegroups";
27 $tabs=array();
28 $tabs []= tab_tags();
29
30 // -------------------- 
31 $node_filter=array();
32
33
34 // fetch objs
35 $nodegroup_columns=array("nodegroup_id","groupname","tagname","value","node_ids");
36
37 // server-side filtering - set pattern in $_GET for filtering on hostname
38 if ($pattern) {
39   $nodegroup_filter['groupname']=$pattern;
40   $title .= " matching " . $pattern;
41  } else {
42   $nodegroup_filter['groupname']="*";
43  }
44
45 // go
46 $nodegroups=$api->GetNodeGroups($nodegroup_filter,$nodegroup_columns);
47
48 // --------------------
49 drupal_set_title($title);
50
51 plc_tabs($tabs);
52
53 if ( ! $nodegroups ) {
54   drupal_set_message ('No node group found');
55   return;
56  }
57   
58
59 $headers = array ( "Name"=>"string",
60                    "Tag"=>"string",
61                    "Value"=>"string",
62                    "Nodes"=>"int");
63
64 # initial sort on groupname
65 $table=new PlcTable("nodegroups",$headers,0);
66 $table->start();
67
68 foreach ($nodegroups as $nodegroup) {
69   $table->row_start();
70   $table->cell (href(l_nodegroup($nodegroup['nodegroup_id']),$nodegroup['groupname']));
71   $table->cell ($nodegroup['tagname']);
72   $table->cell ($nodegroup['value']);
73   $table->cell (count($nodegroup['node_ids']));
74   $table->row_end();
75 }
76
77 $table->end();
78
79 //plc_tabs ($tabs,"bottom");
80
81 // Print footer
82 include 'plc_footer.php';
83
84 ?>