summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
authorJosh Kearney <josh@jk0.org>2011-03-24 04:10:57 +0000
committerTarmac <>2011-03-24 04:10:57 +0000
commitaf22892a2b1dc413f7d11c2f6efe2f820e3257ed (patch)
treedd7d9530d5dd80ddb7584a3f6e75d90266f06bf0 /nova/utils.py
parent20d77ea69bde623cf50531647d9d20ffc7e4bc88 (diff)
parent10e61af8a23c126c15fcfcf25156d32facf19ec2 (diff)
downloadnova-af22892a2b1dc413f7d11c2f6efe2f820e3257ed.tar.gz
nova-af22892a2b1dc413f7d11c2f6efe2f820e3257ed.tar.xz
nova-af22892a2b1dc413f7d11c2f6efe2f820e3257ed.zip
Offers the ability to run a periodic_task that sweeps through rescued instances older than 24 hours and forcibly unrescues them.
Flag added: rescue_timeout (default is 0 - disabled)
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/nova/utils.py b/nova/utils.py
index 8b9ce4734..03a6e8095 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -335,6 +335,14 @@ def utcnow():
utcnow.override_time = None
+def is_older_than(before, seconds):
+ """Return True if before is older than 'seconds'"""
+ if utcnow() - before > datetime.timedelta(seconds=seconds):
+ return True
+ else:
+ return False
+
+
def utcnow_ts():
"""Timestamp version of our utcnow function."""
return time.mktime(utcnow().timetuple())