X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fnodes%2Findex.php;h=3a5cb1cff34f078377230b9346dd5adf783eccfc;hb=b7593d9531a46312c686b0e4e20a5d8d6e7e7647;hp=11b263620054aadb8061ff3e211c2fd85520e323;hpb=ff9f6693c80b77de767cd8940ad29ea3fc785091;p=plewww.git
diff --git a/planetlab/nodes/index.php b/planetlab/nodes/index.php
index 11b2636..3a5cb1c 100644
--- a/planetlab/nodes/index.php
+++ b/planetlab/nodes/index.php
@@ -5,502 +5,7 @@
// Require login
require_once 'plc_login.php';
-// Get session and API handles
-require_once 'plc_session.php';
-global $plc, $api, $adm;
-
-// Print header
-require_once 'plc_drupal.php';
-drupal_set_title('Nodes');
-include 'plc_header.php';
-
-// Common functions
-require_once 'plc_functions.php';
-require_once 'plc_sorts.php';
-
-// find person roles
-$_person= $plc->person;
-$_roles= $_person['role_ids'];
-
-////////////////////
-// The set of columns to fetch
-// and the filter applied for fetching sites
-$columns = array( "node_id", "hostname", "boot_state", "peer_id" ) ;
-$filter = array("node_type"=>"regular");
-if ( in_array( '10', $_roles ) || in_array('20', $_roles) || in_array('40',$_roles)) {
- // admins, PIs and techs can see interface details
- $columns [] = "interface_ids";
- }
-
-//////////////////
-// perform post-processing on objects as returned by GetNodes
-// performs sanity check and summarize the result in a single column
-// performs in-place replacement, so passes a reference
-function layout_node ($node) {
-
- // we need the 'interface_ids' field to do this
- // so regular users wont run this
- if ( ! array_key_exists ('interface_ids', $node))
- return $node;
-
- $messages=array();
-
- // do all this stuff on local nodes only
- if ( ! $node['peer_id'] ) {
- // check that the node has keys
- if (count($node['interface_ids']) == 0)
- $messages [] = "No interface";
-
- }
- // but always cleanup $node columns
- unset ($node['interface_ids']);
- $node['status'] = plc_make_table('plc-warning',$messages);
- $node['comon'] = plc_comon_button("node_id",$node['node_id']);
- return $node;
-}
-
-// if nodepattern is set then set id to that node's id.
-// we use GET rather than POST so paginate can display the right contents on subsequent pages
-// can be useful for writing bookmarkable URL's as well
-if( $_GET['nodepattern'] || $_GET['peerscope']) {
-
- // nodepattern
- $nodepattern= $_GET['nodepattern'];
- // need to use a hash filter for patterns to be properly handled
- if (empty($nodepattern)) {
- $nodepattern="*";
- }
- $filter = array_merge (array( "hostname"=>$nodepattern ), $filter);
-
- // peerscope
- list ( $peer_filter, $peer_label) = plc_peer_info($api,$_GET['peerscope']);
- $filter=array_merge($filter,$peer_filter);
-
- $nodes= $api->GetNodes($filter, $columns);
- $nodes_count = count ($nodes);
- if ( $nodes_count == 1) {
- header( "location: index.php?id=". $nodes[0]['node_id'] );
- exit();
- } else if ( $nodes_count == 0) {
- echo " No node matching $nodepattern ";
- } else {
- drupal_set_title ("Nodes matching $nodepattern on". $peer_label);
- $nodes = array_map(layout_node,$nodes);
- sort_nodes ($nodes);
- echo paginate( $nodes, "node_id", "Nodes", 25, "hostname");
- }
-}
-// if a site_id is given, display the site nodes only
-else if( $_GET['site_id'] ) {
-
- $site_id= $_GET['site_id'];
-
- // Get site info
- $site_info= $api->GetSites( array( intval( $site_id ) ), array( "name", "node_ids" ) );
- drupal_set_title("Nodes on site " . $site_info[0]['name']);
-
- // Get site nodes
- $nodes= $api->GetNodes( array_merge(array('node_id'=>$site_info[0]['node_ids']),$filter), $columns);
-
- if ( empty ($nodes) ) {
- echo "No node to display";
- } else {
-
- $nodes = array_map(layout_node,$nodes);
- sort_nodes( $nodes );
-
- echo paginate( $nodes, "node_id", "Nodes", 25, "hostname");
- }
-
-}
-// if a slice_id is given, display only the nodes related to this slice
-else if( $_GET['slice_id'] ) {
-
- $slice_id= $_GET['slice_id'];
-
- // Get slice infos
- $slice_info= $api->GetSlices( array( intval( $slice_id ) ), array( "name", "node_ids" ) );
- drupal_set_title("nodes where " . $slice_info[0]['name'] . " is running");
-
- // Get slice nodes
- $nodes= $api->GetNodes( array_merge(array('node_id'=>$slice_info[0]['node_ids']),$filter), $columns);
-
- if ( empty ($nodes) ) {
- echo "No node to display";
- } else {
-
- $nodes = array_map(layout_node,$nodes);
- sort_nodes( $nodes );
-
- echo paginate( $nodes, "node_id", "Nodes", 25, "hostname");
- echo "
"; - if ($is_admin) { - echo plc_event_button("Node","node",$node_id); - echo " | "; - } - echo plc_comon_button("node_id",$node_id); - echo " | "; - echo "\n"; - - echo " |
Hostname: | $hostname |
---|---|
Model: | $model |
Version: | $version |
Boot State: | "; - if ($peer_id) { - echo $boot_state; - } else { - echo ""; - } - echo " |
Download | "; - echo ""; - echo " |
Site: | $site_name |
All site nodes: | ";
- if (empty($site_node)) {
- echo "Site has no node";
- } else {
- foreach( $site_node as $key => $val ) {
- echo "$val "; - } - } - echo " |
"; - } - echo " | IP Address | Method | Type | MAC | Bandwidth Limit | |
---|---|---|---|---|---|---|
"; - if (!$nn_primary) { - echo plc_delete_link_button('interfaces.php?id=' . $nn_id . '&delete=1&submitted=1', '\\nInterface ' . $nn_ip); - } else { - echo ' P '; - } - echo " | "; - } - echo ""; - if( $is_admin || $is_pi || $is_tech ) { - echo "$nn_ip"; - } else { - echo " | $nn_ip | "; - } - echo "$nn_method | $nn_type | $nn_mac | $nn_bwlimit |
No interface. Please add an interface to make this a usable PLC node
.\n"; - } - - echo "Name | Description | "; - if( in_array( 10, $_roles ) ) echo ""; - echo " | |
---|---|---|---|
". $node_group['name'] ." | ". $node_group['description'] ." | "; - - if( in_array( '10', $_roles ) || ( in_array( 20, $_roles ) && in_array( $site_id, $_person['site_ids'] ) ) || ( in_array( 40, $_roles ) && in_array( $site_id, $_person['site_ids'] ) ) ) - echo "Update | remove | "; - - echo "
This node is not in any nodegroup.
\n"; - } - - // select list for adding to node group - // get nodegroup info - $full_ng_info= $api->GetNodeGroups( NULL ); - if( empty( $node_groups ) ) { - $person_ng= $full_ng_info; - } else { - $person_ng= arr_diff( $full_ng_info, $node_groups ); - } - - sort_nodegroups( $person_ng ); - - if( !empty( $person_ng ) ) { - echo "Select nodegroup to add this node to.
\n";
- echo "\n";
- }
-
-
- // display slices
- echo "
This node is not associated to any slice.
\n"; - } - - - // display events - disabled, see GetEvents above - if( !empty( $event_info ) ) { - echo "Call Name | Call | Message | Time | |
---|---|---|---|---|
". $event['call'] ." | ". $event['message'] ." | ". $event['time'] ." |
Back to nodes list"; - - } - -// Print footer -include 'plc_footer.php'; +if ($_GET['id']) require ('node.php') ; +else require ('nodes.php'); ?>