3 // $Id: index.php 11577 2009-01-16 06:29:51Z thierry $
6 require_once 'plc_login.php';
8 // Get session and API handles
9 require_once 'plc_session.php';
13 require_once 'plc_drupal.php';
14 include 'plc_header.php';
17 require_once 'plc_functions.php';
18 require_once 'plc_minitabs.php';
19 require_once 'plc_tables.php';
22 //require_once 'plc_sorts.php';
24 $_person= $plc->person;
25 $_roles= $_person['role_ids'];
27 // --------------------
28 // recognized URL arguments
29 $node_id=intval($_GET['id']);
30 if ( ! $node_id ) { plc_error('Malformed URL - id not set'); return; }
33 // Get all columns as we focus on only one entry
34 $nodes= $api->GetNodes( array($node_id));
37 drupal_set_message ("Node " . $node_id . " not found");
41 $hostname= $node['hostname'];
42 $boot_state= $node['boot_state'];
43 $site_id= $node['site_id'];
44 $model= $node['model'];
45 $version= $node['version'];
46 $node_type = $node['node_type'];
48 // arrays of ids of node info
49 $slice_ids= $node['slice_ids'];
50 $conf_file_ids= $node['conf_file_ids'];
51 $interface_ids= $node['interface_ids'];
52 $nodegroup_ids= $node['nodegroup_ids'];
53 $pcu_ids= $node['pcu_ids'];
56 $peer_id= $node['peer_id'];
59 $sites= $api->GetSites( array( $site_id ) );
61 $site_name= $site['name'];
62 $site_node_ids= $site['node_ids'];
64 $site_node_hash=array();
65 if( !empty( $site_node_ids ) ) {
66 // get site node info basics
67 $site_nodes= $api->GetNodes( $site_node_ids );
69 foreach( $site_nodes as $site_node ) {
70 $site_node_hash[$site_node['node_id']]= $site_node['hostname'];
74 // gets slice info for each slice
75 if( !empty( $slice_ids ) )
76 $slices= $api->GetSlices( $slice_ids, array( "slice_id", "name" , "peer_id" ) );
78 // gets conf file info
79 if( !empty( $conf_file_ids ) )
80 $conf_files= $api->GetConfFiles( $conf_file_ids );
83 if( !empty( $interface_ids ) )
84 $interfaces= $api->GetInterfaces( $interface_ids );
86 // gets nodegroup info
87 if( !empty( $nodegroup_ids ) )
88 $nodegroups= $api->GetNodeGroups( $nodegroup_ids, array("groupname","tag_type_id","value"));
90 // xxx Thierry : disabling call to GetEvents, that gets the session deleted in the DB
91 // needs being reworked
93 // gets pcu and port info key to both is $pcu_id
94 if( !empty( $pcu_ids ) )
95 $PCUs= $api->GetPCUs( $pcu_ids );
99 plc_peer_block_start ($peer_hash,$peer_id);
101 drupal_set_title("Details for node " . $hostname);
103 // extra privileges to admins, and (pi||tech) on this site
104 $extra_privileges = plc_is_admin () || ( plc_in_site($site_id) && ( plc_is_pi() || plc_is_tech()));
108 if ( ! $peer_id && $extra_privileges ) {
110 $tabs['Update'] = array ('url'=>"/db/nodes/node_actions.php",
112 'values'=>array('action'=>'prompt-update','node_id'=>$node_id));
113 $tabs['Delete'] = array ('url'=>"/db/nodes/node_actions.php",
115 'values'=>array('action'=>'delete','node_id'=>$node_id),
116 'confirm'=>'Are you sure to delete ' . $hostname. ' ?');
117 // xxx subject to roles
118 $tabs["Add Interface"]=l_interface_add_u($node_id);
119 $tabs["Comon"]=l_comon("node_id",$node_id);
120 $tabs["Events"]=l_event("Node","node",$node_id);
122 $tabs["All nodes"]=l_nodes();
129 echo "<table><tbody>\n";
131 echo "<tr><th>Hostname: </th><td> $hostname </td></tr>\n";
132 echo "<tr><th>Type: </th><td> $node_type</td></tr>\n";
133 echo "<tr><th>Model: </th><td> $model</td></tr>\n";
134 echo "<tr><th>Version: </th><td> $version</td></tr>\n";
136 echo "<tr><th>Boot State: </th><td>";
140 echo "<form name='bootstate' action='/db/nodes/node_actions.php' method=post>\n";
141 echo "<input type=hidden name='node_id' value='$node_id'>\n";
142 echo "<input type=hidden name='action' value='boot-state'>\n";
143 echo "<select name='boot_state' onChange=\"submit();\">\n";
145 $states= array( 'boot'=>'Boot', 'dbg'=>'Debug', 'inst'=>'Install', 'rins'=>'Reinstall', 'rcnf'=>'Reconfigure', 'new'=>'New' );
147 foreach( $states as $key => $val ) {
148 echo "<option value='$key'";
150 if( $key == $boot_state )
153 echo ">$val</option>\n";
157 echo "</select></input></form>";
161 if ( ! $peer_id && $extra_privileges) {
163 echo "<tr><th>Download </th><td>";
164 echo "<form name='download' action='/db/nodes/node_actions.php' method='post'>\n";
165 echo "<input type=hidden name='node_id' value='$node_id'></input>\n";
166 echo "<select name='action' onChange='submit();'>\n";
167 echo "<option value='' selected='selected'> Download Mode </option>\n";
168 echo "<option value='' disabled='disabled'> -- All in one images -- </option>";
169 echo "<option value='download-node-iso' $new_api_only> Download ISO image for $hostname</option>\n";
170 echo "<option value='download-node-usb' $new_api_only> Download USB image for $hostname</option>\n";
171 echo "<option value='' disabled='disabled'> -- Floppy + generic image -- </option>";
172 echo "<option value='download-node-floppy'> Download Floppy file for $hostname</option>\n";
173 echo "<option value='download-generic-iso' $new_api_only> Download generic ISO image (requires floppy) </option>\n";
174 echo "<option value='download-generic-usb' $new_api_only> Download generic USB image (requires floppy) </option>\n";
175 echo "</select></form>";
180 // site info and all site nodes
181 echo "<tr><td colspan=2> </td></tr>\n";
182 echo "<tr><th>Site: </th><td> <a href='/db/sites/index.php?id=$site_id'>$site_name</a></td></tr>\n";
183 echo "<tr><th>All site nodes: </th><td>";
184 if (empty($site_node_hash)) {
185 echo "<span class='plc-warning'>Site has no node</span>";
187 foreach( $site_node_hash as $key => $val ) {
188 echo "<a href=index.php?id=$key>$val</a><br />";
193 echo "</tbody></table><br />\n";
195 //////////////////////////////////////////////////////////// interfaces
198 // display interfaces
199 if( ! $interfaces ) {
200 echo "<p><span class='plc-warning'>No interface</span>. Please add an interface to make this a usable PLC node</p>.\n";
203 if ( $extra_privileges ) {
204 // a single symbol, marking 'p' for primary and a delete button for non-primary
205 $columns[' ']='string';
208 $columns["IP"]="IPAddress";
209 $columns["Method"]="string";
210 $columns["Type"]="string";
211 $columns["MAC"]="string";
212 $columns["bw limit"]="FileSize";
215 plc_table_title('Interfaces');
216 plc_table_start("interfaces",$columns,2,false);
218 foreach ( $interfaces as $interface ) {
219 $interface_id= $interface['interface_id'];
220 $interface_ip= $interface['ip'];
221 $interface_broad= $interface['broadcast'];
222 $interface_primary= $interface['is_primary'];
223 $interface_network= $interface['network'];
224 $interface_dns1= $interface['dns1'];
225 $interface_dns2= $interface['dns2'];
226 $interface_hostname= $interface['hostname'];
227 $interface_netmaks= $interface['netmask'];
228 $interface_gatewary= $interface['gateway'];
229 $interface_mac= $interface['mac'];
230 $interface_bwlimit= $interface['bwlimit'];
231 $interface_type= $interface['type'];
232 $interface_method= $interface['method'];
234 plc_table_row_start($interface['ip']);
235 if ( $extra_privileges ) {
236 if (!$interface_primary) {
238 plc_table_cell (plc_delete_link_button ('interfaces.php?id=' . $interface_id . '&delete=1&submitted=1',
239 '\\nInterface ' . $interface_ip));
244 plc_table_cell(l_interface2($interface_id,$interface_ip));
245 plc_table_cell($interface_method);
246 plc_table_cell($interface_type);
247 plc_table_cell($interface_mac);
248 plc_table_cell($interface_bwlimit);
256 //////////////////////////////////////////////////////////// slices
258 $peer_hash = plc_peer_get_hash ($api);
261 plc_table_title ("Slices");
263 echo "<p><span class='plc-warning'>This node is not associated to any slice.</span></p>\n";
266 $columns['Peer']="string";
267 $columns['Name']="string";
268 $columns['Slivers']="string";
269 plc_table_start ("slivers",$columns,1);
271 foreach ($slices as $slice) {
272 plc_table_row_start($slice['name']);
273 plc_table_cell (plc_peer_shortname($peer_hash,$slice['peer_id']));
274 plc_table_cell (l_slice2 ($slice['slice_id'],$slice['name']));
275 plc_table_cell (l_sliver3 ($node_id,$slice['slice_id'],'view'));
281 //////////////////////////////////////////////////////////// nodegroups
282 // display node group info
283 if ( ! $nodegroups ) {
284 echo "<p><span class='plc-warning'>This node is not in any nodegroup.</span></p>\n";
287 $columns['Name']="string";
288 $columns['Tag']="string";
289 $columns['Value']="string";
292 plc_table_title("Nodegroups");
293 plc_table_start("nodegroups",$columns,0,false);
295 foreach( $nodegroups as $nodegroup ) {
296 plc_table_row_start();
297 plc_table_cell(l_nodegroup2($nodegroup_id,$nodegroup['groupname']));
298 $tag_types=$api->GetTagTypes(array($nodegroup['tag_type_id']));
299 plc_table_cell($tag_types[0]['tagname']);
300 plc_table_cell($nodegroup['value']);
306 ////////////////////////////////////////////////////////////
307 plc_peer_block_end();
311 include 'plc_footer.php';