Reload enforcement-point api

Change-Id: I842ea0d45f40c95674a0c199c346ec056197ff3e
This commit is contained in:
Adit Sarfaty 2019-08-19 11:22:46 +03:00
parent 243e93b081
commit 3547654c6f
2 changed files with 18 additions and 2 deletions

View File

@ -2176,6 +2176,16 @@ class TestPolicyEnforcementPoint(NsxPolicyLibTestCase):
TEST_TENANT, ep_id)
api_get.assert_called_once_with(path, silent=False)
def test_reload(self):
ef_id = '111'
with mock.patch.object(self.policy_api.client, "url_post") as api_post:
self.resourceApi.reload(ef_id, tenant=TEST_TENANT)
expected_def = core_defs.EnforcementPointDef(ep_id=ef_id,
tenant=TEST_TENANT)
api_post.assert_called_once_with(
expected_def.get_resource_path() + '?action=reload',
None, expected_results=None, headers=None)
class TestPolicyDeploymentMap(NsxPolicyLibTestCase):

View File

@ -91,9 +91,9 @@ class NsxPolicyResourceBase(object):
"""Create new or overwrite existing resource
Create would list keys and attributes, set defaults and
perform nesessary validations.
perform necessary validations.
If object with same IDs exists on backend, it will
be overriden.
be overridden.
"""
pass
@ -3345,6 +3345,12 @@ class NsxPolicyEnforcementPointApi(NsxPolicyResourceBase):
silent=silent,
realization_info=realization_info)
def reload(self, ep_id, tenant=constants.POLICY_INFRA_TENANT):
# Use post command to reload the enforcement point
ep_def = core_defs.EnforcementPointDef(ep_id=ep_id, tenant=tenant)
path = "%s?action=reload" % ep_def.get_resource_path()
self.policy_api.client.create(path)
class NsxPolicyTransportZoneApi(NsxPolicyResourceBase):