/mandos/release

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

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Björn Påhlsson
  • Date: 2010-09-12 18:12:11 UTC
  • mto: (237.7.1 mandos)
  • mto: This revision was merged to the branch mainline in revision 270.
  • Revision ID: belorn@fukt.bsnet.se-20100912181211-wvkt0sk37zhx7tws
mandos-client: Added never ending loop for --connect
mandos-ctl: Better option parsing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
locale.setlocale(locale.LC_ALL, u'')
14
14
 
15
15
tablewords = {
16
 
    'Name': u'Name',
17
 
    'Enabled': u'Enabled',
18
 
    'Timeout': u'Timeout',
19
 
    'LastCheckedOK': u'Last Successful Check',
20
 
    'Created': u'Created',
21
 
    'Interval': u'Interval',
22
 
    'Host': u'Host',
23
 
    'Fingerprint': u'Fingerprint',
24
 
    'CheckerRunning': u'Check Is Running',
25
 
    'LastEnabled': u'Last Enabled',
26
 
    'Checker': u'Checker',
 
16
    'name': u'Name',
 
17
    'enabled': u'Enabled',
 
18
    'timeout': u'Timeout',
 
19
    'last_checked_ok': u'Last Successful Check',
 
20
    'created': u'Created',
 
21
    'interval': u'Interval',
 
22
    'host': u'Host',
 
23
    'fingerprint': u'Fingerprint',
 
24
    'checker_running': u'Check Is Running',
 
25
    'last_enabled': u'Last Enabled',
 
26
    'checker': u'Checker',
27
27
    }
28
 
defaultkeywords = ('Name', 'Enabled', 'Timeout', 'LastCheckedOK')
 
28
defaultkeywords = ('name', 'enabled', 'timeout', 'last_checked_ok')
29
29
domain = 'se.bsnet.fukt'
30
30
busname = domain + '.Mandos'
31
31
server_path = '/'
100
100
    # Create format string to print table rows
101
101
    format_string = u' '.join(u'%%-%ds' %
102
102
                              max(len(tablewords[key]),
103
 
                                  max(len(valuetostring(client[key],
104
 
                                                        key))
 
103
                                  max(len(valuetostring(client[key], key))
105
104
                                      for client in
106
105
                                      clients))
107
106
                              for key in keywords)
203
202
        else:
204
203
            for name in client_names:
205
204
                for path, client in mandos_clients.iteritems():
206
 
                    if client['Name'] == name:
 
205
                    if client['name'] == name:
207
206
                        client_objc = bus.get_object(busname, path)
208
207
                        clients.append(client_objc)
209
208
                        break
213
212
            
214
213
        if not has_actions(options) and clients:
215
214
            if options.verbose:
216
 
                keywords = ('Name', 'Enabled', 'Timeout', 'LastCheckedOK',
217
 
                            'Created', 'Interval', 'Host', 'Fingerprint',
218
 
                            'CheckerRunning', 'LastEnabled', 'Checker')
 
215
                keywords = ('name', 'enabled', 'timeout', 'last_checked_ok',
 
216
                            'created', 'interval', 'host', 'fingerprint',
 
217
                            'checker_running', 'last_enabled', 'checker')
219
218
            else:
220
219
                keywords = defaultkeywords
221
220
                
237
236
                    client.StopChecker(dbus_interface=client_interface)
238
237
                if options.is_enabled:
239
238
                    sys.exit(0 if client.Get(client_interface,
240
 
                                             u"Enabled",
 
239
                                             u"enabled",
241
240
                                             dbus_interface=dbus.PROPERTIES_IFACE)
242
241
                             else 1)
243
242
                if options.checker:
244
 
                    client.Set(client_interface, u"Checker", options.checker,
 
243
                    client.Set(client_interface, u"checker", options.checker,
245
244
                               dbus_interface=dbus.PROPERTIES_IFACE)
246
245
                if options.host:
247
 
                    client.Set(client_interface, u"Host", options.host,
 
246
                    client.Set(client_interface, u"host", options.host,
248
247
                               dbus_interface=dbus.PROPERTIES_IFACE)
249
248
                if options.interval:
250
 
                    client.Set(client_interface, u"Interval",
 
249
                    client.Set(client_interface, u"interval",
251
250
                               timedelta_to_milliseconds
252
251
                               (string_to_delta(options.interval)),
253
252
                               dbus_interface=dbus.PROPERTIES_IFACE)
254
253
                if options.timeout:
255
 
                    client.Set(client_interface, u"Timeout",
 
254
                    client.Set(client_interface, u"timeout",
256
255
                               timedelta_to_milliseconds(string_to_delta
257
256
                                                         (options.timeout)),
258
257
                               dbus_interface=dbus.PROPERTIES_IFACE)
259
258
                if options.secret:
260
 
                    client.Set(client_interface, u"Secret",
 
259
                    client.Set(client_interface, u"secret",
261
260
                               dbus.ByteArray(open(options.secret, u'rb').read()),
262
261
                               dbus_interface=dbus.PROPERTIES_IFACE)
263
262
                if options.approve: