Merge "Bug 5268 - Handle l3vpn delete and recreate scenario -Handle switch restart...
authorVivek Srivastava <vivek.v.srivastava@ericsson.com>
Thu, 10 Mar 2016 09:38:19 +0000 (09:38 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 10 Mar 2016 09:38:19 +0000 (09:38 +0000)
features/pom.xml
features/src/main/features/features.xml
fibmanager/fibmanager-impl/src/main/java/org/opendaylight/vpnservice/fibmanager/NexthopManager.java
fibmanager/fibmanager-shell/pom.xml [new file with mode: 0644]
fibmanager/fibmanager-shell/src/main/java/org/opendaylight/vpnservice/fibmanager/shell/ShowFibCommand.java [new file with mode: 0644]
fibmanager/fibmanager-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml [new file with mode: 0644]
fibmanager/pom.xml
neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronPortChangeListener.java
neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronvpnManager.java
vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/vpnservice/VpnInterfaceManager.java

index 8ca0dc3f9d14ce58e69a65baec643b76f425131d..c21897e9410671c7973d2280c57d9e47c235c976 100644 (file)
@@ -273,6 +273,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <classifier>config</classifier>
       <type>xml</type>
     </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>fibmanager-shell</artifactId>
+      <version>${fibmanager.version}</version>
+    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>fibmanager-api</artifactId>
index abd034196b136862997aa5149b8410bb2639b0e6..a831dfb617742a4b2f2a81d9e8ac136b902abbb5 100644 (file)
@@ -59,6 +59,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <bundle>mvn:org.opendaylight.vpnservice/interfacemgr-impl/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/vpnmanager-impl/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/fibmanager-impl/{{VERSION}}</bundle>
+    <bundle>mvn:org.opendaylight.vpnservice/fibmanager-shell/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/itm-impl/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/neutronvpn-impl/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/neutronvpn-shell/{{VERSION}}</bundle>
index a3cd7c4eea9af109c9fde30e87a205b3441bbad3..f82a3e6ecba39e83fe3b3289ff1d212b3d56c1fe 100644 (file)
@@ -403,7 +403,7 @@ public class NexthopManager implements AutoCloseable {
                     GroupEntity groupEntity = MDSALUtil.buildGroupEntity(
                             dpnId, nh.getEgressPointer(), ipAddress, GroupTypes.GroupIndirect, null);
                     // remove Group ...
-                    mdsalManager.syncRemoveGroup(groupEntity);
+                    mdsalManager.removeGroup(groupEntity);
                     //update MD-SAL DS
                     removeVpnNexthopFromDS(vpnId, ipAddress);
                     //release groupId
diff --git a/fibmanager/fibmanager-shell/pom.xml b/fibmanager/fibmanager-shell/pom.xml
new file mode 100644 (file)
index 0000000..90ad96d
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <parent>
+    <groupId>org.opendaylight.vpnservice</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.3.0-SNAPSHOT</version>
+    <relativePath>../../commons/config-parent</relativePath>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>fibmanager-shell</artifactId>
+  <version>${vpnservices.version}</version>
+  <packaging>bundle</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.vpnservice</groupId>
+      <artifactId>fibmanager-api</artifactId>
+      <version>${vpnservices.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.karaf.shell</groupId>
+      <artifactId>org.apache.karaf.shell.console</artifactId>
+      <version>${karaf.shell.console.version}</version>
+   </dependency>
+  </dependencies>
+
+</project>
diff --git a/fibmanager/fibmanager-shell/src/main/java/org/opendaylight/vpnservice/fibmanager/shell/ShowFibCommand.java b/fibmanager/fibmanager-shell/src/main/java/org/opendaylight/vpnservice/fibmanager/shell/ShowFibCommand.java
new file mode 100644 (file)
index 0000000..4a8d4d6
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.vpnservice.fibmanager.shell;
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.fibmanager.api.IFibManager;
+
+@Command(scope = "vpnservice", name = "fib-show", description = "Displays fib entries")
+public class ShowFibCommand extends OsgiCommandSupport {
+    private IFibManager fibManager;
+
+    public void setFibManager(IFibManager fibManager) {
+        this.fibManager = fibManager;
+    }
+
+    @Override
+    protected Object doExecute() throws Exception {
+        for (String p : fibManager.printFibEntries()) {
+            System.out.println(p);
+        }
+        return null;
+    }
+}
diff --git a/fibmanager/fibmanager-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/fibmanager/fibmanager-shell/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644 (file)
index 0000000..1047431
--- /dev/null
@@ -0,0 +1,21 @@
+<!--    * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+        *
+        * This program and the accompanying materials are made available under the
+        * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+        * and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <reference id="fibManagerRef" interface="org.opendaylight.fibmanager.api.IFibManager" availability="optional"/>
+    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+
+        <command>
+            <action class="org.opendaylight.vpnservice.fibmanager.shell.ShowFibCommand">
+                <property name="fibManager" ref="fibManagerRef"/>
+            </action>
+        </command>
+
+    </command-bundle>
+
+</blueprint>
index 1fd88b04416ab1331e891fbf29855db24f9fbb33..1fe5403788810dff61b346c890f8915a0e3ce56f 100644 (file)
@@ -5,45 +5,47 @@ This program and the accompanying materials are made available under the
 terms of the Eclipse Public License v1.0 which accompanies this distribution,
 and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
-  <parent>
-    <groupId>org.opendaylight.odlparent</groupId>
-    <artifactId>odlparent</artifactId>
-    <version>1.7.0-SNAPSHOT</version>
-    <relativePath/>
-  </parent>
+    <parent>
+        <groupId>org.opendaylight.odlparent</groupId>
+        <artifactId>odlparent</artifactId>
+        <version>1.7.0-SNAPSHOT</version>
+        <relativePath/>
+    </parent>
 
-  <groupId>org.opendaylight.vpnservice</groupId>
-  <artifactId>fibmanager-aggregator</artifactId>
-  <version>0.3.0-SNAPSHOT</version>
-  <name>fibmanager</name>
-  <packaging>pom</packaging>
-  <modelVersion>4.0.0</modelVersion>
-  <prerequisites>
-    <maven>3.1.1</maven>
-  </prerequisites>
-  <modules>
-    <module>fibmanager-api</module>
-    <module>fibmanager-impl</module>
-  </modules>
-  <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-deploy-plugin</artifactId>
-        <configuration>
-          <skip>true</skip>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-install-plugin</artifactId>
-        <configuration>
-          <skip>true</skip>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
+    <groupId>org.opendaylight.vpnservice</groupId>
+    <artifactId>fibmanager-aggregator</artifactId>
+    <version>0.3.0-SNAPSHOT</version>
+    <name>fibmanager</name>
+    <packaging>pom</packaging>
+    <modelVersion>4.0.0</modelVersion>
+    <prerequisites>
+        <maven>3.1.1</maven>
+    </prerequisites>
+    <modules>
+        <module>fibmanager-api</module>
+        <module>fibmanager-impl</module>
+        <module>fibmanager-shell</module>
+    </modules>
+    <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-install-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
index 9a14c570bf505181b97c7c29dff8633dddf8ad07..c4ba484b8ea6a103d6e9bea3ab93ffa9ef0c3e4f 100644 (file)
@@ -165,14 +165,14 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
 
     private void handleNeutronPortUpdated(Port portoriginal, Port portupdate) {
         LOG.debug("Add port to subnet");
-        // add port FixedIPs to local Subnets DS
+        // add port FixedIP to local Subnets DS
         Uuid vpnIdup = addPortToSubnets(portupdate);
 
         if (vpnIdup != null) {
             nvpnManager.createVpnInterface(vpnIdup, portupdate);
         }
 
-        // remove port FixedIPs from local Subnets DS
+        // remove port FixedIP from local Subnets DS
         Uuid vpnIdor = removePortFromSubnets(portoriginal);
 
         if (vpnIdor != null) {
@@ -252,25 +252,22 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
     private Uuid addPortToSubnets(Port port) {
         Uuid subnetId = null;
         Uuid vpnId = null;
-        String name = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
-
-        // find all subnets to which this port is associated
-        List<FixedIps> ips = port.getFixedIps();
-        for (FixedIps ip : ips) {
-            String ipValue = ip.getIpAddress().getIpv4Address().getValue();
-
-            InstanceIdentifier id = NeutronvpnUtils.buildFixedIpToPortNameIdentifier(ipValue);
-            PortFixedipToPortNameBuilder builder = new PortFixedipToPortNameBuilder().setPortFixedip(ipValue)
-                    .setPortName(name);
-            MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, id, builder.build());
-            LOG.debug("fixedIp-name map for neutron port with fixedIp: {}, name: {} added to NeutronPortData DS",
-                    ipValue, name);
-
-            subnetId = ip.getSubnetId();
-            Subnetmap subnetmap = nvpnManager.updateSubnetNode(subnetId, null, null, null, null, null, port.getUuid());
-            if (subnetmap != null) {
-                vpnId = subnetmap.getVpnId();
-            }
+        Subnetmap subnetmap = null;
+        String infName = port.getUuid().getValue();
+
+        // find the subnet to which this port is associated
+        FixedIps ip = port.getFixedIps().get(0);
+        String ipValue = ip.getIpAddress().getIpv4Address().getValue();
+        InstanceIdentifier id = NeutronvpnUtils.buildFixedIpToPortNameIdentifier(ipValue);
+        PortFixedipToPortNameBuilder builder = new PortFixedipToPortNameBuilder().setPortFixedip(ipValue)
+                .setPortName(infName);
+        MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, id, builder.build());
+        LOG.debug("fixedIp-name map for neutron port with fixedIp: {}, name: {} added to NeutronPortData DS",
+                ipValue, infName);
+        subnetId = ip.getSubnetId();
+        subnetmap = nvpnManager.updateSubnetNode(subnetId, null, null, null, null, null, port.getUuid());
+        if (subnetmap != null) {
+            vpnId = subnetmap.getVpnId();
         }
         return vpnId;
     }
@@ -278,21 +275,18 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
     private Uuid removePortFromSubnets(Port port) {
         Uuid subnetId = null;
         Uuid vpnId = null;
-
-        // find all Subnets to which this port is associated
-        List<FixedIps> ips = port.getFixedIps();
-        for (FixedIps ip : ips) {
-            String ipValue = ip.getIpAddress().getIpv4Address().getValue();
-
-            InstanceIdentifier id = NeutronvpnUtils.buildFixedIpToPortNameIdentifier(ipValue);
-            MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, id);
-            LOG.debug("fixedIp-name map for neutron port with fixedIp: {} deleted from NeutronPortData DS", ipValue);
-
-            subnetId = ip.getSubnetId();
-            Subnetmap subnetmap = nvpnManager.removeFromSubnetNode(subnetId, null, null, null, port.getUuid());
-            if (vpnId == null && subnetmap != null) {
-                vpnId = subnetmap.getVpnId();
-            }
+        Subnetmap subnetmap = null;
+
+        // find the subnet to which this port is associated
+        FixedIps ip = port.getFixedIps().get(0);
+        String ipValue = ip.getIpAddress().getIpv4Address().getValue();
+        InstanceIdentifier id = NeutronvpnUtils.buildFixedIpToPortNameIdentifier(ipValue);
+        MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, id);
+        LOG.debug("fixedIp-name map for neutron port with fixedIp: {} deleted from NeutronPortData DS", ipValue);
+        subnetId = ip.getSubnetId();
+        subnetmap = nvpnManager.removeFromSubnetNode(subnetId, null, null, null, port.getUuid());
+        if (subnetmap != null) {
+            vpnId = subnetmap.getVpnId();
         }
         return vpnId;
     }
index 87803b969519ae33c561bd8cce443538e2194788..0cf6cccdc08aa163dd00065c540c6cbc3c6f9a00 100644 (file)
@@ -440,9 +440,9 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable {
         if (vpnId == null || port == null) {
             return;
         }
-        String portname = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
+        String infName = port.getUuid().getValue();
         List<Adjacency> adjList = new ArrayList<Adjacency>();
-        InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(portname);
+        InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(infName);
 
         // find router associated to vpn
         Uuid routerId = NeutronvpnUtils.getRouterforVpn(broker, vpnId);
@@ -463,7 +463,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable {
             // create extra route adjacency
             if (rtr != null && rtr.getRoutes() != null) {
                 List<Routes> routeList = rtr.getRoutes();
-                List<Adjacency> erAdjList = addAdjacencyforExtraRoute(routeList, false, portname);
+                List<Adjacency> erAdjList = addAdjacencyforExtraRoute(routeList, false, infName);
                 if (erAdjList != null && !erAdjList.isEmpty()) {
                     adjList.addAll(erAdjList);
                 }
@@ -471,19 +471,19 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable {
         }
         // create vpn-interface on this neutron port
         Adjacencies adjs = new AdjacenciesBuilder().setAdjacency(adjList).build();
-        VpnInterfaceBuilder vpnb = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(portname)).
-                setName(portname).setVpnInstanceName(vpnId.getValue()).addAugmentation(Adjacencies.class, adjs);
+        VpnInterfaceBuilder vpnb = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(infName)).
+                setName(infName).setVpnInstanceName(vpnId.getValue()).addAugmentation(Adjacencies.class, adjs);
         VpnInterface vpnIf = vpnb.build();
 
         try {
-            isLockAcquired = NeutronvpnUtils.lock(lockManager, portname);
+            isLockAcquired = NeutronvpnUtils.lock(lockManager, infName);
             logger.debug("Creating vpn interface {}", vpnIf);
             MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIf);
         } catch (Exception ex) {
-            logger.error("Creation of vpninterface {} failed due to {}", portname, ex);
+            logger.error("Creation of vpninterface {} failed due to {}", infName, ex);
         } finally {
             if (isLockAcquired) {
-                NeutronvpnUtils.unlock(lockManager, portname);
+                NeutronvpnUtils.unlock(lockManager, infName);
             }
         }
     }
@@ -492,18 +492,18 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable {
 
         if (port != null) {
             boolean isLockAcquired = false;
-            String pname = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
-            InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(pname);
+            String infName = port.getUuid().getValue();
+            InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(infName);
 
             try {
-                isLockAcquired = NeutronvpnUtils.lock(lockManager, pname);
-                logger.debug("Deleting vpn interface {}", pname);
+                isLockAcquired = NeutronvpnUtils.lock(lockManager, infName);
+                logger.debug("Deleting vpn interface {}", infName);
                 MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
             } catch (Exception ex) {
-                logger.error("Deletion of vpninterface {} failed due to {}", pname, ex);
+                logger.error("Deletion of vpninterface {} failed due to {}", infName, ex);
             } finally {
                 if (isLockAcquired) {
-                    NeutronvpnUtils.unlock(lockManager, pname);
+                    NeutronvpnUtils.unlock(lockManager, infName);
                 }
             }
         }
@@ -514,26 +514,25 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable {
             return;
         }
         boolean isLockAcquired = false;
-        String portname = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
-        String ifname = new StringBuilder(portname).append(":0").toString();
-        InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(ifname);
+        String infName = port.getUuid().getValue();
+        InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(infName);
         try {
             Optional<VpnInterface> optionalVpnInterface = NeutronvpnUtils.read(broker, LogicalDatastoreType
                     .CONFIGURATION, vpnIfIdentifier);
             if (optionalVpnInterface.isPresent()) {
                 VpnInterfaceBuilder vpnIfBuilder = new VpnInterfaceBuilder(optionalVpnInterface.get());
                 VpnInterface vpnIf = vpnIfBuilder.setVpnInstanceName(vpnId.getValue()).build();
-                isLockAcquired = NeutronvpnUtils.lock(lockManager, ifname);
+                isLockAcquired = NeutronvpnUtils.lock(lockManager, infName);
                 logger.debug("Updating vpn interface {}", vpnIf);
                 MDSALUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIf);
             } else {
-                logger.error("VPN Interface {} not found", ifname);
+                logger.error("VPN Interface {} not found", infName);
             }
         } catch (Exception ex) {
-            logger.error("Updation of vpninterface {} failed due to {}", ifname, ex);
+            logger.error("Updation of vpninterface {} failed due to {}", infName, ex);
         } finally {
             if (isLockAcquired) {
-                NeutronvpnUtils.unlock(lockManager, ifname);
+                NeutronvpnUtils.unlock(lockManager, infName);
             }
         }
     }
@@ -635,7 +634,10 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable {
                         vpnsIdentifier);
                 if (optionalVpns.isPresent() && optionalVpns.get().getVpnInstance() != null) {
                     for (VpnInstance vpn : optionalVpns.get().getVpnInstance()) {
-                        vpns.add(vpn);
+                        // eliminating internal VPNs from getL3VPN output
+                        if (vpn.getIpv4Family().getRouteDistinguisher() != null) {
+                            vpns.add(vpn);
+                        }
                     }
                 } else {
                     // No VPN present
@@ -800,38 +802,38 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable {
                 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,
-                        destination, tapPortName);
+                String infName = NeutronvpnUtils.getNeutronPortNamefromPortFixedIp(broker, nextHop);
+                logger.trace("Adding extra route with nexthop {}, destination {}, infName {}", nextHop,
+                        destination, infName);
                 Adjacency erAdj = new AdjacencyBuilder().setIpAddress(destination).setNextHopIp(nextHop).setKey
                         (new AdjacencyKey(destination)).build();
                 if (rtrUp == false) {
-                    if (tapPortName.equals(vpnifname)) {
+                    if (infName.equals(vpnifname)) {
                         adjList.add(erAdj);
                     }
                     continue;
                 }
                 InstanceIdentifier<VpnInterface> vpnIfIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).
-                        child(VpnInterface.class, new VpnInterfaceKey(tapPortName)).build();
+                        child(VpnInterface.class, new VpnInterfaceKey(infName)).build();
                 try {
                     Optional<VpnInterface> optionalVpnInterface = NeutronvpnUtils.read(broker, LogicalDatastoreType
                             .CONFIGURATION, vpnIfIdentifier);
                     if (optionalVpnInterface.isPresent()) {
                         Adjacencies erAdjs = new AdjacenciesBuilder().setAdjacency(Arrays.asList(erAdj)).build();
-                        VpnInterface vpnIf = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(tapPortName))
+                        VpnInterface vpnIf = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(infName))
                                 .addAugmentation(Adjacencies.class, erAdjs).build();
-                        isLockAcquired = NeutronvpnUtils.lock(lockManager, vpnifname);
+                        isLockAcquired = NeutronvpnUtils.lock(lockManager, infName);
                         logger.debug("Adding extra route {}", route);
                         MDSALUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIf);
                     } else {
                         logger.error("VM adjacency for interface {} not present ; cannot add extra route adjacency",
-                                tapPortName);
+                                infName);
                     }
                 } catch (Exception e) {
                     logger.error("exception in adding extra route: {}" + e);
                 } finally {
                     if (isLockAcquired) {
-                        NeutronvpnUtils.unlock(lockManager, vpnifname);
+                        NeutronvpnUtils.unlock(lockManager, infName);
                     }
                 }
             } else {
@@ -848,21 +850,21 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable {
                 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,
-                        destination, tapPortName);
+                String infName = NeutronvpnUtils.getNeutronPortNamefromPortFixedIp(broker, nextHop);
+                logger.trace("Removing extra route with nexthop {}, destination {}, infName {}", nextHop,
+                        destination, infName);
                 InstanceIdentifier<Adjacency> adjacencyIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).
-                        child(VpnInterface.class, new VpnInterfaceKey(tapPortName)).augmentation(Adjacencies.class)
+                        child(VpnInterface.class, new VpnInterfaceKey(infName)).augmentation(Adjacencies.class)
                         .child(Adjacency.class, new AdjacencyKey(destination)).build();
                 try {
-                    isLockAcquired = NeutronvpnUtils.lock(lockManager, tapPortName);
+                    isLockAcquired = NeutronvpnUtils.lock(lockManager, infName);
                     MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, adjacencyIdentifier);
                     logger.trace("extra route {} deleted successfully", route);
                 } catch (Exception e) {
                     logger.error("exception in deleting extra route: {}" + e);
                 } finally {
                     if (isLockAcquired) {
-                        NeutronvpnUtils.unlock(lockManager, tapPortName);
+                        NeutronvpnUtils.unlock(lockManager, infName);
                     }
                 }
             } else {
@@ -1255,18 +1257,18 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable {
 
     public List<String> showNeutronPortsCLI() {
         List<String> result = new ArrayList<String>();
-        result.add(String.format(" %-22s  %-22s  %-22s  %-6s ", "PortName", "Mac Address", "IP Address",
+        result.add(String.format(" %-34s  %-22s  %-22s  %-6s ", "PortName", "Mac Address", "IP Address",
                 "Prefix Length"));
         result.add("---------------------------------------------------------------------------------------");
         InstanceIdentifier<Ports> portidentifier = InstanceIdentifier.create(Neutron.class).child(Ports.class);
         try {
             Optional<Ports> ports = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, portidentifier);
-            if (ports.isPresent() && ports.get().getPort()!= null) {
+            if (ports.isPresent() && ports.get().getPort() != null) {
                 List<Port> portList = ports.get().getPort();
                 for (Port port : portList) {
-                    result.add(String.format(" %-22s  %-22s  %-22s  %-6s ", NeutronvpnUtils.uuidToTapPortName(port
-                            .getUuid()), port.getMacAddress(), port.getFixedIps().get(0).getIpAddress().getIpv4Address()
-                            .getValue(), NeutronvpnUtils.getIPPrefixFromPort(broker, port)));
+                    result.add(String.format(" %-34s  %-22s  %-22s  %-6s ", port.getUuid().getValue(), port
+                            .getMacAddress(), port.getFixedIps().get(0).getIpAddress().getIpv4Address().getValue(),
+                            NeutronvpnUtils.getIPPrefixFromPort(broker, port)));
                 }
             }
         } catch (Exception e) {
index f98e3fb78b6ee561c9de80e7397c1b54d46942e8..2443cb8a772d0f32d68f535e68092a6fff9eeb9b 100644 (file)
@@ -744,8 +744,8 @@ public class VpnInterfaceManager extends AbstractDataChangeListener<VpnInterface
             BigInteger dpnId = InterfaceUtils.getDpnForInterface(interfaceManager, intfName);
             String nextHopIp = InterfaceUtils.getEndpointIpAddressForDPN(broker, dpnId);
             if (nextHopIp == null && !nextHopIp.isEmpty()) {
-                LOG.error("NextHop for interface {} is null. Failed adding extra route for prefix {}", intfName, destination);
-                return;
+                LOG.error("NextHop for interface {} is null. Adding extra route {} without nextHop", intfName,
+                        destination);
             }
             nextHop = nextHopIp;
         }