Add function to get security policy rule
Add function to get a specific security policy rule Change-Id: I07da7baba990206087cf9a67e3baea92d67a4884
This commit is contained in:
@@ -1420,6 +1420,22 @@ class TestPolicyCommunicationMap(NsxPolicyLibTestCase):
|
||||
self.assert_called_with_def(api_call, expected_def)
|
||||
self.assertEqual(map_id, result['id'])
|
||||
|
||||
def test_get_entry(self):
|
||||
domain_id = '111'
|
||||
map_id = '222'
|
||||
entry_id = '333'
|
||||
with mock.patch.object(self.policy_api, "get",
|
||||
return_value={'id': entry_id}) as api_call:
|
||||
result = self.resourceApi.get_entry(domain_id, map_id,
|
||||
entry_id, tenant=TEST_TENANT)
|
||||
expected_def = self.entryDef(
|
||||
domain_id=domain_id,
|
||||
map_id=map_id,
|
||||
entry_id=entry_id,
|
||||
tenant=TEST_TENANT)
|
||||
self.assert_called_with_def(api_call, expected_def)
|
||||
self.assertEqual(entry_id, result['id'])
|
||||
|
||||
def test_get_by_name(self):
|
||||
domain_id = '111'
|
||||
name = 'cm1'
|
||||
|
||||
@@ -2572,6 +2572,15 @@ class NsxPolicySecurityPolicyBaseApi(NsxPolicyResourceBase):
|
||||
tenant=tenant)
|
||||
return self.policy_api.get(map_def, silent=silent)
|
||||
|
||||
def get_entry(self, domain_id, map_id, entry_id,
|
||||
tenant=constants.POLICY_INFRA_TENANT, silent=False):
|
||||
entry_def = self.entry_def(
|
||||
domain_id=domain_id,
|
||||
map_id=map_id,
|
||||
entry_id=entry_id,
|
||||
tenant=tenant)
|
||||
return self.policy_api.get(entry_def, silent=silent)
|
||||
|
||||
def get_by_name(self, domain_id, name,
|
||||
tenant=constants.POLICY_INFRA_TENANT):
|
||||
"""Return first communication map entry matched by name"""
|
||||
|
||||
Reference in New Issue
Block a user