mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-09-03 20:52:56 -05:00
Added upgrade step executed before schmema is upgraded
Class PreSchemaUpdate is executed before ldap schema update This is required by ticket: https://fedorahosted.org/freeipa/ticket/3210 Reviewed-By: Martin Kosek <mkosek@redhat.com>
This commit is contained in:
committed by
Martin Kosek
parent
5568e357d1
commit
c1f3fd6831
@@ -191,12 +191,6 @@ class LDAPUpdater_NonUpgrade(LDAPUpdater):
|
||||
|
||||
modified = False
|
||||
|
||||
if options.update_schema:
|
||||
modified = schemaupdate.update_schema(
|
||||
options.schema_files,
|
||||
dm_password=self.dirman_password,
|
||||
live_run=not options.test) or modified
|
||||
|
||||
ld = LDAPUpdate(
|
||||
dm_password=self.dirman_password,
|
||||
sub_dict={},
|
||||
@@ -204,6 +198,14 @@ class LDAPUpdater_NonUpgrade(LDAPUpdater):
|
||||
ldapi=options.ldapi,
|
||||
plugins=options.plugins or self.run_plugins)
|
||||
|
||||
modified = ld.pre_schema_update(ordered=True)
|
||||
|
||||
if options.update_schema:
|
||||
modified = schemaupdate.update_schema(
|
||||
options.schema_files,
|
||||
dm_password=self.dirman_password,
|
||||
live_run=not options.test) or modified
|
||||
|
||||
if not self.files:
|
||||
self.files = ld.get_all_files(UPDATES_DIR)
|
||||
|
||||
|
||||
@@ -42,7 +42,8 @@ from ipalib import api
|
||||
from ipaplatform.paths import paths
|
||||
from ipapython.dn import DN
|
||||
from ipapython.ipa_log_manager import *
|
||||
from ipaserver.install.plugins import PRE_UPDATE, POST_UPDATE
|
||||
from ipaserver.install.plugins import (PRE_UPDATE, POST_UPDATE,
|
||||
PRE_SCHEMA_UPDATE)
|
||||
from ipaserver.plugins import ldap2
|
||||
|
||||
UPDATES_DIR=paths.UPDATES_DIR
|
||||
@@ -794,6 +795,18 @@ class LDAPUpdate:
|
||||
for dn, update in sorted_updates:
|
||||
self._delete_record(update)
|
||||
|
||||
def pre_schema_update(self, ordered=False):
|
||||
"""Execute the update before the LDPA schema is updated.
|
||||
"""
|
||||
if self.plugins:
|
||||
self.info('PRE_SCHEMA_UPDATE')
|
||||
all_updates = {}
|
||||
updates = api.Backend.updateclient.update(PRE_SCHEMA_UPDATE, self.dm_password, self.ldapi, self.live_run)
|
||||
self.merge_updates(all_updates, updates)
|
||||
self._run_updates(all_updates)
|
||||
|
||||
return self.modified
|
||||
|
||||
def update(self, files, ordered=False):
|
||||
"""Execute the update. files is a list of the update files to use.
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
"""
|
||||
Provide a separate api for updates.
|
||||
"""
|
||||
PRE_SCHEMA_UPDATE = 0
|
||||
PRE_UPDATE = 1
|
||||
POST_UPDATE = 2
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
from ipalib import api
|
||||
from ipalib import Updater, Object
|
||||
from ipaserver.install import service
|
||||
from ipaserver.install.plugins import PRE_UPDATE, POST_UPDATE, MIDDLE
|
||||
from ipaserver.install.plugins import (PRE_UPDATE, POST_UPDATE,
|
||||
PRE_SCHEMA_UPDATE, MIDDLE)
|
||||
|
||||
class DSRestart(service.Service):
|
||||
"""
|
||||
@@ -55,6 +56,18 @@ class update(Object):
|
||||
|
||||
api.register(update)
|
||||
|
||||
|
||||
class PreSchemaUpdate(Updater):
|
||||
"""
|
||||
Base class for updates that run after file processing.
|
||||
"""
|
||||
updatetype = PRE_SCHEMA_UPDATE
|
||||
order = MIDDLE
|
||||
|
||||
def __init__(self):
|
||||
super(PreSchemaUpdate, self).__init__()
|
||||
|
||||
|
||||
class PreUpdate(Updater):
|
||||
"""
|
||||
Base class for updates that run prior to file processing.
|
||||
|
||||
@@ -78,6 +78,7 @@ 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)
|
||||
self.step("preparing server upgrade", self.__pre_schema_upgrade)
|
||||
if self.schema_files:
|
||||
self.step("updating schema", self.__update_schema)
|
||||
self.step("upgrading server", self.__upgrade)
|
||||
@@ -115,6 +116,22 @@ class IPAUpgrade(service.Service):
|
||||
installutils.set_directive(self.filename, 'nsslapd-ldapientrysearchbase',
|
||||
None, quotes=False, separator=':')
|
||||
|
||||
def __pre_schema_upgrade(self):
|
||||
try:
|
||||
ld = ldapupdate.LDAPUpdate(dm_password='', ldapi=True, live_run=self.live_run, plugins=True)
|
||||
self.modified = (ld.pre_schema_update(ordered=True) or
|
||||
self.modified)
|
||||
except ldapupdate.BadSyntax, e:
|
||||
root_logger.error('Bad syntax in pre schema upgrade %s' % str(e))
|
||||
self.modified = False
|
||||
self.badsyntax = True
|
||||
except Exception, e:
|
||||
# Bad things happened, return gracefully
|
||||
self.modified = False
|
||||
self.upgradefailed = True
|
||||
root_logger.error('Pre schema upgrade failed with %s' % str(e))
|
||||
root_logger.debug('%s', traceback.format_exc())
|
||||
|
||||
def __update_schema(self):
|
||||
self.modified = schemaupdate.update_schema(
|
||||
self.schema_files,
|
||||
|
||||
Reference in New Issue
Block a user