models_v2.IPAllocation.subnet_id == internal_subnet_id
)
- router_port = routerport_qry.first()
-
- if router_port and router_port.router.gw_port:
- return router_port.router.id
+ for router_port in routerport_qry:
+ router_id = router_port.router.id
+ router_gw_qry = context.session.query(models_v2.Port)
+ has_gw_port = router_gw_qry.filter_by(
+ network_id=external_network_id,
+ device_id=router_id,
+ device_owner=DEVICE_OWNER_ROUTER_GW).count()
+ if has_gw_port:
+ return router_id
raise l3.ExternalGatewayForFloatingIPNotFound(
subnet_id=internal_subnet_id,
self._delete('floatingips', fp2['floatingip']['id'])
self._delete('floatingips', fp3['floatingip']['id'])
+ def test_floatingip_multi_external_one_internal(self):
+ with contextlib.nested(self.subnet(cidr="10.0.0.0/24"),
+ self.subnet(cidr="11.0.0.0/24"),
+ self.subnet(cidr="12.0.0.0/24")
+ ) as (exs1, exs2, ins1):
+ network_ex_id1 = exs1['subnet']['network_id']
+ network_ex_id2 = exs2['subnet']['network_id']
+ self._set_net_external(network_ex_id1)
+ self._set_net_external(network_ex_id2)
+
+ r2i_fixed_ips = [{'ip_address': '12.0.0.2'}]
+ with contextlib.nested(self.router(no_delete=True),
+ self.router(no_delete=True),
+ self.port(subnet=ins1,
+ fixed_ips=r2i_fixed_ips)
+ ) as (r1, r2, r2i_port):
+ self._add_external_gateway_to_router(
+ r1['router']['id'],
+ network_ex_id1)
+ self._router_interface_action('add', r1['router']['id'],
+ ins1['subnet']['id'],
+ None)
+ self._add_external_gateway_to_router(
+ r2['router']['id'],
+ network_ex_id2)
+ self._router_interface_action('add', r2['router']['id'],
+ None,
+ r2i_port['port']['id'])
+
+ with self.port(subnet=ins1,
+ fixed_ips=[{'ip_address': '12.0.0.3'}]
+ ) as private_port:
+
+ fp1 = self._make_floatingip(self.fmt, network_ex_id1,
+ private_port['port']['id'],
+ floating_ip='10.0.0.3')
+ fp2 = self._make_floatingip(self.fmt, network_ex_id2,
+ private_port['port']['id'],
+ floating_ip='11.0.0.3')
+ self.assertEqual(fp1['floatingip']['router_id'],
+ r1['router']['id'])
+ self.assertEqual(fp2['floatingip']['router_id'],
+ r2['router']['id'])
+
def test_floatingip_delete_router_intf_with_subnet_id_returns_409(self):
found = False
with self.floatingip_with_assoc():