qos: fix shared filter for policies
The filter was working in Liberty, but was broken in Mitaka when the field became synthetic as part of RBAC enablement for the resource. _get_collection already knows how to handle the filter on database level, so we just need to register the filter to pass it deeper into db_api. Change-Id: I40657bd15d9bf1e2bc6b0224254c916c35391cd1 Closes-Bug: #1591222
This commit is contained in:
parent
3ead5f959e
commit
389f7b0b08
|
@ -302,6 +302,7 @@ class RbacNeutronMetaclass(type):
|
|||
mcs.update_synthetic_fields(bases, dct)
|
||||
mcs.replace_class_methods_with_hooks(bases, dct)
|
||||
cls = type(name, (RbacNeutronDbObjectMixin,) + bases, dct)
|
||||
cls.add_extra_filter_name('shared')
|
||||
mcs.subscribe_to_rbac_events(cls)
|
||||
|
||||
return cls
|
||||
|
|
|
@ -397,3 +397,22 @@ class QosPolicyDbObjectTestCase(test_base.BaseDbObjectTestCase,
|
|||
self.assertNotIn(rule_obj_dscp, policy_obj_v1_0.rules)
|
||||
#NOTE(mangelajo): we should not check .VERSION, since that's the
|
||||
# local version on the class definition
|
||||
|
||||
def test_filter_by_shared(self):
|
||||
policy_obj = policy.QosPolicy(
|
||||
self.context, name='shared-policy', shared=True)
|
||||
policy_obj.create()
|
||||
|
||||
policy_obj = policy.QosPolicy(
|
||||
self.context, name='private-policy', shared=False)
|
||||
policy_obj.create()
|
||||
|
||||
shared_policies = policy.QosPolicy.get_objects(
|
||||
self.context, shared=True)
|
||||
self.assertEqual(1, len(shared_policies))
|
||||
self.assertEqual('shared-policy', shared_policies[0].name)
|
||||
|
||||
private_policies = policy.QosPolicy.get_objects(
|
||||
self.context, shared=False)
|
||||
self.assertEqual(1, len(private_policies))
|
||||
self.assertEqual('private-policy', private_policies[0].name)
|
||||
|
|
Loading…
Reference in New Issue