From: Jenkins Date: Thu, 5 Dec 2013 14:09:51 +0000 (+0000) Subject: Merge "Midonet to support port association at floating IP creation" X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=1863338bad99f23e449f797d897c0cc24344bea6;p=openstack-build%2Fneutron-build.git Merge "Midonet to support port association at floating IP creation" --- 1863338bad99f23e449f797d897c0cc24344bea6 diff --cc neutron/plugins/midonet/plugin.py index 8016ef56a,1884baad7..e4bdb9955 --- a/neutron/plugins/midonet/plugin.py +++ b/neutron/plugins/midonet/plugin.py @@@ -1044,8 -1026,42 +1044,42 @@@ class MidonetPluginV2(db_base_plugin_v2 "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})