more inline updates & cleaned up tags
[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 ["All nodegroups"] = array ('url'=>l_nodegroups(),
46                                   'bubble'=>'All nodegroups');
47 $tabs ["All tags"] = array ('url'=>l_tags(),
48                             'bubble'=>'All tags');
49 $tabs ["Local nodes"] = array ('url'=>l_nodes_peer('local'),
50                              'bubble'=>'All local nodes');
51
52 drupal_set_title("Details for node group " . $nodegroup['groupname']);
53 plc_tabs($tabs);
54
55 $details=new PlcDetails(false);
56 $details->start();
57 $details->line ("Node group name",$nodegroup['groupname']);
58 $details->line ("Based on tag",href(l_tag($nodegroup['tag_type_id']),$tagname));
59 $details->line("Matching value",$nodegroup['value']);
60 $details->line("# nodes",count($nodegroup['node_ids']));
61 $details->end();
62
63 // xxx : add & delete buttons would make sense here too
64 plc_section("Nodes");
65
66 $headers["Hostname"]="string";
67
68 $table = new PlcTable("nodegroup_nodes",$headers,0,array('search_width'=>15));
69 $table->start();
70 if ($nodes) foreach ($nodes as $node) {
71   $table->row_start ();
72   $table->cell ( href (l_node ($node['node_id']),$node['hostname']));
73   $table->row_end ();
74 }
75
76 $table->end ();
77 // Print footer
78 include 'plc_footer.php';
79
80 ?>