annotate all_operations.py @ 332:d4893670f888 default tip

WIP: use watchdog reboot timer on pi
author drewp@bigasterisk.com
date Thu, 27 Feb 2025 11:09:29 -0800
parents 5b88b38f2471
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
326
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
1 import importlib
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
2 import os
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
3 from pyinfra.context import host
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
4
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
5
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
6 def gatherFuncs():
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
7 for opGroup in [
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
8 'users',
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
9 'system',
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
10 'apt',
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
11 'packages',
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
12 'net',
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
13 'dns',
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
14 'wireguard',
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
15 'kube',
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
16 'sync',
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
17 'mail',
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
18 'home',
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
19 ]:
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
20 if os.environ.get('GROUP') and opGroup != os.environ['GROUP']:
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
21 continue
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
22 mod = importlib.import_module(f'{opGroup}.{opGroup}')
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
23 operations = getattr(mod, 'operations')
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
24 for func in operations:
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
25 funcFullName = f'{mod.__name__}.{func.__name__}.{host.name}'
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
26 yield (funcFullName, func)
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
27
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
28
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
29 funcs = list(gatherFuncs())
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
30
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
31 for name, func in funcs:
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents:
diff changeset
32 func()