/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-12 18:23:40 UTC
  • mfrom: (426 mandos)
  • mto: (237.4.3 mandos-release)
  • mto: This revision was merged to the branch mainline in revision 428.
  • Revision ID: belorn@fukt.bsnet.se-20100912182340-09gzhdzd2a4zde5y
merge

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
 
    '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',
 
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',
27
27
    }
28
 
defaultkeywords = ('name', 'enabled', 'timeout', 'last_checked_ok')
 
28
defaultkeywords = ('Name', 'Enabled', 'Timeout', 'LastCheckedOK')
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], key))
 
103
                                  max(len(valuetostring(client[key],
 
104
                                                        key))
104
105
                                      for client in
105
106
                                      clients))
106
107
                              for key in keywords)
202
203
        else:
203
204
            for name in client_names:
204
205
                for path, client in mandos_clients.iteritems():
205
 
                    if client['name'] == name:
 
206
                    if client['Name'] == name:
206
207
                        client_objc = bus.get_object(busname, path)
207
208
                        clients.append(client_objc)
208
209
                        break
212
213
            
213
214
        if not has_actions(options) and clients:
214
215
            if options.verbose:
215
 
                keywords = ('name', 'enabled', 'timeout', 'last_checked_ok',
216
 
                            'created', 'interval', 'host', 'fingerprint',
217
 
                            'checker_running', 'last_enabled', 'checker')
 
216
                keywords = ('Name', 'Enabled', 'Timeout', 'LastCheckedOK',
 
217
                            'Created', 'Interval', 'Host', 'Fingerprint',
 
218
                            'CheckerRunning', 'LastEnabled', 'Checker')
218
219
            else:
219
220
                keywords = defaultkeywords
220
221
                
236
237
                    client.StopChecker(dbus_interface=client_interface)
237
238
                if options.is_enabled:
238
239
                    sys.exit(0 if client.Get(client_interface,
239
 
                                             u"enabled",
 
240
                                             u"Enabled",
240
241
                                             dbus_interface=dbus.PROPERTIES_IFACE)
241
242
                             else 1)
242
243
                if options.checker:
243
 
                    client.Set(client_interface, u"checker", options.checker,
 
244
                    client.Set(client_interface, u"Checker", options.checker,
244
245
                               dbus_interface=dbus.PROPERTIES_IFACE)
245
246
                if options.host:
246
 
                    client.Set(client_interface, u"host", options.host,
 
247
                    client.Set(client_interface, u"Host", options.host,
247
248
                               dbus_interface=dbus.PROPERTIES_IFACE)
248
249
                if options.interval:
249
 
                    client.Set(client_interface, u"interval",
 
250
                    client.Set(client_interface, u"Interval",
250
251
                               timedelta_to_milliseconds
251
252
                               (string_to_delta(options.interval)),
252
253
                               dbus_interface=dbus.PROPERTIES_IFACE)
253
254
                if options.timeout:
254
 
                    client.Set(client_interface, u"timeout",
 
255
                    client.Set(client_interface, u"Timeout",
255
256
                               timedelta_to_milliseconds(string_to_delta
256
257
                                                         (options.timeout)),
257
258
                               dbus_interface=dbus.PROPERTIES_IFACE)
258
259
                if options.secret:
259
 
                    client.Set(client_interface, u"secret",
 
260
                    client.Set(client_interface, u"Secret",
260
261
                               dbus.ByteArray(open(options.secret, u'rb').read()),
261
262
                               dbus_interface=dbus.PROPERTIES_IFACE)
262
263
                if options.approve: