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)
-/* 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;
-}
+/* 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 {
/****************************************/
/* registrations */
div.site-register {
$this->node_id = $node['node_id'];
$this->hostname = $node['hostname'];
$this->boot_state = $node['boot_state'];
$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'];
$this->date_created = $node['date_created'];
$this->last_updated = $node['last_updated'];
$this->last_contact = $node['last_contact'];
function lastContact() {
return $this->timeaway($this->last_contact);
}
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() . ")";
+ }
+
+ $STALE_LENGTH = 2*60*60; /* TODO: set by some policy */
- $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));
function timeaway($val) {
if ( $val != NULL ) {
$ret = timeDiff(intval($val));
$ret = "Never";
}
return $ret;
$ret = "Never";
}
return $ret;
// boot area
$details->space ();
// 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;
if ( ! ($local_peer && $privileges)) {
// just display it
$boot_value=$boot_state;
// Common functions
require_once 'plc_functions.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';
require_once 'plc_peers.php';
require_once 'plc_visibletags.php';
require_once 'linetabs.php';
// performs sanity check and summarize the result in a single column
function node_status ($node) {
// 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";
-
- // 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
}
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();
'interface_ids','peer_id', 'slice_ids');
$visibletags = new VisibleTags ($api, 'node');
$visiblecolumns = $visibletags->column_names();
$short="D"; $long="toplevel domain name"; $type='string';
$headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
$headers["Site"]="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["Hostname"]="string";
-$headers["Type"]="string";
$short="IP"; $long="IP Address"; $type='sortIPAddress';
$headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
$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="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);
# initial sort on hostnames
$table=new PlekitTable ("nodes",$headers,4+$offset);
$peers = new Peers ($api);
// write rows
foreach ($nodes as $node) {
$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'];
$hostname=$node['hostname'];
$node_id=$node['node_id'];
$site_id=$node['site_id'];
$ip=$interface_hash[$node['node_id']]['ip'];
$interface_id=$interface_hash[$node['node_id']]['interface_id'];
$peer_id=$node['peer_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();
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));
$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 (l_node_t($node_id,$hostname));
- $table->cell ($node_type);
$table->cell (l_interface_t($interface_id,$ip),array('only-if'=> !$peer_id));
$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));
$table->cell (count($node['slice_ids']));
foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]);
$table->cell (node_status($node));
// Common functions
require_once 'plc_functions.php';
require_once 'plc_peers.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';
require_once 'plc_visibletags.php';
require_once 'linetabs.php';
require_once 'table.php';
// (.) type is passed to the javascript table, for sorting (default is 'string')
// minimal list as a start
// (.) 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();
// create a VisibleTags object : basically the list of tag columns to show
$visibletags = new VisibleTags ($api, 'node');
$visiblecolumns = $visibletags->column_names();
$notes=array();
$headers['peer']='string';
$headers['hostname']='string';
$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());
$headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
// the extra tags
$headers=array_merge($headers,$visibletags->headers());
$form->start();
$table->start();
if ($nodes) foreach ($nodes as $node) {
$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'];
$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']));
foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]);
if ($privileges) $table->cell ($form->checkbox_html('node_ids[]',$node['node_id']));
$notes=array();
$headers['peer']='string';
$headers['hostname']='string';
$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());
// the extra tags
$headers=array_merge($headers,$visibletags->headers());
$notes=array_merge($notes,$visibletags->notes());
$form->start();
$table->start();
if ($potential_nodes) foreach ($potential_nodes as $node) {
$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));
$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]);
$class=($run_level == 'boot') ? 'node-ok' : 'node-ko';
$table->cell($run_level,array('class'=>$class));
foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]);