git://git.onelab.eu
/
plewww.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
handling toggle parts visible tag: now rely on local storage, so avoid
[plewww.git]
/
planetlab
/
nodes
/
node_add.php
diff --git
a/planetlab/nodes/node_add.php
b/planetlab/nodes/node_add.php
index
98aa70e
..
cbcb3d0
100644
(file)
--- a/
planetlab/nodes/node_add.php
+++ b/
planetlab/nodes/node_add.php
@@
-1,7
+1,5
@@
<?php
<?php
-// $Id$
-
// Require login
require_once 'plc_login.php';
// Require login
require_once 'plc_login.php';
@@
-18,8
+16,13
@@
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();
// if not a admin, pi, or tech then redirect to node index
// xxx does not take site into account
$has_privileges=plc_is_admin();
+$is_pi_or_tech=plc_is_pi() || plc_is_tech();
if( ! $has_privileges) {
if( ! $has_privileges) {
- drupal_set_error ("Insufficient 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;
}
header( "index.php" );
return 0;
}
@@
-36,8
+39,9
@@
if ( $_POST['add-node'] ) {
$site_id = trim($_POST['site_id']);
$hostname = trim($_POST['hostname']);
$model= trim($_POST['model']);
$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']);
$method = trim($_POST['method']);
+ $ip = trim($_POST['ip']);
$netmask = trim($_POST['netmask']);
$network = trim($_POST['network']);
$broadcast = trim($_POST['broadcast']);
$netmask = trim($_POST['netmask']);
$network = trim($_POST['network']);
$broadcast = trim($_POST['broadcast']);
@@
-81,7
+85,7
@@
if ( $_POST['add-node'] ) {
drupal_set_error(plc_itemize($errors));
} else {
// add new node and its interface
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) ) {
$node_id= $api->AddNode( intval( $site_id ), $node_fields );
if ( empty($node_id) || ($node_id < 0) ) {
@@
-140,12
+144,15
@@
drupal_set_html_head ('
drupal_set_title('Add a new node to site');
// defaults
drupal_set_title('Add a new node to site');
// defaults
-$method = $_POST['method'];
-if( ! $method ) $method= "static";
-
$model = $_POST['model'];
if( ! $model ) $model= "Custom";
$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.
print <<< EOF
<p class='node_add'>
This page lets you declare a new machine to a site.
@@
-161,7
+168,7
@@
EOF;
$toggle = new PlekitToggle ('add-node',"Add Node",
array('bubble'=>'Add a node - does not enforce PCU - for admins only !',
$toggle = new PlekitToggle ('add-node',"Add Node",
array('bubble'=>'Add a node - does not enforce PCU - for admins only !',
- 'visible'=>get_arg('show_details'
,true
)));
+ 'visible'=>get_arg('show_details')));
$toggle->start();
$details=new PlekitDetails($has_privileges);
$toggle->start();
$details=new PlekitDetails($has_privileges);
@@
-186,6
+193,11
@@
$details->th_td("Site",
$details->th_td("Hostname",$hostname,"hostname");
$details->th_td("Model",$model,"model");
$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',
$method_select = $form->select_html ("method",
interface_method_selectors($api,$method,true),
array('id'=>'method',