Merge "Add parameter for segment port delete api"
This commit is contained in:
commit
9086057bd6
@ -5418,6 +5418,22 @@ class TestPolicySegmentPort(NsxPolicyLibTestCase):
|
|||||||
super(TestPolicySegmentPort, self).setUp()
|
super(TestPolicySegmentPort, self).setUp()
|
||||||
self.resourceApi = self.policy_lib.segment_port
|
self.resourceApi = self.policy_lib.segment_port
|
||||||
|
|
||||||
|
def testSegmentPortDef(self):
|
||||||
|
port_def = core_defs.SegmentPortDef(
|
||||||
|
segment_id="mock_seg", port_id="mock_port",
|
||||||
|
tenant=constants.POLICY_INFRA_TENANT)
|
||||||
|
path = port_def.get_resource_path()
|
||||||
|
self.assertEqual(path,
|
||||||
|
"infra/segments/mock_seg/ports/mock_port")
|
||||||
|
port_def = core_defs.SegmentPortDef(
|
||||||
|
segment_id="mock_seg", port_id="mock_port",
|
||||||
|
tenant=constants.POLICY_INFRA_TENANT,
|
||||||
|
skip_host_detach=True)
|
||||||
|
path = port_def.get_resource_path()
|
||||||
|
self.assertEqual(path,
|
||||||
|
"infra/segments/mock_seg/ports/mock_port?"
|
||||||
|
"skip_host_detach=true")
|
||||||
|
|
||||||
def test_feature_supported(self):
|
def test_feature_supported(self):
|
||||||
with mock.patch.object(self.policy_lib, "get_version",
|
with mock.patch.object(self.policy_lib, "get_version",
|
||||||
return_value='2.5.0'):
|
return_value='2.5.0'):
|
||||||
@ -5708,6 +5724,17 @@ class TestPolicySegmentPort(NsxPolicyLibTestCase):
|
|||||||
"%s/segments/%s/ports/%s" % (TEST_TENANT, segment_id, port_id),
|
"%s/segments/%s/ports/%s" % (TEST_TENANT, segment_id, port_id),
|
||||||
{'attachment': None, 'tags': tags})
|
{'attachment': None, 'tags': tags})
|
||||||
|
|
||||||
|
def test_delete_skip_host_detach(self):
|
||||||
|
segment_id = "segment"
|
||||||
|
port_id = "port"
|
||||||
|
with mock.patch.object(self.policy_api.client,
|
||||||
|
"delete", return_value={}) as api_delete:
|
||||||
|
self.resourceApi.delete_skip_host_detach(segment_id=segment_id,
|
||||||
|
port_id=port_id)
|
||||||
|
api_delete.assert_called_once_with(
|
||||||
|
"%s/segments/%s/ports/%s?skip_host_detach=true" % (
|
||||||
|
"infra", segment_id, port_id), headers=None)
|
||||||
|
|
||||||
def test_detach_with_vif(self):
|
def test_detach_with_vif(self):
|
||||||
segment_id = "segment"
|
segment_id = "segment"
|
||||||
port_id = "port"
|
port_id = "port"
|
||||||
|
@ -1299,6 +1299,12 @@ class SegmentPortDef(ResourceDef):
|
|||||||
def path_ids(self):
|
def path_ids(self):
|
||||||
return ('tenant', 'segment_id', 'port_id')
|
return ('tenant', 'segment_id', 'port_id')
|
||||||
|
|
||||||
|
def get_resource_path(self):
|
||||||
|
if self.has_attr("skip_host_detach"):
|
||||||
|
base_path = super().get_resource_path()
|
||||||
|
return base_path + "?skip_host_detach=true"
|
||||||
|
return super().get_resource_path()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resource_type():
|
def resource_type():
|
||||||
return 'SegmentPort'
|
return 'SegmentPort'
|
||||||
|
@ -2594,6 +2594,13 @@ class NsxPolicySegmentPortApi(NsxPolicyResourceBase):
|
|||||||
tenant=tenant)
|
tenant=tenant)
|
||||||
self._delete_with_retry(port_def)
|
self._delete_with_retry(port_def)
|
||||||
|
|
||||||
|
def delete_skip_host_detach(self, segment_id, port_id):
|
||||||
|
port_def = self.entry_def(segment_id=segment_id,
|
||||||
|
port_id=port_id,
|
||||||
|
tenant=constants.POLICY_INFRA_TENANT,
|
||||||
|
skip_host_detach=True)
|
||||||
|
self._delete_with_retry(port_def)
|
||||||
|
|
||||||
def get(self, segment_id, port_id,
|
def get(self, segment_id, port_id,
|
||||||
tenant=constants.POLICY_INFRA_TENANT,
|
tenant=constants.POLICY_INFRA_TENANT,
|
||||||
silent=False):
|
silent=False):
|
||||||
|
Loading…
Reference in New Issue
Block a user