Imported Upstream version 4.3.1

This commit is contained in:
Mario Fetka
2021-08-10 02:37:58 +02:00
parent a791de49a2
commit 2f177da8f2
2056 changed files with 421730 additions and 1668138 deletions

View File

@@ -23,25 +23,23 @@
# TODO
# save undo files?
from __future__ import print_function, absolute_import
from __future__ import print_function
import logging
import os
import sys
import six
from ipalib import api
from ipapython import admintool
from ipapython import ipautil, admintool
from ipaplatform.paths import paths
from ipaserver.install import installutils, schemaupdate
from ipaserver.install import installutils, dsinstance, schemaupdate
from ipaserver.install.ldapupdate import LDAPUpdate, UPDATES_DIR, BadSyntax
from ipaserver.install.upgradeinstance import IPAUpgrade
if six.PY3:
unicode = str
logger = logging.getLogger(__name__)
class LDAPUpdater(admintool.AdminTool):
command_name = 'ipa-ldap-updater'
@@ -72,8 +70,8 @@ class LDAPUpdater(admintool.AdminTool):
self.files = self.args
if not (self.files or options.schema_files):
logger.info("To execute overall IPA upgrade please use "
"'ipa-server-upgrade' command")
self.log.info("To execute overall IPA upgrade please use "
"'ipa-server-upgrade' command")
raise admintool.ScriptError("No update files or schema file were "
"specified")
@@ -84,7 +82,8 @@ class LDAPUpdater(admintool.AdminTool):
try:
installutils.check_server_configuration()
except RuntimeError as e:
raise admintool.ScriptError(e)
print(unicode(e))
sys.exit(1)
def setup_logging(self):
super(LDAPUpdater, self).setup_logging(log_file_mode='a')
@@ -92,7 +91,7 @@ class LDAPUpdater(admintool.AdminTool):
def run(self):
super(LDAPUpdater, self).run()
api.bootstrap(in_server=True, context='updates', confdir=paths.ETC_IPA)
api.bootstrap(in_server=True, context='updates')
api.finalize()
def handle_error(self, exception):
@@ -104,7 +103,6 @@ class LDAPUpdater_Upgrade(LDAPUpdater):
def run(self):
super(LDAPUpdater_Upgrade, self).run()
api.Backend.ldap2.connect()
options = self.options
realm = api.env.realm
@@ -120,11 +118,9 @@ class LDAPUpdater_Upgrade(LDAPUpdater):
raise admintool.ScriptError('IPA upgrade failed.', 1)
else:
if upgrade.modified:
logger.info('Update complete')
self.log.info('Update complete')
else:
logger.info('Update complete, no data were modified')
api.Backend.ldap2.disconnect()
self.log.info('Update complete, no data were modified')
class LDAPUpdater_NonUpgrade(LDAPUpdater):
@@ -132,7 +128,6 @@ class LDAPUpdater_NonUpgrade(LDAPUpdater):
def run(self):
super(LDAPUpdater_NonUpgrade, self).run()
api.Backend.ldap2.connect()
options = self.options
modified = False
@@ -152,8 +147,6 @@ class LDAPUpdater_NonUpgrade(LDAPUpdater):
modified = ld.update(self.files) or modified
if modified:
logger.info('Update complete')
self.log.info('Update complete')
else:
logger.info('Update complete, no data were modified')
api.Backend.ldap2.disconnect()
self.log.info('Update complete, no data were modified')