return usort ($peers, "__cmp_peers");
}
-function __cmp_nodenetwork_settings($a,$b) {
+function __cmp_interface_settings($a,$b) {
$cat=strcmp($a['category'],$b['category']);
if ($cat != 0) {
return $cat;
}
}
-function sort_nodenetwork_settings (&$nodenetwork_settings) {
- return usort ($nodenetwork_settings,"__cmp_nodenetwork_settings");
+function sort_interface_settings (&$interface_settings) {
+ return usort ($interface_settings,"__cmp_interface_settings");
}
?>
}
}
- $nodenetwork_id= $api->AddNodeNetwork( $node_id, $optional_vals);
- // if AddNodeNetwork fails, we have the node created,
+ $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,
// peer_id
// from that we get a set of nodes and compute a comon URL to gather them all
-$fields=array("hostname","node_id","peer_id", "nodenetwork_ids");
+$fields=array("hostname","node_id","peer_id", "interface_ids");
if ($_GET['node_id']) {
$node_id=intval($_GET['node_id']);
}
// first pass
-// * gather nodenetwork_ids for local nodes
+// * gather interface_ids for local nodes
// * gather hostnames for foreign nodes
-$nodenetwork_ids=array();
+$interface_ids=array();
$hostnames = array();
foreach ($nodes as $node) {
if (empty($node['peer_id'])) {
- foreach ($node['nodenetwork_ids'] as $id=>$nnid) {
- $nodenetwork_ids [] = $nnid;
+ foreach ($node['interface_ids'] as $id=>$nnid) {
+ $interface_ids [] = $nnid;
}
} else {
$hostnames[] = $node['hostname'];
}
// Gather local ips from primary interfaces
-// fetch primary nodenetworks
+// fetch primary interfaces
$local_ips=array();
-$nns = $api->GetNodeNetworks(array("is_primary"=>TRUE,"nodenetwork_id"=>$nodenetwork_ids),
+$nns = $api->GetInterfaces(array("is_primary"=>TRUE,"interface_id"=>$interface_ids),
array("ip"));
foreach ($nns as $nn) {
$local_ips[] = $nn['ip'];
$columns = array( "node_id", "hostname", "boot_state", "peer_id" ) ;
$filter = array();
if ( in_array( '10', $_roles ) || in_array('20', $_roles) || in_array('40',$_roles)) {
- // admins, PIs and techs can see nodenetwork details
- $columns [] = "nodenetwork_ids";
+ // admins, PIs and techs can see interface details
+ $columns [] = "interface_ids";
}
//////////////////
// performs in-place replacement, so passes a reference
function layout_node ($node) {
- // we need the 'nodenetwork_ids' field to do this
+ // we need the 'interface_ids' field to do this
// so regular users wont run this
- if ( ! array_key_exists ('nodenetwork_ids', $node))
+ if ( ! array_key_exists ('interface_ids', $node))
return $node;
$messages=array();
// do all this stuff on local nodes only
if ( ! $node['peer_id'] ) {
// check that the node has keys
- if (count($node['nodenetwork_ids']) == 0)
- $messages [] = "No nodenetwork";
+ if (count($node['interface_ids']) == 0)
+ $messages [] = "No interface";
}
// but always cleanup $node columns
- unset ($node['nodenetwork_ids']);
+ unset ($node['interface_ids']);
$node['status'] = plc_make_table('plc-warning',$messages);
$node['comon'] = plc_comon_button("node_id",$node['node_id']);
return $node;
// arrays of ids of node info
$slice_ids= $node_info[0]['slice_ids'];
$conf_file_ids= $node_info[0]['conf_file_ids'];
- $nodenetwork_ids= $node_info[0]['nodenetwork_ids'];
+ $interface_ids= $node_info[0]['interface_ids'];
$nodegroup_ids= $node_info[0]['nodegroup_ids'];
$pcu_ids= $node_info[0]['pcu_ids'];
$ports= $node_info[0]['ports'];
$conf_files= $api->GetConfFiles( $conf_file_ids );
// get node network info
- if( !empty( $nodenetwork_ids ) )
- $node_networks= $api->GetNodeNetworks( $nodenetwork_ids );
+ if( !empty( $interface_ids ) )
+ $node_networks= $api->GetInterfaces( $interface_ids );
// gets nodegroup info
if( !empty( $nodegroup_ids ) )
echo "<th class='list_set'>IP Address</th><th class='list_set'>Method</th><th class='list_set'>Type</th><th class='list_set'>MAC</th><th class='list_set'>Bandwidth Limit</th></tr></thead><tbody>\n";
foreach( $node_networks as $node_network ) {
- $nn_id= $node_network['nodenetwork_id'];
+ $nn_id= $node_network['interface_id'];
$nn_ip= $node_network['ip'];
$nn_broad= $node_network['broadcast'];
$nn_primary= $node_network['is_primary'];
}
$hostname= $node_detail['hostname'];
- $return= $api->GetNodeNetworks( array( "node_id" => $node_id ), NULL );
+ $return= $api->GetInterfaces( array( "node_id" => $node_id ), NULL );
$can_gen_config= 1;
$has_primary= 0;
print( "<tr><th>Hostname:</th>" );
print( "<td>" . $node_detail['hostname'] . "</td></tr>\n" );
- $nn_id = $node_network_detail['nodenetwork_id'];
+ $nn_id = $node_network_detail['interface_id'];
print( "<tr><th colspan=2><a href='node_networks.php?id=$nn_id'>Node Network Details</a></th></tr>" );
print( "<tr><th>Method:</th>" );
}
}
- if (method_exists ($api,'GetNodeNetworkSettings')) {
+ if (method_exists ($api,'GetInterfaceSettings')) {
print ("<tr><th colspan=2><a href='node_networks.php?id=$nn_id'>Additional Settings</a></th></tr>\n");
- $nn_id = $node_network_detail['nodenetwork_id'];
- $settings=$api->GetNodeNetworkSettings(array("nodenetwork_id" => array($nn_id)));
+ $nn_id = $node_network_detail['interface_id'];
+ $settings=$api->GetInterfaceSettings(array("interface_id" => array($nn_id)));
foreach ($settings as $setting) {
$category=$setting['category'];
$name=$setting['name'];
$_person= $plc->person;
$_roles= $_person['role_ids'];
-$nodenetwork = array();
+$interface = array();
-// If nodenetwork_id is specified, load data
+// If interface_id is specified, load data
if( isset( $_GET['id'] ) ) {
$id= intval( $_GET['id'] );
- $nodenetworks= $api->GetNodeNetworks( array( $id ) );
- if( $nodenetworks ) {
- $nodenetwork= $nodenetworks[0];
- $node_id= $nodenetwork['node_id'];
+ $interfaces= $api->GetInterfaces( array( $id ) );
+ if( $interfaces ) {
+ $interface= $interfaces[0];
+ $node_id= $interface['node_id'];
}
}
foreach( array( 'method', 'type', 'ip', 'gateway', 'network', 'broadcast', 'netmask', 'dns1', 'dns2', 'hostname', 'mac', 'bwlimit', 'node_id' ) as $field ) {
if( isset( $_POST[$field] ) ) {
if( $_POST[$field] == "" ) {
- $nodenetwork[$field]= NULL;
+ $interface[$field]= NULL;
} else {
- $nodenetwork[$field]= $_POST[$field];
+ $interface[$field]= $_POST[$field];
if( in_array( $field, array( 'bwlimit', 'node_id' ) ) ) {
- $nodenetwork[$field]= intval( $nodenetwork[$field] );
+ $interface[$field]= intval( $interface[$field] );
}
}
}
- if( isset( $nodenetwork[$field] ) ) {
- // E.g., $method = $nodenetwork['method'];
- $$field= $nodenetwork[$field];
+ if( isset( $interface[$field] ) ) {
+ // E.g., $method = $interface['method'];
+ $$field= $interface[$field];
}
}
-// Either nodenetwork_id or node_id must be specified in URL
+// Either interface_id or node_id must be specified in URL
if( !isset( $_GET['node_id'] ) && !( $nodes= $api->GetNodes( array( intval($node_id) ), array( 'node_id', 'hostname', 'site_id' ) ) ) ) {
Header( "Location: index.php" );
exit();
if( $can_update && (isset( $_POST['submitted'] ) || isset ($_GET['submitted'])) ) {
if( isset( $_POST['add'] ) ) {
- $api->AddNodeNetwork( intval( $node_id ), $nodenetwork );
+ $api->AddInterface( intval( $node_id ), $interface );
}
elseif ( isset( $_POST['delete'] ) || isset( $_GET['delete']) || isset( $_POST['update'] ) ) {
- // nodenetwork_id must be specified in URL
+ // interface_id must be specified in URL
if( !isset( $id ) ) {
Header( "Location: index.php?id=$node_id" );
exit();
}
if( isset( $_POST['delete'] ) || isset ($_GET['delete']) ) {
- $api->DeleteNodeNetwork( $id );
+ $api->DeleteInterface( $id );
}
elseif( isset( $_POST['update'] ) ) {
- $api->UpdateNodeNetwork( $id, $nodenetwork );
+ $api->UpdateInterface( $id, $interface );
}
}
// Start form
$action= "node_networks.php";
if( isset( $id ) ) {
- $action.= "?id=" . $nodenetwork['nodenetwork_id'];
+ $action.= "?id=" . $interface['interface_id'];
}
elseif( isset($node_id)) {
$action.= "?node_id=" . $node_id;
EOF;
// displays related settings, if supported by the API
-if (method_exists ($api,'GetNodeNetworkSettings')) {
+if (method_exists ($api,'GetInterfaceSettings')) {
$is_admin=in_array( 10, $_roles );
$is_pi=in_array( 20, $_roles );
print "<hr />";
- if (empty ($nodenetwork['nodenetwork_setting_ids'])) {
+ if (empty ($interface['interface_setting_ids'])) {
print "<p> This network interface has no additional setting</p>";
if( $is_admin || $is_pi )
echo "<p><a href='settings.php?add=$id'>Add a Network Setting</a></p>\n";
} else {
- $nodenetwork_settings = $api->GetNodeNetworkSettings($nodenetwork['nodenetwork_setting_ids']);
- sort_nodenetwork_settings ($nodenetwork_settings);
+ $interface_settings = $api->GetInterfaceSettings($interface['interface_setting_ids']);
+ sort_interface_settings ($interface_settings);
print "<table cellpadding='5' cellspacing='5' class='list_set'><caption class='list_set'>Additional Settings</caption>";
print "<thead><tr class='list_set'>";
// the column for the delete button
if( $is_admin )
print "<th></th>";
print "<th class='list_set'>Name</th><th class='list_set'>Category</th><th class='list_set'>Description</th><th class='list_set'>Value</th></tr></thead><tbody>";
- foreach ($nodenetwork_settings as $setting) {
+ foreach ($interface_settings as $setting) {
echo "<tr class='list_set'>";
if ($is_admin) {
echo("<td>");
- echo plc_delete_link_button('setting_action.php?rem_id=' . $setting['nodenetwork_setting_id'],
+ echo plc_delete_link_button('setting_action.php?rem_id=' . $setting['interface_setting_id'],
'\\n [ ' . $setting['name'] . ' = ' . $setting['value']);
echo("</td>");
}
if ($is_admin || $is_pi)
- printf ("<td class='list_set'> <a href='settings.php?id=%s'>%s </a></td>",$setting['nodenetwork_setting_id'],$setting['name']);
+ printf ("<td class='list_set'> <a href='settings.php?id=%s'>%s </a></td>",$setting['interface_setting_id'],$setting['name']);
else
printf ("<td class='list_set'> %s </td>",$setting['name']);
printf ("<td class='list_set'> %s</td><td class='list_set'> %s</td><td class='list_set'> %s </td></tr>",
// attribute type updates
if( $_POST['edit_type'] ) {
- $setting_type_id= intval( $_POST['nodenetwork_setting_type_id'] );
+ $setting_type_id= intval( $_POST['interface_setting_type_id'] );
$setting_type = array ('category' => $_POST['category'],
'name' => $_POST['name'],
'min_role_id' => intval( $_POST['min_role_id'] ),
'description' => $_POST['description']);
// Update it!
- $api->UpdateNodeNetworkSettingType( $setting_type_id, $setting_type );
+ $api->UpdateInterfaceSettingType( $setting_type_id, $setting_type );
$api_error=$api->error();
if (!empty($api_error)) {
print "<div class='plc-error'>" . $api_error . "</div>";
'min_role_id' => intval( $_POST['min_role_id'] ),
'description' => $_POST['description']);
// add it!!
- $api->AddNodeNetworkSettingType( $setting_type );
+ $api->AddInterfaceSettingType( $setting_type );
header( "location: settings.php" );
exit();
// get the id of the attrib to remove from GET
$setting_id= intval( $_GET['rem_id'] );
- // get nodenetwork_id
- $setting= $api->GetNodeNetworkSettings( array( $setting_id ), array( "nodenetwork_id" ) );
- $nodenetwork_id= $setting[0]['nodenetwork_id'];
+ // get interface_id
+ $setting= $api->GetInterfaceSettings( array( $setting_id ), array( "interface_id" ) );
+ $interface_id= $setting[0]['interface_id'];
// delete the attribute
- $api->DeleteNodeNetworkSetting( $setting_id );
+ $api->DeleteInterfaceSetting( $setting_id );
- header( "location: node_networks.php?id=$nodenetwork_id" );
+ header( "location: node_networks.php?id=$interface_id" );
exit();
}
// attribute adds
if( $_POST['add_setting'] ) {
- // get the nodenetwork_id, attribute_type_id, and value from POST
- $nodenetwork_id= intval( $_POST['nodenetwork_id'] );
- $nodenetwork_setting_type_id= intval( $_POST['nodenetwork_setting_type_id'] );
+ // get the interface_id, attribute_type_id, and value from POST
+ $interface_id= intval( $_POST['interface_id'] );
+ $interface_setting_type_id= intval( $_POST['interface_setting_type_id'] );
$value= $_POST['value'];
// add it!
- $api->AddNodeNetworkSetting( $nodenetwork_id, $nodenetwork_setting_type_id, $value );
+ $api->AddInterfaceSetting( $interface_id, $interface_setting_type_id, $value );
- header( "location: node_networks.php?id=$nodenetwork_id" );
+ header( "location: node_networks.php?id=$interface_id" );
exit();
}
// get the id of the setting to update and the value from POST
$setting_id= intval( $_POST['setting_id'] );
$value= $_POST['value'];
- $nodenetwork_id= $_POST['nodenetwork_id'];
+ $interface_id= $_POST['interface_id'];
// update it!
- $api->UpdateNodeNetworkSetting($setting_id, $value );
+ $api->UpdateInterfaceSetting($setting_id, $value );
- header( "location: node_networks.php?id=$nodenetwork_id" );
+ header( "location: node_networks.php?id=$interface_id" );
exit();
}
$type_id= intval( $_GET['del_type'] );
// delete it!
- $api->DeleteNodeNetworkSettingType( $type_id );
+ $api->DeleteInterfaceSettingType( $type_id );
header( "location: settings.php" );
exit();
// Print header
require_once 'plc_drupal.php';
-drupal_set_title('Nodenetwork Setting Types');
+drupal_set_title('Interface Setting Types');
include 'plc_header.php';
// Common functions
//plc_debug("person", $_person );
-$columns=array( "nodenetwork_setting_type_id", "category", "name", "description", "min_role_id" );
+$columns=array( "interface_setting_type_id", "category", "name", "description", "min_role_id" );
// prepare dict role_id => role_name
global $roles;
}
//plc_debug("person_role",$person_role);
-// post-process results from GetNodeNetworkSettingTypes
+// post-process results from GetInterfaceSettingTypes
// with planetlab 4.2, we've moved to php-5.2
// with the former 5.0 reelase, I could invoke array_map
// with a function that took a reference and could do side-effects
// get types
global $person_role;
$filter = array (']min_role_id'=>$person_role);
- $setting_types= $api->GetNodeNetworkSettingTypes( $filter, $columns );
+ $setting_types= $api->GetInterfaceSettingTypes( $filter, $columns );
$setting_types = array_map(layout_setting_type,$setting_types);
- sort_nodenetwork_settings ($setting_types);
+ sort_interface_settings ($setting_types);
// list them
// if admin display delete links
if( in_array( "10", $_person['role_ids'] ) ) {
echo "<td>";
- echo plc_delete_link_button('setting_action.php?del_type='. $type['nodenetwork_setting_type_id'],
+ echo plc_delete_link_button('setting_action.php?del_type='. $type['interface_setting_type_id'],
$type['name']);
echo "</td>";
}
// if admin, the name is a link to edition
if (in_array( "10", $_person['role_ids'])) {
- echo "<td><a href='settings.php?edit_type=". $type['nodenetwork_setting_type_id'] . "'>" . $type['name'] . "</a></td>";
+ echo "<td><a href='settings.php?edit_type=". $type['interface_setting_type_id'] . "'>" . $type['name'] . "</a></td>";
} else {
echo "<td>" . $type['name'] . "</td>";
}
// if its edit get the attribute info
if( $_GET['edit_type'] ) {
$type_id= intval( $_GET['edit_type'] );
- $type= $api->GetNodeNetworkSettingTypes( array( $type_id ) );
+ $type= $api->GetInterfaceSettingTypes( array( $type_id ) );
$category=$type[0]['category'];
$name= $type[0]['name'];
echo "</td></tr>\n";
echo "<tr><td colspan=2 align=center>";
if( $_GET['edit_type'] ) {
- echo "<input type=hidden name='nodenetwork_setting_type_id' value='$type_id'>\n";
+ echo "<input type=hidden name='interface_setting_type_id' value='$type_id'>\n";
echo "<input type=submit name='edit_type' value='Edit Setting Type'>\n";
} else {
- echo "<input type=submit name='add_type' value='Add Nodenetwork Type'>\n";
+ echo "<input type=submit name='add_type' value='Add Interface Type'>\n";
}
echo "</td></tr>";
echo "</table>";
}
elseif( $_GET['add'] ) {
- // get nodenetwork id from GET
- $nodenetwork_id= intval( $_GET['add'] );
+ // get interface id from GET
+ $interface_id= intval( $_GET['add'] );
// get all setting types
global $person_role;
$filter = array (']min_role_id'=>$person_role);
- $setting_types= $api->GetNodeNetworkSettingTypes( $filter, array( "nodenetwork_setting_type_id", "name" , "category") );
- sort_nodenetwork_settings($setting_types);
+ $setting_types= $api->GetInterfaceSettingTypes( $filter, array( "interface_setting_type_id", "name" , "category") );
+ sort_interface_settings($setting_types);
- // get nodenetwork's settings
- $nodenetwork = $api->GetNodeNetworks( array( $nodenetwork_id ), array( "nodenetwork_setting_ids","ip" ) );
+ // get interface's settings
+ $interface = $api->GetInterfaces( array( $interface_id ), array( "interface_setting_ids","ip" ) );
- drupal_set_title("Add a setting to ". $nodenetwork[0]['ip']);
+ drupal_set_title("Add a setting to ". $interface[0]['ip']);
// start form
echo "<form action='setting_action.php' method='post'>\n";
- echo "<input type=hidden name='nodenetwork_id' value='$nodenetwork_id'>\n";
+ echo "<input type=hidden name='interface_id' value='$interface_id'>\n";
echo "<table cellpadding='2'> <caption> New Setting </caption>";
- echo "<tr><th>Select</th><td><select name='nodenetwork_setting_type_id'><option value=''>Choose a type to add</option>\n";
+ echo "<tr><th>Select</th><td><select name='interface_setting_type_id'><option value=''>Choose a type to add</option>\n";
foreach( $setting_types as $setting_type ) {
- echo "<option value='". $setting_type['nodenetwork_setting_type_id'] ."'>". $setting_type['category'] . ":" . $setting_type['name'] ."</option>\n";
+ echo "<option value='". $setting_type['interface_setting_type_id'] ."'>". $setting_type['category'] . ":" . $setting_type['name'] ."</option>\n";
}
echo "</select></td</tr>\n";
$setting_id= intval( $_GET['id'] );
// get setting info
- $setting= $api->GetNodeNetworkSettings( array( $setting_id ));
+ $setting= $api->GetInterfaceSettings( array( $setting_id ));
- // nodenetwork info
- $nodenetwork= $api->GetNodeNetworks( array( $setting[0]['nodenetwork_id'] ), array( "ip" ) );
+ // interface info
+ $interface= $api->GetInterfaces( array( $setting[0]['interface_id'] ), array( "ip" ) );
- drupal_set_title("Edit setting ". $setting[0]['name'] ." on ". $nodenetwork[0]['ip']);
+ drupal_set_title("Edit setting ". $setting[0]['name'] ." on ". $interface[0]['ip']);
// start form and put values in to be edited.
echo "<form action='setting_action.php' method='post'>\n";
- echo "<input type=hidden name='setting_id' value='". $setting[0]['nodenetwork_setting_id'] ."'>\n";
- echo "<input type=hidden name='nodenetwork_id' value='". $setting[0]['nodenetwork_id'] ."'>\n";
+ echo "<input type=hidden name='setting_id' value='". $setting[0]['interface_setting_id'] ."'>\n";
+ echo "<input type=hidden name='interface_id' value='". $setting[0]['interface_id'] ."'>\n";
echo "<table cellpadding='2'> <caption> Edit Setting </caption>";
echo "<tr><th> Category </th> <td>" . $setting[0]['category'] . "</td></tr>";