caa62b6932eb552455c35186ec1f1c46730b3352
[plewww.git] / planetlab / tags / nodegroup.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 require_once 'plc_details.php';
21
22 // -------------------- 
23 // recognized URL arguments
24 $nodegroup_id=intval($_GET['id']);
25 if ( ! $nodegroup_id ) { plc_error('Malformed URL - id not set'); return; }
26
27 ////////////////////
28 // Get all columns as we focus on only one entry
29 $nodegroups= $api->GetNodeGroups( array($nodegroup_id));
30
31 if (empty($nodegroups)) {
32   drupal_set_message ("NodeGroup " . $nodegroup_id . " not found");
33   return;
34  }
35
36 $nodegroup=$nodegroups[0];
37 $node_ids=$nodegroup['node_ids'];
38 $tagname=$nodegroup['tagname'];
39
40 # fetch corresponding nodes
41 $node_columns = array("hostname","node_id");
42
43 $nodes = $api->GetNodes( $node_ids, $node_columns);
44
45 $tabs = array();
46
47 $tabs []= tab_tags();
48 $tabs []= tab_nodegroups();
49 $tabs []= tab_nodes_local();
50
51 drupal_set_title("Details for node group " . $nodegroup['groupname']);
52 plc_tabs($tabs);
53
54 $details=new PlcDetails(false);
55 $details->start();
56 $details->th_td ("Node group name",$nodegroup['groupname']);
57 $details->th_td ("Based on tag",href(l_tag($nodegroup['tag_type_id']),$tagname));
58 $details->th_td("Matching value",$nodegroup['value']);
59 $details->th_td("# nodes",count($nodegroup['node_ids']));
60 $details->end();
61
62 // xxx : add & delete buttons would make sense here too
63 plc_section("Nodes");
64
65 $headers["Hostname"]="string";
66
67 $table = new PlcTable("nodegroup_nodes",$headers,0,array('search_width'=>15));
68 $table->start();
69 if ($nodes) foreach ($nodes as $node) {
70   $table->row_start ();
71   $table->cell ( href (l_node ($node['node_id']),$node['hostname']));
72   $table->row_end ();
73 }
74
75 $table->end ();
76
77 plc_tabs ($tabs,"bottom");
78
79 // Print footer
80 include 'plc_footer.php';
81
82 ?>