Add transport_node_uuid in VifAttachmentContext
For bare metal container support, add transport_node_uuid in LSP creation API. Change-Id: I79221be68d657965e291195562e40dd787c8b864
This commit is contained in:
parent
e722b6fa0f
commit
c1a775e492
@ -427,6 +427,56 @@ class LogicalPortTestCase(BaseTestResource):
|
||||
|
||||
self.assertEqual(fake_port, result)
|
||||
|
||||
def test_create_logical_port_with_tn_uuid(self):
|
||||
"""Test creating port with transport_node_uuid."""
|
||||
fake_port = copy.deepcopy(test_constants.FAKE_CONTAINER_PORT)
|
||||
fake_port['parent_vif_id'] = None
|
||||
fake_port_ctx = fake_port['attachment']['context']
|
||||
fake_port_ctx['vif_type'] = 'INDEPENDENT'
|
||||
fake_port_ctx['transport_node_uuid'] = test_constants.FAKE_TN_UUID
|
||||
|
||||
profile_dicts = self._get_profile_dicts(fake_port)
|
||||
pkt_classifiers, binding_repr = self._get_pktcls_bindings()
|
||||
fake_port['address_bindings'] = binding_repr
|
||||
|
||||
mocked_resource = self.get_mocked_resource()
|
||||
switch_profile = resources.SwitchingProfile
|
||||
|
||||
mocked_resource.create(
|
||||
fake_port['logical_switch_id'],
|
||||
fake_port['attachment']['id'],
|
||||
traffic_tag=fake_port_ctx['vlan_tag'],
|
||||
address_bindings=pkt_classifiers,
|
||||
switch_profile_ids=switch_profile.build_switch_profile_ids(
|
||||
mock.Mock(), *profile_dicts),
|
||||
vif_type=fake_port_ctx['vif_type'], app_id=fake_port_ctx['app_id'],
|
||||
allocate_addresses=fake_port_ctx['allocate_addresses'],
|
||||
tn_uuid=fake_port_ctx['transport_node_uuid'])
|
||||
|
||||
resp_body = {
|
||||
'logical_switch_id': fake_port['logical_switch_id'],
|
||||
'switching_profile_ids': fake_port['switching_profile_ids'],
|
||||
'attachment': {
|
||||
'attachment_type': 'VIF',
|
||||
'id': fake_port['attachment']['id'],
|
||||
'context': {
|
||||
'resource_type': 'VifAttachmentContext',
|
||||
'allocate_addresses': 'Both',
|
||||
'app_id': fake_port_ctx['app_id'],
|
||||
'vif_type': 'INDEPENDENT',
|
||||
'transport_node_uuid': test_constants.FAKE_TN_UUID,
|
||||
}
|
||||
},
|
||||
'admin_state': 'UP',
|
||||
'address_bindings': fake_port['address_bindings']
|
||||
}
|
||||
|
||||
test_client.assert_json_call(
|
||||
'post', mocked_resource,
|
||||
'https://1.2.3.4/api/v1/logical-ports',
|
||||
data=jsonutils.dumps(resp_body, sort_keys=True),
|
||||
headers=self.default_headers())
|
||||
|
||||
def test_delete_resource(self):
|
||||
"""Test deleting port."""
|
||||
super(LogicalPortTestCase, self).test_delete_resource(
|
||||
|
@ -131,7 +131,7 @@ class LogicalPort(utils.NsxLibApiBase):
|
||||
|
||||
def _prepare_attachment(self, attachment_type, vif_uuid,
|
||||
allocate_addresses, vif_type,
|
||||
parent_vif_id, traffic_tag, app_id):
|
||||
parent_vif_id, traffic_tag, app_id, tn_uuid):
|
||||
if attachment_type and vif_uuid:
|
||||
attachment = {'attachment_type': attachment_type,
|
||||
'id': vif_uuid}
|
||||
@ -143,6 +143,9 @@ class LogicalPort(utils.NsxLibApiBase):
|
||||
context['parent_vif_id'] = parent_vif_id
|
||||
context['traffic_tag'] = traffic_tag
|
||||
context['app_id'] = app_id
|
||||
elif tn_uuid:
|
||||
context['transport_node_uuid'] = tn_uuid
|
||||
context['app_id'] = app_id
|
||||
attachment['context'] = context
|
||||
return attachment
|
||||
elif attachment_type is None and vif_uuid is None:
|
||||
@ -156,7 +159,7 @@ class LogicalPort(utils.NsxLibApiBase):
|
||||
parent_vif_id=None, traffic_tag=None,
|
||||
switch_profile_ids=None, vif_type=None, app_id=None,
|
||||
allocate_addresses=nsx_constants.ALLOCATE_ADDRESS_NONE,
|
||||
description=None):
|
||||
description=None, tn_uuid=None):
|
||||
tags = tags or []
|
||||
body = {'logical_switch_id': lswitch_id}
|
||||
# NOTE(arosen): If parent_vif_id is specified we need to use
|
||||
@ -164,7 +167,7 @@ class LogicalPort(utils.NsxLibApiBase):
|
||||
attachment = self._prepare_attachment(attachment_type, vif_uuid,
|
||||
allocate_addresses, vif_type,
|
||||
parent_vif_id, traffic_tag,
|
||||
app_id)
|
||||
app_id, tn_uuid)
|
||||
body.update(self._build_body_attrs(
|
||||
display_name=name,
|
||||
admin_state=admin_state, tags=tags,
|
||||
@ -185,11 +188,11 @@ class LogicalPort(utils.NsxLibApiBase):
|
||||
parent_vif_id=None, traffic_tag=None,
|
||||
vif_type=None, app_id=None,
|
||||
allocate_addresses=nsx_constants.ALLOCATE_ADDRESS_NONE,
|
||||
description=None):
|
||||
description=None, tn_uuid=None):
|
||||
attachment = self._prepare_attachment(attachment_type, vif_uuid,
|
||||
allocate_addresses, vif_type,
|
||||
parent_vif_id, traffic_tag,
|
||||
app_id)
|
||||
app_id, tn_uuid)
|
||||
lport = {}
|
||||
if tags_update is not None:
|
||||
lport['tags_update'] = tags_update
|
||||
|
Loading…
x
Reference in New Issue
Block a user