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

Patch attached.

--
Martin Basti

From b0d103418427b4c769c149e0c5ef4bf86b4dbff1 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Mon, 10 Aug 2015 10:53:28 +0200
Subject: [PATCH] Fix upgrade of sidgen and extdom plugins

If configuration entries already exist, upgrade will not add them
again.

https://fedorahosted.org/freeipa/ticket/5151
---
 ipaserver/install/dsinstance.py     | 28 +++++++++++++++++++++++++---
 ipaserver/install/server/upgrade.py |  9 ++++++---
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
index 34827c9bf4c159c5ffd4f810279cbd32e45df930..b1f887faf488c6c20afe6fc472badc273ddc7a39 100644
--- a/ipaserver/install/dsinstance.py
+++ b/ipaserver/install/dsinstance.py
@@ -958,20 +958,42 @@ class DsInstance(service.Service):
     def __add_range_check_plugin(self):
         self._ldap_mod("range-check-conf.ldif", self.sub_dict)
 
-    # These two methods are not local, they are also called from the upgrade code
     def _add_sidgen_plugin(self):
         """
         Add sidgen directory server plugin configuration if it does not already exist.
         """
         self._ldap_mod('ipa-sidgen-conf.ldif', self.sub_dict)
 
+    def add_sidgen_plugin(self):
+        """
+        Add sidgen plugin configuration only if it does not already exist.
+        """
+        dn = DN('cn=IPA SIDGEN,cn=plugins,cn=config')
+        try:
+            self.admin_conn.get_entry(dn)
+        except errors.NotFound:
+            self._add_sidgen_plugin()
+        else:
+            root_logger.debug("sidgen plugin is already configured")
+
     def _add_extdom_plugin(self):
         """
-        Add directory server configuration for the extdom extended operation
-        if it does not already exist.
+        Add directory server configuration for the extdom extended operation.
         """
         self._ldap_mod('ipa-extdom-extop-conf.ldif', self.sub_dict)
 
+    def add_extdom_plugin(self):
+        """
+        Add extdom configuration if it does not already exist.
+        """
+        dn = DN('cn=ipa_extdom_extop,cn=plugins,cn=config')
+        try:
+            self.admin_conn.get_entry(dn)
+        except errors.NotFound:
+            self._add_extdom_plugin()
+        else:
+            root_logger.debug("extdom plugin is already configured")
+
     def replica_populate(self):
         self.ldap_connect()
 
diff --git a/ipaserver/install/server/upgrade.py b/ipaserver/install/server/upgrade.py
index a342642b03abc05d0ce108ff2b774ea25904bd8e..ee357bb24e50cf76dc014c4c1c5547bb8e01c5ff 100644
--- a/ipaserver/install/server/upgrade.py
+++ b/ipaserver/install/server/upgrade.py
@@ -1261,11 +1261,11 @@ def ds_enable_sidgen_extdom_plugins(ds):
     root_logger.info('[Enable sidgen and extdom plugins by default]')
 
     if sysupgrade.get_upgrade_state('ds', 'enable_ds_sidgen_extdom_plugins'):
-        root_logger.info('sidgen and extdom plugins are enabled already')
+        root_logger.debug('sidgen and extdom plugins are enabled already')
         return
 
-    ds._add_sidgen_plugin()
-    ds._add_extdom_plugin()
+    ds.add_sidgen_plugin()
+    ds.add_extdom_plugin()
     sysupgrade.set_upgrade_state('ds', 'enable_ds_sidgen_extdom_plugins', True)
 
 def ca_upgrade_schema(ca):
@@ -1415,7 +1415,10 @@ def upgrade_configuration():
     ds.fqdn = fqdn
     ds.realm = api.env.realm
     ds.suffix = ipautil.realm_to_suffix(api.env.realm)
+
+    ds.ldap_connect()
     ds_enable_sidgen_extdom_plugins(ds)
+    ds.ldap_disconnect()
 
     # Now 389-ds is available, run the remaining http tasks
     if not http.is_kdcproxy_configured():
-- 
2.4.3

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to