if (l3_db.EXTERNAL_GW_INFO in r and
r[l3_db.EXTERNAL_GW_INFO] is not None):
# Gateway created
- gw_port = self._get_port(context.elevated(),
- r["gw_port_id"])
- gw_ip = gw_port['fixed_ips'][0]['ip_address']
+ gw_port_neutron = self._get_port(
+ context.elevated(), r["gw_port_id"])
+ gw_ip = gw_port_neutron['fixed_ips'][0]['ip_address']
# First link routers and set up the routes
self._set_router_gateway(r["id"],
self._get_provider_router(),
gw_ip)
+ gw_port_midonet = self.client.get_link_port(
+ self._get_provider_router(), r["id"])
# Get the NAT chains and add dynamic SNAT rules.
chain_names = _nat_chain_names(r["id"])
self.client.add_dynamic_snat(tenant_id,
chain_names['pre-routing'],
chain_names['post-routing'],
- gw_ip, gw_port["id"], **props)
+ gw_ip,
+ gw_port_midonet.get_id(),
+ **props)
self.client.update_router(id, **router_data)
self._add_external_gateway_to_router(
r['router']['id'],
public_sub['subnet']['network_id'])
+
+ # Check that get_link_port was called - if not, Source NAT
+ # will not be set up correctly on the MidoNet side
+ self.assertTrue(
+ self.instance.return_value.get_link_port.called)
+
self._router_interface_action('add', r['router']['id'],
private_sub['subnet']['id'],
None)