NSX|V3: Add tags for DownLink logical router port

Add the following tags for a DownLink router port:
- os-api-version
- os-project-id
- os-project-name
- os-neutron-rport-id
- os-subnet-id

Change-Id: I3b4cf40d71a4923a5541e7c0156552033ff397fe
This commit is contained in:
Shih-Hao Li 2015-12-23 14:56:34 -08:00
parent 037a8963d9
commit a047d0ad79
4 changed files with 15 additions and 4 deletions

View File

@ -317,13 +317,15 @@ class LogicalRouterPort(AbstractRESTResource):
def create(self, logical_router_id,
display_name,
tags,
resource_type,
logical_port_id,
address_groups,
edge_cluster_member_index=None):
body = {'display_name': display_name,
'resource_type': resource_type,
'logical_router_id': logical_router_id}
'logical_router_id': logical_router_id,
'tags': tags or []}
if address_groups:
body['subnets'] = address_groups
if resource_type in [nsx_constants.LROUTERPORT_UPLINK,

View File

@ -79,14 +79,14 @@ class RouterLib(object):
def add_router_link_port(self, tier1_uuid, tier0_uuid, edge_members):
# Create Tier0 logical router link port
tier0_link_port = self._router_port_client.create(
tier0_uuid, display_name=TIER0_ROUTER_LINK_PORT_NAME,
tier0_uuid, display_name=TIER0_ROUTER_LINK_PORT_NAME, tags=None,
resource_type=nsx_constants.LROUTERPORT_LINKONTIER0,
logical_port_id=None,
address_groups=None)
linked_logical_port_id = tier0_link_port['id']
# Create Tier1 logical router link port
self._router_port_client.create(
tier1_uuid, display_name=TIER1_ROUTER_LINK_PORT_NAME,
tier1_uuid, display_name=TIER1_ROUTER_LINK_PORT_NAME, tags=None,
resource_type=nsx_constants.LROUTERPORT_LINKONTIER1,
logical_port_id=linked_logical_port_id,
address_groups=None)
@ -128,6 +128,7 @@ class RouterLib(object):
def create_logical_router_intf_port_by_ls_id(self, logical_router_id,
display_name,
tags,
ls_id,
logical_switch_port_id,
address_groups):
@ -137,6 +138,7 @@ class RouterLib(object):
return self._router_port_client.create(
logical_router_id,
display_name,
tags,
nsx_constants.LROUTERPORT_DOWNLINK,
logical_switch_port_id,
address_groups)

View File

@ -1201,9 +1201,14 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin,
context, router_id, network_id)
display_name = utils.get_name_and_uuid(
subnet['name'], subnet['id'])
tags = utils.build_v3_tags_payload(
port, resource_type='os-neutron-rport-id',
project_name=context.tenant_name)
tags.append({'scope': 'os-subnet-id', 'tag': subnet['id']})
self._routerlib.create_logical_router_intf_port_by_ls_id(
logical_router_id=nsx_router_id,
display_name=display_name,
tags=tags,
ls_id=nsx_net_id,
logical_switch_port_id=nsx_port_id,
address_groups=address_groups)

View File

@ -329,13 +329,15 @@ class LogicalRouterPortTestCase(nsxlib_testcase.NsxClientTestCase):
lrport.create(fake_router_port['logical_router_id'],
fake_router_port['display_name'],
None,
fake_router_port['resource_type'],
None, None, None)
data = {
'display_name': fake_router_port['display_name'],
'logical_router_id': fake_router_port['logical_router_id'],
'resource_type': fake_router_port['resource_type']
'resource_type': fake_router_port['resource_type'],
'tags': []
}
test_client.assert_json_call(