6917d6a33f3efa10e7b4ace3c467e393284d5ac0
[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 'linetabs.php';
19 require_once 'table.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","tag_type_id");
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 plekit_linetabs($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 PlekitTable("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   // yes, a nodegroup is not a tag, but knows enough for this to work
72   $table->cell (l_tag_obj($nodegroup));
73   $table->cell ($nodegroup['value']);
74   $table->cell (count($nodegroup['node_ids']));
75   $table->row_end();
76 }
77
78 $table->end();
79
80 //plekit_linetabs ($tabs,"bottom");
81
82 // Print footer
83 include 'plc_footer.php';
84
85 ?>