Updating segment port with empty attachment type

From NSX 3.0.0, the attachment type PARENT will be deprecated,
if attachment type is empty, that has the same meaning as PARENT,
but other fields in attachment should be allowed to apply under
such scenario.

Change-Id: I17bb17c4986afdbc95f534a54aa98d855bb3f645
(cherry picked from commit 27d4662f90)
This commit is contained in:
sean 2019-11-05 19:16:08 -08:00 committed by Adit Sarfaty
parent 81b37943af
commit 07211d7173
1 changed files with 7 additions and 3 deletions

View File

@ -1046,9 +1046,11 @@ class SegmentPortDef(ResourceDef):
if address_bindings:
body['address_bindings'] = [binding.get_obj_dict()
for binding in address_bindings]
if self.has_attr('attachment_type') or self.has_attr('vif_id'):
if (self.has_attr('attachment_type') or self.has_attr('vif_id') or
self.has_attr('hyperbus_mode')):
if (not self.get_attr('attachment_type') and
not self.get_attr('vif_id')):
not self.get_attr('vif_id') and
not self.get_attr('hyperbus_mode')):
# detach operation
body['attachment'] = None
else:
@ -1057,13 +1059,15 @@ class SegmentPortDef(ResourceDef):
attachment['type'] = self.get_attr('attachment_type')
if self.get_attr('vif_id'):
attachment['id'] = self.get_attr('vif_id')
if self.get_attr('hyperbus_mode'):
self._set_attr_if_supported(attachment, 'hyperbus_mode')
self._set_attrs_if_specified(attachment,
['context_id',
'app_id',
'traffic_tag',
'allocate_addresses'])
self._set_attr_if_supported(body, 'hyperbus_mode')
body['attachment'] = attachment
if (self.has_attr('admin_state') and