From 3547654c6f2814cf0d1350a57c2a548df127dde0 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Mon, 19 Aug 2019 11:22:46 +0300 Subject: [PATCH] Reload enforcement-point api Change-Id: I842ea0d45f40c95674a0c199c346ec056197ff3e --- vmware_nsxlib/tests/unit/v3/policy/test_resources.py | 10 ++++++++++ vmware_nsxlib/v3/policy/core_resources.py | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py index e3391867..1fbf03d7 100644 --- a/vmware_nsxlib/tests/unit/v3/policy/test_resources.py +++ b/vmware_nsxlib/tests/unit/v3/policy/test_resources.py @@ -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): diff --git a/vmware_nsxlib/v3/policy/core_resources.py b/vmware_nsxlib/v3/policy/core_resources.py index c0d58328..771b4efa 100644 --- a/vmware_nsxlib/v3/policy/core_resources.py +++ b/vmware_nsxlib/v3/policy/core_resources.py @@ -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):