/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: Teddy Hogeborn
  • Date: 2019-03-03 14:04:14 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 382.
  • Revision ID: teddy@recompile.se-20190303140414-4jspvi9mi83f9cpl
mandos-ctl: Refactor

* mandos-ctl (Command.run): Take a "mandos" argument and save it.
  (PrintCmd.run): Take, but ignore, a "mandos" argument.
  (RemoveCmd.__init__): Remove.
  (main): Don't pass mandos_serv to RemoveCmd constructor.  Instead,
          always pass mandos_serv to command.run().

Show diffs side-by-side

added added

removed removed

Lines of Context:
348
348
# Abstract classes first
349
349
class Command(object):
350
350
    """Abstract class for commands"""
351
 
    def run(self, clients):
 
351
    def run(self, mandos, clients):
352
352
        """Normal commands should implement run_on_one_client(), but
353
353
        commands which want to operate on all clients at the same time
354
354
        can override this run() method instead."""
 
355
        self.mandos = mandos
355
356
        for client in clients:
356
357
            self.run_on_one_client(client)
357
358
 
364
365
                    "LastApprovalRequest", "ApprovalDelay",
365
366
                    "ApprovalDuration", "Checker", "ExtendedTimeout",
366
367
                    "Expires", "LastCheckerStatus")
367
 
    def run(self, clients):
 
368
    def run(self, mandos, clients):
368
369
        print(self.output(clients))
369
370
 
370
371
class PropertyCmd(Command):
425
426
                          dbus_interface=dbus.PROPERTIES_IFACE)
426
427
 
427
428
class RemoveCmd(Command):
428
 
    def __init__(self, mandos):
429
 
        self.mandos = mandos
430
429
    def run_on_one_client(self, client):
431
430
        self.mandos.RemoveClient(client.__dbus_object_path__)
432
431
 
630
629
        commands.append(IsEnabledCmd())
631
630
 
632
631
    if options.remove:
633
 
        commands.append(RemoveCmd(mandos_serv))
 
632
        commands.append(RemoveCmd())
634
633
 
635
634
    if options.checker is not None:
636
635
        commands.append(SetCheckerCmd())
716
715
 
717
716
    # Run all commands on clients
718
717
    for command in commands:
719
 
        command.run(clients)
 
718
        command.run(mandos_serv, clients)
720
719
 
721
720
 
722
721
class Test_milliseconds_to_string(unittest.TestCase):