Update version check to use POST API when restore vif
According to NSX side fix merged in NSX versions 3.2.3 (and later impactor releases if any) and 4.1.*, update the version check. Change-Id: I8e5b29da1d10b076bef159d45ba436d135718ca8
This commit is contained in:
parent
acb8f2d53f
commit
3a627ed498
@ -5452,81 +5452,85 @@ class TestPolicySegmentPort(NsxPolicyLibTestCase):
|
|||||||
admin_state = True
|
admin_state = True
|
||||||
init_state = 'RESTORE_VIF'
|
init_state = 'RESTORE_VIF'
|
||||||
|
|
||||||
with mock.patch.object(
|
for version in [nsx_constants.NSX_VERSION_3_2_3,
|
||||||
self.policy_api.client, "url_post") as api_post, \
|
nsx_constants.NSX_VERSION_4_1_0]:
|
||||||
mock.patch.object(self.resourceApi, 'version',
|
with mock.patch.object(
|
||||||
nsx_constants.NSX_VERSION_4_1_0):
|
self.policy_api.client, "url_post") as api_post, \
|
||||||
result = self.resourceApi.create_or_overwrite(
|
mock.patch.object(self.resourceApi, 'version', version):
|
||||||
name, segment_id, port_id=port_id, description=description,
|
result = self.resourceApi.create_or_overwrite(
|
||||||
address_bindings=address_bindings,
|
name, segment_id, port_id=port_id, description=description,
|
||||||
attachment_type=attachment_type, vif_id=vif_id, app_id=app_id,
|
address_bindings=address_bindings,
|
||||||
context_id=context_id, traffic_tag=traffic_tag,
|
attachment_type=attachment_type,
|
||||||
allocate_addresses=allocate_addresses,
|
vif_id=vif_id, app_id=app_id,
|
||||||
hyperbus_mode=hyperbus_mode, admin_state=admin_state,
|
context_id=context_id, traffic_tag=traffic_tag,
|
||||||
tags=tags,
|
allocate_addresses=allocate_addresses,
|
||||||
tenant=TEST_TENANT,
|
hyperbus_mode=hyperbus_mode, admin_state=admin_state,
|
||||||
init_state=init_state)
|
tags=tags,
|
||||||
|
tenant=TEST_TENANT,
|
||||||
|
init_state=init_state)
|
||||||
|
|
||||||
expected_def = core_defs.SegmentPortDef(
|
expected_def = core_defs.SegmentPortDef(
|
||||||
nsx_version=nsx_constants.NSX_VERSION_4_1_0,
|
nsx_version=version,
|
||||||
segment_id=segment_id,
|
segment_id=segment_id,
|
||||||
port_id=port_id,
|
port_id=port_id,
|
||||||
name=name,
|
name=name,
|
||||||
description=description,
|
description=description,
|
||||||
address_bindings=address_bindings,
|
address_bindings=address_bindings,
|
||||||
attachment_type=attachment_type,
|
attachment_type=attachment_type,
|
||||||
vif_id=vif_id,
|
vif_id=vif_id,
|
||||||
app_id=app_id,
|
app_id=app_id,
|
||||||
context_id=context_id,
|
context_id=context_id,
|
||||||
traffic_tag=traffic_tag,
|
traffic_tag=traffic_tag,
|
||||||
allocate_addresses=allocate_addresses,
|
allocate_addresses=allocate_addresses,
|
||||||
admin_state=admin_state,
|
admin_state=admin_state,
|
||||||
tags=tags,
|
tags=tags,
|
||||||
tenant=TEST_TENANT,
|
tenant=TEST_TENANT,
|
||||||
hyperbus_mode=hyperbus_mode,
|
hyperbus_mode=hyperbus_mode,
|
||||||
init_state=init_state)
|
init_state=init_state)
|
||||||
|
|
||||||
api_post.assert_called_once_with(
|
api_post.assert_called_once_with(
|
||||||
expected_def.get_resource_path(),
|
expected_def.get_resource_path(),
|
||||||
expected_def.get_obj_dict(), headers=None,
|
expected_def.get_obj_dict(), headers=None,
|
||||||
expected_results=None, retry_confirm=False)
|
expected_results=None, retry_confirm=False)
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
with mock.patch.object(
|
for version in [nsx_constants.NSX_VERSION_3_2_1,
|
||||||
self.policy_api, "create_or_update") as api_call, \
|
nsx_constants.NSX_VERSION_4_0_0]:
|
||||||
mock.patch.object(self.resourceApi, 'version',
|
with mock.patch.object(
|
||||||
nsxlib_testcase.LATEST_VERSION):
|
self.policy_api, "create_or_update") as api_call, \
|
||||||
result = self.resourceApi.create_or_overwrite(
|
mock.patch.object(self.resourceApi, 'version', version):
|
||||||
name, segment_id, port_id=port_id, description=description,
|
result = self.resourceApi.create_or_overwrite(
|
||||||
address_bindings=address_bindings,
|
name, segment_id, port_id=port_id, description=description,
|
||||||
attachment_type=attachment_type, vif_id=vif_id, app_id=app_id,
|
address_bindings=address_bindings,
|
||||||
context_id=context_id, traffic_tag=traffic_tag,
|
attachment_type=attachment_type,
|
||||||
allocate_addresses=allocate_addresses,
|
vif_id=vif_id, app_id=app_id,
|
||||||
hyperbus_mode=hyperbus_mode, admin_state=admin_state,
|
context_id=context_id, traffic_tag=traffic_tag,
|
||||||
tags=tags,
|
allocate_addresses=allocate_addresses,
|
||||||
tenant=TEST_TENANT,
|
hyperbus_mode=hyperbus_mode, admin_state=admin_state,
|
||||||
init_state=init_state)
|
tags=tags,
|
||||||
|
tenant=TEST_TENANT,
|
||||||
|
init_state=init_state)
|
||||||
|
|
||||||
expected_def = core_defs.SegmentPortDef(
|
expected_def = core_defs.SegmentPortDef(
|
||||||
nsx_version=nsxlib_testcase.LATEST_VERSION,
|
nsx_version=version,
|
||||||
segment_id=segment_id,
|
segment_id=segment_id,
|
||||||
port_id=port_id,
|
port_id=port_id,
|
||||||
name=name,
|
name=name,
|
||||||
description=description,
|
description=description,
|
||||||
address_bindings=address_bindings,
|
address_bindings=address_bindings,
|
||||||
attachment_type=attachment_type,
|
attachment_type=attachment_type,
|
||||||
vif_id=vif_id,
|
vif_id=vif_id,
|
||||||
app_id=app_id,
|
app_id=app_id,
|
||||||
context_id=context_id,
|
context_id=context_id,
|
||||||
traffic_tag=traffic_tag,
|
traffic_tag=traffic_tag,
|
||||||
allocate_addresses=allocate_addresses,
|
allocate_addresses=allocate_addresses,
|
||||||
admin_state=admin_state,
|
admin_state=admin_state,
|
||||||
tags=tags,
|
tags=tags,
|
||||||
tenant=TEST_TENANT,
|
tenant=TEST_TENANT,
|
||||||
hyperbus_mode=hyperbus_mode,
|
hyperbus_mode=hyperbus_mode,
|
||||||
init_state=init_state)
|
init_state=init_state)
|
||||||
self.assert_called_with_def(api_call, expected_def)
|
self.assert_called_with_def(api_call, expected_def)
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
def test_create_with_unsupported_attribute(self):
|
def test_create_with_unsupported_attribute(self):
|
||||||
name = 'test'
|
name = 'test'
|
||||||
|
@ -164,6 +164,7 @@ NSX_VERSION_3_0_2 = '3.0.2'
|
|||||||
NSX_VERSION_3_1_0 = '3.1.0'
|
NSX_VERSION_3_1_0 = '3.1.0'
|
||||||
NSX_VERSION_3_2_0 = '3.2.0'
|
NSX_VERSION_3_2_0 = '3.2.0'
|
||||||
NSX_VERSION_3_2_1 = '3.2.1'
|
NSX_VERSION_3_2_1 = '3.2.1'
|
||||||
|
NSX_VERSION_3_2_3 = '3.2.3'
|
||||||
NSX_VERSION_4_0_0 = '4.0.0'
|
NSX_VERSION_4_0_0 = '4.0.0'
|
||||||
NSX_VERSION_4_1_0 = '4.1.0'
|
NSX_VERSION_4_1_0 = '4.1.0'
|
||||||
NSX_VERSION_4_1_1 = '4.1.1'
|
NSX_VERSION_4_1_1 = '4.1.1'
|
||||||
|
@ -2548,6 +2548,10 @@ class NsxPolicySegmentPortApi(NsxPolicyResourceBase):
|
|||||||
tenant=tenant)
|
tenant=tenant)
|
||||||
if init_state == nsx_constants.INIT_STATE_RESTORE_VIF:
|
if init_state == nsx_constants.INIT_STATE_RESTORE_VIF:
|
||||||
if (version.LooseVersion(self.version) >=
|
if (version.LooseVersion(self.version) >=
|
||||||
|
version.LooseVersion(nsx_constants.NSX_VERSION_3_2_3) and
|
||||||
|
version.LooseVersion(self.version) <
|
||||||
|
version.LooseVersion(nsx_constants.NSX_VERSION_4_0_0) or
|
||||||
|
version.LooseVersion(self.version) >=
|
||||||
version.LooseVersion(nsx_constants.NSX_VERSION_4_1_0)):
|
version.LooseVersion(nsx_constants.NSX_VERSION_4_1_0)):
|
||||||
path = port_def.get_resource_path()
|
path = port_def.get_resource_path()
|
||||||
body = port_def.get_obj_dict()
|
body = port_def.get_obj_dict()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user