mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-27 16:46:42 -06:00
Fix update plugin order
Sort a filtered list in the update plugin ordering method. Unlike the previous algorithm, this always gives a correct order. It should also be faster and more readable. https://fedorahosted.org/freeipa/ticket/2820
This commit is contained in:
parent
3e3ac0ebab
commit
4507dcda58
@ -106,22 +106,12 @@ class updateclient(backend.Executioner):
|
||||
self.Backend.ldap2.connect(bind_dn='cn=Directory Manager', bind_pw=dm_password, autobind=autobind)
|
||||
|
||||
def order(self, updatetype):
|
||||
"""Return plugins of the given updatetype in sorted order.
|
||||
"""
|
||||
Calculate rough order of plugins.
|
||||
"""
|
||||
order = []
|
||||
for plugin in api.Updater(): #pylint: disable=E1101
|
||||
if plugin.updatetype != updatetype:
|
||||
continue
|
||||
if plugin.order == FIRST:
|
||||
order.insert(0, plugin)
|
||||
elif plugin.order == MIDDLE:
|
||||
order.insert(len(order)/2, plugin)
|
||||
else:
|
||||
order.append(plugin)
|
||||
|
||||
for o in order:
|
||||
yield o
|
||||
ordered = [plugin for plugin in api.Updater() # pylint: disable=E1101
|
||||
if plugin.updatetype == updatetype]
|
||||
ordered.sort(key=lambda p: p.order)
|
||||
return ordered
|
||||
|
||||
def update(self, updatetype, dm_password, ldapi, live_run):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user