Creation/Update of Network RBAC policies is broken

Bug #2101856 reported by Xavier Abellan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ansible-collections-openstack
New
Undecided
Unassigned

Bug Description

There is a bug in /plugins/modules/neutron_rbac_policy.py _find_matches that makes it impossible to use it.

When checking the match against the specified parameters, "all" should be used instead of "any". As it is now, _find_matches returns partial matches (several policies belonging to the same project, but for different object for example.). This then results in _find failing with 'Found more a single matching RBAC policy which match the given parameters.'. There is also a typo in that error, by the way.

Suggested fix, correcting both problems:

--- a/plugins/modules/neutron_rbac_policy.py
+++ b/plugins/modules/neutron_rbac_policy.py
@@ -252,7 +252,7 @@ class NeutronRBACPolicy(OpenStackModule):

         matches = self._find_matches()
         if len(matches) > 1:
- self.fail_json(msg='Found more a single matching RBAC policy'
+ self.fail_json(msg='Found more than a single matching RBAC policy'
                                ' which match the given parameters.')
         elif len(matches) == 1:
             return matches[0]
@@ -274,7 +274,7 @@ class NeutronRBACPolicy(OpenStackModule):
         policies = self.conn.network.rbac_policies(**kwargs)

         return [p for p in policies
- if any(p[k] == self.params[k]
+ if all(p[k] == self.params[k]
                        for k in ['object_id'])]

     def _update(self, policy, update):

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.