Fix update of shared QoS policy
When user updates QoS policy which is globaly shared, it will be still
marked as globally shared even if this flag was not set explicitly
in update request.
For example, updating description of QoS policy will not change shared
flag to default value which is "False".
Co-Authored-By: Haim Daniel <hdaniel@redhat.com>
Conflicts:
neutron/objects/rbac_db.py
neutron/tests/api/test_qos.py
Change-Id: I2c59e71eae0bf2e73475bba321afc4aaa514b317
Closes-Bug: #1585373
(cherry picked from commit 3c27beb8c0
)
This commit is contained in:
parent
9ad13f48a0
commit
65e3639b05
|
@ -203,14 +203,18 @@ class RbacNeutronDbObjectMixin(rbac_db_mixin.RbacPluginMixin,
|
|||
return self._context.session.delete(shared_prev)
|
||||
|
||||
|
||||
def _update_post(self):
|
||||
self.update_shared(self.shared, self.id)
|
||||
def _update_post(self, obj_changes):
|
||||
if "shared" in obj_changes:
|
||||
self.update_shared(self.shared, self.id)
|
||||
|
||||
|
||||
def _update_hook(self, update_orig):
|
||||
with db_api.autonested_transaction(self._context.session):
|
||||
# NOTE(slaweq): copy of object changes is required to pass it later to
|
||||
# _update_post method because update() will reset all those changes
|
||||
obj_changes = self.obj_get_changes()
|
||||
update_orig(self)
|
||||
_update_post(self)
|
||||
_update_post(self, obj_changes)
|
||||
|
||||
|
||||
def _create_post(self):
|
||||
|
|
|
@ -80,6 +80,24 @@ class QosTestJSON(base.BaseAdminNetworkTest):
|
|||
self.assertTrue(retrieved_policy['shared'])
|
||||
self.assertEqual([], retrieved_policy['rules'])
|
||||
|
||||
@test.idempotent_id('ee263db4-009a-4641-83e5-d0e83506ba4c')
|
||||
def test_shared_policy_update(self):
|
||||
policy = self.create_qos_policy(name='test-policy',
|
||||
description='',
|
||||
shared=True)
|
||||
|
||||
self.admin_client.update_qos_policy(policy['id'],
|
||||
description='test policy desc2')
|
||||
retrieved_policy = self.admin_client.show_qos_policy(policy['id'])
|
||||
retrieved_policy = retrieved_policy['policy']
|
||||
self.assertTrue(retrieved_policy['shared'])
|
||||
|
||||
self.admin_client.update_qos_policy(policy['id'],
|
||||
shared=False)
|
||||
retrieved_policy = self.admin_client.show_qos_policy(policy['id'])
|
||||
retrieved_policy = retrieved_policy['policy']
|
||||
self.assertFalse(retrieved_policy['shared'])
|
||||
|
||||
@test.attr(type='smoke')
|
||||
@test.idempotent_id('1cb42653-54bd-4a9a-b888-c55e18199201')
|
||||
def test_delete_policy(self):
|
||||
|
|
Loading…
Reference in New Issue