"info=%r"), info)
return info
+ def _assoc_fip(self, fip):
+ router = self.client.get_router(fip["router_id"])
+ link_port = self.client.get_link_port(
+ self._get_provider_router(), router.get_id())
+ self.client.add_router_route(
+ self._get_provider_router(),
+ src_network_addr='0.0.0.0',
+ src_network_length=0,
+ dst_network_addr=fip["floating_ip_address"],
+ dst_network_length=32,
+ next_hop_port=link_port.get_peer_id())
+ props = {OS_FLOATING_IP_RULE_KEY: fip['id']}
+ tenant_id = router.get_tenant_id()
+ chain_names = _nat_chain_names(router.get_id())
+ for chain_type, name in chain_names.items():
+ src_ip, target_ip = _get_nat_ips(chain_type, fip)
+ if chain_type == 'pre-routing':
+ nat_type = 'dnat'
+ else:
+ nat_type = 'snat'
+ self.client.add_static_nat(tenant_id, name, src_ip,
+ target_ip,
+ link_port.get_id(),
+ nat_type, **props)
+
+ def create_floatingip(self, context, floatingip):
+ session = context.session
+ with session.begin(subtransactions=True):
+ fip = super(MidonetPluginV2, self).create_floatingip(
+ context, floatingip)
+ if fip['port_id']:
+ self._assoc_fip(fip)
+ return fip
+
def update_floatingip(self, context, id, floatingip):
- """Handle floating IP assocation and disassociation."""
+ """Handle floating IP association and disassociation."""
LOG.debug(_("MidonetPluginV2.update_floatingip called: id=%(id)s "
"floatingip=%(floatingip)s "),
{'id': id, 'floatingip': floatingip})