From: Panos Date: Fri, 22 Oct 2010 14:53:45 +0000 (-0400) Subject: Merge branch 'master' of git.onelab.eu:/git/plewww X-Git-Tag: plewww-4.3-54~4 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=98babcb7ca66f2369bc523c52e5e8efde0cb856b;hp=-c;p=plewww.git Merge branch 'master' of git.onelab.eu:/git/plewww --- 98babcb7ca66f2369bc523c52e5e8efde0cb856b diff --combined planetlab/slices/slice.php index d162442,d6de73e..dedddf1 --- a/planetlab/slices/slice.php +++ b/planetlab/slices/slice.php @@@ -17,14 -17,13 +17,14 @@@ include 'plc_header.php' require_once 'plc_functions.php'; require_once 'plc_peers.php'; require_once 'plc_objects.php'; -require_once 'plc_visibletags.php'; +require_once 'plc_visibletags2.php'; require_once 'linetabs.php'; -require_once 'table.php'; +require_once 'table2.php'; require_once 'details.php'; require_once 'toggle.php'; require_once 'form.php'; require_once 'raphael.php'; +require_once 'columns.php'; // keep css separate for now drupal_set_html_head(' @@@ -77,7 -76,6 +77,6 @@@ if ($profiling) plc_debug_prof('3: peer $sites= $api->GetSites( array( $site_id ) ); $site=$sites[0]; $site_name= $site['name']; - $max_slices = $site['max_slices']; if ($profiling) plc_debug_prof('4: sites',count($sites)); //////////////////////////////////////// building blocks for the renew area @@@ -207,18 -205,18 +206,18 @@@ $tabs [] = tab_site($site) // are these the right privileges for deletion ? if ($privileges) { + $tabs["Events"]=array_merge(tablook_event(), + array('url'=>l_event("Slice","slice",$slice_id), + 'bubble'=>"Events for slice $name")); $tabs ['Delete']= array('url'=>l_actions(), 'method'=>'post', 'values'=>array('action'=>'delete-slice','slice_id'=>$slice_id), 'bubble'=>"Delete slice $name", 'confirm'=>"Are you sure to delete slice $name"); - $tabs["Events"]=array_merge(tablook_event(), - array('url'=>l_event("Slice","slice",$slice_id), - 'bubble'=>"Events for slice $name")); - $tabs["Comon"]=array_merge(tablook_comon(), - array('url'=>l_comon("slice_id",$slice_id), - 'bubble'=>"Comon page about slice $name")); + //$tabs["Comon"]=array_merge(tablook_comon(), + //array('url'=>l_comon("slice_id",$slice_id), + //'bubble'=>"Comon page about slice $name")); } plekit_linetabs($tabs); @@@ -296,7 -294,7 +295,7 @@@ $count=count($persons) if ($profiling) plc_debug_prof('4: persons',count($persons)); $toggle= - new PlekitToggle ('my-slice-persons',"$count Users", + new PlekitToggle ('my-slice-persons',"$count users", array('bubble'=> 'Manage accounts attached to this slice', 'visible'=>get_arg('show_persons',false))); @@@ -406,128 -404,17 +405,128 @@@ $toggle->end() // (.) type is passed to the javascript table, for sorting (default is 'string') // minimal list as a start -$node_fixed_columns = array('hostname','node_id','peer_id','slice_ids_whitelist', +$node_fixed_columns = array('hostname','node_id','peer_id','slice_ids_whitelist', 'site_id', 'run_level','boot_state','last_contact','node_type'); // create a VisibleTags object : basically the list of tag columns to show -$visibletags = new VisibleTags ($api, 'node'); -$visiblecolumns = $visibletags->column_names(); -$node_columns=array_merge($node_fixed_columns,$visiblecolumns); +//$visibletags = new VisibleTags ($api, 'node'); +//$visiblecolumns = $visibletags->column_names(); // optimizing calls to GetNodes -$all_nodes=$api->GetNodes(NULL,$node_columns); +//$all_nodes=$api->GetNodes(NULL,$node_columns); //$slice_nodes=$api->GetNodes(array('node_id'=>$slice['node_ids']),$node_columns); //$potential_nodes=$api->GetNodes(array('~node_id'=>$slice['node_ids']),$node_columns); + + +//NEW CODE FOR ENABLING COLUMN CONFIGURATION + +//prepare fix and configurable columns + +$fix_columns = array(); +$fix_columns[]=array('tagname'=>'hostname', 'header'=>'hostname', 'type'=>'string', 'title'=>'The name of the node'); +$fix_columns[]=array('tagname'=>'peer_id', 'header'=>'AU', 'type'=>'string', 'title'=>'Authority'); +$fix_columns[]=array('tagname'=>'run_level', 'header'=>'ST', 'type'=>'string', 'title'=>'Status'); +$fix_columns[]=array('tagname'=>'node_type', 'header'=>'RES', 'type'=>'string', 'title'=>'Reservable'); + +// columns that correspond to the visible tags for nodes (*node/ui*) +$visibletags = new VisibleTags ($api, 'node'); +$visibletags->columns(); +$tag_columns = $visibletags->headers(); + +// extra columns that are not tags (for the moment not sorted correctly) + +$extra_columns = array(); +$extra_columns[]=array('tagname'=>'sitename', 'header'=>'SN', 'type'=>'string', 'title'=>'Site name', 'fetched'=>true); +$extra_columns[]=array('tagname'=>'domain', 'header'=>'DN', 'type'=>'string', 'title'=>'Toplevel domain name', 'fetched'=>true); +$extra_columns[]=array('tagname'=>'ipaddress', 'header'=>'IP', 'type'=>'string', 'title'=>'IP Address', 'fetched'=>true); +$extra_columns[]=array('tagname'=>'fcdistro', 'header'=>'OS', 'type'=>'string', 'title'=>'Operating system', 'fetched'=>false); + +//Get user's column configuration + +$default_configuration = "hostname:f|ST:f|AU:f|RES:f|R|L|OS|MS"; +$column_configuration = ""; +$slice_column_configuration = ""; + +$show_configuration = ""; +$show_reservable_message = '1'; +$show_columns_message = true; + + +//$PersonTags=$api->GetPersonTags (array('person_id'=>$plc->person['person_id'])); +$PersonTags=$api->GetPersonTags (array('person_id'=>$plc->person['person_id'])); +//print_r($PersonTags); +foreach ($PersonTags as $ptag) { + if ($ptag['tagname'] == 'columnconf') + { + $column_configuration = $ptag['value']; + $conf_tag_id = $ptag['person_tag_id']; + } + if ($ptag['tagname'] == 'showconf') + { + $show_configuration = $ptag['value']; + $show_tag_id = $ptag['person_tag_id']; + } +} + +//print("
person column configuration = ".$column_configuration); +//print("
person show configuration = ".$show_configuration); + +$sliceconf_exists = false; +if ($column_configuration == "") +{ + $column_configuration = $slice_id.";default"; + $sliceconf_exists = true; +} +else { + $slice_conf = explode(";",$column_configuration); + for ($i=0; $islice configuration = ".$slice_column_configuration); + + +if ($slice_column_configuration == "") + $full_configuration = $default_configuration; +else + $full_configuration = $default_configuration."|".$slice_column_configuration; + + +//instantiate the column configuration class, which prepares the headers array +$ConfigureColumns =new PlekitColumns($full_configuration, $fix_columns, $tag_columns, $extra_columns); + +$visiblecolumns = $ConfigureColumns->node_tags(); + +$node_columns=array_merge($node_fixed_columns,$visiblecolumns); +//print_r($node_columns); +$all_nodes=$api->GetNodes(NULL,$node_columns); + +//print("
person show configuration = ".$show_configuration); + +$show_conf = explode(";",$show_configuration); +foreach ($show_conf as $ss) { + if ($ss =="reservable") + $show_reservable_message = '0'; + if ($ss =="columns") + $show_columns_message = false; +} + +//print("res:".$show_reservable_message." - cols:".$show_columns_message); + $slice_nodes=array(); $potential_nodes=array(); $reservable_nodes=array(); @@@ -550,43 -437,31 +549,43 @@@ $toggle=new PlekitToggle ('my-slice-nod 'visible'=>get_arg('show_nodes',false))); $toggle->start(); + +//////////////////// reservable nodes area + +$count=count($reservable_nodes); +if ($count && $privileges) { + // having reservable nodes in white lists looks a bit off scope for now... + $toggle_nodes=new PlekitToggle('my-slice-nodes-reserve', + "Leases - " . count($reservable_nodes) . " reservable node(s)", + array('visible'=>$show_reservable_message, 'info_div'=>'note_reservable_div')); + $toggle_nodes->start(); + +if ($show_reservable_message) +$note_display = ""; +else +$note_display = "display:none;"; + ////////// show a notice to people having attached a reservable node if (count($reservable_nodes) && $privileges) { $mark=reservable_mark(); print << +
+
+
You have attached one or more reservable nodes to your slice. Reservable nodes show up with the '$mark' mark. -Your slice will be available only during timeslots +Your slivers will be available only during timeslots where you have obtained leases. You can manage your leases in the tab below.
Please note that as of August 2010 this feature is experimental. Feedback is appreciated at devel@planet-lab.org -

+
hide message +
+
EOF; } -//////////////////// reservable nodes area -$count=count($reservable_nodes); -if ($count && $privileges) { - // having reservable nodes in white lists looks a bit off scope for now... - $toggle_nodes=new PlekitToggle('my-slice-nodes-reserve', - "Leases - " . count($reservable_nodes) . " reservable node(s)", - array('visible'=>get_arg('show_nodes_resa',false))); - $toggle_nodes->start(); $grain=$api->GetLeaseGranularity(); if ($profiling) plc_debug_prof('6 granul',$grain); // where to start from, expressed as an offset in hours from now @@@ -672,72 -547,6 +671,72 @@@ EOF $toggle_nodes->end(); } + +//////////////////// node configuration panel + +if ($show_columns_message) +$column_conf_visible = '1'; +else +$column_conf_visible = '0'; + + +$toggle_nodes=new PlekitToggle('my-slice-nodes-configuration', + "Node table layout", + array('visible'=>$column_conf_visible, 'info_div'=>'note_columns_div')); +$toggle_nodes->start(); + +//usort ($table_headers, create_function('$col1,$col2','return strcmp($col1["header"],$col2["header"]);')); +//print("

TABLE HEADERS

"); +//print_r($table_headers); + +print("

"); +print(""); +print(""); +print(""); +print(""); +print(""); +print(""); +print("
"); +print(""); +print(""); + +//print ("showing column message = ".$show_columns_message); +if ($show_columns_message) +$note_display = ""; +else +$note_display = "display:none;"; + + print << +
+This tab allows you to customize the columns in the node tables, below. Information on the nodes comes from a variety of monitoring sources. If you, as either a user or a provider of monitoring data, would like to see additional columns made available, please send us your request in mail to devel@planet-lab.org +hide message permanently +
+ +EOF; + +$ConfigureColumns->configuration_panel_html(true); + +$ConfigureColumns->javascript_init(); + +$toggle_nodes->end(); + + +$all_sites=$api->GetSites(NULL, array('site_id','login_base')); +$site_hash=array(); +foreach ($all_sites as $tmp_site) $site_hash[$tmp_site['site_id']]=$tmp_site['login_base']; + +$interface_columns=array('ip','node_id','interface_id'); +$interface_filter=array('is_primary'=>TRUE); +$interfaces=$api->GetInterfaces($interface_filter,$interface_columns); + +$interface_hash=array(); +foreach ($interfaces as $interface) $interface_hash[$interface['node_id']]=$interface; + + + + + //////////////////// nodes currently in $toggle_nodes=new PlekitToggle('my-slice-nodes-current', count_english($slice_nodes,"node") . " currently in $name", @@@ -746,10 -555,6 +745,10 @@@ $toggle_nodes->start() $headers=array(); $notes=array(); +//$notes=array_merge($notes,$visibletags->notes()); +$notes [] = "For information about the different columns please see the node table layout tab above or mouse over the column headers"; + +/* $headers['peer']='string'; $headers['hostname']='string'; $short="-S-"; $long=Node::status_footnote(); $type='string'; @@@ -758,51 -563,27 +757,51 @@@ $short=reservable_mark(); $long=reserva $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; // the extra tags, configured for the UI $headers=array_merge($headers,$visibletags->headers()); -$notes=array_merge($notes,$visibletags->notes()); if ($privileges) $headers[plc_delete_icon()]="none"; +*/ + +$edit_header = array(); +if ($privileges) $edit_header[plc_delete_icon()]="none"; +$headers = array_merge($ConfigureColumns->get_headers(),$edit_header); + +//print("

HEADERS

"); +//print_r($headers); $table_options = array('notes'=>$notes, 'search_width'=>15, - 'pagesize'=>20); -$table=new PlekitTable('nodes',$headers,'1',$table_options); + 'pagesize'=>20, + 'configurable'=>true); + +$table=new PlekitTable('nodes',$headers,NULL,$table_options); $form=new PlekitForm(l_actions(),array('slice_id'=>$slice['slice_id'])); $form->start(); $table->start(); if ($slice_nodes) foreach ($slice_nodes as $node) { $table->row_start(); - $peers->cell($table,$node['peer_id']); + +$table->cell($node['node_id'], array('display'=>'none')); + $table->cell(l_node_obj($node)); + $peers->cell($table,$node['peer_id']); $run_level=$node['run_level']; list($label,$class) = Node::status_label_class_($node); $table->cell ($label,array('class'=>$class)); $table->cell( ($node['node_type']=='reservable')?reservable_mark():"" ); - foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]); + + $hostname=$node['hostname']; + $ip=$interface_hash[$node['node_id']]['ip']; + $interface_id=$interface_hash[$node['node_id']]['interface_id']; + +//extra columns +$node['domain'] = topdomain($hostname); +$node['sitename'] = l_site_t($node['site_id'],$site_hash[$node['site_id']]); +$node['ipaddress'] = l_interface_t($interface_id,$ip); + + + //foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]); + $ConfigureColumns->cells($table, $node); if ($privileges) $table->cell ($form->checkbox_html('node_ids[]',$node['node_id'])); $table->row_end(); @@@ -841,9 -622,6 +840,9 @@@ if ($privileges) if ( $potential_nodes ) { $headers=array(); $notes=array(); + + +/* $headers['peer']='string'; $headers['hostname']='string'; $short="-S-"; $long=Node::status_footnote(); $type='string'; @@@ -852,43 -630,22 +851,43 @@@ $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; // the extra tags, configured for the UI $headers=array_merge($headers,$visibletags->headers()); - $notes=array_merge($notes,$visibletags->notes()); $headers['+']="none"; +*/ + + $add_header = array(); + $add_header['+']="none"; + $headers = array_merge($ConfigureColumns->get_headers(),$add_header); + + //$notes=array_merge($notes,$visibletags->notes()); +$notes [] = "For information about the different columns please see the node table layout tab above or mouse over the column headers"; - $table=new PlekitTable('add_nodes',$headers,'1', $table_options); + $table=new PlekitTable('add_nodes',$headers,NULL, $table_options); $form=new PlekitForm(l_actions(), array('slice_id'=>$slice['slice_id'])); $form->start(); $table->start(); if ($potential_nodes) foreach ($potential_nodes as $node) { $table->row_start(); - $peers->cell($table,$node['peer_id']); + +$table->cell($node['node_id'], array('display'=>'none')); + $table->cell(l_node_obj($node)); + $peers->cell($table,$node['peer_id']); list($label,$class) = Node::status_label_class_($node); $table->cell ($label,array('class'=>$class)); $table->cell( ($node['node_type']=='reservable')?reservable_mark():"" ); - foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]); + + //extra columns + $hostname=$node['hostname']; + $ip=$interface_hash[$node['node_id']]['ip']; + $interface_id=$interface_hash[$node['node_id']]['interface_id']; + $node['domain'] = topdomain($hostname); + $node['sitename'] = l_site_t($node['site_id'],$site_hash[$node['site_id']]); + $node['ipaddress'] = l_interface_t($interface_id,$ip); + + //foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]); + $ConfigureColumns->cells($table, $node); + $table->cell ($form->checkbox_html('node_ids[]',$node['node_id'])); $table->row_end(); }