Merge "NVP: Correct NVP router port mac to match neutron"

This commit is contained in:
Jenkins 2013-10-26 16:41:42 +00:00 committed by Gerrit Code Review
commit fd952c9fbe
3 changed files with 27 additions and 17 deletions

View File

@ -271,7 +271,8 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
lrouter_port = nvplib.create_router_lport(
cluster, router_id, port_data.get('tenant_id', 'fake'),
port_data.get('id', 'fake'), port_data.get('name', 'fake'),
port_data.get('admin_state_up', True), ip_addresses)
port_data.get('admin_state_up', True), ip_addresses,
port_data.get('mac_address'))
LOG.debug(_("Created NVP router port:%s"), lrouter_port['uuid'])
except NvpApiClient.NvpApiException:
LOG.exception(_("Unable to create port on NVP logical router %s"),

View File

@ -855,7 +855,8 @@ def create_lport(cluster, lswitch_uuid, tenant_id, neutron_port_id,
def create_router_lport(cluster, lrouter_uuid, tenant_id, neutron_port_id,
display_name, admin_status_enabled, ip_addresses):
display_name, admin_status_enabled, ip_addresses,
mac_address=None):
"""Creates a logical port on the assigned logical router."""
tags = [dict(scope='os_tid', tag=tenant_id),
dict(scope='q_port_id', tag=neutron_port_id),
@ -868,6 +869,10 @@ def create_router_lport(cluster, lrouter_uuid, tenant_id, neutron_port_id,
ip_addresses=ip_addresses,
type="LogicalRouterPortConfig"
)
# Only add the mac_address to lport_obj if present. This is because
# when creating the fake_ext_gw there is no mac_address present.
if mac_address:
lport_obj['mac_address'] = mac_address
path = _build_uri_path(LROUTERPORT_RESOURCE,
parent_resource_id=lrouter_uuid)
result = do_request(HTTP_POST, path, json.dumps(lport_obj),

View File

@ -690,7 +690,8 @@ class TestNvplibLogicalRouters(NvplibTestCase):
router_port_uuids = [nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo',
'qp_id_%s' % k, 'port-%s' % k, True,
['192.168.0.%s' % k])['uuid'] for k in range(0, 3)]
['192.168.0.%s' % k], '00:11:22:33:44:55')['uuid']
for k in range(0, 3)]
ports = nvplib.query_lrouter_lports(self.fake_cluster, lrouter['uuid'])
self.assertEqual(len(ports), 3)
for res_port in ports:
@ -700,7 +701,7 @@ class TestNvplibLogicalRouters(NvplibTestCase):
self.assertRaises(
exceptions.NotFound, nvplib.create_router_lport,
self.fake_cluster, 'booo', 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1'])
'name', True, ['192.168.0.1'], '00:11:22:33:44:55')
def test_create_and_get_lrouter_port(self):
lrouter = nvplib.create_lrouter(self.fake_cluster,
@ -709,7 +710,7 @@ class TestNvplibLogicalRouters(NvplibTestCase):
'10.0.0.1')
nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1'])
'name', True, ['192.168.0.1'], '00:11:22:33:44:55')
ports = nvplib.query_lrouter_lports(self.fake_cluster, lrouter['uuid'])
self.assertEqual(len(ports), 1)
res_port = ports[0]
@ -724,7 +725,7 @@ class TestNvplibLogicalRouters(NvplibTestCase):
self.assertRaises(
exceptions.NotFound, nvplib.create_router_lport,
self.fake_cluster, 'booo', 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1'])
'name', True, ['192.168.0.1'], '00:11:22:33:44:55')
def test_update_lrouter_port(self):
lrouter = nvplib.create_lrouter(self.fake_cluster,
@ -733,7 +734,7 @@ class TestNvplibLogicalRouters(NvplibTestCase):
'10.0.0.1')
lrouter_port = nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1'])
'name', True, ['192.168.0.1'], '00:11:22:33:44:55')
nvplib.update_router_lport(
self.fake_cluster, lrouter['uuid'], lrouter_port['uuid'],
'pippo', 'another_port_id', 'name', False,
@ -773,7 +774,8 @@ class TestNvplibLogicalRouters(NvplibTestCase):
'fake-lrouter',
'10.0.0.1')
lrouter_port = nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'x', 'y', True, [])
self.fake_cluster, lrouter['uuid'], 'pippo', 'x', 'y', True, [],
'00:11:22:33:44:55')
ports = nvplib.query_lrouter_lports(self.fake_cluster, lrouter['uuid'])
self.assertEqual(len(ports), 1)
nvplib.delete_router_lport(self.fake_cluster, lrouter['uuid'],
@ -801,7 +803,8 @@ class TestNvplibLogicalRouters(NvplibTestCase):
'fake-lrouter',
'10.0.0.1')
lrouter_port = nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'x', 'y', True, [])
self.fake_cluster, lrouter['uuid'], 'pippo', 'x', 'y', True, [],
'00:11:22:33:44:55')
def fakegetport(*args, **kwargs):
return {'_relations': {'LogicalPortAttachment':
@ -819,7 +822,7 @@ class TestNvplibLogicalRouters(NvplibTestCase):
'10.0.0.1')
lrouter_port = nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1'])
'name', True, ['192.168.0.1'], '00:11:22:33:44:55')
nvplib.update_lrouter_port_ips(
self.fake_cluster, lrouter['uuid'], lrouter_port['uuid'],
['10.10.10.254'], [])
@ -836,7 +839,8 @@ class TestNvplibLogicalRouters(NvplibTestCase):
'10.0.0.1')
lrouter_port = nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1', '10.10.10.254'])
'name', True, ['192.168.0.1', '10.10.10.254'],
'00:11:22:33:44:55')
nvplib.update_lrouter_port_ips(
self.fake_cluster, lrouter['uuid'], lrouter_port['uuid'],
[], ['10.10.10.254'])
@ -852,7 +856,7 @@ class TestNvplibLogicalRouters(NvplibTestCase):
'10.0.0.1')
lrouter_port = nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1'])
'name', True, ['192.168.0.1'], '00:11:22:33:44:55')
nvplib.update_lrouter_port_ips(
self.fake_cluster, lrouter['uuid'], lrouter_port['uuid'],
['10.10.10.254'], ['192.168.0.1'])
@ -873,7 +877,7 @@ class TestNvplibLogicalRouters(NvplibTestCase):
'10.0.0.1')
lrouter_port = nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1'])
'name', True, ['192.168.0.1'], '00:11:22:33:44:55')
def raise_nvp_exc(*args, **kwargs):
raise NvpApiClient.NvpApiException()
@ -900,7 +904,7 @@ class TestNvplibLogicalRouters(NvplibTestCase):
'10.0.0.1')
lrouter_port = nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1'])
'name', True, ['192.168.0.1'], '00:11:22:33:44:55:66')
result = nvplib.plug_router_port_attachment(
self.fake_cluster, lrouter['uuid'],
lrouter_port['uuid'],
@ -915,7 +919,7 @@ class TestNvplibLogicalRouters(NvplibTestCase):
'10.0.0.1')
lrouter_port = nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1'])
'name', True, ['192.168.0.1'], '00:11:22:33:44:55:66')
result = nvplib.plug_router_port_attachment(
self.fake_cluster, lrouter['uuid'],
lrouter_port['uuid'],
@ -931,7 +935,7 @@ class TestNvplibLogicalRouters(NvplibTestCase):
'10.0.0.1')
lrouter_port = nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1'])
'name', True, ['192.168.0.1'], '00:11:22:33:44:55')
result = nvplib.plug_router_port_attachment(
self.fake_cluster, lrouter['uuid'],
lrouter_port['uuid'],
@ -950,7 +954,7 @@ class TestNvplibLogicalRouters(NvplibTestCase):
'10.0.0.1')
lrouter_port = nvplib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1'])
'name', True, ['192.168.0.1'], '00:11:22:33:44:55')
self.assertRaises(nvp_exc.NvpInvalidAttachmentType,
nvplib.plug_router_port_attachment,
self.fake_cluster, lrouter['uuid'],