Ensure floating IP create does not break

Commit 088e317cd2 breaks floating IP
creation.

This changed the API and mandated that 'subnet_id' and
'floating_ip_address' be passed in the API.

This also cleans up tests with invalid inputs.

Change-Id: I7bc758eed56610c269485681f67a5379730d8ef5
Closes-Bug: #1738612
This commit is contained in:
Gary Kotton 2017-12-17 01:12:34 -08:00
parent bfaae98396
commit e3488f451e
3 changed files with 2 additions and 26 deletions

View File

@ -1290,9 +1290,9 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
# floating_ip_address is not in the subnet,
# InvalidIpForSubnet exception will be raised.
fixed_ip = {}
if fip['subnet_id']:
if validators.is_attr_set(fip.get('subnet_id')):
fixed_ip['subnet_id'] = fip['subnet_id']
if fip['floating_ip_address']:
if validators.is_attr_set(fip.get('floating_ip_address')):
fixed_ip['ip_address'] = fip['floating_ip_address']
if fixed_ip:
port['fixed_ips'] = [fixed_ip]

View File

@ -335,8 +335,6 @@ class L3DvrTestCase(L3DvrTestCaseBase):
'router_id': router['id'],
'port_id': int_port['port']['id'],
'tenant_id': int_port['port']['tenant_id'],
'subnet_id': None,
'floating_ip_address': None,
'dns_name': '', 'dns_domain': ''}
with mock.patch.object(
self.l3_plugin, '_l3_rpc_notifier') as l3_notif:
@ -426,8 +424,6 @@ class L3DvrTestCase(L3DvrTestCaseBase):
floating_ip = {'floating_network_id': ext_net_id,
'router_id': router1['id'],
'port_id': int_port1['port']['id'],
'subnet_id': None,
'floating_ip_address': None,
'tenant_id': int_port1['port']['tenant_id'],
'dns_name': '', 'dns_domain': ''}
floating_ip = self.l3_plugin.create_floatingip(
@ -532,8 +528,6 @@ class L3DvrTestCase(L3DvrTestCaseBase):
'router_id': router['id'],
'port_id': int_port['port']['id'],
'tenant_id': int_port['port']['tenant_id'],
'subnet_id': None,
'floating_ip_address': None,
'dns_name': '', 'dns_domain': ''}
floating_ip = self.l3_plugin.create_floatingip(
self.context, {'floatingip': floating_ip})
@ -738,8 +732,6 @@ class L3DvrTestCase(L3DvrTestCaseBase):
floating_ip = {'floating_network_id': ext_net['network']['id'],
'router_id': router['id'],
'port_id': vrrp_port['port']['id'],
'subnet_id': None,
'floating_ip_address': None,
'tenant_id': vrrp_port['port']['tenant_id']}
floating_ip = self.l3_plugin.create_floatingip(
self.context, {'floatingip': floating_ip})
@ -807,8 +799,6 @@ class L3DvrTestCase(L3DvrTestCaseBase):
fip1 = {'floating_network_id': ext_net['network']['id'],
'router_id': router['id'],
'port_id': int_port1['port']['id'],
'subnet_id': None,
'floating_ip_address': None,
'tenant_id': int_port1['port']['tenant_id']}
self.l3_plugin.create_floatingip(
self.context, {'floatingip': fip1})
@ -820,8 +810,6 @@ class L3DvrTestCase(L3DvrTestCaseBase):
fip2 = {'floating_network_id': ext_net['network']['id'],
'router_id': router['id'],
'port_id': int_port2['port']['id'],
'subnet_id': None,
'floating_ip_address': None,
'tenant_id': int_port2['port']['tenant_id']}
self.l3_plugin.create_floatingip(
self.context, {'floatingip': fip2})
@ -886,8 +874,6 @@ class L3DvrTestCase(L3DvrTestCaseBase):
floating_ip = {'floating_network_id': ext_net['network']['id'],
'router_id': router['id'],
'port_id': int_port1['port']['id'],
'subnet_id': None,
'floating_ip_address': None,
'tenant_id': int_port1['port']['tenant_id']}
floating_ip = self.l3_plugin.create_floatingip(
self.context, {'floatingip': floating_ip})
@ -968,8 +954,6 @@ class L3DvrTestCase(L3DvrTestCaseBase):
floating_ip = {'floating_network_id': ext_net['network']['id'],
'router_id': router['id'],
'port_id': vm_port['id'],
'subnet_id': None,
'floating_ip_address': None,
'tenant_id': vm_port['tenant_id']}
floating_ip = self.l3_plugin.create_floatingip(
self.context, {'floatingip': floating_ip})
@ -1092,8 +1076,6 @@ class L3DvrTestCase(L3DvrTestCaseBase):
floating_ip = {'floating_network_id': ext_net['network']['id'],
'router_id': router['id'],
'port_id': vrrp_port['port']['id'],
'subnet_id': None,
'floating_ip_address': None,
'tenant_id': vrrp_port['port']['tenant_id']}
floating_ip = self.l3_plugin.create_floatingip(
self.context, {'floatingip': floating_ip})
@ -1225,8 +1207,6 @@ class L3DvrTestCase(L3DvrTestCaseBase):
floating_ip = {'floating_network_id': ext_net['network']['id'],
'router_id': router['id'],
'port_id': vrrp_port['port']['id'],
'subnet_id': None,
'floating_ip_address': None,
'tenant_id': vrrp_port['port']['tenant_id']}
floating_ip = self.l3_plugin.create_floatingip(
self.context, {'floatingip': floating_ip})
@ -1442,8 +1422,6 @@ class L3DvrTestCase(L3DvrTestCaseBase):
floating_ip = {'floating_network_id': ext_net_id,
'router_id': router['id'],
'port_id': vm_port['port']['id'],
'subnet_id': None,
'floating_ip_address': None,
'tenant_id': vm_port['port']['tenant_id'],
'dns_name': '', 'dns_domain': ''}
floating_ip = self.l3_plugin.create_floatingip(

View File

@ -946,8 +946,6 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
context.get_admin_context(),
{'floatingip': {'floating_network_id': n['network']['id'],
'tenant_id': n['network']['tenant_id'],
'subnet_id': None,
'floating_ip_address': None,
'dns_name': '', 'dns_domain': ''}}
)
self._delete('networks', n['network']['id'])