From 8016ed7972d9211e7f0db14e45bc9658a7b292ef Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Mon, 22 May 2017 22:34:58 +0200 Subject: Enabling all subsystems on startup. The operations script has been modified to enable all subsystems on startup by default. If the selftest fails, the subsystem will be shutdown again automatically as before. A pki.conf option has been added to configure this behavior. https://pagure.io/dogtagpki/issue/2699 Change-Id: Iaf367ba2d88d73f377662eee5eafbb99e088ae50 --- base/server/python/pki/server/cli/subsystem.py | 58 +++++++++++++++++++------- 1 file changed, 42 insertions(+), 16 deletions(-) (limited to 'base/server/python') diff --git a/base/server/python/pki/server/cli/subsystem.py b/base/server/python/pki/server/cli/subsystem.py index ee5d2d2de..8395bd2cd 100644 --- a/base/server/python/pki/server/cli/subsystem.py +++ b/base/server/python/pki/server/cli/subsystem.py @@ -200,7 +200,7 @@ class SubsystemEnableCLI(pki.cli.CLI): try: opts, args = getopt.gnu_getopt(argv, 'i:v', [ - 'instance=', + 'instance=', 'all', 'verbose', 'help']) except getopt.GetoptError as e: @@ -209,11 +209,15 @@ class SubsystemEnableCLI(pki.cli.CLI): sys.exit(1) instance_name = 'pki-tomcat' + all_subsystems = False for o, a in opts: if o in ('-i', '--instance'): instance_name = a + elif o == '--all': + all_subsystems = True + elif o in ('-v', '--verbose'): self.set_verbose(True) @@ -226,13 +230,6 @@ class SubsystemEnableCLI(pki.cli.CLI): self.usage() sys.exit(1) - if len(args) != 1: - print('ERROR: missing subsystem ID') - self.usage() - sys.exit(1) - - subsystem_name = args[0] - instance = pki.server.PKIInstance(instance_name) if not instance.is_valid(): @@ -241,6 +238,22 @@ class SubsystemEnableCLI(pki.cli.CLI): instance.load() + if all_subsystems: + for subsystem in instance.subsystems: + if not subsystem.is_enabled(): + subsystem.enable() + + self.print_message('Enabled all subsystems') + + return + + if len(args) != 1: + print('ERROR: missing subsystem ID') + self.usage() + sys.exit(1) + + subsystem_name = args[0] + subsystem = instance.get_subsystem(subsystem_name) if not subsystem: print('ERROR: No %s subsystem in instance ' @@ -276,7 +289,7 @@ class SubsystemDisableCLI(pki.cli.CLI): try: opts, args = getopt.gnu_getopt(argv, 'i:v', [ - 'instance=', + 'instance=', 'all', 'verbose', 'help']) except getopt.GetoptError as e: @@ -285,11 +298,15 @@ class SubsystemDisableCLI(pki.cli.CLI): sys.exit(1) instance_name = 'pki-tomcat' + all_subsystems = False for o, a in opts: if o in ('-i', '--instance'): instance_name = a + elif o == '--all': + all_subsystems = True + elif o in ('-v', '--verbose'): self.set_verbose(True) @@ -302,13 +319,6 @@ class SubsystemDisableCLI(pki.cli.CLI): self.usage() sys.exit(1) - if len(args) != 1: - print('ERROR: missing subsystem ID') - self.usage() - sys.exit(1) - - subsystem_name = args[0] - instance = pki.server.PKIInstance(instance_name) if not instance.is_valid(): @@ -317,6 +327,22 @@ class SubsystemDisableCLI(pki.cli.CLI): instance.load() + if all_subsystems: + for subsystem in instance.subsystems: + if subsystem.is_enabled(): + subsystem.disable() + + self.print_message('Disabled all subsystems') + + return + + if len(args) != 1: + print('ERROR: missing subsystem ID') + self.usage() + sys.exit(1) + + subsystem_name = args[0] + subsystem = instance.get_subsystem(subsystem_name) if not subsystem: print('ERROR: No %s subsystem in instance ' -- cgit