-
Notifications
You must be signed in to change notification settings - Fork 22
/
mtda-systemd-helper
executable file
·67 lines (54 loc) · 1.82 KB
/
mtda-systemd-helper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
# ---------------------------------------------------------------------------
# Command Line Interface for MTDA
# ---------------------------------------------------------------------------
#
# This software is a part of MTDA.
# Copyright (C) 2024 Siemens Digital Industries Software
#
# ---------------------------------------------------------------------------
# SPDX-License-Identifier: MIT
# ---------------------------------------------------------------------------
# System imports
import getopt
import os
import sys
# Local imports
from mtda.main import MultiTenantDeviceAccess
import mtda.constants as CONSTS
class Application:
def __init__(self):
self.agent = None
def print_help(self):
return None
def print_version(self):
return None
def main(self):
config = None
options, stuff = getopt.getopt(
sys.argv[1:], 'c:hv',
['config', 'help', 'version'])
for opt, arg in options:
if opt in ('-c', '--config'):
config = arg
if opt in ('-h', '--help'):
self.print_help()
sys.exit(0)
if opt in ('-v', '--version'):
self.print_version()
sys.exit(0)
if config is not None and os.path.exists(config) is False:
print(f'could not find config file: {config}', file=sys.stderr)
return 1
self.agent = MultiTenantDeviceAccess()
self.agent.load_config(None, True, config)
try:
self.agent.systemd_configure()
except PermissionError:
print('could not reconfigure systemd: '
'permission denied!', file=sys.stderr)
return 1
return 0
if __name__ == '__main__':
app = Application()
sys.exit(app.main())