From: Thierry Parmentelat Date: Tue, 4 Oct 2011 10:28:16 +0000 (+0200) Subject: 'add node' dialog can create reservable nodes X-Git-Tag: plewww-4.3-68~8 X-Git-Url: http://git.onelab.eu/?p=plewww.git;a=commitdiff_plain;h=c0e69680677e153e96e0302633e97e31b1e2c7a6 'add node' dialog can create reservable nodes --- diff --git a/planetlab/includes/plc_functions.php b/planetlab/includes/plc_functions.php index a05fdd9..8de54c5 100644 --- a/planetlab/includes/plc_functions.php +++ b/planetlab/includes/plc_functions.php @@ -510,6 +510,18 @@ function plc_redirect ($url) { exit (); } +//////////////////// the options for an nodetype - suitable for plekit/form +function node_type_selectors ($api,$nodetype) { + $builtin_types = array ( "regular" => "Regular/Shared", + "reservable" => "Reservable (requires to get leases)"); + foreach ($builtin_types as $value=>$display) { + $selector=array('display'=>$display, 'value'=>$value); + if ($value == $nodetype) $selector['selected']=true; + $selectors []= $selector; + } + return $selectors; +} + //////////////////// the options for an interface - suitable for plekit/form //>>> GetNetworkMethods() //[u'static', u'dhcp', u'proxy', u'tap', u'ipmi', u'unknown'] diff --git a/planetlab/nodes/node_add.php b/planetlab/nodes/node_add.php index 115f177..8a17774 100644 --- a/planetlab/nodes/node_add.php +++ b/planetlab/nodes/node_add.php @@ -1,7 +1,5 @@ $hostname, "model"=>$model ); + $node_fields= array( "hostname"=>$hostname, "model"=>$model , "node_type" => $node_type); $node_id= $api->AddNode( intval( $site_id ), $node_fields ); if ( empty($node_id) || ($node_id < 0) ) { @@ -145,12 +144,15 @@ drupal_set_html_head (' drupal_set_title('Add a new node to site'); // defaults -$method = $_POST['method']; -if( ! $method ) $method= "static"; - $model = $_POST['model']; if( ! $model ) $model= "Custom"; +$node_type = $_POST['node_type']; +if ( ! $node_type ) $node_type= "regular"; + +$method = $_POST['method']; +if( ! $method ) $method= "static"; + print <<< EOF

This page lets you declare a new machine to a site. @@ -191,6 +193,11 @@ $details->th_td("Site", $details->th_td("Hostname",$hostname,"hostname"); $details->th_td("Model",$model,"model"); +$node_type_select = $form->select_html ("node_type", + node_type_selectors($api,$node_type), + array('id'=>'node_type')); +$details->th_td("Reservation",$node_type_select,"node_type", + array('input_type'=>'select','value'=>$node_type)); $method_select = $form->select_html ("method", interface_method_selectors($api,$method,true), array('id'=>'method',