Merge branch 'master' of ssh://git.onelab.eu/git/plewww
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 4 Oct 2011 11:11:50 +0000 (13:11 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 4 Oct 2011 11:11:50 +0000 (13:11 +0200)
planetlab/common/actions.php
planetlab/includes/plc_functions.php
planetlab/nodes/node.php
planetlab/nodes/node_add.php
planetlab/nodes/nodes.php

index dd6a661..8c4beab 100644 (file)
@@ -49,7 +49,7 @@ $known_actions []= "node-boot-state";
 $known_actions []= "delete-node";      
 //     expects:        node_id
 $known_actions []= "update-node";      
-//     expects:        node_id, hostname, model
+//     expects:        node_id, hostname, model, node_type
 $known_actions []= "attach-pcu";
 //     expects:        node_id, pcu_id, port (pcu_id <0 means detach)
 $known_actions []= "reboot-node-with-pcu";
@@ -349,8 +349,9 @@ switch ($action) {
    $node_id=intval($_POST['node_id']);
    $hostname= $_POST['hostname'];
    $model= $_POST['model'];
+   $node_type= $_POST['node_type'];
 
-   $fields= array( "hostname"=>$hostname, "model"=>$model );
+   $fields= array( "hostname"=>$hostname, "model"=>$model, "node_type"=>$node_type );
    $api->UpdateNode( $node_id, $fields );
    $error= $api->error();
 
index a05fdd9..d40de74 100644 (file)
@@ -510,6 +510,27 @@ function plc_redirect ($url) {
   exit ();
 }
 
+//////////////////// the options for an nodetype - suitable for plekit/form
+global $builtin_node_types;
+$builtin_node_types = array ( "regular" => "Regular/Shared",
+                             "reservable" => "Reservable (requires to get leases)");
+function node_type_display ($api, $node_type) {
+  global $builtin_node_types;
+  $val=$builtin_node_types[$node_type];
+  if ( ! $val) $val="??undefined??";
+  return $val;
+}
+
+function node_type_selectors ($api,$node_type) {
+  global $builtin_node_types;
+  foreach ($builtin_node_types as $value=>$display) {
+    $selector=array('display'=>$display, 'value'=>$value);
+    if ($value == $node_type) $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']
index 4d8ccb5..f7c5e6f 100644 (file)
@@ -42,8 +42,8 @@ $boot_state= $node['boot_state'];
 $run_level = $node['run_level'];
 $site_id= $node['site_id'];
 $model= $node['model'];
+$node_type= $node['node_type'];
 $version= $node['version'];
-$node_type = $node['node_type'];
 
 // arrays of ids of node info
 $slice_ids= $node['slice_ids'];
@@ -99,7 +99,8 @@ $local_peer= ! $peer_id;
 
   
 // extra privileges to admins, and (pi||tech) on this site
-$privileges = (plc_is_admin () && $local_peer) || ( plc_in_site($site_id) && ( plc_is_pi() || plc_is_tech()));
+$admin_privileges=(plc_is_admin () && $local_peer);
+$privileges =  $admin_privileges || ( plc_in_site($site_id) && ( plc_is_pi() || plc_is_tech()));
   
 $tabs=array();
 // available actions
@@ -146,6 +147,15 @@ $details->form_start(l_actions(),array("action"=>"update-node", "node_id"=>$node
 //$details->th_td("Hostname",$hostname,"hostname"); 
 $details->th_td("Hostname",$hostname); 
 $details->th_td("Model",$model,"model");
+// reservation ?
+if ( $admin_privileges) {
+  $reservation_value = $details->form->select_html("node_type",
+                                                  node_type_selectors ($api, $node_type));
+} else {
+  $reservation_value = node_type_display ($api,$node_type);
+}
+$details->th_td("Reservation",$reservation_value);
+
 $details->tr_submit("submit","Update Node");
 $details->form_end();
 if ($privileges) $details->space();
@@ -276,7 +286,6 @@ I've experienced a problem rebooting $hostname with the pcu_id $pcu_id;
 $details->space();
 
 //////////////////// type & version
-$details->th_td("Type",$node_type);
 $details->th_td("Version",$version);
 // let's use plc_objects
 $Node = new Node($node);
index 115f177..8a17774 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 
-// $Id$ 
-
 // Require login
 require_once 'plc_login.php';
 
@@ -41,8 +39,9 @@ if ( $_POST['add-node'] )  {
   $site_id = trim($_POST['site_id']);
   $hostname = trim($_POST['hostname']);
   $model= trim($_POST['model']);
-  $ip = trim($_POST['ip']);
+  $node_type = trim ($_POST['node_type']);
   $method = trim($_POST['method']);
+  $ip = trim($_POST['ip']);
   $netmask = trim($_POST['netmask']);
   $network = trim($_POST['network']);
   $broadcast = trim($_POST['broadcast']);
@@ -86,7 +85,7 @@ if ( $_POST['add-node'] )  {
     drupal_set_error(plc_itemize($errors));
   } else {
     // add new node and its interface
-    $node_fields= array( "hostname"=>$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
 <p class='node_add'>
 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',
index ff11dc4..8f9a9b6 100644 (file)
@@ -71,8 +71,6 @@ function node_status ($node) {
 }
 
 
-$first_time_configuration = false;
-
 if (plc_is_admin()) 
        $default_configuration = "ID:f|hostname:f|ST:f|AU:f|RES:f";
 else
@@ -104,7 +102,6 @@ foreach ($PersonTags as $ptag) {
 $nodesconf_exists = false;
 if ($column_configuration == "")
 {
-        $first_time_configuration = true;
         $column_configuration = "nodes;default";
         $nodesconf_exists = true;
 }
@@ -319,37 +316,10 @@ if ( ! $nodes ) {
   
 $nifty=new PlekitNifty ('','objects-list','big');
 $nifty->start();
-$headers = array (); $offset=0;
+$headers = array (); 
 $notes=array();
 $notes [] = "For information about the different columns please see the <b>node table layout</b> tab above or <b>mouse over</b> the column headers";
 
-
-/*
-// fixed columns
-if (plc_is_admin()) { 
-  $short="I"; $long="node_id"; $type='int'; 
-       $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
-  $offset=1; 
- }
-$short="P"; $long="Peer"; $type='string'; 
-       $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
-$short="D"; $long="toplevel domain name"; $type='string'; 
-       $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
-$headers["Site"]="string";
-$headers["Hostname"]="string";
-$short="IP"; $long="IP Address"; $type='sortIPAddress'; 
-       $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
-$short="ST"; $long=Node::status_footnote(); $type='string'; 
-       $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
-$short="SL"; $long="Number of slivers"; $type='int'; 
-       $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
-
-$headers=array_merge($headers,$visibletags->headers());
-$notes=array_merge($notes,$visibletags->notes());
-$short="?"; $long="extra status info"; $type='string'; 
-       $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
-*/
-
 $info_header = array();
 $short="?"; $long="extra status info"; $type='string'; 
 $info_header[$short]=array('type'=>$type,'title'=>$long, 'label'=>'?', 'header'=>'?', 'visible'=>true); 
@@ -357,11 +327,6 @@ $info_header[$short]=array('type'=>$type,'title'=>$long, 'label'=>'?', 'header'=
 //$info_header["?"] = "none";
 $headers = array_merge($ConfigureColumns->get_headers(),$info_header);
 
-if ($first_time_configuration)
-$column_conf_visible = '1';
-else
-$column_conf_visible = '0';
-
 $layout_help='
 This tab allows you to customize the columns in the node tables,
 below. Information on the nodes comes from a variety of monitoring
@@ -374,7 +339,7 @@ href="http://trac.myslice.info">http://trac.myslice.info</a>.
 ';
 $toggle_nodes=new PlekitToggle('nodes-layout',
                                "Node table layout",
-                               array('visible'=>$column_conf_visible
+                               array('visible'=>NULL
                                     'info-text'=>$layout_help,
                                     'info-visible'=>$show_columns_message));
 $toggle_nodes->start();
@@ -400,7 +365,7 @@ $table_options = array('notes'=>$notes,
                         'configurable'=>true);
 
 # initial sort on hostnames
-$table=new PlekitTable ("nodes",$headers,3+$offset, $table_options);
+$table=new PlekitTable ("nodes",$headers,3, $table_options);
 $table->start();
 
 $peers = new Peers ($api);