Use PUT instead of PATCH for segment port detach
Change-Id: Ib411f1898778362030c91ddc707bdd8dc1e07760
This commit is contained in:
parent
cddf191084
commit
6c71cfb145
@ -4567,21 +4567,18 @@ class TestPolicySegmentPort(NsxPolicyLibTestCase):
|
|||||||
segment_id = "segment"
|
segment_id = "segment"
|
||||||
port_id = "port"
|
port_id = "port"
|
||||||
tags = [{'scope': 'a', 'tag': 'b'}]
|
tags = [{'scope': 'a', 'tag': 'b'}]
|
||||||
with mock.patch.object(self.policy_api,
|
with mock.patch.object(self.policy_api.client,
|
||||||
"create_or_update") as api_call:
|
"get", return_value={}) as api_get,\
|
||||||
|
mock.patch.object(self.policy_api.client,
|
||||||
|
"update") as api_put:
|
||||||
self.resourceApi.detach(
|
self.resourceApi.detach(
|
||||||
segment_id, port_id, tags=tags,
|
segment_id, port_id, tags=tags,
|
||||||
tenant=TEST_TENANT)
|
tenant=TEST_TENANT)
|
||||||
|
|
||||||
expected_def = core_defs.SegmentPortDef(
|
api_get.assert_called_once()
|
||||||
segment_id=segment_id,
|
api_put.assert_called_once_with(
|
||||||
port_id=port_id,
|
"%s/segments/%s/ports/%s" % (TEST_TENANT, segment_id, port_id),
|
||||||
attachment_type=None,
|
{'attachment': None})
|
||||||
vif_id=None,
|
|
||||||
tags=tags,
|
|
||||||
tenant=TEST_TENANT)
|
|
||||||
|
|
||||||
self.assert_called_with_def(api_call, expected_def)
|
|
||||||
|
|
||||||
|
|
||||||
class TestPolicySegmentProfileBase(NsxPolicyLibTestCase):
|
class TestPolicySegmentProfileBase(NsxPolicyLibTestCase):
|
||||||
|
@ -2183,14 +2183,22 @@ class NsxPolicySegmentPortApi(NsxPolicyResourceBase):
|
|||||||
|
|
||||||
def detach(self, segment_id, port_id, tags=IGNORE,
|
def detach(self, segment_id, port_id, tags=IGNORE,
|
||||||
tenant=constants.POLICY_INFRA_TENANT):
|
tenant=constants.POLICY_INFRA_TENANT):
|
||||||
|
# Due to platform limitation, PUT should be used here and not PATCH
|
||||||
|
port_def = self.entry_def(
|
||||||
|
segment_id=segment_id,
|
||||||
|
port_id=port_id,
|
||||||
|
tenant=tenant)
|
||||||
|
path = port_def.get_resource_path()
|
||||||
|
|
||||||
port_def = self.entry_def(segment_id=segment_id,
|
@utils.retry_upon_exception(
|
||||||
port_id=port_id,
|
exceptions.StaleRevision,
|
||||||
vif_id=None,
|
max_attempts=self.policy_api.client.max_attempts)
|
||||||
attachment_type=None,
|
def _detach():
|
||||||
tags=tags,
|
port = self.policy_api.get(port_def)
|
||||||
tenant=tenant)
|
port['attachment'] = None
|
||||||
self.policy_api.create_or_update(port_def)
|
self.policy_api.client.update(path, port)
|
||||||
|
|
||||||
|
_detach()
|
||||||
|
|
||||||
def attach(self, segment_id, port_id,
|
def attach(self, segment_id, port_id,
|
||||||
attachment_type,
|
attachment_type,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user