590d18
From 60cbb2471829504edb207c0914edd56a962593cf Mon Sep 17 00:00:00 2001
590d18
From: Jan Cholasta <jcholast@redhat.com>
590d18
Date: Mon, 12 Oct 2015 14:58:40 +0200
590d18
Subject: [PATCH] upgrade: make sure ldap2 is connected in export_kra_agent_pem
590d18
590d18
https://fedorahosted.org/freeipa/ticket/5360
590d18
590d18
Reviewed-By: Ales 'alich' Marecek <amarecek@redhat.com>
590d18
---
590d18
 ipaserver/install/server/upgrade.py | 7 +++++++
590d18
 1 file changed, 7 insertions(+)
590d18
590d18
diff --git a/ipaserver/install/server/upgrade.py b/ipaserver/install/server/upgrade.py
590d18
index 51a2dd3d0e3693c12f11579a84175c7719651da9..e0a45a097171613397db42e1c035f0d818a3ecf5 100644
590d18
--- a/ipaserver/install/server/upgrade.py
590d18
+++ b/ipaserver/install/server/upgrade.py
590d18
@@ -1252,6 +1252,13 @@ def export_kra_agent_pem():
590d18
         root_logger.info("KRA agent PEM file already exported")
590d18
         return
590d18
 
590d18
+    if not api.Backend.ldap2.isconnected():
590d18
+        try:
590d18
+            api.Backend.ldap2.connect(autobind=True)
590d18
+        except ipalib.errors.PublicError as e:
590d18
+            root_logger.error("Cannot connect to LDAP: %s", e)
590d18
+            return
590d18
+
590d18
     if not api.Command.kra_is_enabled()['result']:
590d18
         root_logger.info("KRA is not enabled")
590d18
         return
590d18
-- 
590d18
2.4.3
590d18