Merge branch 'master' of git.onelab.eu:/git/plewww
[plewww.git] / planetlab / nodes / node_downloads.php
index c457934..d43ada6 100644 (file)
@@ -59,9 +59,11 @@ function deliver_and_unlink ($filename) {
   header ("Pragma: hack");
   header ("Cache-Control: public, must-revalidate");
 
-  // outputs the whole file contents
-  print (file_get_contents($filename));
-  
+  // turn off output buffering
+  ob_end_flush();
+  // outputs the whole file contents without copying it to memory
+  readfile($filename);
   // unlink the file
   if (! unlink ($filename) ) {
     // cannot unlink, but how can we notify this ?
@@ -143,6 +145,8 @@ switch ($action) {
  case "download-node-floppy":
  case "download-node-iso":
  case "download-node-usb":
+ case "download-node-usb-partition":
+
    
    $nodes = $api->GetNodes( array( $node_id ) );
    $node = $nodes[0];
@@ -196,18 +200,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";
@@ -248,7 +260,10 @@ EOF;
    $details->start();
 
    if( ! $interface ) {
+     print ("<center>");
      print (plc_warning("This node has no configured primary interface."));
+     print ("You can add one " . href(l_interface_add($node_id), "here "));
+     print ("</center>");
    } else {
      $details->tr(l_node_t($node_id,"Node details"),"center");
      $details->th_td("node_id",$node_id);