NSX|V Fix policy security group update

Updating the policy of the security group was not reflected in the DB

Change-Id: I83ce48404722df67daa00e3df703c6902a5ef84d
This commit is contained in:
Adit Sarfaty 2018-08-19 11:47:06 +03:00
parent 2e8c80eb0f
commit 62bb92d4ef
2 changed files with 10 additions and 4 deletions

View File

@ -152,11 +152,12 @@ class ExtendedSecurityGroupPropertiesMixin(object):
(sg_policy.POLICY in sg_req and
(sg_req[sg_policy.POLICY] !=
sg_res.get(sg_policy.POLICY)))):
prop = self._get_security_group_properties(context, sg_res['id'])
with db_api.context_manager.writer.using(context):
prop.update({
sg_logging.LOGGING: sg_req.get(sg_logging.LOGGING, False),
sg_policy.POLICY: sg_req.get(sg_policy.POLICY)})
prop = context.session.query(
NsxExtendedSecurityGroupProperties).filter_by(
security_group_id=sg_res['id']).one()
prop.logging = sg_req.get(sg_logging.LOGGING, False)
prop.policy = sg_req.get(sg_policy.POLICY)
sg_res[sg_logging.LOGGING] = sg_req.get(sg_logging.LOGGING, False)
sg_res[sg_policy.POLICY] = sg_req.get(sg_policy.POLICY)

View File

@ -110,6 +110,11 @@ class SecGroupPolicyExtensionTestCase(
sg['security_group']['id'])
updated_sg = self.deserialize(self.fmt, req.get_response(self.ext_api))
self.assertEqual(new_policy, updated_sg['security_group']['policy'])
# Verify the same result in 'get'
req = self.new_show_request('security-groups',
sg['security_group']['id'])
shown_sg = self.deserialize(self.fmt, req.get_response(self.ext_api))
self.assertEqual(new_policy, shown_sg['security_group']['policy'])
def test_secgroup_update_no_policy_change(self):
# Test updating without changing the policy