X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fnodes%2Finterface.php;h=744ce3f69a834f5c6696d0cb8998f582fe31a7ca;hb=1ce86fd37ce8da9b475847a59394c0241a8dbbff;hp=d199c0ca3aa267c40988193231d41a07a9df411a;hpb=e6d716d08141881786f36c376821f2cc8c25c5c7;p=plewww.git diff --git a/planetlab/nodes/interface.php b/planetlab/nodes/interface.php index d199c0c..744ce3f 100644 --- a/planetlab/nodes/interface.php +++ b/planetlab/nodes/interface.php @@ -1,5 +1,7 @@ GetInterfaces(array('interface_id'=>$interface_id)); $interface=$interfaces[0]; $node_id=$interface['node_id']; + $title=('Updating interface ' . $interface['ip']); } else if (isset ($_GET['node_id'])) { $mode='add'; $interface=array(); $node_id=$_GET['node_id']; + $title=('Adding interface'); } // check if ( ! $node_id) { @@ -44,50 +49,52 @@ if ( ! $node_id) { } $tabs=array(); -$tabs[] = array('label'=>'Back to node', 'url'=>l_node($node_id), +$tabs[] = array('label'=>'Back to node', 'url'=>l_node($node_id), + 'values' => array('show_interfaces'=>True), 'bubble'=>'Cancel pending changes'); -plc_tabs($tabs); +plekit_linetabs($tabs); $fields=array( 'method', 'type', 'ip', 'gateway', 'network', 'broadcast', 'netmask', 'dns1', 'dns2', 'hostname', 'mac', 'bwlimit', 'node_id' ); ////////////////////////////// -$nodes= $api->GetNodes( array( intval($node_id) ), array( 'node_id', 'hostname', 'site_id' ) ); +$node_columns = array( 'node_id', 'hostname', 'site_id', 'interface_ids' ); +$nodes= $api->GetNodes( array( intval($node_id) ), $node_columns); $node= $nodes[0]; $site_id=$node['site_id']; $can_update= plc_is_admin() || ( plc_in_site ($site_id) && ( plc_is_pi() || plc_is_tech())); -drupal_set_title("Interface on " . $node['hostname']); +drupal_set_title($title . " on " . $node['hostname']); // include javacsript helpers -drupal_set_title (' +require_once 'prototype.php'; +drupal_set_html_head (' '); -$details=new PlcDetails($can_update); +$nifty_id = ($mode == 'add' ) ? 'add-interface' : 'interface'; +$toggle = new PlekitToggle ($nifty_id,"Details", + array('bubble'=>'Display and modify details for that interface', + 'visible'=>get_arg('show_details'))); +$toggle->start(); + +$details=new PlekitDetails($can_update); // xxx hardwire network type for now $form_variables = array('node_id'=>$node_id,'type'=>"ipv4"); if ($mode == "update") $form_variables['interface_id']=$interface_id; -$form=$details->form_start(l_actions(),$form_variables); +$form=$details->form_start(l_actions(),$form_variables, + array('onSubmit'=>'return interfaceSubmit()')); $details->start(); -//>>> GetNetworkMethods() -//[u'static', u'dhcp', u'proxy', u'tap', u'ipmi', u'unknown'] -function method_selectors ($api, $method) { - $builtin_methods=array("static"=>"Static", "dhcp"=>"DHCP", "proxy"=>"Proxy", - "tap"=>"TUN/TAP", "ipmi"=>"IPMI"); - $selectors=array(); - foreach ($builtin_methods as $value=>$display) { - $selector=array('display'=>$display, 'value'=>$value); - if ($value == $method) $selector['selected']=true; - $selectors []= $selector; - } - return $selectors; -} -$method_select = $form->select_html ("method",method_selectors($api,$interface['method']), +if ($mode == 'add') + $method_default = 'dhcp'; +else + $method_default = $interface['method']; +$method_select = $form->select_html ("method", + interface_method_selectors($api,$method_default,false), array('id'=>'method','onChange'=>'updateMethodFields()')); $details->th_td("Method",$method_select,"method",array('input_type'=>'select','value'=>$interface['method'])); @@ -112,17 +119,25 @@ $details->th_td("DNS 2",$interface['dns2'],"dns2",array('width'=>15, $details->space(); $details->th_td("BW limit (bps)",$interface['bwlimit'],"bwlimit",array('width'=>11)); $details->th_td("Hostname",$interface['hostname'],"hostname"); -# should the user be allowed to change this ? -$mac=$interface['mac']; -if ($mac) $details->th_td("MAC address",$mac); +$details->th_td("Mac address",$interface['mac'],"mac", array('onChange'=>'macChecker("mac", true)')); // the buttons -$update_button = $form->submit_html ("update-interface","Update", - array('onSubmit'=>'interfaceSubmit()')); +$update_button = $form->submit_html ("update-interface","Update"); $add_button = $form->submit_html ("add-interface","Add as new", array('onSubmit'=>'interfaceSubmit()')); switch ($mode) { case 'add': + // primary interfaces can't be virtual + $is_primary = (count($node['interface_ids']) == 0); + if ( ! $is_primary) { + // default is to create virtual interfaces + $details->th_th("Virtual Interface", + $form->checkbox_html('is-virtual','yes',array('id'=>'virtual', + 'checked'=>'checked', + 'onChange'=>'updateVirtualArea()'))); + $details->th_td("Interface name","eth0",'ifname'); + $details->th_td("alias (leave empty if unsure)","",'alias'); + } $details->tr($add_button,"right"); break; case 'update': @@ -132,27 +147,32 @@ switch ($mode) { $details->end(); $form->end(); +$toggle->end(); // no tags if the interface has not been created yet if ($mode == 'add') return; //////////////////////////////////////// tags -$form = new PlcForm (l_actions(),array('interface_id'=>$interface_id)); +$tags=$api->GetInterfaceTags (array('interface_id'=>$interface_id)); +$toggle=new PlekitToggle ('tags',count_english($tags,'tag'), + array('visible'=>get_arg('show_tags'))); +$toggle->start(); + +$form = new PlekitForm (l_actions(),array('interface_id'=>$interface_id)); $form->start(); -$tags=$api->GetInterfaceTags (array('interface_id'=>$interface_id)); function get_tagname ($tag) { return $tag['tagname'];} $tagnames = array_map ("get_tagname",$tags); -plc_section("Tags"); + $headers=array("Name"=>"string", "Value"=>"string", ); if ($can_update) $headers[plc_delete_icon()]="none"; $table_options=array("notes_area"=>false,"pagesize_area"=>false,"search_width"=>10); -$table=new PlcTable("interface_tags",$headers,0,$table_options); +$table=new PlekitTable("interface_tags",$headers,0,$table_options); $table->start(); if ($tags) foreach ($tags as $tag) { $table->row_start(); @@ -170,7 +190,7 @@ if ($can_update) { $table->row_start(); $table->cell($form->submit_html("delete-interface-tags","Remove Tags"), // use the whole columns and right adjust - $table->columns(), "right"); + array('hfill'=>true,'align'=>'right')); $table->row_end(); // set tag area @@ -182,14 +202,16 @@ if ($can_update) { $selector=array_map("tag_selector",$all_tags); $table->cell($form->select_html("tag_type_id",$selector,array('label'=>"Choose"))); $table->cell($form->text_html("value","",array('width'=>8))); + //cell-xxx $table->cell($form->submit_html("set-tag-on-interface","Set Tag"),2,"left"); $table->row_end(); } $table->end(); $form->end(); +$toggle->end(); -plc_tabs ($tabs,"bottom"); +//plekit_linetabs ($tabs,"bottom"); // Print footer include 'plc_footer.php';