From 4ec8df27392b4f47c03c2cded26d6695d8c38186 Mon Sep 17 00:00:00 2001 From: Martin Basti Date: Fri, 23 Oct 2015 14:15:00 +0200 Subject: [PATCH] KRA: fix check that CA is installed https://fedorahosted.org/freeipa/ticket/5345 Reviewed-By: Martin Babinsky --- ipaserver/install/ipa_kra_install.py | 42 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/ipaserver/install/ipa_kra_install.py b/ipaserver/install/ipa_kra_install.py index 1ae361edc..add8250d4 100644 --- a/ipaserver/install/ipa_kra_install.py +++ b/ipaserver/install/ipa_kra_install.py @@ -32,6 +32,7 @@ from ipapython import dogtag from ipapython import ipautil from ipapython.dn import DN from ipaserver.install import service +from ipaserver.install import cainstance from ipaserver.install import krainstance from ipaserver.install import dsinstance from ipaserver.install import installutils @@ -134,28 +135,13 @@ class KRAInstaller(KRAInstall): " in unattended mode" ) - self.installing_replica = dogtaginstance.is_installing_replica("KRA") - self.options.promote = False - - if self.installing_replica: - domain_level = dsinstance.get_domain_level(api) - if domain_level > DOMAIN_LEVEL_0: - self.options.promote = True - return - - if not self.args: - self.option_parser.error("A replica file is required.") - if len(self.args) > 1: - self.option_parser.error("Too many arguments provided") - + if len(self.args) > 1: + self.option_parser.error("Too many arguments provided") + elif len(self.args) == 1: self.replica_file = self.args[0] if not ipautil.file_exists(self.replica_file): self.option_parser.error( "Replica file %s does not exist" % self.replica_file) - else: - if self.args: - self.option_parser.error("Too many parameters provided. " - "No replica file is required.") def ask_for_options(self): super(KRAInstaller, self).ask_for_options() @@ -170,6 +156,26 @@ class KRAInstaller(KRAInstall): def _run(self): super(KRAInstaller, self).run() + + if not cainstance.is_ca_installed_locally(): + raise RuntimeError("Dogtag CA is not installed. " + "Please install the CA first") + + # this check can be done only when CA is installed + self.installing_replica = dogtaginstance.is_installing_replica("KRA") + self.options.promote = False + + if self.installing_replica: + domain_level = dsinstance.get_domain_level(api) + if domain_level > DOMAIN_LEVEL_0: + self.options.promote = True + elif not self.args: + raise RuntimeError("A replica file is required.") + else: + if self.args: + raise RuntimeError("Too many parameters provided. " + "No replica file is required.") + print(dedent(self.INSTALLER_START_MESSAGE)) self.options.dm_password = self.options.password