summaryrefslogtreecommitdiff
path: root/roles/storage
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2021-05-19 23:45:39 +0200
committerChristian Pointner <equinox@spreadspace.org>2021-05-19 23:45:39 +0200
commit131b103fa7c3659f84007bda2e60ada9649c996a (patch)
treed47c1981d89c459c2028dc000d4fa8a950f11a58 /roles/storage
parentsyncoid: run vs pull and fix autosuspend timer (diff)
syncoid/autosuspend: output state of checks in any case
Diffstat (limited to 'roles/storage')
-rw-r--r--roles/storage/zfs/syncoid/templates/autosuspend.py.j212
1 files changed, 9 insertions, 3 deletions
diff --git a/roles/storage/zfs/syncoid/templates/autosuspend.py.j2 b/roles/storage/zfs/syncoid/templates/autosuspend.py.j2
index e54ddd1b..fdeada52 100644
--- a/roles/storage/zfs/syncoid/templates/autosuspend.py.j2
+++ b/roles/storage/zfs/syncoid/templates/autosuspend.py.j2
@@ -4,7 +4,7 @@ import sys
import dbus
import re
import datetime
-#import pprint
+# import pprint
class AutoSuspender(object):
@@ -12,7 +12,7 @@ class AutoSuspender(object):
def __init__(self):
self.__bus = dbus.SystemBus()
self.__timer_re = re.compile('^syncoid-run-.*\.timer$')
- #self.__pp = pprint.PrettyPrinter(indent=2)
+ # self.__pp = pprint.PrettyPrinter(indent=2)
def _get_interface(self, dest, object, interface):
try:
@@ -65,14 +65,18 @@ class AutoSuspender(object):
if(len(users) > 0):
print("%d users logged in: %s" % (len(users), ", ".join([user[0] for user in users])))
result = False
+ else:
+ print("no users logged in.")
timers = self._get_syncoid_timers()
for timer in timers:
next = self._get_timer_next_elapse(timer[1])
until = next - datetime.datetime.now()
if(until < datetime.timedelta(minutes=10)):
- print("Timer %s elapses in less then 10 Minutes -> %s (%s)" % (timer[0], next, until))
+ print("timer '%s' elapses in less then 10 Minutes -> %s (%s)" % (timer[0], next, until))
result = False
+ else:
+ print("timer '%s' elapses in %s (%s)" % (timer[0], until, next))
return result
@@ -90,3 +94,5 @@ if __name__ == "__main__":
s = AutoSuspender()
if s.check():
s.suspend()
+ else:
+ print("not suspending system")