assigning floating_ips to different public interfaces

asked 2015-08-27 14:43:47 -0500

I'm trying to have nova and nova-network assign floating ips onto different networks on different interfaces, but not multi-nic. The problem is that nova doesn't respect the interface variable (like below), instead if defaults to the public_interface variable in nova.conf.

nova floating-ip-bulk-list
+----------------------------------+--------------+--------------------------------------+------------+-----------+
| project_id                       | address      | instance_uuid         | pool       | interface |
+----------------------------------+--------------+--------------------------------------+------------+-----------+
| 819b88e99e3d42b89760ec01180c74cd | 10.10.11.97  | -       | public1  | enp4s0    |
| 738bd11a6a0546a0927d6ced9631f540 | 10.10.10.209 | -       | public2  | enp3s0    |

There has been a bug report that happens to overlap with my issue (Nova bug 1407893), but it hasn't received any attention since January so it's expired.

I've naively modified the openstack source to get it working, and it seems to be ok. Any reason why this shouldn't work or this shouldn't be addressed in the official source?

This is my patch:

--- nova/network/floating_ips.py
+++ nova/network/floating_ips.py
@@ -86,7 +86,7 @@
                     msg = _('Fixed ip %s not found') % floating_ip.fixed_ip_id
                     LOG.debug(msg)
                     continue
-                interface = CONF.public_interface or floating_ip.interface
+                interface = floating_ip.interface or CONF.public_interface
                 try:
                     self.l3driver.add_floating_ip(floating_ip.address,
                                                   fixed_ip.address,
@@ -353,7 +353,7 @@
     def _associate_floating_ip(self, context, floating_address, fixed_address,
                                interface, instance_uuid):
         """Performs db and driver calls to associate floating ip & fixed ip."""
-        interface = CONF.public_interface or interface
+        interface = interface or CONF.public_interface

         @utils.synchronized(unicode(floating_address))
         def do_associate():
@@ -449,7 +449,7 @@
     def _disassociate_floating_ip(self, context, address, interface,
                                   instance_uuid):
         """Performs db and driver calls to disassociate floating ip."""
-        interface = CONF.public_interface or interface
+        interface = interface or CONF.public_interface

         @utils.synchronized(unicode(address))
         def do_disassociate():
@@ -545,7 +545,7 @@
                          {'address': address, 'instance_uuid': instance_uuid})
                 continue

-            interface = CONF.public_interface or floating_ip.interface
+            interface = floating_ip.interface or CONF.public_interface
             fixed_ip = floating_ip.fixed_ip
             self.l3driver.remove_floating_ip(floating_ip.address,
                                              fixed_ip.address,
@@ -584,7 +584,7 @@
             floating_ip.host = dest
             floating_ip.save()

-            interface = CONF.public_interface or floating_ip.interface
+            interface = floating_ip.interface or CONF.public_interface
             fixed_ip = floating_ip.fixed_ip
             self.l3driver.add_floating_ip(floating_ip.address,
                                           fixed_ip.address,
edit retag flag offensive close merge delete