$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";
$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();
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']
$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'];
// 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
//$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();
$details->space();
//////////////////// type & version
-$details->th_td("Type",$node_type);
$details->th_td("Version",$version);
// let's use plc_objects
$Node = new Node($node);
<?php
-// $Id$
-
// Require login
require_once 'plc_login.php';
$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']);
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) ) {
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.
$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',
}
-$first_time_configuration = false;
-
if (plc_is_admin())
$default_configuration = "ID:f|hostname:f|ST:f|AU:f|RES:f";
else
$nodesconf_exists = false;
if ($column_configuration == "")
{
- $first_time_configuration = true;
$column_configuration = "nodes;default";
$nodesconf_exists = true;
}
$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);
//$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
';
$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();
'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);