person; $_roles= $_person['role_ids']; // if not a admin, pi, or tech then redirect to node index if( !(in_array( 10, $plc->person['role_ids'] ) || in_array( 20, $plc->person['role_ids'] ) || in_array( 40, $plc->person['role_ids'] )) ) { header( "index.php" ); } // this sets up which box is to be checked the first time the page is loaded $method= $_POST['method']; if( $method == "" ) $method= "static"; $model= $_POST['model']; if( $model == "" ) $model= "Custom"; $submitted = false; // if submitted validate and add if( $_POST['submitted'] ) { $submitted = true; $errors= array(); $method = trim($_POST['method']); $ip = trim($_POST['ip']); $netmask = trim($_POST['netmask']); $network = trim($_POST['network']); $gateway = trim($_POST['gateway']); $broadcast = trim($_POST['broadcast']); $dns1 = trim($_POST['dns1']); $dns2 = trim($_POST['dns2']); $hostname = trim($_POST['hostname']); $model= trim($_POST['model']); // used to generate error strings for static fields only $static_fields= array(); $static_fields['netmask']= "Netmask address"; $static_fields['network']= "Network address"; $static_fields['gateway']= "Gateway address"; $static_fields['broadcast']= "Broadcast address"; $static_fields['dns1']= "Primary DNS address"; if( $method == 'static' ) { foreach( $static_fields as $field => $desc ) { if( trim($_POST[$field]) == "" ) { $errors[] = "$desc is required"; } elseif( !is_valid_ip(trim($_POST[$field])) ) { $errors[] = "$desc is not a valid address"; } } if( !is_valid_network_addr($network,$netmask) ) { $errors[] = "The network address does not coorespond to the netmask"; } } if( $hostname == "" ) { $errors[] = "Hostname is required"; } if( $ip == "" ) { $errors[] = "IP is required"; } if( count($errors) == 0 ) { $success= 1; // add new node and its interface $optional_vals= array( "hostname"=>$hostname, "model"=>$model ); $site_id= $_person['site_ids'][0]; $node_id= $api->AddNode( intval( $site_id ), $optional_vals ); if ( $api->error() ) { $errors[] = "Hostname already present or not valid"; $success= 0; } else { // now, try to add the network. $optional_vals= array(); $optional_vals['is_primary']= true; $optional_vals['ip']= $ip; $optional_vals['type']= 'ipv4'; $optional_vals['method']= $method; if( $method == 'static' ) { $optional_vals['gateway']= $gateway; $optional_vals['network']= $network; $optional_vals['broadcast']= $broadcast; $optional_vals['netmask']= $netmask; $optional_vals['dns1']= $dns1; if (!empty($dns2)) { $optional_vals['dns2']= $dns2; } } $interface_id= $api->AddInterface( $node_id, $optional_vals); // if AddInterface fails, we have the node created, // but no primary interface is present. // The primary interface can be added later, // but take a look at the possible Methods, // if we specify TUN/TAP Method we will have // an error on download of the configuration file } } } // Print header require_once 'plc_drupal.php'; drupal_set_title('Nodes'); include 'plc_header.php'; ?>

Node Created

The node has been successfully added.

View node details and download a configuration file here.

Add A New Node

This page will allow you to add a new machine to your site. This must be done before the machine is turned on, as it will allow you to download a configuration file when complete for this node.

Even for DHCP, you must enter the IP address of the node. 0 ) { print( "

The following errors occured:" ); print( "

\n" ); } $self = $_SERVER['PHP_SELF']; if (!empty($_SERVER['QUERY_STRING'])) { $self .= "?" . $_SERVER['QUERY_STRING']; } ?>

Node Details

Hostname:
Model:

Network Settings

Addressing Method >DHCP >Static
IP Address
Netmask
Network address
Gateway Address
Broadcast address
Primary DNS
Secondary DNS (optional)