X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fnodes%2Fnode.php;h=f45712120636b1a05be6b156b7bc68a90d269ffe;hb=15c340da9dcec704b94592a1a7cb27feb2787279;hp=c4bd0c640e918ffbbbc4ca6ce52ea54270450bbe;hpb=9e7cfb617205a762d83cd4c4eb96ebfc4f799624;p=plewww.git diff --git a/planetlab/nodes/node.php b/planetlab/nodes/node.php index c4bd0c6..f457121 100644 --- a/planetlab/nodes/node.php +++ b/planetlab/nodes/node.php @@ -1,8 +1,6 @@ GetNodes( array($node_id)); +// Need to mention columns explicitly as we want hrn which is a tag +$columns=array ('hostname','boot_state','run_level','site_id','model','node_type','version', + 'slice_ids','conf_file_ids','interface_ids','nodegroup_ids','peer_id', + 'pcu_ids','ports','hrn'); +$nodes= $api->GetNodes( array($node_id),$columns); if (empty($nodes)) { drupal_set_message ("Node " . $node_id . " not found"); @@ -37,21 +41,23 @@ if (empty($nodes)) { $node=$nodes[0]; // node info $hostname= $node['hostname']; +$hrn=$node['hrn']; $boot_state= $node['boot_state']; +$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']; $conf_file_ids= $node['conf_file_ids']; $interface_ids= $node['interface_ids']; $nodegroup_ids= $node['nodegroup_ids']; -$pcu_ids= $node['pcu_ids']; -// get peer -$peer_id= $node['peer_id']; +// get peers +$peer_id = $node['peer_id']; +$peers=new Peers ($api); // gets site info $sites= $api->GetSites( array( $site_id ) ); @@ -82,239 +88,465 @@ if( !empty( $interface_ids ) ) if( !empty( $nodegroup_ids ) ) $nodegroups= $api->GetNodeGroups( $nodegroup_ids, array("groupname","tag_type_id","value")); -// xxx Thierry : remaining stuff -// (*) events: should display the latest events relating to that node. -// disabling call to GetEvents, that gets the session deleted in the DB -// (*) conf_files: is fetched but not displayed -if( !empty( $conf_file_ids ) ) - $conf_files= $api->GetConfFiles( $conf_file_ids ); -// (*) idem for PCUs -// gets pcu and port info key to both is $pcu_id -if( !empty( $pcu_ids ) ) - $PCUs= $api->GetPCUs( $pcu_ids ); +// Thierry : remaining stuff +// (*) events: xxx todo xxx for admins xxx +// should display the latest events relating to that node. +// historically we had to turn this off at some point as GetEvents was getting the session deleted in the DB +// (*) conf_files: xxx todo xxx for admins xxx +//if( !empty( $conf_file_ids ) ) +// $conf_files= $api->GetConfFiles( $conf_file_ids ); //////////////////// display node info -// fetches peers and initialize hash peer_id->peer -$peer_hash = plc_peer_global_hash ($api); -// show gray background on foreign objects : start a
This node is not associated to any slice.
\n"; - } else { - $headers=array(); - $headers['Peer']="string"; - $headers['Name']="string"; - $headers['Slivers']="string"; - $table_options = array('notes_area'=>false,"search_width"=>10); - plc_table_start ("node-slices",$headers,1,$table_options); - - foreach ($slices as $slice) { - plc_table_row_start($slice['name']); - plc_table_cell (plc_peer_shortname($peer_hash,$slice['peer_id'])); - plc_table_cell (l_slice_t ($slice['slice_id'],$slice['name'])); - plc_table_cell (l_sliver_t ($node_id,$slice['slice_id'],'view')); - plc_table_row_end(); +//////////////////////////////////////////////////////////// Tags +// tags section +if ( $local_peer ) { + + $tags=$api->GetNodeTags (array('node_id'=>$node_id)); + function get_tagname ($tag) { return $tag['tagname'];} + // xxx looks like tech-only see an error here, + // might be that GetNodeTags is not accessible or something + $tagnames = array_map ("get_tagname",$tags); + $nodegroups_hash=plc_nodegroup_global_hash($api,$tagnames); + + $toggle = new PlekitToggle ('tags',count_english($tags,'tag'), + array('bubble'=>'Inspect and set tags on that node', + 'visible'=>get_arg('show_tags'))); + $toggle->start(); + + $headers=array("Name"=>"string", + "Value"=>"string", + "Nodegroup"=>"string", + ); + if (plc_is_admin()) $headers[plc_delete_icon()]="none"; + + $table_options=array("notes_area"=>false,"pagesize_area"=>false,"search_width"=>10); + $table=new PlekitTable("node_tags",$headers,0,$table_options); + $table->start(); + if ($tags) foreach ($tags as $tag) { + // does this match a nodegroup ? + $nodegroup_name="n/a"; + $nodegroup_key=$tag['tagname'] . "=" . $tag['value']; + $nodegroup=$nodegroups_hash[$nodegroup_key]; + if ($nodegroup) $nodegroup_name=l_nodegroup_t($nodegroup['nodegroup_id'],$nodegroup['groupname']); + $table->row_start(); + $table->cell(l_tag_obj($tag)); + $table->cell($tag['value']); + $table->cell($nodegroup_name); + // the remove checkbox + if (plc_is_admin()) $table->cell ($form->checkbox_html('node_tag_ids[]',$tag['node_tag_id'])); + $table->row_end(); + } + + if ($privileges) { + $table->tfoot_start(); + + // remove tag + $table->row_start(); + $table->cell($form->submit_html("delete-node-tags","Remove Tags"), + // use the whole columns and right adjust + array('hfill'=>true,'align'=>'right')); + $table->row_end(); + + // set tag area + $table->row_start(); + // get list of tag names in the node/* category + $all_tags= $api->GetTagTypes( array ("category"=>"node*","-SORT"=>"tagname"), array("tagname","tag_type_id")); + // xxx cannot use onchange=submit() - would need to somehow pass action name + function tag_selector ($tag) { return array("display"=>$tag['tagname'],"value"=>$tag['tag_type_id']); } + $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))); + $table->cell($form->submit_html("set-tag-on-node","Set Tag"),array('columns'=>2,'align'=>'left')); + $table->row_end(); } - plc_table_end("node-slices"); - } + + $table->end(); + $toggle->end(); +} //////////////////////////////////////////////////////////// interfaces -if ( ! $peer_id ) { - +if ( $local_peer ) { + $toggle=new PlekitToggle ('interfaces',count_english_warning($interfaces,'interface'), + array('bubble'=>'Inspect and tune interfaces on that node', + 'visible'=>get_arg('show_interfaces'))); + $toggle->start(); // display interfaces if( ! $interfaces ) { - echo "No interface. Please add an interface to make this a usable PLC node
.\n"; - } else { + echo ''; + plc_warning_html("This node has no interface"); + echo "Please add an interface to make this a usable PLC node.
\n"; + } // else { // show this unconditionnally as otherwise there's no mean to create one.. + + // display a hostname column iff at least one interface has a hostname + $need_hostname=false; + if ($interfaces) foreach ($interfaces as $interface) if ($interface['hostname']) $need_hostname=true; + $headers=array(); - if ( $privileges ) { - // a single symbol, marking 'p' for primary and a delete button for non-primary - $headers[' ']='string'; - } - - $headers["IP"]="IPAddress"; + + $sort_column=0; + if (plc_is_admin()) { $headers['I']='int'; $sort_column +=1;} + $headers["IP"]="sortIPAddress"; + if ($need_hostname) $headers['hostname']='string'; $headers["Method"]="string"; $headers["Type"]="string"; $headers["MAC"]="string"; - $headers["bw limit"]="FileSize"; + $headers["bw limit"]="sortBandwidth"; + $headers["tags"]=array('type'=>'int', + 'title'=>"number of tags set on interface"); + // a single symbol, marking 'p' for primary and a delete button for non-primary + if ( $privileges ) $headers[plc_delete_icon()]='string'; - plc_section('Interfaces'); $table_options=array('search_area'=>false,"pagesize_area"=>false,'notes_area'=>false); - plc_table_start("node-interfaces",$headers,2,$table_options); + $table=new PlekitTable("node_interfaces",$headers,$sort_column,$table_options); + $table->start(); - foreach ( $interfaces as $interface ) { + if ($interfaces) foreach ( $interfaces as $interface ) { $interface_id= $interface['interface_id']; $interface_ip= $interface['ip']; - $interface_broad= $interface['broadcast']; - $interface_primary= $interface['is_primary']; - $interface_network= $interface['network']; - $interface_dns1= $interface['dns1']; - $interface_dns2= $interface['dns2']; - $interface_hostname= $interface['hostname']; - $interface_netmaks= $interface['netmask']; - $interface_gatewary= $interface['gateway']; - $interface_mac= $interface['mac']; - $interface_bwlimit= $interface['bwlimit']; - $interface_type= $interface['type']; - $interface_method= $interface['method']; - - plc_table_row_start($interface['ip']); + + $table->row_start(); + if (plc_is_admin()) $table->cell(l_interface_t($interface_id,$interface_id)); + $table->cell(l_interface_t($interface_id,$interface_ip)); + if ($need_hostname) $table->cell($interface['hostname']); + $table->cell($interface['method']); + $table->cell($interface['type']); + $table->cell($interface['mac']); + $table->cell(pretty_bandwidth($interface['bwlimit'])); + $table->cell(href(l_interface_tags($interface_id), + count($interface['interface_tag_ids']))); if ( $privileges ) { - if (!$interface_primary) { - // xxx - plc_table_cell (plc_delete_link_button ('interfaces.php?id=' . $interface_id . '&delete=1&submitted=1', - '\\nInterface ' . $interface_ip)); + if ($interface['is_primary']) { + $table->cell(plc_bubble("p","Cannot delete a primary interface")); } else { - plc_table_cell('p'); + $table->cell ($form->checkbox_html('interface_ids[]',$interface_id)); } } - plc_table_cell(l_interface_t($interface_id,$interface_ip)); - plc_table_cell($interface_method); - plc_table_cell($interface_type); - plc_table_cell($interface_mac); - plc_table_cell($interface_bwlimit); - plc_table_row_end(); + $table->row_end(); } if ($privileges) { - $button=plc_form_simple_button(l_interface_add($node_id),"Add interface","GET"); - $footers=array(plc_table_td_text($button,6,"right")); + $table->tfoot_start(); + $table->row_start(); + // we should have 6 cols, use 3 for the left (new) and the rest for the right (remove) + //$add_button=new PlekitFormButton (l_interface_add($node_id),"add","Add Interface","GET"); + //$table->cell($add_button->html(),array('columns'=> 3,'align'=>'left')); + $table->cell($form->submit_html("new-interface","Add Interface"), + array('columns'=> 3,'align'=>'left')); + $table->cell($form->submit_html("delete-interfaces","Remove Interfaces"), + array('columns'=>$table->columns()-3,'align'=>'right')); + $table->row_end(); } - plc_table_end("node-interfaces",array("footers"=>$footers)); - } + $table->end(); + // } + $toggle->end(); } - + +$form->end(); + //////////////////////////////////////////////////////////// -plc_peer_block_end(); +$peers->block_end($peer_id); +//plekit_linetabs ($tabs,"bottom"); // Print footer include 'plc_footer.php';