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