Browse Source

Add api to remove segment tier1 connectivity

Change-Id: I8550e7797b7e6baa50d1737d32ad4c03041e3cd5
(cherry picked from commit 12f0edff2f)
changes/80/725480/1
asarfaty 2 months ago
committed by Adit Sarfaty
parent
commit
067bb9ee40
2 changed files with 27 additions and 0 deletions
  1. +12
    -0
      vmware_nsxlib/tests/unit/v3/policy/test_resources.py
  2. +15
    -0
      vmware_nsxlib/v3/policy/core_resources.py

+ 12
- 0
vmware_nsxlib/tests/unit/v3/policy/test_resources.py View File

@@ -3720,6 +3720,18 @@ class TestPolicySegment(NsxPolicyLibTestCase):
'%s/segments/%s' % (TEST_TENANT, segment_id),
{'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):
gateway_address = "10.0.0.1/24"
dhcp_ranges = None


+ 15
- 0
vmware_nsxlib/v3/policy/core_resources.py View File

@@ -1917,6 +1917,21 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase):

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,
tenant=constants.POLICY_INFRA_TENANT,
realization_info=None):


Loading…
Cancel
Save