From: Thierry Parmentelat Date: Fri, 17 Apr 2009 15:59:14 +0000 (+0000) Subject: improvements X-Git-Tag: PLEWWW-4.3-9~7 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=9699127454f02cca42f1fceed81ded05a3e3765e;p=plewww.git improvements --- diff --git a/planetlab/includes/plc_functions.php b/planetlab/includes/plc_functions.php index 50370d6..a54dd65 100644 --- a/planetlab/includes/plc_functions.php +++ b/planetlab/includes/plc_functions.php @@ -28,6 +28,11 @@ function plc_in_site ($site_id) { return in_array( $site_id, $plc->person['site_ids']); } +function plc_my_site_ids () { + global $plc; + return $plc->person['site_ids']; +} + function plc_my_site_id () { global $plc; return $plc->person['site_ids'][0]; @@ -61,6 +66,7 @@ function l_nodes_site ($site_id) { return "/db/nodes/index.php?site_id=$site_id" function l_nodes_slice ($slice_id) { return "/db/nodes/index.php?slice_id=$slice_id"; } function l_interface ($interface_id) { return "/db/nodes/interface.php?id=$interface_id"; } +function l_interface_tags($interface_id){ return "/db/nodes/interface.php?id=$interface_id&show_details=0&show_tags=1"; } function l_interface_t ($interface_id,$text) { return href (l_interface($interface_id),$text); } function l_interface_add($node_id) { return "/db/nodes/interface.php?node_id=$node_id"; } diff --git a/planetlab/nodes/interface.php b/planetlab/nodes/interface.php index 248ca4f..e766efb 100644 --- a/planetlab/nodes/interface.php +++ b/planetlab/nodes/interface.php @@ -70,6 +70,11 @@ drupal_set_html_head (' '); +$toggle = new PlekitToggle ('interface',"Details", + array('bubble'=>'Display and modify details for that interface', + 'visible'=>get_arg('show_details',true))); +$toggle->start(); + $details=new PlekitDetails($can_update); // xxx hardwire network type for now @@ -125,6 +130,7 @@ switch ($mode) { $details->end(); $form->end(); +$toggle->end(); // no tags if the interface has not been created yet if ($mode == 'add') return; diff --git a/planetlab/nodes/node_add.php b/planetlab/nodes/node_add.php index c19791c..09ab074 100644 --- a/planetlab/nodes/node_add.php +++ b/planetlab/nodes/node_add.php @@ -18,20 +18,13 @@ require_once 'form.php'; // xxx does not take site into account $has_privileges=plc_is_admin() || plc_is_pi() || plc_is_tech(); if( ! $has_privileges) { - drupal_set_error ("Unsufficient provileges to add a node"); + drupal_set_error ("Insufficient provileges to add a node"); header( "index.php" ); + return 0; } //plc_debug('POST',$_POST); -// this sets up which box is to be checked the first time the page is loaded -// start with static; starting with dhcp does not disable the useless fields -$method= $_POST['method']; -if( $method == "" ) $method= "static"; - -$model= $_POST['model']; -if( $model == "" ) $model= "Custom"; - // if submitted validate and add // could go in actions.php but OTOH when things fail it's more convenient // to show the current values again @@ -144,10 +137,18 @@ drupal_set_html_head (' '); $sites=$api->GetSites(array(plc_my_site_id())); -$sitename=$sites[0]['name']; +$site=$site; +$sitename=$site['name']; drupal_set_title('Add a new node in site "' . $sitename . '"'); +// defaults +$method = $_POST['method']; +if( ! $method ) $method= "static"; + +$model = $_POST['model']; +if( ! $model ) $model= "Custom"; + print <<< EOF

This page lets you declare a new machine in your site. diff --git a/planetlab/nodes/node_downloads.php b/planetlab/nodes/node_downloads.php index f83ebf0..c457934 100644 --- a/planetlab/nodes/node_downloads.php +++ b/planetlab/nodes/node_downloads.php @@ -38,6 +38,7 @@ global $plc, $api; // Common functions require_once 'plc_functions.php'; +require_once 'details.php'; // NOTE: this function exits() after it completes its job, // simply returning leads to html decorations being added around the contents @@ -74,7 +75,8 @@ function show_download_confirm_button ($api, $node_id, $action, $can_gen_config, if( $can_gen_config ) { if ($show_details) { $preview=$api->GetBootMedium($node_id,"node-preview",""); - print ("


Current node configuration contents

"); + print ("
"); + print ("

Configuration file contents

"); print ("
\n$preview
\n"); print ("
"); } @@ -83,12 +85,12 @@ function show_download_confirm_button ($api, $node_id, $action, $can_gen_config, 'download-node-usb' => 'USB image' ); $format = $action_labels [ $action ] ; - print( "

\n"); - print ("\n"); - print ("\n"); - print ("\n"); - print( "\n" ); - print( "
\n" ); + print( "
"); + print (""); + print (""); + print (""); + print( "" ); + print( "
\n" ); } else { echo "

Configuration file cannot be created until missing values above are updated."; } @@ -142,63 +144,48 @@ switch ($action) { case "download-node-iso": case "download-node-usb": - $return= $api->GetNodes( array( $node_id ) ); - $node_detail= $return[0]; + $nodes = $api->GetNodes( array( $node_id ) ); + $node = $nodes[0]; // non-admin people need to be affiliated with the right site if( ! plc_is_admin() ) { - $node_site_id = $node_detail['site_id']; + $node_site_id = $node['site_id']; $in_site = plc_in_site($node_site_id); if( ! $in_site) { $error= "Insufficient permission. You cannot create configuration files for this node."; } } - $hostname= $node_detail['hostname']; - $return= $api->GetInterfaces( array( "node_id" => $node_id ), NULL ); + $hostname= $node['hostname']; + // search for the primary interface + $interfaces = $api->GetInterfaces( array( "node_id" => $node_id, "is_primary"=>true ), NULL ); $can_gen_config= 1; - $has_primary= 0; - - if( count($return) > 0 ) { - foreach( $return as $interface_detail ) { - if( $interface_detail['is_primary'] == true ) { - $has_primary= 1; - break; - } - } - } - if( !$has_primary ) { + if ( ! $interfaces ) { $can_gen_config= 0; } else { - if( $node_detail['hostname'] == "" ) { + $interface = $interfaces[0]; + if ( $node['hostname'] == "" ) { $can_gen_config= 0; - $node_detail['hostname']= "Missing"; + $node['hostname']= plc_warning("Missing"); } + # fields to check $fields= array("method","ip"); + if ( $interface['method'] == "static" ) + $fields = array_merge ( $fields, array("gateway","netmask","network","broadcast","dns1")); foreach( $fields as $field ) { - if( $interface_detail[$field] == "" ) { + if( $interface[$field] == "" ) { $can_gen_config= 0; - $interface_detail[$field]= "Missing"; + $interface[$field]= plc_warning("Missing"); } } - if( $interface_detail['method'] == "static" ) { - $fields= array("gateway","netmask","network","broadcast","dns1"); - foreach( $fields as $field ) { - if( $interface_detail[$field] == "" ) { - $can_gen_config= 0; - $interface_detail[$field]= "Missing"; - } - } - } - - if( $interface_detail['method'] != "static" - && $interface_detail['method'] != "dhcp" ) { + if( $interface['method'] != "static" + && $interface['method'] != "dhcp" ) { $can_gen_config= 0; - $interface_detail['method']= "Unknown method"; + $interface['method']= "Unknown method"; } } @@ -235,77 +222,66 @@ switch ($action) { } } - drupal_set_title("Download boot material for $hostname"); + drupal_set_title("Download boot medium for $hostname"); $header= <<In order to create a configuration file for this node using this page, -all the interface settings must be up to date. Below is summary of these -values. Any missing values must be entered before this can be used. +

+WARNING: Downloading a new boot medium +for this node will generate a new node key, and any +formerly downloaded boot medium for that node will become outdated. +
+
+In order to create a configuration file for this node using this page, +the interface settings must be up to date. Below is summary of these +values. +

EOF; echo $header; show_download_confirm_button($api, $node_id, $action, $can_gen_config, false); - print ("

"); - print ("

Current interface settings

\n"); - -if( $has_primary ) { - print( "\n" ); - - print( "" ); - print( "" ); - print( "\n" ); - print( "" ); - print( "\n" ); - - $nn_id = $interface_detail['interface_id']; - print( "" ); - - print( "" ); - print( "\n" ); - print( "" ); - print( "\n" ); - - if( $interface_detail['method'] == "static" ) { - print( "" ); - print( "\n" ); - print( "" ); - print( "\n" ); - print( "" ); - print( "\n" ); - print( "" ); - print( "\n" ); - print( "" ); - print( "\n" ); - print( "" ); - if( $interface_detail['dns2'] == "" ) { - print( "\n" ); - } else { - print( "\n" ); - } - } + print ("
"); + print ("

Current node configuration

"); - print ("\n"); - $nn_id = $interface_detail['interface_id']; - $settings=$api->GetInterfaceTags(array("interface_id" => array($nn_id))); - foreach ($settings as $setting) { - $category=$setting['category']; - $name=$setting['tagname']; - $value=$setting['value']; - print (" \n"); - } + $details = new PlekitDetails (false); + $details->start(); - print( "
Node Details
node_id:$node_id
Hostname:" . $node_detail['hostname'] . "
Interface Details
Method:" . $interface_detail['method'] . "
IP:" . $interface_detail['ip'] . "
Gateway:" . $interface_detail['gateway'] . "
Network mask:" . $interface_detail['netmask'] . "
Network address:" . $interface_detail['network'] . "
Broadcast address:" . $interface_detail['broadcast'] . "
DNS 1:" . $interface_detail['dns1'] . "
DNS 2:Optional, missing
" . $interface_detail['dns2'] . "
Additional Settings
$category $name $value
\n" ); -} else { - print( "

This node has no configured primary interface.

\n" ); -} + if( ! $interface ) { + print (plc_warning("This node has no configured primary interface.")); + } else { + $details->tr(l_node_t($node_id,"Node details"),"center"); + $details->th_td("node_id",$node_id); + $details->th_td("Hostname",$node['hostname']); + + $interface_id = $interface['interface_id']; + $details->tr(l_interface_t($interface_id,"Interface Details"),"center"); + $details->th_td("Method",$interface['method']); + $details->th_td("IP",$interface['ip']); + + if( $interface['method'] == "static" ) { + $details->th_td("Gateway",$interface['gateway']); + $details->th_td("Network mask",$interface['netmask']); + $details->th_td("Network address",$interface['network']); + $details->th_td("Broadcast address",$interface['broadcast']); + $details->th_td("DNS 1",$interface['dns1']); + if ($interface['dns2']) + $details->th_td("DNS 2",$interface['dns2']); + } + + $details->tr(href(l_interface_tags($interface_id),"Interface extra settings (tags)"),"center"); + $interface_id = $interface['interface_id']; + $settings=$api->GetInterfaceTags(array("interface_id" => array($interface_id))); + if ( ! $settings) { + $details->tr("no tag set","center"); + } else foreach ($settings as $setting) { + $category=$setting['category']; + $name=$setting['tagname']; + $value=$setting['value']; + $details->th_td($category . " " . $name,$value); + } + } + $details->end(); show_download_confirm_button($api, $node_id, $action, $can_gen_config, true); break; diff --git a/planetlab/sites/sites.php b/planetlab/sites/sites.php index 3ae1e97..3fcda14 100644 --- a/planetlab/sites/sites.php +++ b/planetlab/sites/sites.php @@ -100,7 +100,7 @@ if (! plc_is_admin()) { if (plc_is_admin()) $tabs['Joining Sites'] = array ('url'=>l_sites_pending(), - 'bubble'=>'Review pending join requests'); + 'bubble'=>'Review pending join requests'); drupal_set_title($title); plekit_linetabs($tabs);