summaryrefslogtreecommitdiffstats
path: root/base/server/python/pki/server
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2017-05-22 22:34:58 +0200
committerEndi S. Dewata <edewata@redhat.com>2017-05-23 21:03:20 +0200
commit8016ed7972d9211e7f0db14e45bc9658a7b292ef (patch)
tree581e4894afa88205489aa9f90cc1b5604f8f1808 /base/server/python/pki/server
parent0df4ba1372e0a5942806fda3b56f0b9ea70c6e05 (diff)
downloadpki-8016ed7972d9211e7f0db14e45bc9658a7b292ef.tar.gz
pki-8016ed7972d9211e7f0db14e45bc9658a7b292ef.tar.xz
pki-8016ed7972d9211e7f0db14e45bc9658a7b292ef.zip
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
Diffstat (limited to 'base/server/python/pki/server')
-rw-r--r--base/server/python/pki/server/cli/subsystem.py58
1 files changed, 42 insertions, 16 deletions
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 '