Merge "Allow tags to be specified while creating Policy Rules"

This commit is contained in:
Zuul 2021-04-07 21:21:32 +00:00 committed by Gerrit Code Review
commit dfcfd10336
2 changed files with 11 additions and 4 deletions

View File

@ -1624,6 +1624,7 @@ class TestPolicyCommunicationMap(NsxPolicyLibTestCase):
service1_id = 'c1' service1_id = 'c1'
service2_id = 'c2' service2_id = 'c2'
tag = 'abc1234' tag = 'abc1234'
tags = ['dummy']
with mock.patch.object(self.policy_api, with mock.patch.object(self.policy_api,
"create_or_update") as api_call: "create_or_update") as api_call:
result = self.resourceApi.create_entry( result = self.resourceApi.create_entry(
@ -1637,7 +1638,7 @@ class TestPolicyCommunicationMap(NsxPolicyLibTestCase):
sequence_number=1, sequence_number=1,
direction=nsx_constants.IN, direction=nsx_constants.IN,
ip_protocol=nsx_constants.IPV4, ip_protocol=nsx_constants.IPV4,
tag=tag, tag=tag, tags=tags,
tenant=TEST_TENANT) tenant=TEST_TENANT)
expected_entry_def = self.entryDef( expected_entry_def = self.entryDef(
@ -1656,6 +1657,7 @@ class TestPolicyCommunicationMap(NsxPolicyLibTestCase):
scope=None, scope=None,
logged=False, logged=False,
tag=tag, tag=tag,
tags=tags,
tenant=TEST_TENANT) tenant=TEST_TENANT)
self.assert_called_with_def(api_call, expected_entry_def) self.assert_called_with_def(api_call, expected_entry_def)
@ -1669,6 +1671,7 @@ class TestPolicyCommunicationMap(NsxPolicyLibTestCase):
source_group = 'g1' source_group = 'g1'
dest_group = 'g2' dest_group = 'g2'
tag = 'abc1234' tag = 'abc1234'
tags = ['abc1234']
with mock.patch.object(self.policy_api, with mock.patch.object(self.policy_api,
"create_or_update") as api_call: "create_or_update") as api_call:
result = self.resourceApi.create_entry( result = self.resourceApi.create_entry(
@ -1677,7 +1680,7 @@ class TestPolicyCommunicationMap(NsxPolicyLibTestCase):
source_groups=[source_group], source_groups=[source_group],
dest_groups=[dest_group], dest_groups=[dest_group],
sequence_number=1, sequence_number=1,
tag=tag, tag=tag, tags=tags,
tenant=TEST_TENANT) tenant=TEST_TENANT)
expected_entry_def = self.entryDef( expected_entry_def = self.entryDef(
@ -1696,6 +1699,7 @@ class TestPolicyCommunicationMap(NsxPolicyLibTestCase):
scope=None, scope=None,
logged=False, logged=False,
tag=tag, tag=tag,
tags=tags,
tenant=TEST_TENANT) tenant=TEST_TENANT)
self.assert_called_with_def(api_call, expected_entry_def) self.assert_called_with_def(api_call, expected_entry_def)
@ -1713,6 +1717,7 @@ class TestPolicyCommunicationMap(NsxPolicyLibTestCase):
seq_num = 1 seq_num = 1
ret_comm = {'rules': [{'sequence_number': seq_num}]} ret_comm = {'rules': [{'sequence_number': seq_num}]}
tag = 'abc1234' tag = 'abc1234'
tags = ['dummy']
with mock.patch.object(self.policy_api, with mock.patch.object(self.policy_api,
"create_or_update") as api_call,\ "create_or_update") as api_call,\
mock.patch.object(self.policy_api, mock.patch.object(self.policy_api,
@ -1724,7 +1729,7 @@ class TestPolicyCommunicationMap(NsxPolicyLibTestCase):
source_groups=[source_group], source_groups=[source_group],
dest_groups=[dest_group], dest_groups=[dest_group],
logged=False, logged=False,
tag=tag, tag=tag, tags=tags,
tenant=TEST_TENANT) tenant=TEST_TENANT)
expected_entry_def = self.entryDef( expected_entry_def = self.entryDef(
@ -1743,6 +1748,7 @@ class TestPolicyCommunicationMap(NsxPolicyLibTestCase):
scope=None, scope=None,
logged=False, logged=False,
tag=tag, tag=tag,
tags=tags,
tenant=TEST_TENANT) tenant=TEST_TENANT)
self.assert_called_with_def(api_call, expected_entry_def) self.assert_called_with_def(api_call, expected_entry_def)

View File

@ -3661,7 +3661,7 @@ class NsxPolicySecurityPolicyBaseApi(NsxPolicyResourceBase):
description=None, sequence_number=None, service_ids=None, description=None, sequence_number=None, service_ids=None,
action=constants.ACTION_ALLOW, action=constants.ACTION_ALLOW,
source_groups=None, dest_groups=None, source_groups=None, dest_groups=None,
scope=None, scope=None, tags=IGNORE,
ip_protocol=nsx_constants.IPV4_IPV6, ip_protocol=nsx_constants.IPV4_IPV6,
direction=nsx_constants.IN_OUT, direction=nsx_constants.IN_OUT,
logged=False, tag=None, logged=False, tag=None,
@ -3705,6 +3705,7 @@ class NsxPolicySecurityPolicyBaseApi(NsxPolicyResourceBase):
direction=direction, direction=direction,
logged=logged, logged=logged,
tag=tag, tag=tag,
tags=tags,
service_entries=service_entries, service_entries=service_entries,
tenant=tenant, tenant=tenant,
plain_groups=plain_groups) plain_groups=plain_groups)