From: Thierry Parmentelat Date: Mon, 16 Nov 2009 23:09:19 +0000 (+0000) Subject: consistency in the way nodes status is displayed in the node and slice areas X-Git-Tag: PLEWWW-4.3-37~2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=de3b1cb925d7a36b4e5a9610318ab4f21041c49e;p=plewww.git consistency in the way nodes status is displayed in the node and slice areas takes into account observed, preferred if missing, last_contact & stale (moved up to 2 hours) review the nodes page, remove type (report actual type in last column if not regular) --- diff --git a/planetlab/css/my_slice.css b/planetlab/css/my_slice.css index fa07f33..1cf26f9 100644 --- a/planetlab/css/my_slice.css +++ b/planetlab/css/my_slice.css @@ -18,10 +18,3 @@ div#toggle-container-my-slice-nodes-add { background: #f0e0e0; } -/* qualify enough so that this wins over the even/odd row patterns in tables */ -tbody>tr>td.node-ok { - background: #a0f0e6; -} -tbody>tr>td.node-ko { - background: #ffa7a8; -} diff --git a/planetlab/css/plc_style.css b/planetlab/css/plc_style.css index 87657d1..4715bea 100644 --- a/planetlab/css/plc_style.css +++ b/planetlab/css/plc_style.css @@ -89,6 +89,13 @@ h3.node_download { text-align: center; } +/* qualify enough so that this wins over the even/odd row patterns in tables */ +tbody>tr>td.node-ok { + background: #a0f0e6; +} +tbody>tr>td.node-ko { + background: #ffa7a8; +} /****************************************/ /* registrations */ div.site-register { diff --git a/planetlab/includes/plc_objects.php b/planetlab/includes/plc_objects.php index a51e2f5..e4d3801 100644 --- a/planetlab/includes/plc_objects.php +++ b/planetlab/includes/plc_objects.php @@ -211,6 +211,7 @@ class Node extends PlcObject { $this->node_id = $node['node_id']; $this->hostname = $node['hostname']; $this->boot_state = $node['boot_state']; + $this->run_level = $node['run_level']; $this->date_created = $node['date_created']; $this->last_updated = $node['last_updated']; $this->last_contact = $node['last_contact']; @@ -271,15 +272,26 @@ class Node extends PlcObject { function lastContact() { return $this->timeaway($this->last_contact); } + // returns a tuple ( label, class) + // $node needs at least 'run_level' 'boot_state' + function status_label_class () { + $label= $this->run_level ? $this->run_level : ( $this->boot_state . '*' ) ; + if ($this->stale()) $label .= '...'; + $class=($label=="boot") ? 'node-ok' : 'node-ko'; + return array($label,$class); + } + + static function status_footnote () { + return "state; * if node doesn't have an observed state; ... if status is stale (" . Node::stale_text() . ")"; + } + function stale() { + $STALE_LENGTH = 2*60*60; /* TODO: set by some policy */ $now = time(); - $STALE_LENGTH = 60*60; /* TODO: set by some policy */ - if ( $this->last_contact + $STALE_LENGTH > $now ) { - return False; - } else { - return True; - } + return ( $this->last_contact + $STALE_LENGTH < $now ); } + static function stale_text() { return "2 hours"; } + function timeaway($val) { if ( $val != NULL ) { $ret = timeDiff(intval($val)); @@ -287,7 +299,6 @@ class Node extends PlcObject { $ret = "Never"; } return $ret; - } } diff --git a/planetlab/nodes/node.php b/planetlab/nodes/node.php index ec3e03d..11df5b8 100644 --- a/planetlab/nodes/node.php +++ b/planetlab/nodes/node.php @@ -241,7 +241,8 @@ $details->th_td("Last contact",$Node->lastContact()); // boot area $details->space (); -$details->th_td ("Observed Boot state",$run_level . ( $Node->stale() ? " -- stale value" : "" )); +$stale_text = $Node->stale() ? ("... (more than " . Node::stale_text() . " ago)") : "" ; +$details->th_td ("Observed Boot state", $run_level . $stale_text); if ( ! ($local_peer && $privileges)) { // just display it $boot_value=$boot_state; diff --git a/planetlab/nodes/nodes.php b/planetlab/nodes/nodes.php index 951e985..59df3d9 100644 --- a/planetlab/nodes/nodes.php +++ b/planetlab/nodes/nodes.php @@ -15,6 +15,7 @@ include 'plc_header.php'; // Common functions require_once 'plc_functions.php'; +require_once 'plc_objects.php'; require_once 'plc_peers.php'; require_once 'plc_visibletags.php'; require_once 'linetabs.php'; @@ -49,20 +50,21 @@ $node_filter=array(); // performs sanity check and summarize the result in a single column function node_status ($node) { - // do all this stuff on local nodes only - if ( $node['peer_id'] ) - return "n/a"; - $messages=array(); - // check that the node has interfaces - if (count($node['interface_ids']) == 0) { - $messages [] = "No interface"; + if ($node['node_type'] != 'regular') + $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'); } // fetch nodes -$node_fixed_columns=array('hostname','node_type','site_id','node_id','boot_state','run_level', +$node_fixed_columns=array('hostname','node_type','site_id','node_id','boot_state','run_level','last_contact', 'interface_ids','peer_id', 'slice_ids'); $visibletags = new VisibleTags ($api, 'node'); $visiblecolumns = $visibletags->column_names(); @@ -169,18 +171,18 @@ $short="P"; $long="Peer"; $type='string'; $short="D"; $long="toplevel domain name"; $type='string'; $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; $headers["Site"]="string"; -$headers["State"]="string"; - $notes []= "state* = node doesn't have an observed state, preferred state is displayed"; $headers["Hostname"]="string"; -$headers["Type"]="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()); -$headers["?"]="string"; $notes []= "? = extra status info"; +$short="?"; $long="extra status info"; $type='string'; + $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; # initial sort on hostnames $table=new PlekitTable ("nodes",$headers,4+$offset); @@ -189,6 +191,7 @@ $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']; @@ -197,21 +200,16 @@ foreach ($nodes as $node) { $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(); if (plc_is_admin()) $table->cell(l_node_t($node_id,$node_id)); $peers->cell ($table,$peer_id); $table->cell (topdomain($hostname)); $table->cell (l_site_t($site_id,$login_base)); - if ($node['run_level']) { - $table->cell($node['run_level']); - } else { - $table->cell ($node['boot_state'] . '*'); - } $table->cell (l_node_t($node_id,$hostname)); - $table->cell ($node_type); $table->cell (l_interface_t($interface_id,$ip),array('only-if'=> !$peer_id)); + list($label,$class) = $node_obj->status_label_class(); + $table->cell ($label,array('class'=>$class)); $table->cell (count($node['slice_ids'])); foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]); $table->cell (node_status($node)); diff --git a/planetlab/slices/slice.php b/planetlab/slices/slice.php index 91721ce..eae7b9a 100644 --- a/planetlab/slices/slice.php +++ b/planetlab/slices/slice.php @@ -16,6 +16,7 @@ include 'plc_header.php'; // Common functions require_once 'plc_functions.php'; require_once 'plc_peers.php'; +require_once 'plc_objects.php'; require_once 'plc_visibletags.php'; require_once 'linetabs.php'; require_once 'table.php'; @@ -384,7 +385,7 @@ $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','run_level','boot_state'); +$node_fixed_columns = array('hostname','node_id','peer_id','slice_ids_whitelist','run_level','boot_state','last_contact'); // create a VisibleTags object : basically the list of tag columns to show $visibletags = new VisibleTags ($api, 'node'); $visiblecolumns = $visibletags->column_names(); @@ -410,7 +411,7 @@ $headers=array(); $notes=array(); $headers['peer']='string'; $headers['hostname']='string'; -$short="ST"; $long="Last known status"; $type='string'; +$short="ST"; $long=Node::status_footnote(); $type='string'; $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; // the extra tags $headers=array_merge($headers,$visibletags->headers()); @@ -427,13 +428,13 @@ $form=new PlekitForm(l_actions(),array('slice_id'=>$slice['slice_id'])); $form->start(); $table->start(); if ($nodes) foreach ($nodes as $node) { + $node_obj=new Node($node); $table->row_start(); $peers->cell($table,$node['peer_id']); $table->cell(l_node_obj($node)); $run_level=$node['run_level']; - if ( empty($run_level)) $run_level=$node['boot_state']; - $class=($run_level == 'boot') ? 'node-ok' : 'node-ko'; - $table->cell($run_level,array('class'=>$class)); + list($label,$class) = $node_obj->status_label_class(); + $table->cell ($label,array('class'=>$class)); foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]); if ($privileges) $table->cell ($form->checkbox_html('node_ids[]',$node['node_id'])); @@ -478,8 +479,8 @@ if ($privileges) { $notes=array(); $headers['peer']='string'; $headers['hostname']='string'; - $headers['S']='string'; - $notes[]='S = last known status'; + $short="ST"; $long=Node::status_footnote(); $type='string'; + $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long"; // the extra tags $headers=array_merge($headers,$visibletags->headers()); $notes=array_merge($notes,$visibletags->notes()); @@ -491,11 +492,12 @@ if ($privileges) { $form->start(); $table->start(); if ($potential_nodes) foreach ($potential_nodes as $node) { + $node_obj=new Node($node); $table->row_start(); $peers->cell($table,$node['peer_id']); $table->cell(l_node_obj($node)); - $run_level=$node['run_level']; - if ( empty($run_level)) $run_level=$node['boot_state']; + list($label,$class) = $node_obj->status_label_class(); + $table->cell ($label,array('class'=>$class)); $class=($run_level == 'boot') ? 'node-ok' : 'node-ko'; $table->cell($run_level,array('class'=>$class)); foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]);