From 5c02f783308fe396cc2c41a4c40c860b6257d376 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 26 May 2008 19:05:11 +0000 Subject: [PATCH] towards 5.0 --- planetlab/includes/plc_sorts.php | 6 ++-- planetlab/nodes/add_node.php | 4 +-- planetlab/nodes/comon.php | 14 ++++---- planetlab/nodes/index.php | 22 ++++++------- planetlab/nodes/node_actions.php | 10 +++--- planetlab/nodes/node_networks.php | 50 ++++++++++++++-------------- planetlab/nodes/setting_action.php | 34 +++++++++---------- planetlab/nodes/settings.php | 52 +++++++++++++++--------------- 8 files changed, 96 insertions(+), 96 deletions(-) diff --git a/planetlab/includes/plc_sorts.php b/planetlab/includes/plc_sorts.php index 3c342cc..b135754 100644 --- a/planetlab/includes/plc_sorts.php +++ b/planetlab/includes/plc_sorts.php @@ -62,7 +62,7 @@ function sort_peers (&$peers) { 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; @@ -71,8 +71,8 @@ function __cmp_nodenetwork_settings($a,$b) { } } -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"); } ?> diff --git a/planetlab/nodes/add_node.php b/planetlab/nodes/add_node.php index 61de309..03fe6f0 100644 --- a/planetlab/nodes/add_node.php +++ b/planetlab/nodes/add_node.php @@ -126,8 +126,8 @@ if( $_POST['submitted'] ) } } - $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, diff --git a/planetlab/nodes/comon.php b/planetlab/nodes/comon.php index d049e71..22ca872 100644 --- a/planetlab/nodes/comon.php +++ b/planetlab/nodes/comon.php @@ -44,7 +44,7 @@ function plc_comon_url_from_ips($comon_server_url, $ips) { // 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']); @@ -68,16 +68,16 @@ if ($_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']; @@ -85,9 +85,9 @@ foreach ($nodes as $node) { } // 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']; diff --git a/planetlab/nodes/index.php b/planetlab/nodes/index.php index 94e23f1..91aeaa1 100644 --- a/planetlab/nodes/index.php +++ b/planetlab/nodes/index.php @@ -28,8 +28,8 @@ $_roles= $_person['role_ids']; $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"; } ////////////////// @@ -38,9 +38,9 @@ if ( in_array( '10', $_roles ) || in_array('20', $_roles) || in_array('40',$_rol // 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(); @@ -48,12 +48,12 @@ function layout_node ($node) { // 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; @@ -216,7 +216,7 @@ if ( $_GET['id'] ) { // 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']; @@ -247,8 +247,8 @@ if ( $_GET['id'] ) { $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 ) ) @@ -392,7 +392,7 @@ if ( $_GET['id'] ) { echo "IP AddressMethodTypeMACBandwidth Limit\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']; diff --git a/planetlab/nodes/node_actions.php b/planetlab/nodes/node_actions.php index 1a52e0b..3844031 100644 --- a/planetlab/nodes/node_actions.php +++ b/planetlab/nodes/node_actions.php @@ -272,7 +272,7 @@ switch ($action) { } $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; @@ -395,7 +395,7 @@ if( $has_primary ) { print( "Hostname:" ); print( "" . $node_detail['hostname'] . "\n" ); - $nn_id = $node_network_detail['nodenetwork_id']; + $nn_id = $node_network_detail['interface_id']; print( "Node Network Details" ); print( "Method:" ); @@ -422,10 +422,10 @@ if( $has_primary ) { } } - if (method_exists ($api,'GetNodeNetworkSettings')) { + if (method_exists ($api,'GetInterfaceSettings')) { print ("Additional Settings\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']; diff --git a/planetlab/nodes/node_networks.php b/planetlab/nodes/node_networks.php index 4b7ef71..50e38b2 100644 --- a/planetlab/nodes/node_networks.php +++ b/planetlab/nodes/node_networks.php @@ -15,15 +15,15 @@ require_once 'plc_sorts.php'; $_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']; } } @@ -34,21 +34,21 @@ if( $_GET['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(); @@ -67,19 +67,19 @@ if( !in_array( 10, $_roles ) ) { 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 ); } } @@ -102,7 +102,7 @@ include 'plc_header.php'; // 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; @@ -189,35 +189,35 @@ echo <<"; - if (empty ($nodenetwork['nodenetwork_setting_ids'])) { + if (empty ($interface['interface_setting_ids'])) { print "

This network interface has no additional setting

"; if( $is_admin || $is_pi ) echo "

Add a Network Setting

\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 ""; print ""; // the column for the delete button if( $is_admin ) print ""; print ""; - foreach ($nodenetwork_settings as $setting) { + foreach ($interface_settings as $setting) { echo ""; if ($is_admin) { echo(""); } if ($is_admin || $is_pi) - printf ("",$setting['nodenetwork_setting_id'],$setting['name']); + printf ("",$setting['interface_setting_id'],$setting['name']); else printf ("",$setting['name']); printf ("", diff --git a/planetlab/nodes/setting_action.php b/planetlab/nodes/setting_action.php index 3522148..8dbe20c 100644 --- a/planetlab/nodes/setting_action.php +++ b/planetlab/nodes/setting_action.php @@ -29,14 +29,14 @@ $_roles= $_person['role_ids']; // 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 "
" . $api_error . "
"; @@ -53,7 +53,7 @@ if( $_POST['add_type'] ) { '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(); @@ -65,28 +65,28 @@ if( $_GET['rem_id'] ) { // 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(); } @@ -95,12 +95,12 @@ if( $_POST['edit_setting'] ) { // 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(); } @@ -115,7 +115,7 @@ if( $_GET['del_type'] ) { $type_id= intval( $_GET['del_type'] ); // delete it! - $api->DeleteNodeNetworkSettingType( $type_id ); + $api->DeleteInterfaceSettingType( $type_id ); header( "location: settings.php" ); exit(); diff --git a/planetlab/nodes/settings.php b/planetlab/nodes/settings.php index 4d6c76a..386658e 100644 --- a/planetlab/nodes/settings.php +++ b/planetlab/nodes/settings.php @@ -11,7 +11,7 @@ global $plc, $api; // 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 @@ -24,7 +24,7 @@ $_roles= $_person['role_ids']; //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; @@ -45,7 +45,7 @@ foreach ($_person['role_ids'] as $role_id) { } //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 @@ -65,9 +65,9 @@ if( !$_GET['id'] && !$_GET['add'] && !$_GET['add_type'] && !$_GET['edit_type'] ) // 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 @@ -90,13 +90,13 @@ if( !$_GET['id'] && !$_GET['add'] && !$_GET['add_type'] && !$_GET['edit_type'] ) // if admin display delete links if( in_array( "10", $_person['role_ids'] ) ) { echo ""; } // if admin, the name is a link to edition if (in_array( "10", $_person['role_ids'])) { - echo ""; + echo ""; } else { echo ""; } @@ -119,7 +119,7 @@ elseif( $_GET['add_type'] || $_GET['edit_type'] ) { // 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']; @@ -151,10 +151,10 @@ elseif( $_GET['add_type'] || $_GET['edit_type'] ) { echo "\n"; echo ""; echo "
Additional Settings
NameCategoryDescriptionValue
"); - 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(" %s %s %s %s %s %s
"; - 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 "" . $type['name'] . "" . $type['name'] . "" . $type['name'] . "
"; if( $_GET['edit_type'] ) { - echo "\n"; + echo "\n"; echo "\n"; } else { - echo "\n"; + echo "\n"; } echo "
"; @@ -165,30 +165,30 @@ elseif( $_GET['add_type'] || $_GET['edit_type'] ) { } 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 "
\n"; - echo "\n"; + echo "\n"; echo ""; - echo "
New Setting
Select
Select\n"; @@ -204,17 +204,17 @@ else { $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 "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; echo ""; echo ""; -- 2.43.0
Edit Setting
Category " . $setting[0]['category'] . "