brute-force changed access to $_GET['key'] to use get_array instead
[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_array($_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 $toggle=new PlekitToggle('details','Details');
56 $toggle->start();
57 $details=new PlekitDetails(plc_is_admin());
58 $details->start();
59 $details->form_start(l_actions(),array("action"=>"update-nodegroup", "nodegroup_id"=>$nodegroup_id));
60 $details->th_td ("Node group name",$nodegroup['groupname'],'groupname');
61 // can't change the target tag
62 $details->th_td ("Based on tag",href(l_tag($nodegroup['tag_type_id']),$tagname));
63 $details->th_td("Matching value",$nodegroup['value'],'value');
64 $details->th_td("# nodes",count($nodegroup['node_ids']));
65 $details->tr_submit("submit","Update Nodegroup");
66 $details->form_end();
67 $details->end();
68
69 $toggle->end();
70
71 // xxx : add & delete buttons would make sense here too
72 $toggle=new PlekitToggle('nodes',"Nodes");
73 $toggle->start();
74
75 $headers["Hostname"]="string";
76
77 $table = new PlekitTable("nodegroup_nodes",$headers,0,array('search_width'=>15));
78 $table->start();
79 if ($nodes) foreach ($nodes as $node) {
80   $table->row_start ();
81   $table->cell ( href (l_node ($node['node_id']),$node['hostname']));
82   $table->row_end ();
83 }
84
85 $table->end ();
86 $toggle->end();
87
88 //plekit_linetabs ($tabs,"bottom");
89
90 // Print footer
91 include 'plc_footer.php';
92
93 ?>