summaryrefslogtreecommitdiffstats
path: root/ipaserver/install
diff options
context:
space:
mode:
authorMartin Basti <mbasti@redhat.com>2015-03-17 12:23:06 +0100
committerTomas Babej <tbabej@redhat.com>2015-03-19 12:48:41 +0100
commitc3d441ae0314bd3669a75b3f33d544d9ca09d197 (patch)
treeb7c2e14b54874983f18309338b4f1c3a54290615 /ipaserver/install
parent4190b1a47c709f3973913116416b9f5b8168ba28 (diff)
downloadfreeipa-c3d441ae0314bd3669a75b3f33d544d9ca09d197.tar.gz
freeipa-c3d441ae0314bd3669a75b3f33d544d9ca09d197.tar.xz
freeipa-c3d441ae0314bd3669a75b3f33d544d9ca09d197.zip
Server Upgrade: remove --test option
As --test option is not used for developing, and it is not recommended to test if upgrade will pass, this path removes it copmletely. https://fedorahosted.org/freeipa/ticket/3448 Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipaserver/install')
-rw-r--r--ipaserver/install/ipa_ldap_updater.py21
-rw-r--r--ipaserver/install/ldapupdate.py53
-rw-r--r--ipaserver/install/plugins/updateclient.py21
-rw-r--r--ipaserver/install/schemaupdate.py10
-rw-r--r--ipaserver/install/upgradeinstance.py8
5 files changed, 46 insertions, 67 deletions
diff --git a/ipaserver/install/ipa_ldap_updater.py b/ipaserver/install/ipa_ldap_updater.py
index 5df7cdf42..3d6c80437 100644
--- a/ipaserver/install/ipa_ldap_updater.py
+++ b/ipaserver/install/ipa_ldap_updater.py
@@ -46,9 +46,6 @@ class LDAPUpdater(admintool.AdminTool):
def add_options(cls, parser):
super(LDAPUpdater, cls).add_options(parser, debug_option=True)
- parser.add_option("-t", "--test", action="store_true", dest="test",
- default=False,
- help="run through the update without changing anything")
parser.add_option("-y", dest="password",
help="file containing the Directory Manager password")
parser.add_option("-l", '--ldapi', action="store_true", dest="ldapi",
@@ -139,7 +136,7 @@ class LDAPUpdater_Upgrade(LDAPUpdater):
updates = None
realm = krbV.default_context().default_realm
- upgrade = IPAUpgrade(realm, self.files, live_run=not options.test,
+ upgrade = IPAUpgrade(realm, self.files,
schema_files=options.schema_files)
upgrade.create_instance()
upgradefailed = upgrade.upgradefailed
@@ -149,9 +146,10 @@ class LDAPUpdater_Upgrade(LDAPUpdater):
'Bad syntax detected in upgrade file(s).', 1)
elif upgrade.upgradefailed:
raise admintool.ScriptError('IPA upgrade failed.', 1)
- elif upgrade.modified and options.test:
- self.log.info('Update complete, changes to be made, test mode')
- return 2
+ elif upgrade.modified:
+ self.log.info('Update complete')
+ else:
+ self.log.info('Update complete, no data were modified')
class LDAPUpdater_NonUpgrade(LDAPUpdater):
@@ -195,13 +193,11 @@ class LDAPUpdater_NonUpgrade(LDAPUpdater):
modified = schemaupdate.update_schema(
options.schema_files,
dm_password=self.dirman_password,
- live_run=not options.test,
ldapi=options.ldapi) or modified
ld = LDAPUpdate(
dm_password=self.dirman_password,
sub_dict={},
- live_run=not options.test,
ldapi=options.ldapi,
plugins=options.plugins or self.run_plugins)
@@ -210,6 +206,7 @@ class LDAPUpdater_NonUpgrade(LDAPUpdater):
modified = ld.update(self.files) or modified
- if modified and options.test:
- self.log.info('Update complete, changes to be made, test mode')
- return 2
+ if modified:
+ self.log.info('Update complete')
+ else:
+ self.log.info('Update complete, no data were modified')
diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index 3e59a9115..199b23ba8 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -112,7 +112,7 @@ def safe_output(attr, values):
class LDAPUpdate:
action_keywords = ["default", "add", "remove", "only", "onlyifexist", "deleteentry", "replace", "addifnew", "addifexist"]
- def __init__(self, dm_password, sub_dict={}, live_run=True,
+ def __init__(self, dm_password, sub_dict={},
online=True, ldapi=False, plugins=False):
'''
:parameters:
@@ -120,8 +120,6 @@ class LDAPUpdate:
Directory Manager password
sub_dict
substitution dictionary
- live_run
- Apply the changes or just test
online
Do an online LDAP update or use an experimental LDIF updater
ldapi
@@ -158,7 +156,6 @@ class LDAPUpdate:
'''
log_mgr.get_logger(self, True)
self.sub_dict = sub_dict
- self.live_run = live_run
self.dm_password = dm_password
self.conn = None
self.modified = False
@@ -391,8 +388,7 @@ class LDAPUpdate:
"""Create a task to update an index for an attribute"""
# Sleep a bit to ensure previous operations are complete
- if self.live_run:
- time.sleep(5)
+ time.sleep(5)
cn_uuid = uuid.uuid1()
# cn_uuid.time is in nanoseconds, but other users of LDAPUpdate expect
@@ -412,8 +408,7 @@ class LDAPUpdate:
self.info("Creating task to index attribute: %s", attribute)
self.debug("Task id: %s", dn)
- if self.live_run:
- self.conn.add_entry(e)
+ self.conn.add_entry(e)
return dn
@@ -423,10 +418,6 @@ class LDAPUpdate:
assert isinstance(dn, DN)
- if not self.live_run:
- # If not doing this live there is nothing to monitor
- return
-
# Pause for a moment to give the task time to be created
time.sleep(1)
@@ -642,19 +633,18 @@ class LDAPUpdate:
updated = False
if not found:
try:
- if self.live_run:
- if len(entry):
- # addifexist may result in an entry with only a
- # dn defined. In that case there is nothing to do.
- # It means the entry doesn't exist, so skip it.
- try:
- self.conn.add_entry(entry)
- except errors.NotFound:
- # parent entry of the added entry does not exist
- # this may not be an error (e.g. entries in NIS container)
- self.info("Parent DN of %s may not exist, cannot create the entry",
- entry.dn)
- return
+ if len(entry):
+ # addifexist may result in an entry with only a
+ # dn defined. In that case there is nothing to do.
+ # It means the entry doesn't exist, so skip it.
+ try:
+ self.conn.add_entry(entry)
+ except errors.NotFound:
+ # parent entry of the added entry does not exist
+ # this may not be an error (e.g. entries in NIS container)
+ self.info("Parent DN of %s may not exist, cannot create the entry",
+ entry.dn)
+ return
added = True
self.modified = True
except Exception, e:
@@ -669,8 +659,8 @@ class LDAPUpdate:
for (type, attr, values) in changes:
safe_changes.append((type, attr, safe_output(attr, values)))
self.debug("%s" % safe_changes)
- self.debug("Live %d, updated %d" % (self.live_run, updated))
- if self.live_run and updated:
+ self.debug("Updated %d" % updated)
+ if updated:
self.conn.update_entry(entry)
self.info("Done")
except errors.EmptyModlist:
@@ -709,8 +699,7 @@ class LDAPUpdate:
dn = updates['dn']
try:
self.info("Deleting entry %s", dn)
- if self.live_run:
- self.conn.delete_entry(dn)
+ self.conn.delete_entry(dn)
self.modified = True
except errors.NotFound, e:
self.info("%s did not exist:%s", dn, e)
@@ -757,7 +746,8 @@ class LDAPUpdate:
self.create_connection()
if self.plugins:
self.info('PRE_UPDATE')
- updates = api.Backend.updateclient.update(PRE_UPDATE, self.dm_password, self.ldapi, self.live_run)
+ updates = api.Backend.updateclient.update(
+ PRE_UPDATE, self.dm_password, self.ldapi)
# flush out PRE_UPDATE plugin updates before we begin
self._run_updates(updates)
@@ -779,7 +769,8 @@ class LDAPUpdate:
if self.plugins:
self.info('POST_UPDATE')
- updates = api.Backend.updateclient.update(POST_UPDATE, self.dm_password, self.ldapi, self.live_run)
+ updates = api.Backend.updateclient.update(
+ POST_UPDATE, self.dm_password, self.ldapi)
self._run_updates(updates)
finally:
self.close_connection()
diff --git a/ipaserver/install/plugins/updateclient.py b/ipaserver/install/plugins/updateclient.py
index 85ee3f8a0..824d32b65 100644
--- a/ipaserver/install/plugins/updateclient.py
+++ b/ipaserver/install/plugins/updateclient.py
@@ -111,21 +111,21 @@ class updateclient(backend.Executioner):
ordered.sort(key=lambda p: p.order)
return ordered
- def update(self, updatetype, dm_password, ldapi, live_run):
+ def update(self, updatetype, dm_password, ldapi):
"""
Execute all update plugins of type updatetype.
"""
self.create_context(dm_password)
- kw = dict(live_run=live_run)
+ kw = dict()
result = []
- ld = LDAPUpdate(dm_password=dm_password, sub_dict={}, live_run=live_run, ldapi=ldapi)
+ ld = LDAPUpdate(dm_password=dm_password, sub_dict={}, ldapi=ldapi)
for update in self.order(updatetype):
(restart, apply_now, res) = self.run(update.name, **kw)
if restart:
# connection has to be closed before restart, otherwise
# ld instance will try to reuse old non-valid connection
ld.close_connection()
- self.restart(dm_password, live_run)
+ self.restart(dm_password)
if apply_now:
ld.update_from_dict(res)
@@ -142,16 +142,13 @@ class updateclient(backend.Executioner):
"""
return self.Updater[method](**kw)
- def restart(self, dm_password, live_run):
+ def restart(self, dm_password):
dsrestart = DSRestart()
socket_name = paths.SLAPD_INSTANCE_SOCKET_TEMPLATE % \
api.env.realm.replace('.','-')
- if live_run:
- self.destroy_context()
- dsrestart.create_instance()
- wait_for_open_socket(socket_name)
- self.create_context(dm_password)
- else:
- self.log.warn("Test mode, skipping restart")
+ self.destroy_context()
+ dsrestart.create_instance()
+ wait_for_open_socket(socket_name)
+ self.create_context(dm_password)
api.register(updateclient)
diff --git a/ipaserver/install/schemaupdate.py b/ipaserver/install/schemaupdate.py
index eaa45d5e9..9a882c9b6 100644
--- a/ipaserver/install/schemaupdate.py
+++ b/ipaserver/install/schemaupdate.py
@@ -83,7 +83,7 @@ def _get_oid_dependency_order(schema, cls):
return ordered_oid_groups
-def update_schema(schema_files, ldapi=False, dm_password=None, live_run=True):
+def update_schema(schema_files, ldapi=False, dm_password=None,):
"""Update schema to match the given ldif files
Schema elements present in the LDIF files but missing from the DS schema
@@ -99,11 +99,9 @@ def update_schema(schema_files, ldapi=False, dm_password=None, live_run=True):
:param schema_files: List of filenames to update from
:param ldapi: if true, use ldapi to connect
:param dm_password: directory manager password
- :live_run: if false, changes will not be applied
:return:
True if modifications were made
- (or *would be* made, for live_run=false)
"""
SCHEMA_ELEMENT_CLASSES_KEYS = [x[0] for x in SCHEMA_ELEMENT_CLASSES]
@@ -162,11 +160,9 @@ def update_schema(schema_files, ldapi=False, dm_password=None, live_run=True):
if new_elements:
modlist = schema_entry.generate_modlist()
log.debug("Schema modlist:\n%s", pprint.pformat(modlist))
+ conn.update_entry(schema_entry)
- if live_run:
- conn.update_entry(schema_entry)
-
- if not (modified and live_run):
+ if not modified:
log.info('Not updating schema')
return modified
diff --git a/ipaserver/install/upgradeinstance.py b/ipaserver/install/upgradeinstance.py
index 018db87a3..2f9039dd7 100644
--- a/ipaserver/install/upgradeinstance.py
+++ b/ipaserver/install/upgradeinstance.py
@@ -39,11 +39,10 @@ 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, schema_files=[]):
+ def __init__(self, realm_name, files=[], schema_files=[]):
"""
realm_name: kerberos realm name, used to determine DS instance dir
files: list of update files to process. If none use UPDATEDIR
- live_run: boolean that defines if we are in test or live mode.
"""
ext = ''
@@ -55,7 +54,6 @@ class IPAUpgrade(service.Service):
serverid = dsinstance.realm_to_serverid(realm_name)
self.filename = '%s/%s' % (paths.ETC_DIRSRV_SLAPD_INSTANCE_TEMPLATE % serverid, DSE)
self.savefilename = '%s/%s.ipa.%s' % (paths.ETC_DIRSRV_SLAPD_INSTANCE_TEMPLATE % serverid, DSE, ext)
- self.live_run = live_run
self.files = files
self.modified = False
self.badsyntax = False
@@ -124,11 +122,11 @@ class IPAUpgrade(service.Service):
def __update_schema(self):
self.modified = schemaupdate.update_schema(
self.schema_files,
- dm_password='', ldapi=True, live_run=self.live_run) or self.modified
+ dm_password='', ldapi=True) or self.modified
def __upgrade(self):
try:
- ld = ldapupdate.LDAPUpdate(dm_password='', ldapi=True, live_run=self.live_run, plugins=True)
+ ld = ldapupdate.LDAPUpdate(dm_password='', ldapi=True, plugins=True)
if len(self.files) == 0:
self.files = ld.get_all_files(ldapupdate.UPDATES_DIR)
self.modified = (ld.update(self.files) or self.modified)