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>

Change-Id: I2c59e71eae0bf2e73475bba321afc4aaa514b317
Closes-Bug: #1585373
This commit is contained in:
Sławek Kapłoński
2016-06-05 09:49:27 +00:00
parent ff9e501821
commit 3c27beb8c0
2 changed files with 25 additions and 3 deletions

View File

@@ -204,14 +204,18 @@ class RbacNeutronDbObjectMixin(rbac_db_mixin.RbacPluginMixin,
return self.obj_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.obj_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):

View File

@@ -75,6 +75,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.idempotent_id('1cb42653-54bd-4a9a-b888-c55e18199201')
def test_delete_policy(self):
policy = self.admin_client.create_qos_policy(