X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fnodes%2Fnode_add.php;h=8a17774d936d6b820ade66e0838afae9c50e991d;hb=c0e69680677e153e96e0302633e97e31b1e2c7a6;hp=efec0e3a08eb4c5945806dc5ec6dde1b93d4a584;hpb=86e79674275169c962e48b353d58a4b2976e7cc7;p=plewww.git diff --git a/planetlab/nodes/node_add.php b/planetlab/nodes/node_add.php index efec0e3..8a17774 100644 --- a/planetlab/nodes/node_add.php +++ b/planetlab/nodes/node_add.php @@ -9,27 +9,26 @@ global $plc, $api; // Common functions require_once 'plc_functions.php'; +require_once 'toggle.php'; require_once 'details.php'; require_once 'form.php'; // if not a admin, pi, or tech then redirect to node index // xxx does not take site into account -$has_privileges=plc_is_admin() || plc_is_pi() || plc_is_tech(); +$has_privileges=plc_is_admin(); +$is_pi_or_tech=plc_is_pi() || plc_is_tech(); if( ! $has_privileges) { - drupal_set_error ("Unsufficient provileges to add a node"); + if ( $is_pi_or_tech) { + drupal_goto(l_register_node()); + return 0; + } + drupal_set_error ("Insufficient privileges 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 @@ -37,10 +36,12 @@ if ( $_POST['add-node'] ) { $errors= array(); + $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']); @@ -84,8 +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 ); - $site_id= plc_my_site_id(); + $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) ) { @@ -141,31 +141,63 @@ drupal_set_html_head (' '); -$sites=$api->GetSites(array(plc_my_site_id())); -$sitename=$sites[0]['name']; - -drupal_set_title('Add a new node in site "' . $sitename . '"'); +drupal_set_title('Add a new node to site'); + +// defaults +$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 in your site.
-This must be done before the machine is turned on, as it will allow you to download a boot image when complete for this node.
+This page lets you declare a new machine to a site.
+
+This must be done before the machine is turned on,
+as it will allow you to download a boot image when complete for this node.
-You must enter an IP address even if you use DHCP.
+It is now reserved to admins, as regular users are supposed to use the register wizard, that among other things enforces PCU deployment.
+
+An IP address is required even if you use DHCP.