/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Björn Påhlsson
  • Date: 2010-09-09 22:06:10 UTC
  • mto: (237.4.3 mandos-release)
  • mto: This revision was merged to the branch mainline in revision 421.
  • Revision ID: belorn@fukt.bsnet.se-20100909220610-fcpkaykznlq22oaw
minor debug info for plugin-runner.
Commit before merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
locale.setlocale(locale.LC_ALL, u'')
13
13
 
14
14
tablewords = {
15
 
    'Name': u'Name',
16
 
    'Enabled': u'Enabled',
17
 
    'Timeout': u'Timeout',
18
 
    'LastCheckedOK': u'Last Successful Check',
19
 
    'Created': u'Created',
20
 
    'Interval': u'Interval',
21
 
    'Host': u'Host',
22
 
    'Fingerprint': u'Fingerprint',
23
 
    'CheckerRunning': u'Check Is Running',
24
 
    'LastEnabled': u'Last Enabled',
25
 
    'Checker': u'Checker',
 
15
    'name': u'Name',
 
16
    'enabled': u'Enabled',
 
17
    'timeout': u'Timeout',
 
18
    'last_checked_ok': u'Last Successful Check',
 
19
    'created': u'Created',
 
20
    'interval': u'Interval',
 
21
    'host': u'Host',
 
22
    'fingerprint': u'Fingerprint',
 
23
    'checker_running': u'Check Is Running',
 
24
    'last_enabled': u'Last Enabled',
 
25
    'checker': u'Checker',
26
26
    }
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'
30
30
server_path = '/'
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],
112
 
                                                        key))
 
111
                                  max(len(valuetostring(client[key], key))
113
112
                                      for client in
114
113
                                      clients))
115
114
                              for key in keywords)
167
166
if not clients and mandos_clients.values():
168
167
    keywords = defaultkeywords
169
168
    if options.all:
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())
174
173
 
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,
191
 
                                 u"Enabled",
 
190
                                 u"enabled",
192
191
                                 dbus_interface=dbus.PROPERTIES_IFACE)
193
192
                 else 1)
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)
197
196
    if options.host:
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)
217
215
    if options.deny:
218
 
        client.Approve(dbus.Boolean(False),
219
 
                       dbus_interface=client_interface)
 
216
        client.Approve(dbus.Boolean(False), dbus_interface=client_interface)