12
12
locale.setlocale(locale.LC_ALL, u'')
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',
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',
27
defaultkeywords = ('name', 'enabled', 'timeout', 'last_checked_ok')
27
defaultkeywords = ('Name', 'Enabled', 'Timeout', 'LastCheckedOK')
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], key))
111
max(len(valuetostring(client[key],
114
115
for key in keywords)
166
167
if not clients and mandos_clients.values():
167
168
keywords = defaultkeywords
169
keywords = ('name', 'enabled', 'timeout', 'last_checked_ok',
170
'created', 'interval', 'host', 'fingerprint',
171
'checker_running', 'last_enabled', 'checker')
170
keywords = ('Name', 'Enabled', 'Timeout', 'LastCheckedOK',
171
'Created', 'Interval', 'Host', 'Fingerprint',
172
'CheckerRunning', 'LastEnabled', 'Checker')
172
173
print_clients(mandos_clients.values())
174
175
# Process each client in the list by all selected options
187
188
client.StopChecker(dbus_interface=client_interface)
188
189
if options.is_enabled:
189
190
sys.exit(0 if client.Get(client_interface,
191
192
dbus_interface=dbus.PROPERTIES_IFACE)
193
194
if options.checker:
194
client.Set(client_interface, u"checker", options.checker,
195
client.Set(client_interface, u"Checker", options.checker,
195
196
dbus_interface=dbus.PROPERTIES_IFACE)
197
client.Set(client_interface, u"host", options.host,
198
client.Set(client_interface, u"Host", options.host,
198
199
dbus_interface=dbus.PROPERTIES_IFACE)
199
200
if options.interval:
200
client.Set(client_interface, u"interval",
201
client.Set(client_interface, u"Interval",
201
202
timedelta_to_milliseconds
202
203
(string_to_delta(options.interval)),
203
204
dbus_interface=dbus.PROPERTIES_IFACE)
204
205
if options.timeout:
205
client.Set(client_interface, u"timeout",
206
client.Set(client_interface, u"Timeout",
206
207
timedelta_to_milliseconds(string_to_delta
207
208
(options.timeout)),
208
209
dbus_interface=dbus.PROPERTIES_IFACE)
209
210
if options.secret:
210
client.Set(client_interface, u"secret",
211
client.Set(client_interface, u"Secret",
211
212
dbus.ByteArray(open(options.secret, u'rb').read()),
212
213
dbus_interface=dbus.PROPERTIES_IFACE)
213
214
if options.approve:
214
client.Approve(dbus.Boolean(True), dbus_interface=client_interface)
215
client.Approve(dbus.Boolean(True),
216
dbus_interface=client_interface)
216
client.Approve(dbus.Boolean(False), dbus_interface=client_interface)
218
client.Approve(dbus.Boolean(False),
219
dbus_interface=client_interface)