From 4d38a9f27bb1e4ff10863dd3ba164747f76cd8ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Fri, 11 Dec 2009 12:22:56 +0000 Subject: [PATCH] - "Add Node" is admin only. - Let admins select a site for the node. --- planetlab/nodes/node_add.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/planetlab/nodes/node_add.php b/planetlab/nodes/node_add.php index 63b9fd5..98aa70e 100644 --- a/planetlab/nodes/node_add.php +++ b/planetlab/nodes/node_add.php @@ -17,7 +17,7 @@ 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(); if( ! $has_privileges) { drupal_set_error ("Insufficient provileges to add a node"); header( "index.php" ); @@ -33,6 +33,7 @@ if ( $_POST['add-node'] ) { $errors= array(); + $site_id = trim($_POST['site_id']); $hostname = trim($_POST['hostname']); $model= trim($_POST['model']); $ip = trim($_POST['ip']); @@ -81,7 +82,6 @@ if ( $_POST['add-node'] ) { } else { // add new node and its interface $node_fields= array( "hostname"=>$hostname, "model"=>$model ); - $site_id= plc_my_site_id(); $node_id= $api->AddNode( intval( $site_id ), $node_fields ); if ( empty($node_id) || ($node_id < 0) ) { @@ -137,11 +137,7 @@ drupal_set_html_head (' '); -$sites=$api->GetSites(array(plc_my_site_id())); -$site=$sites[0]; -$sitename=$site['name']; - -drupal_set_title('Add a new node in site "' . $sitename . '"'); +drupal_set_title('Add a new node to site'); // defaults $method = $_POST['method']; @@ -152,12 +148,12 @@ if( ! $model ) $model= "Custom"; print <<< EOF

-This page lets you declare a new machine in your site. +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.
- It is now reserved to admins, as regular users are supposed to use the register wizard, that among other things enforces PCU deployment. +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.

@@ -178,6 +174,16 @@ $form=$details->form_start('/db/nodes/node_add.php',$form_variables, $details->start(); +$site_columns=array( "site_id", "name", "login_base" ); +$local_sites= $api->GetSites( array("peer_id"=>NULL, '-SORT'=>'name'), $site_columns ); +function site_selector($site) { return array('display'=>$site['name'],"value"=>$site['site_id']); } +$site_selector = array_map ("site_selector",$local_sites); +$site_select = $form->select_html("site_id", $site_selector, array('id'=>'site_id')); +$details->th_td("Site", + $site_select, + "site_id", + array('input_type'=>'select','value'=>$interface['site_id'])); + $details->th_td("Hostname",$hostname,"hostname"); $details->th_td("Model",$model,"model"); $method_select = $form->select_html ("method", -- 2.45.2