diff options
Diffstat (limited to 'roles/storage/zfs/syncoid/templates/autosuspend.py.j2')
-rw-r--r-- | roles/storage/zfs/syncoid/templates/autosuspend.py.j2 | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/roles/storage/zfs/syncoid/templates/autosuspend.py.j2 b/roles/storage/zfs/syncoid/templates/autosuspend.py.j2 index 3dd893b2..58752328 100644 --- a/roles/storage/zfs/syncoid/templates/autosuspend.py.j2 +++ b/roles/storage/zfs/syncoid/templates/autosuspend.py.j2 @@ -56,7 +56,7 @@ class AutoSuspender(object): try: return datetime.datetime.fromtimestamp(int(props['NextElapseUSecRealtime']) / 1000000) except ValueError: - return datetime.datetime.now() + return None def check(self): result = True @@ -71,6 +71,11 @@ class AutoSuspender(object): timers = self._get_syncoid_timers() for timer in timers: next = self._get_timer_next_elapse(timer[1]) + if next == None: + print(" [NO] the next elapse of timer '%s' is invalid, assuming the unit is currently active" % (timer[0])) + result = False + continue + until = next - datetime.datetime.now() if(until < datetime.timedelta(minutes=10)): print(" [NO] timer '%s' elapses in less then 10 Minutes -> %s (%s)" % (timer[0], next, until)) @@ -85,7 +90,11 @@ class AutoSuspender(object): if not manager.CanSuspend(): print("suspending is not possible!") return - manager.Suspend(False) + try: + manager.Suspend(False) + except dbus.exceptions.DBusException: + print("ERR: %s" % error) + return None if __name__ == "__main__": |