nodes can set tags, tags and nodegroups are mostly OK
[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 //require_once 'plc_forms.php';
22 //require_once 'plc_peers.php';
23
24 // -------------------- 
25 // recognized URL arguments
26 $nodegroup_id=intval($_GET['id']);
27 if ( ! $nodegroup_id ) { plc_error('Malformed URL - id not set'); return; }
28
29 ////////////////////
30 // Get all columns as we focus on only one entry
31 $nodegroups= $api->GetNodeGroups( array($nodegroup_id));
32
33 if (empty($nodegroups)) {
34   drupal_set_message ("NodeGroup " . $nodegroup_id . " not found");
35   return;
36  }
37
38 $nodegroup=$nodegroups[0];
39 $node_ids=$nodegroup['node_ids'];
40 $tagname=$nodegroup['tagname'];
41
42 # fetch corresponding nodes
43 $node_columns = array("hostname","node_id");
44
45 $nodes = $api->GetNodes( $node_ids, $node_columns);
46
47 $tabs ["All nodegroups"] = array ('url'=>l_nodegroups(),
48                                   'bubble'=>'All nodegroups');
49 $tabs ["All tags"] = array ('url'=>l_tags(),
50                             'bubble'=>'All tags');
51 $tabs ["Local nodes"] = array ('url'=>l_nodes_peer('local'),
52                              'bubble'=>'All local nodes');
53
54 drupal_set_title("Details for node group " . $nodegroup['groupname']);
55 plc_tabs($tabs);
56
57 plc_details_start();
58 plc_details_line ("Node group name",$nodegroup['groupname']);
59 plc_details_line ("Based on tag",href(l_tag($nodegroup['tag_type_id']),$tagname));
60 plc_details_line("Matching value",$nodegroup['value']);
61 plc_details_line("# nodes",count($nodegroup['node_ids']));
62 plc_details_end();
63
64 // xxx : add & delete buttons would make sense here too
65 plc_section("Nodes");
66
67 $headers["Hostname"]="string";
68
69 plc_table_start("nodegroup_nodes",$headers,0,array('search_width'=>15));
70 if ($nodes) foreach ($nodes as $node) {
71   plc_table_row_start ();
72   plc_table_cell ( href (l_node ($node['node_id']),$node['hostname']));
73   plc_table_row_end ();
74 }
75
76 plc_table_end ("nodegroup_nodes");
77 // Print footer
78 include 'plc_footer.php';
79
80 ?>