Bug 1844 : Callback from neutron's router interface to be handled via neutron port... 07/11107/1
authorFlavio Fernandes <ffernand@redhat.com>
Fri, 12 Sep 2014 12:38:52 +0000 (08:38 -0400)
committerFlavio Fernandes <ffernand@redhat.com>
Fri, 12 Sep 2014 13:42:36 +0000 (09:42 -0400)
In the absence of explicit router interface add/remove callback, check the interface
owner of the neutron port and determine if that represents a router interface. From there,
simply map the event as the expected router interface event.

Change-Id: Ib5a58ad166e632b89cc97a23b2c8545f6462ca66
Signed-off-by: Flavio Fernandes <ffernand@redhat.com>
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NeutronL3Adapter.java

index 21fdd4f3d5edc0b02de697c966552a17a0e8a67c..2884bab77ce288c8a063d3edaa392f4f340aa0a8 100644 (file)
@@ -119,8 +119,28 @@ public class NeutronL3Adapter {
         final boolean isAdd = action == Action.ADD;
         final boolean isDelete = action == Action.DELETE;
 
-        if (isAdd || isDelete) {
-            updateL3ForNeutronPort(neutronPort, null /*neutronRouterInterfaceFilter*/, isDelete);
+        // add 'before'
+        if (isAdd) {
+            updateL3ForNeutronPort(neutronPort, null /*neutronRouterInterfaceFilter*/, false /*isDelete*/);
+        }
+
+        // Also treat the port event as a router interface event iff the port belongs to router. This is a
+        // helper for handling cases when handleNeutronRouterInterfaceEvent is not available
+        //
+        if (neutronPort.getDeviceOwner().equalsIgnoreCase("network:router_interface")) {
+            for (Neutron_IPs neutronIP : neutronPort.getFixedIPs()) {
+                NeutronRouter_Interface neutronRouterInterface =
+                        new NeutronRouter_Interface(neutronIP.getSubnetUUID(), neutronPort.getPortUUID());
+                neutronRouterInterface.setID(neutronIP.getSubnetUUID());  // id of router interface to be same as subnet
+                neutronRouterInterface.setTenantID(neutronPort.getTenantID());
+
+                this.handleNeutronRouterInterfaceEvent(null /*neutronRouter*/, neutronRouterInterface, action);
+            }
+        }
+
+        // delete 'after'
+        if (isDelete) {
+                updateL3ForNeutronPort(neutronPort, null /*neutronRouterInterfaceFilter*/, true /*isDelete*/);
         }
     }
 
@@ -132,7 +152,7 @@ public class NeutronL3Adapter {
                                                   final NeutronRouter_Interface neutronRouterInterface,
                                                   Action action) {
         logger.debug(" Router {} interface {} got event {}. Subnet {}",
-                     neutronRouter.getName(),
+                     neutronRouter != null ? neutronRouter.getName() : "-",
                      neutronRouterInterface.getPortUUID(),
                      action,
                      neutronRouterInterface.getSubnetUUID());