X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fnodes%2Fnodes.php;h=7800b31b7d4754ab01629af08f1dc177a03559ea;hb=fa425f537d2e4aced1a2362672791aed274dd903;hp=43b994f9a7234d877e1070e91aa8528d4bb41ca9;hpb=232e3e3ce1e8f07de912ba0d5302b03bfe71f283;p=plewww.git diff --git a/planetlab/nodes/nodes.php b/planetlab/nodes/nodes.php index 43b994f..7800b31 100644 --- a/planetlab/nodes/nodes.php +++ b/planetlab/nodes/nodes.php @@ -15,12 +15,22 @@ include 'plc_header.php'; // Common functions require_once 'plc_functions.php'; +require_once 'plc_objects.php'; require_once 'plc_peers.php'; +require_once 'plc_visibletags2.php'; require_once 'linetabs.php'; -require_once 'table.php'; +require_once 'table2.php'; require_once 'nifty.php'; +require_once 'toggle.php'; +require_once 'columns.php'; -ini_set("memory_limit","48M"); +// keep css separate for now +drupal_set_html_head(' + +'); + + +ini_set("memory_limit","64M"); // -------------------- // recognized URL arguments @@ -28,11 +38,17 @@ $peerscope=$_GET['peerscope']; $pattern=$_GET['pattern']; $site_id=intval($_GET['site_id']); $slice_id=intval($_GET['slice_id']); +$person_id=intval($_GET['person_id']); // --- decoration $title="Nodes"; $tabs=array(); -$tabs []= tab_nodes_mysite(); +$tabs []= tab_nodes(); +if (count (plc_my_site_ids()) == 1) { + $tabs []= tab_nodes_mysite(); +} else { + $tabs []= tab_nodes_all_mysite(); +} $tabs []= tab_nodes_local(); // -------------------- @@ -43,20 +59,115 @@ $node_filter=array(); function node_status ($node) { $messages=array(); - - // do all this stuff on local nodes only - if ( ! $node['peer_id'] ) { - // check that the node has keys - if (count($node['interface_ids']) == 0) { - $messages [] = "No interface"; - } + if ($node['node_type'] != 'regular' && $node['node_type'] != 'reservable' ) + $messages []= $node['node_type']; + + // checks on local nodes only + if ( ( ! $node['peer_id']) ) { + // has it got interfaces + if (count($node['interface_ids']) == 0) + $messages []= "No interface"; } return plc_vertical_table($messages,'plc-warning'); } +$first_time_configuration = 'false'; + +if (plc_is_admin()) + $default_configuration = "ID:f|hostname:f|ST:f|AU:f"; +else + $default_configuration = "hostname:f|ST:f|AU:f"; + +//$extra_default = "LCN|DN|R|L|OS|MS|SN"; +$column_configuration = ""; +$slice_column_configuration = ""; + +$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']; + } +} + +//print("column configuration = ".$column_configuration); + +$nodesconf_exists = false; +if ($column_configuration == "") +{ + $column_configuration = "nodes;default"; + $nodesconf_exists = true; +} +else { + $slice_conf = explode(";",$column_configuration); + for ($i=0; $iOLD"); +//print_r($visiblecolumns); +//$node_columns=array_merge($node_fixed_columns,$visiblecolumns); + + // server-side filtering - set pattern in $_GET for filtering on hostname if ($pattern) { $node_filter['hostname']=$pattern; @@ -88,6 +199,23 @@ if ($slice_id) { $node_filter['node_id'] = $slice['node_ids']; } +// person_id is set : this is mostly oriented towards people managing several sites +if ($person_id) { + // avoid doing a useless call to GetPersons if the person_id is already known though $plc, + // as this is mostly done for the 'all my sites nodes' link + if ($person_id == plc_my_person_id()) { + $person=plc_my_person(); + $site_ids = plc_my_site_ids(); + } else { + // fetch the person's site_ids + $persons = $api->GetPersons(array('person_id'=>$person_id),array('person_id','email','site_ids')); + $person=$persons[0]; + $site_ids=$person['site_ids']; + } + $title .= t_person($person); + $node_filter['site_id']=$site_ids; + } + // go $nodes=$api->GetNodes($node_filter,$node_columns); @@ -127,53 +255,107 @@ if ( ! $nodes ) { $nifty=new PlekitNifty ('','objects-list','big'); $nifty->start(); -$headers = array ("P"=>"string", - "Region"=>"string", - "Site"=>"string", - "State"=>"string", - "Hostname"=>"string", - "IP"=>"IPAddress", - "Type"=>"string", - "Arch"=>"string", - "S"=>'int', - "?"=>"string", - ); +$headers = array (); $offset=0; +$notes=array(); +$notes [] = "For information about the different columns please see the node table layout tab above or mouse over the column headers"; + + +/* +// fixed columns +if (plc_is_admin()) { + $short="I"; $long="node_id"; $type='int'; + $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; + $offset=1; + } +$short="P"; $long="Peer"; $type='string'; + $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; +$short="D"; $long="toplevel domain name"; $type='string'; + $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; +$headers["Site"]="string"; +$headers["Hostname"]="string"; +$short="IP"; $long="IP Address"; $type='sortIPAddress'; + $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; +$short="ST"; $long=Node::status_footnote(); $type='string'; + $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; +$short="SL"; $long="Number of slivers"; $type='int'; + $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; + +$headers=array_merge($headers,$visibletags->headers()); +$notes=array_merge($notes,$visibletags->notes()); +$short="?"; $long="extra status info"; $type='string'; + $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; +*/ + +$info_header = array(); +$short="?"; $long="extra status info"; $type='string'; +$info_header[$short]=array('type'=>$type,'title'=>$long, 'label'=>'?', 'header'=>'?', 'visible'=>true); +//$notes []= "$short = $long"; +//$info_header["?"] = "none"; +$headers = array_merge($ConfigureColumns->get_headers(),$info_header); + +//print("

HEADERS"); +//print_r($headers); + +$toggle_nodes=new PlekitToggle('nodes-column-configuration', + "Node table layout", + array('visible'=>'1')); +$toggle_nodes->start(); +print("

"); +print(""); +print(""); +print(""); +print(""); +print("
"); +//print(""); +print(""); +$ConfigureColumns->configuration_panel_html(true); +$ConfigureColumns->javascript_init(); +$toggle_nodes->end(); + +$table_options = array('notes'=>$notes, + 'search_width'=>15, + 'pagesize'=>20, + 'configurable'=>true); # initial sort on hostnames -$table=new PlekitTable ("nodes",$headers,4); +$table=new PlekitTable ("nodes",$headers,3+$offset, $table_options); $table->start(); $peers = new Peers ($api); // write rows foreach ($nodes as $node) { + //$node_obj = new Node ($node); $hostname=$node['hostname']; $node_id=$node['node_id']; $site_id=$node['site_id']; $site=$site_hash[$site_id]; $login_base = $site['login_base']; - $node_id=$node['node_id']; $ip=$interface_hash[$node['node_id']]['ip']; $interface_id=$interface_hash[$node['node_id']]['interface_id']; $peer_id=$node['peer_id']; - $node_type = $node['node_type']; $table->row_start(); - $peers->cell ($table,$peer_id); - $table->cell (topdomain($hostname)); - $table->cell (l_site_t($site_id,$login_base)); - $table->cell ($node['boot_state']); + $table->cell($node['node_id'], array('display'=>'none')); + if (plc_is_admin()) $table->cell(l_node_t($node_id,$node_id)); $table->cell (l_node_t($node_id,$hostname)); - $table->cell (l_interface_t($interface_id,$ip)); - $table->cell ($node_type); - $table->cell ($node['arch']); - $table->cell (count($node['slice_ids'])); + $peers->cell ($table,$peer_id); + //$table->cell (topdomain($hostname)); + $node['domain'] = topdomain($hostname); + //$table->cell (l_site_t($site_id,$login_base)); + $node['sitename'] = l_site_t($site_id,$login_base); + //$table->cell (l_interface_t($interface_id,$ip),array('only-if'=> !$peer_id)); + $node['ipaddress'] = l_interface_t($interface_id,$ip); + list($label,$class) = Node::status_label_class_($node); + $table->cell ($label,array('class'=>$class)); + //$table->cell (count($node['slice_ids'])); + //foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]); + $ConfigureColumns->cells($table, $node); $table->cell (node_status($node)); $table->row_end(); } -$notes=array("S = number of slivers"); -$table->end(array('notes'=>$notes)); +$table->end(); $nifty->end(); //plekit_linetabs ($tabs,"bottom"); @@ -182,3 +364,4 @@ $nifty->end(); include 'plc_footer.php'; ?> +