[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [pytorctl/master] Add uptime restriction.



Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date: Fri, 2 Jul 2010 22:04:16 -0700
Subject: Add uptime restriction.
Commit: 3d5f402e9f57e327e8c46b679baf53b8f8fca332

---
 PathSupport.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/PathSupport.py b/PathSupport.py
index 395c773..562e238 100644
--- a/PathSupport.py
+++ b/PathSupport.py
@@ -228,6 +228,19 @@ class PercentileRestriction(NodeRestriction):
   def __str__(self):
     return self.__class__.__name__+"("+str(self.pct_skip)+","+str(self.pct_fast)+")"
 
+class UptimeRestriction(NodeRestriction):
+  """Restriction to filter out routers with uptimes < min_uptime or
+     > max_uptime"""
+  def __init__(self, min_uptime=None, max_uptime=None):
+    self.min_uptime = min_uptime
+    self.max_uptime = max_uptime
+
+  def r_is_ok(self, r):
+    "Returns true if r is in the uptime boundaries"
+    if self.min_uptime and r.uptime < self.min_uptime: return False
+    if self.max_uptime and r.uptime > self.max_uptime: return False
+    return True
+
 class RankRestriction(NodeRestriction):
   """Restriction to cut out a list-rank slice of the network."""
   def __init__(self, rank_skip, rank_stop):
-- 
1.7.1