Fix test_router_add_interface_port_without_ips testcase

The patchset https://review.openstack.org/#/c/193440 broke this test
for the nsx plugin because we assume there has to be an ip_address and
device_id on ports that are set as device_owner=DEVICE_OWNER_ROUTER_INTF.
This patch fixes this so this test will pass.

Change-Id: Iebd3ac2b0cb7520f52b4a1b6414dca19c70d8314
Closes-Bug: #1466750
Related-Bug: #1439824
This commit is contained in:
Aaron Rosen 2015-06-24 10:16:55 -07:00
parent c3e60d08d0
commit 67fed74cb1
3 changed files with 8 additions and 4 deletions

View File

@ -175,6 +175,8 @@ def get_nsx_router_id(session, cluster, neutron_router_id):
First, look up the Neutron database. If not found, execute
a query on NSX platform as the mapping might be missing.
"""
if not neutron_router_id:
return
nsx_router_id = nsx_db.get_nsx_router_id(
session, neutron_router_id)
if not nsx_router_id:

View File

@ -552,7 +552,9 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
port_data, False)
# Assuming subnet being attached is on first fixed ip
# element in port data
subnet_id = port_data['fixed_ips'][0]['subnet_id']
subnet_id = None
if len(port_data['fixed_ips']):
subnet_id = port_data['fixed_ips'][0]['subnet_id']
nsx_router_id = nsx_utils.get_nsx_router_id(
context.session, self.cluster, port_data['device_id'])
# Create peer port on logical router

View File

@ -83,9 +83,9 @@ class NsxUtilsTestCase(base.BaseTestCase):
self.assertFalse(exp_ls_uuids)
def _verify_get_nsx_router_id(self, exp_lr_uuid):
# The nsxlib and db calls are mocked, therefore the cluster
# and the neutron_router_id parameters can be set to None
lr_uuid = nsx_utils.get_nsx_router_id(db_api.get_session(), None, None)
neutron_router_id = uuidutils.generate_uuid()
lr_uuid = nsx_utils.get_nsx_router_id(db_api.get_session(), None,
neutron_router_id)
self.assertEqual(exp_lr_uuid, lr_uuid)
def test_get_nsx_switch_and_port_id_from_db_mappings(self):