Bug 7888: handle update of floating ip port 28/52628/5
authorKoby Aizer <koby.aizer@hpe.com>
Thu, 2 Mar 2017 10:24:55 +0000 (12:24 +0200)
committerVivekanandan Narasimhan <n.vivekanandan@ericsson.com>
Fri, 10 Mar 2017 05:19:33 +0000 (05:19 +0000)
In Ocata, when a floating ip port is created, its deviceId may be
set to "PENDING", and an update will follow with the deviceId later on ([1])

This is causing both an uncaught exception in NeutronPortChangeListener.add()
which assumed deviceId is always a Uuid, and also there is no creation of
FloatingIpIdToPortMapping during update().

[1] https://review.openstack.org/#/c/396013/

Change-Id: Ide44ef016f0a8c576f02dfd28d9a4ee9d492841e
Signed-off-by: Koby Aizer <koby.aizer@hpe.com>
vpnservice/neutronvpn/neutronvpn-api/src/main/java/org/opendaylight/netvirt/neutronvpn/api/utils/NeutronConstants.java
vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronPortChangeListener.java

index 7a83cb0e629df504805373c54e729cf6359609f3..5ddb61891c54a63bde5d27f15360173611f8aa4a 100644 (file)
@@ -12,6 +12,7 @@ public class NeutronConstants {
     public static final String DEVICE_OWNER_GATEWAY_INF = "network:router_gateway";
     public static final String DEVICE_OWNER_ROUTER_INF = "network:router_interface";
     public static final String DEVICE_OWNER_FLOATING_IP = "network:floatingip";
+    public static final String FLOATING_IP_DEVICE_ID_PENDING = "PENDING";
     public static final String PREFIX_TAP = "tap";
     public static final String PREFIX_VHOSTUSER = "vhu";
     public static final String RD_IDPOOL_NAME = "RouteDistinguisherPool";
index 55cf817fa2e4000daac153addd4af9dce6e110bb..1ca9890bdf5d649a57425f91621ac64334aa3825 100644 (file)
@@ -118,14 +118,7 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
             if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(input.getDeviceOwner())) {
                 handleRouterGatewayUpdated(input);
             } else if (NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(input.getDeviceOwner())) {
-
-                // populate floating-ip uuid and floating-ip port attributes (uuid, mac and subnet id for the ONLY
-                // fixed IP) to be used by NAT, depopulated in NATService once mac is retrieved in the removal path
-                addToFloatingIpPortInfo(new Uuid(input.getDeviceId()), input.getUuid(), input.getFixedIps().get(0)
-                                .getSubnetId(), input.getMacAddress().getValue());
-
-                elanService.handleKnownL3DmacAddress(input.getMacAddress().getValue(), input.getNetworkId().getValue(),
-                        NwConstants.ADD_FLOW);
+                handleFloatingIpPortUpdated(null, input);
             }
         }
         if (input.getFixedIps() != null && !input.getFixedIps().isEmpty()) {
@@ -229,6 +222,17 @@ public class NeutronPortChangeListener extends AsyncDataTreeChangeListenerBase<P
         if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(update.getDeviceOwner())) {
             handleRouterGatewayUpdated(update);
         } else if (NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(update.getDeviceOwner())) {
+            handleFloatingIpPortUpdated(original, update);
+        }
+    }
+
+    private void handleFloatingIpPortUpdated(Port original, Port update) {
+        if (((original == null) || (original.getDeviceId().equals(NeutronConstants.FLOATING_IP_DEVICE_ID_PENDING)))
+            && !update.getDeviceId().equals(NeutronConstants.FLOATING_IP_DEVICE_ID_PENDING)) {
+            // populate floating-ip uuid and floating-ip port attributes (uuid, mac and subnet id for the ONLY
+            // fixed IP) to be used by NAT, depopulated in NATService once mac is retrieved in the removal path
+            addToFloatingIpPortInfo(new Uuid(update.getDeviceId()), update.getUuid(), update.getFixedIps().get(0)
+                    .getSubnetId(), update.getMacAddress().getValue());
             elanService.handleKnownL3DmacAddress(update.getMacAddress().getValue(), update.getNetworkId().getValue(),
                     NwConstants.ADD_FLOW);
         }