Add api to remove segment tier1 connectivity
Change-Id: I8550e7797b7e6baa50d1737d32ad4c03041e3cd5
(cherry picked from commit 12f0edff2f
)
This commit is contained in:
parent
671280b8a8
commit
067bb9ee40
|
@ -3720,6 +3720,18 @@ class TestPolicySegment(NsxPolicyLibTestCase):
|
||||||
'%s/segments/%s' % (TEST_TENANT, segment_id),
|
'%s/segments/%s' % (TEST_TENANT, segment_id),
|
||||||
{'id': segment_id, 'connectivity_path': None, 'subnets': None})
|
{'id': segment_id, 'connectivity_path': None, 'subnets': None})
|
||||||
|
|
||||||
|
def test_remove_connectivity_path(self):
|
||||||
|
segment_id = '111'
|
||||||
|
with mock.patch.object(self.policy_api, "get",
|
||||||
|
return_value={'id': segment_id}) as api_get,\
|
||||||
|
mock.patch.object(self.policy_api.client, "update") as api_put:
|
||||||
|
self.resourceApi.remove_connectivity_path(
|
||||||
|
segment_id, tenant=TEST_TENANT)
|
||||||
|
api_get.assert_called_once()
|
||||||
|
api_put.assert_called_once_with(
|
||||||
|
'%s/segments/%s' % (TEST_TENANT, segment_id),
|
||||||
|
{'id': segment_id, 'connectivity_path': None})
|
||||||
|
|
||||||
def test_build_subnet(self):
|
def test_build_subnet(self):
|
||||||
gateway_address = "10.0.0.1/24"
|
gateway_address = "10.0.0.1/24"
|
||||||
dhcp_ranges = None
|
dhcp_ranges = None
|
||||||
|
|
|
@ -1917,6 +1917,21 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase):
|
||||||
|
|
||||||
self.policy_api.client.update(path, segment)
|
self.policy_api.client.update(path, segment)
|
||||||
|
|
||||||
|
def remove_connectivity_path(self, segment_id,
|
||||||
|
tenant=constants.POLICY_INFRA_TENANT):
|
||||||
|
"""Disconnect a segment from a router.
|
||||||
|
|
||||||
|
PATCH does not support this action so PUT is used for this
|
||||||
|
"""
|
||||||
|
# Get the current segment and update it
|
||||||
|
segment = self.get(segment_id)
|
||||||
|
segment['connectivity_path'] = None
|
||||||
|
|
||||||
|
segment_def = self.entry_def(segment_id=segment_id, tenant=tenant)
|
||||||
|
path = segment_def.get_resource_path()
|
||||||
|
|
||||||
|
self.policy_api.client.update(path, segment)
|
||||||
|
|
||||||
def get_realized_state(self, segment_id, entity_type=None,
|
def get_realized_state(self, segment_id, entity_type=None,
|
||||||
tenant=constants.POLICY_INFRA_TENANT,
|
tenant=constants.POLICY_INFRA_TENANT,
|
||||||
realization_info=None):
|
realization_info=None):
|
||||||
|
|
Loading…
Reference in New Issue