12
12
locale.setlocale(locale.LC_ALL, u'')
16
'Enabled': u'Enabled',
17
'Timeout': u'Timeout',
18
'LastCheckedOK': u'Last Successful Check',
19
'Created': u'Created',
20
'Interval': u'Interval',
22
'Fingerprint': u'Fingerprint',
23
'CheckerRunning': u'Check Is Running',
24
'LastEnabled': u'Last Enabled',
25
'Checker': u'Checker',
16
'enabled': u'Enabled',
17
'timeout': u'Timeout',
18
'last_checked_ok': u'Last Successful Check',
19
'created': u'Created',
20
'interval': u'Interval',
22
'fingerprint': u'Fingerprint',
23
'checker_running': u'Check Is Running',
24
'last_enabled': u'Last Enabled',
25
'checker': u'Checker',
27
defaultkeywords = ('Name', 'Enabled', 'Timeout', 'LastCheckedOK')
27
defaultkeywords = ('name', 'enabled', 'timeout', 'last_checked_ok')
28
28
domain = 'se.bsnet.fukt'
29
29
busname = domain + '.Mandos'
108
108
# Create format string to print table rows
109
109
format_string = u' '.join(u'%%-%ds' %
110
110
max(len(tablewords[key]),
111
max(len(valuetostring(client[key],
111
max(len(valuetostring(client[key], key))
115
114
for key in keywords)
167
166
if not clients and mandos_clients.values():
168
167
keywords = defaultkeywords
170
keywords = ('Name', 'Enabled', 'Timeout', 'LastCheckedOK',
171
'Created', 'Interval', 'Host', 'Fingerprint',
172
'CheckerRunning', 'LastEnabled', 'Checker')
169
keywords = ('name', 'enabled', 'timeout', 'last_checked_ok',
170
'created', 'interval', 'host', 'fingerprint',
171
'checker_running', 'last_enabled', 'checker')
173
172
print_clients(mandos_clients.values())
175
174
# Process each client in the list by all selected options
188
187
client.StopChecker(dbus_interface=client_interface)
189
188
if options.is_enabled:
190
189
sys.exit(0 if client.Get(client_interface,
192
191
dbus_interface=dbus.PROPERTIES_IFACE)
194
193
if options.checker:
195
client.Set(client_interface, u"Checker", options.checker,
194
client.Set(client_interface, u"checker", options.checker,
196
195
dbus_interface=dbus.PROPERTIES_IFACE)
198
client.Set(client_interface, u"Host", options.host,
197
client.Set(client_interface, u"host", options.host,
199
198
dbus_interface=dbus.PROPERTIES_IFACE)
200
199
if options.interval:
201
client.Set(client_interface, u"Interval",
200
client.Set(client_interface, u"interval",
202
201
timedelta_to_milliseconds
203
202
(string_to_delta(options.interval)),
204
203
dbus_interface=dbus.PROPERTIES_IFACE)
205
204
if options.timeout:
206
client.Set(client_interface, u"Timeout",
205
client.Set(client_interface, u"timeout",
207
206
timedelta_to_milliseconds(string_to_delta
208
207
(options.timeout)),
209
208
dbus_interface=dbus.PROPERTIES_IFACE)
210
209
if options.secret:
211
client.Set(client_interface, u"Secret",
210
client.Set(client_interface, u"secret",
212
211
dbus.ByteArray(open(options.secret, u'rb').read()),
213
212
dbus_interface=dbus.PROPERTIES_IFACE)
214
213
if options.approve:
215
client.Approve(dbus.Boolean(True),
216
dbus_interface=client_interface)
214
client.Approve(dbus.Boolean(True), dbus_interface=client_interface)
218
client.Approve(dbus.Boolean(False),
219
dbus_interface=client_interface)
216
client.Approve(dbus.Boolean(False), dbus_interface=client_interface)