X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fnodes%2Fnode_downloads.php;h=c037c1a7bcbfba614ea071e5956a2034975873b5;hb=2acd8f63883ad55c2c3c204d3b11db86da3417d2;hp=8af032b3571299e9954ae4f2edae48bffd2f4f85;hpb=f99cfc8401815836073effa34c5cda024e77a3a9;p=plewww.git diff --git a/planetlab/nodes/node_downloads.php b/planetlab/nodes/node_downloads.php index 8af032b..c037c1a 100644 --- a/planetlab/nodes/node_downloads.php +++ b/planetlab/nodes/node_downloads.php @@ -1,7 +1,5 @@ GetBootMedium($node_id,"node-preview",""); - print ("

Current node configuration contents

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

Configuration file contents

"); print ("
\n$preview
\n"); print ("
"); } @@ -84,12 +72,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,64 +130,51 @@ switch ($action) { case "download-node-floppy": case "download-node-iso": case "download-node-usb": + case "download-node-usb-partition": + - $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"; } } @@ -210,18 +185,26 @@ switch ($action) { case 'download-node-floppy': $boot_action='node-floppy'; $location = "%d/%n-%v-rename-into-plnode%s"; + $options = array(); break; case 'download-node-iso': $boot_action='node-iso'; $location = "%d/%n-%a-%v%s"; + $options = array(); break; case 'download-node-usb': $boot_action='node-usb'; $location = "%d/%n-%a-%v%s"; + $options = array(); + break; + case "download-node-usb-partition": + $boot_action='node-usb'; + $location = "%d/%n-%a-%v-partition%s"; + $options = array('partition'); break; } - $filename=$api->GetBootMedium($node_id,$boot_action,$location); + $filename=$api->GetBootMedium($node_id,$boot_action,$location,$options); $error=$api->error(); if (empty($error) && empty($filename)) { $error="Unexpected error from GetBootMedium - probably wrong directory modes"; @@ -236,77 +219,69 @@ 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 ("
"); + print (plc_warning("This node has no configured primary interface.")); + print ("You can add one " . href(l_interface_add($node_id), "here ")); + print ("
"); + } 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;