Add unique_id for segment creation

This property is used to specify LS ID when creating segment, this
property is only used in NSX Highline backup/restore case currently.

Change-Id: I5033579623cde5dcf857ffdfd1f2d18390e9ff81
This commit is contained in:
Ran Gu 2020-07-17 13:50:08 +08:00
parent da35c50d58
commit 6c921f1c93
3 changed files with 13 additions and 2 deletions

View File

@ -4041,7 +4041,8 @@ class TestPolicySegment(NsxPolicyLibTestCase):
def _test_create(self, tier1_id=None, tier0_id=None, mdproxy=None,
dhcp_server=None, admin_state=None,
ip_pool_id='external-ip-pool', ls_id=None):
ip_pool_id='external-ip-pool', ls_id=None,
unique_id=None):
name = 'test'
description = 'desc'
subnets = [core_defs.Subnet(gateway_address="2.2.2.0/24")]
@ -4065,6 +4066,8 @@ class TestPolicySegment(NsxPolicyLibTestCase):
if ls_id:
kwargs['ls_id'] = ls_id
if unique_id:
kwargs['unique_id'] = unique_id
with mock.patch.object(self.policy_api,
"create_or_update") as api_call:
@ -4119,6 +4122,9 @@ class TestPolicySegment(NsxPolicyLibTestCase):
def test_create_with_ls_id(self):
self._test_create(ls_id='lsid1')
def test_create_with_unique_id(self):
self._test_create(unique_id='lsid1')
def test_delete(self):
segment_id = '111'
with mock.patch.object(self.policy_api, "delete") as api_call:

View File

@ -960,7 +960,8 @@ class SegmentDef(BaseSegmentDef):
def version_dependant_attr_map(self):
return {'metadata_proxy_id': nsx_constants.NSX_VERSION_3_0_0,
'dhcp_server_config_id': nsx_constants.NSX_VERSION_3_0_0,
'admin_state': nsx_constants.NSX_VERSION_3_0_0}
'admin_state': nsx_constants.NSX_VERSION_3_0_0,
'unique_id': nsx_constants.NSX_VERSION_3_1_0}
def get_obj_dict(self):
body = super(SegmentDef, self).get_obj_dict()
@ -1032,6 +1033,8 @@ class SegmentDef(BaseSegmentDef):
self._set_attr_if_specified(body, 'admin_state',
value=admin_state)
self._set_attr_if_supported(body, 'unique_id')
return body

View File

@ -1941,6 +1941,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase):
dhcp_server_config_id=IGNORE,
admin_state=IGNORE,
ls_id=IGNORE,
unique_id=IGNORE,
tags=IGNORE,
tenant=constants.POLICY_INFRA_TENANT):
@ -1965,6 +1966,7 @@ class NsxPolicySegmentApi(NsxPolicyResourceBase):
dhcp_server_config_id=dhcp_server_config_id,
admin_state=admin_state,
ls_id=ls_id,
unique_id=unique_id,
tags=tags,
tenant=tenant)
self._create_or_store(segment_def)