KRA: fix check that CA is installed

https://fedorahosted.org/freeipa/ticket/5345

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
Martin Basti 2015-10-23 14:15:00 +02:00
parent cc5a659d43
commit 4ec8df2739

View File

@ -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