git://git.onelab.eu
/
plewww.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
recently we had made the address fields optional. While filing site registration...
[plewww.git]
/
planetlab
/
includes
/
plc_objects.php
diff --git
a/planetlab/includes/plc_objects.php
b/planetlab/includes/plc_objects.php
index
e34bf12
..
a51e2f5
100644
(file)
--- a/
planetlab/includes/plc_objects.php
+++ b/
planetlab/includes/plc_objects.php
@@
-23,9
+23,9
@@
function timeDiff ($timestamp,$detailed=false,$n = 0) {
$lengths = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600);
# Go from decades backwards to seconds
$lengths = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600);
# Go from decades backwards to seconds
- $i = sizeof($lengths) - 1;
# Size of the lengths / periods in case you change them
- $time = "";
# The string we will hold our times in
- while($i >
=
$n) {
+ $i = sizeof($lengths) - 1; # Size of the lengths / periods in case you change them
+ $time = ""; # The string we will hold our times in
+ while($i > $n) {
# if the difference is greater than the length we are checking... continue
if ($diff > $lengths[$i-1]) {
# 65 / 60 = 1. That means one minute. 130 / 60 = 2. Two minutes.. etc
# if the difference is greater than the length we are checking... continue
if ($diff > $lengths[$i-1]) {
# 65 / 60 = 1. That means one minute. 130 / 60 = 2. Two minutes.. etc
@@
-216,7
+216,7
@@
class Node extends PlcObject {
$this->last_contact = $node['last_contact'];
$this->site_id = $node['site_id'];
$this->pcu_ids = $node['pcu_ids'];
$this->last_contact = $node['last_contact'];
$this->site_id = $node['site_id'];
$this->pcu_ids = $node['pcu_ids'];
- $this->nn = $api->Get
NodeNetworks($node['nodenetwork
_ids']);
+ $this->nn = $api->Get
Interfaces($node['interface
_ids']);
foreach ($this->nn as $nnet)
{
if ( $nnet['is_primary'] == true )
foreach ($this->nn as $nnet)
{
if ( $nnet['is_primary'] == true )
@@
-271,6
+271,15
@@
class Node extends PlcObject {
function lastContact() {
return $this->timeaway($this->last_contact);
}
function lastContact() {
return $this->timeaway($this->last_contact);
}
+ function stale() {
+ $now = time();
+ $STALE_LENGTH = 60*60; /* TODO: set by some policy */
+ if ( $this->last_contact + $STALE_LENGTH > $now ) {
+ return False;
+ } else {
+ return True;
+ }
+ }
function timeaway($val) {
if ( $val != NULL ) {
$ret = timeDiff(intval($val));
function timeaway($val) {
if ( $val != NULL ) {
$ret = timeDiff(intval($val));