summaryrefslogtreecommitdiffstats
path: root/base/server/python/pki/server/__init__.py
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2015-03-05 23:05:40 -0500
committerEndi S. Dewata <edewata@redhat.com>2015-04-21 16:53:28 -0400
commit79c5627ae28840756d99928fd33701552cc93322 (patch)
tree88850429369d2478a4c28697226a2c4a0831d30f /base/server/python/pki/server/__init__.py
parent42667acb21cee0ce73c58aaf55aea8fee19620ff (diff)
downloadpki-79c5627ae28840756d99928fd33701552cc93322.tar.gz
pki-79c5627ae28840756d99928fd33701552cc93322.tar.xz
pki-79c5627ae28840756d99928fd33701552cc93322.zip
Added server migration command.
New pki-server CLI commands have been added to migrate the server configuration from Tomcat 7 to Tomcat 8 and vice versa. These commands can be used later during system upgrade to migrate existing instances from Tomcat 7 in F22 to Tomcat 8 in F23. The Python CLI framework has been refactored to provide a way to find other CLI modules by the command names. https://fedorahosted.org/pki/ticket/1264
Diffstat (limited to 'base/server/python/pki/server/__init__.py')
-rw-r--r--base/server/python/pki/server/__init__.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/base/server/python/pki/server/__init__.py b/base/server/python/pki/server/__init__.py
index 063acd738..bbdfedc2c 100644
--- a/base/server/python/pki/server/__init__.py
+++ b/base/server/python/pki/server/__init__.py
@@ -33,6 +33,23 @@ REGISTRY_DIR = '/etc/sysconfig/pki'
SUBSYSTEM_TYPES = ['ca', 'kra', 'ocsp', 'tks', 'tps']
+class PKIServer(object):
+
+ @classmethod
+ def instances(cls):
+
+ instances = []
+
+ if not os.path.exists(os.path.join(REGISTRY_DIR, 'tomcat')):
+ return instances
+
+ for instance_name in os.listdir(pki.server.INSTANCE_BASE_DIR):
+ instance = pki.server.PKIInstance(instance_name)
+ instance.load()
+ instances.append(instance)
+
+ return instances
+
class PKISubsystem(object):
def __init__(self, instance, subsystem_name):
@@ -92,14 +109,16 @@ class PKIInstance(object):
self.base_dir = os.path.join(pki.BASE_DIR, name)
self.conf_dir = os.path.join(self.base_dir, 'conf')
- self.registry_file = os.path.join(
- pki.server.REGISTRY_DIR, 'tomcat', self.name, self.name)
+ self.registry_dir = os.path.join(pki.server.REGISTRY_DIR, 'tomcat', self.name)
+ self.registry_file = os.path.join(self.registry_dir, self.name)
self.service_name = 'pki-tomcatd@%s.service' % self.name
self.user = None
self.group = None
+ self.subsystems = []
+
def is_valid(self):
return os.path.exists(self.conf_dir)
@@ -132,6 +151,11 @@ class PKIInstance(object):
if m:
self.group = m.group(1)
+ for subsystem_name in os.listdir(self.registry_dir):
+ if subsystem_name in pki.server.SUBSYSTEM_TYPES:
+ subsystem = PKISubsystem(self, subsystem_name)
+ self.subsystems.append(subsystem)
+
def is_deployed(self, webapp_name):
context_xml = os.path.join(
self.conf_dir, 'Catalina', 'localhost', webapp_name + '.xml')