Browse Source

Allow tags to be specified while creating Policy Rules

Issue: #2747149
Change-Id: Iaee21403ebe3bca5d537fb4f452146e1e38f4ccb
changes/07/785207/1
Gautam Verma 4 months ago
committed by Salvatore Orlando
parent
commit
6d8b00f107
  1. 12
      vmware_nsxlib/tests/unit/v3/policy/test_resources.py
  2. 3
      vmware_nsxlib/v3/policy/core_resources.py

12
vmware_nsxlib/tests/unit/v3/policy/test_resources.py

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

3
vmware_nsxlib/v3/policy/core_resources.py

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

Loading…
Cancel
Save