diff options
author | Petr Viktorin <pviktori@redhat.com> | 2012-05-30 08:03:49 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2012-06-10 20:40:00 -0400 |
commit | 4507dcda58bbe663597c43672f91af7225e2a9b4 (patch) | |
tree | 77ad6af331d5aa7a131ab21a7e3e966c21f27d4a /ipaserver/install | |
parent | 3e3ac0ebabb5db25f9179b16ca8b4967e98a82a6 (diff) | |
download | freeipa-4507dcda58bbe663597c43672f91af7225e2a9b4.tar.gz freeipa-4507dcda58bbe663597c43672f91af7225e2a9b4.tar.xz freeipa-4507dcda58bbe663597c43672f91af7225e2a9b4.zip |
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
Diffstat (limited to 'ipaserver/install')
-rw-r--r-- | ipaserver/install/plugins/updateclient.py | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/ipaserver/install/plugins/updateclient.py b/ipaserver/install/plugins/updateclient.py index a2a2ce2aa..10d899abc 100644 --- a/ipaserver/install/plugins/updateclient.py +++ b/ipaserver/install/plugins/updateclient.py @@ -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): """ |