From e310af569b148ec3a28edaba22144bcd21b3e4a8 Mon Sep 17 00:00:00 2001 From: Vishal Thapar Date: Tue, 2 Feb 2016 15:49:52 +0530 Subject: [PATCH] BUG:5186 Fix for change in extraroutes type Fix for BUG 5137 in Neutron changes the type of extraroutes from string to destination and nexthop. This fix is to change vpnservice code as per neutron change. Neutron change: https://git.opendaylight.org/gerrit/33846 Change-Id: I702f81adc3579943bef9e71e616dde4280692847 Signed-off-by: Vishal Thapar (cherry picked from commit 535c182e3b03fa32aaccc4349fecb835a1468a82) --- .../NeutronRouterChangeListener.java | 12 +++---- .../neutronvpn/NeutronvpnManager.java | 34 ++++++++----------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronRouterChangeListener.java b/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronRouterChangeListener.java index 4cd576e2..9da9f7d4 100644 --- a/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronRouterChangeListener.java +++ b/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronRouterChangeListener.java @@ -8,6 +8,8 @@ package org.opendaylight.vpnservice.neutronvpn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes; + import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; @@ -22,7 +24,6 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -110,9 +111,8 @@ public class NeutronRouterChangeListener extends AbstractDataChangeListener(); List newInterfaces = (update.getInterfaces() != null) ? update.getInterfaces() : new ArrayList(); - List oldRoutes = (original.getRoutes() != null) ? original.getRoutes() : new ArrayList(); - List newRoutes = (update.getRoutes() != null) ? update.getRoutes() : new ArrayList(); - + List oldRoutes = (original.getRoutes() != null) ? original.getRoutes() : new ArrayList(); + List newRoutes = (update.getRoutes() != null) ? update.getRoutes() : new ArrayList(); if (!oldInterfaces.equals(newInterfaces)) { for (Interfaces intrf : newInterfaces) { if (!oldInterfaces.remove(intrf)) { @@ -126,9 +126,9 @@ public class NeutronRouterChangeListener extends AbstractDataChangeListener iterator = newRoutes.iterator(); + Iterator iterator = newRoutes.iterator(); while (iterator.hasNext()) { - String route = iterator.next(); + Routes route = iterator.next(); if (oldRoutes.remove(route)) { iterator.remove(); } diff --git a/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronvpnManager.java b/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronvpnManager.java index f151a3c2..a04c7ec6 100644 --- a/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronvpnManager.java +++ b/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronvpnManager.java @@ -7,9 +7,10 @@ */ package org.opendaylight.vpnservice.neutronvpn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes; + import com.google.common.base.Optional; import com.google.common.util.concurrent.SettableFuture; - import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.vpnservice.mdsalutil.MDSALUtil; @@ -86,7 +87,6 @@ import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -443,7 +443,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable { adjList.add(vmAdj); // create extra route adjacency if (rtr != null && rtr.getRoutes() != null) { - List routeList = rtr.getRoutes(); + List routeList = rtr.getRoutes(); List erAdjList = addAdjacencyforExtraRoute(routeList, false, portname); if (erAdjList != null && !erAdjList.isEmpty()) { adjList.addAll(erAdjList); @@ -733,15 +733,13 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable { } } - protected List addAdjacencyforExtraRoute(List routeList, boolean rtrUp, String vpnifname) { + protected List addAdjacencyforExtraRoute(List routeList, boolean rtrUp, String vpnifname) { List adjList = new ArrayList(); - for (String route : routeList) { - // assuming extra route is strictly in the format "nexthop destination" > "10.1.1.10 40.0.1.0/24" - String[] parts = route.split(" "); - if (parts.length == 2) { + for (Routes route : routeList) { + if (route != null && route.getNexthop() != null && route.getDestination() != null) { boolean isLockAcquired = false; - String nextHop = parts[0]; - String destination = parts[1]; + String nextHop = String.valueOf(route.getNexthop().getValue()); + String destination = String.valueOf(route.getDestination().getValue()); String tapPortName = NeutronvpnUtils.getNeutronPortNamefromPortFixedIp(broker, nextHop); logger.trace("Adding extra route with nexthop {}, destination {}, ifName {}", nextHop, @@ -778,20 +776,18 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable { } } } else { - logger.error("Incorrect input received for extra route. {}", parts); + logger.error("Incorrect input received for extra route. {}", route); } } return adjList; } - protected void removeAdjacencyforExtraRoute(List routeList) { - for (String route : routeList) { - // assuming extra route is strictly in the format "nexthop destination" > "10.1.1.10 40.0.1.0/24" - String[] parts = route.split(" "); - if (parts.length == 2) { + protected void removeAdjacencyforExtraRoute(List routeList) { + for (Routes route : routeList) { + if (route != null && route.getNexthop() != null && route.getDestination() != null) { boolean isLockAcquired = false; - String nextHop = parts[0]; - String destination = parts[1]; + String nextHop = String.valueOf(route.getNexthop().getValue()); + String destination = String.valueOf(route.getDestination().getValue()); String tapPortName = NeutronvpnUtils.getNeutronPortNamefromPortFixedIp(broker, nextHop); logger.trace("Removing extra route with nexthop {}, destination {}, ifName {}", nextHop, @@ -811,7 +807,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable { } } } else { - logger.error("Incorrect input received for extra route. {}", parts); + logger.error("Incorrect input received for extra route. {}", route); } } } -- 2.36.6