summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/upgradeinstance.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-04-26 15:21:35 +0200
committerPetr Viktorin <pviktori@redhat.com>2013-11-18 16:54:21 +0100
commitf52d471aa7d9dfbb1553bcf58e1279459bc6986b (patch)
tree7c1f9a8f05ff61bcd7663d499fdc250128e98eee /ipaserver/install/upgradeinstance.py
parent9e79d2bc5e85874ebb90f97e1660d160a65ebddb (diff)
downloadfreeipa-f52d471aa7d9dfbb1553bcf58e1279459bc6986b.tar.gz
freeipa-f52d471aa7d9dfbb1553bcf58e1279459bc6986b.tar.xz
freeipa-f52d471aa7d9dfbb1553bcf58e1279459bc6986b.zip
Add schema updater based on IPA schema files
The new updater is run as part of `ipa-ldap-updater --upgrade` and `ipa-ldap-updater --schema` (--schema is a new option). The --schema-file option to ipa-ldap-updater may be used (multiple times) to select a non-default set of schema files to update against. The updater adds an X-ORIGIN tag with the current IPA version to all elements it adds or modifies. https://fedorahosted.org/freeipa/ticket/3454
Diffstat (limited to 'ipaserver/install/upgradeinstance.py')
-rw-r--r--ipaserver/install/upgradeinstance.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/ipaserver/install/upgradeinstance.py b/ipaserver/install/upgradeinstance.py
index 895f29b3d..85c39b554 100644
--- a/ipaserver/install/upgradeinstance.py
+++ b/ipaserver/install/upgradeinstance.py
@@ -26,6 +26,7 @@ from ipapython.ipa_log_manager import *
from ipaserver.install import installutils
from ipaserver.install import dsinstance
+from ipaserver.install import schemaupdate
from ipaserver.install import ldapupdate
from ipaserver.install import service
@@ -38,7 +39,7 @@ class IPAUpgrade(service.Service):
listeners and updating over ldapi. This way we know the server is
quiet.
"""
- def __init__(self, realm_name, files=[], live_run=True):
+ def __init__(self, realm_name, files=[], live_run=True, schema_files=[]):
"""
realm_name: kerberos realm name, used to determine DS instance dir
files: list of update files to process. If none use UPDATEDIR
@@ -60,6 +61,7 @@ class IPAUpgrade(service.Service):
self.badsyntax = False
self.upgradefailed = False
self.serverid = serverid
+ self.schema_files = schema_files
def __start_nowait(self):
# Don't wait here because we've turned off port 389. The connection
@@ -75,6 +77,8 @@ class IPAUpgrade(service.Service):
self.step("saving configuration", self.__save_config)
self.step("disabling listeners", self.__disable_listeners)
self.step("starting directory server", self.__start_nowait)
+ if self.schema_files:
+ self.step("updating schema", self.__update_schema)
self.step("upgrading server", self.__upgrade)
self.step("stopping directory server", self.__stop_instance)
self.step("restoring configuration", self.__restore_config)
@@ -110,12 +114,18 @@ class IPAUpgrade(service.Service):
installutils.set_directive(self.filename, 'nsslapd-ldapientrysearchbase',
None, quotes=False, separator=':')
+ def __update_schema(self):
+ self.modified = schemaupdate.update_schema(
+ self.schema_files,
+ dm_password='', ldapi=True, live_run=self.live_run) or self.modified
+
def __upgrade(self):
try:
ld = ldapupdate.LDAPUpdate(dm_password='', ldapi=True, live_run=self.live_run, plugins=True)
if len(self.files) == 0:
self.files = ld.get_all_files(ldapupdate.UPDATES_DIR)
- self.modified = ld.update(self.files, ordered=True)
+ self.modified = (ld.update(self.files, ordered=True) or
+ self.modified)
except ldapupdate.BadSyntax, e:
root_logger.error('Bad syntax in upgrade %s' % str(e))
self.modified = False