mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
* ipca-ca-install: Use a single ldap connection for the entire script. Connecting with ccache in promote is not needed. * ipa-cacert-manage: Always connect to ldap, since renew and install are the only options and renew seems to need ldap connection even for self signed certificates. * ipa-compat-manage: Use one ldap connection for the entire script. Replaced try-finally with proper disconnect, code block reindented. * ipa-csreplica-manage: Properly establish and close the ldap connection. * ipa-dns-install: Proper connect, disconnect to ldap. * ipa-kra-install: Proper connect/disconnect for install and uninstall. * ipa-ldap-update: Proper connect and disconnect to ldap. * ipa-nis-manage: Proper connect/disconnect for ldap. Try-finally removed and code block reindented. * ipa-replica-manage: Proper connect/disconnect to ldap. * ipa-replica-prepare: Connect added to validate_options(), where api is initialized and disconnected added at the end of run. Reconnect in ask_for_options() to validate directory manager password. * ipa-server-certinstall: Use api.Backend.ldap2 for ldap connections. * ipa-server-upgrade: Connect to and disconnect from api.Backend.ldap2. https://fedorahosted.org/freeipa/ticket/6461 Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
60 lines
2.0 KiB
Python
60 lines
2.0 KiB
Python
#
|
|
# Copyright (C) 2015 FreeIPA Contributors see COPYING for license
|
|
#
|
|
|
|
from ipalib import api
|
|
from ipaplatform.paths import paths
|
|
from ipapython import admintool
|
|
from ipaserver.install import installutils
|
|
from ipaserver.install import server
|
|
|
|
|
|
class ServerUpgrade(admintool.AdminTool):
|
|
log_file_name = paths.IPAUPGRADE_LOG
|
|
command_name = 'ipa-server-upgrade'
|
|
|
|
usage = "%prog [options]"
|
|
|
|
@classmethod
|
|
def add_options(cls, parser):
|
|
super(ServerUpgrade, cls).add_options(parser)
|
|
parser.add_option("--force", action="store_true",
|
|
dest="force", default=False,
|
|
help="force upgrade (alias for --skip-version-check)")
|
|
parser.add_option("--skip-version-check", action="store_true",
|
|
dest="skip_version_check", default=False,
|
|
help="skip version check. WARNING: this may break "
|
|
"your system")
|
|
|
|
def validate_options(self):
|
|
super(ServerUpgrade, self).validate_options(needs_root=True)
|
|
|
|
if self.options.force:
|
|
self.options.skip_version_check = True
|
|
|
|
def setup_logging(self):
|
|
super(ServerUpgrade, self).setup_logging(log_file_mode='a')
|
|
|
|
def run(self):
|
|
super(ServerUpgrade, self).run()
|
|
|
|
api.bootstrap(in_server=True, context='updates')
|
|
api.finalize()
|
|
api.Backend.ldap2.connect()
|
|
|
|
try:
|
|
server.upgrade_check(self.options)
|
|
server.upgrade()
|
|
except RuntimeError as e:
|
|
raise admintool.ScriptError(str(e))
|
|
|
|
api.Backend.ldap2.disconnect()
|
|
|
|
def handle_error(self, exception):
|
|
if not isinstance(exception, SystemExit):
|
|
# do not log this message when ipa is not installed
|
|
self.log.error("IPA server upgrade failed: Inspect "
|
|
"/var/log/ipaupgrade.log and run command "
|
|
"ipa-server-upgrade manually.")
|
|
return installutils.handle_error(exception, self.log_file_name)
|