COE external ip ping failure 22/74922/8
authorFaseela K <faseela.k@ericsson.com>
Tue, 7 Aug 2018 15:25:12 +0000 (20:55 +0530)
committerSam Hague <shague@redhat.com>
Thu, 9 Aug 2018 16:03:31 +0000 (16:03 +0000)
JIRA: NETVIRT-1396

Change-Id: Ib2d1ce72f2382978b132aaeaab90e4156e9de98b
Signed-off-by: Faseela K <faseela.k@ericsson.com>
coe/api/pom.xml
coe/api/src/main/java/org/opendaylight/netvirt/coe/api/SouthboundInterfaceInfo.java [new file with mode: 0644]
coe/impl/src/main/java/org/opendaylight/netvirt/coe/listeners/TerminationPointStateListener.java
coe/impl/src/main/java/org/opendaylight/netvirt/coe/utils/CoeUtils.java
coe/impl/src/main/resources/initial/netvirt-coe-config.xml

index dc3f4b29836fd08a240c231bf0f074038bc9e85a..67bc98cf8cd2f9fbbadd0ff8c2ca19ebbac7a241 100644 (file)
@@ -34,5 +34,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-common</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.immutables</groupId>
+            <artifactId>value</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.genius</groupId>
+            <artifactId>mdsalutil-api</artifactId>
+            <version>${genius.version}</version>
+        </dependency>
     </dependencies>
 </project>
diff --git a/coe/api/src/main/java/org/opendaylight/netvirt/coe/api/SouthboundInterfaceInfo.java b/coe/api/src/main/java/org/opendaylight/netvirt/coe/api/SouthboundInterfaceInfo.java
new file mode 100644 (file)
index 0000000..69947af
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2018 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.netvirt.coe.api;
+
+import java.util.Optional;
+import org.immutables.value.Value;
+import org.opendaylight.genius.infra.OpenDaylightImmutableStyle;
+
+@Value.Immutable
+@OpenDaylightImmutableStyle
+public interface SouthboundInterfaceInfo {
+
+    Optional<String> getInterfaceName();
+
+
+    Optional<String> getMacAddress();
+
+
+    Optional<String> getNodeIp();
+
+    Optional<Boolean> isServiceGateway();
+}
index 82db9278827750d0429ea6ec52e3d3f53e8fd62d..c311b628edc9614e8a4a3f9f43a19808a77a57e4 100644 (file)
@@ -13,10 +13,10 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 import javax.annotation.Nullable;
 import javax.inject.Inject;
 import javax.inject.Singleton;
-import org.apache.commons.lang3.tuple.Pair;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
@@ -29,6 +29,7 @@ import org.opendaylight.genius.mdsalutil.NwConstants;
 import org.opendaylight.genius.utils.ServiceIndex;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
 import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
+import org.opendaylight.netvirt.coe.api.SouthboundInterfaceInfo;
 import org.opendaylight.netvirt.coe.caches.PodsCache;
 import org.opendaylight.netvirt.coe.utils.CoeUtils;
 import org.opendaylight.serviceutils.tools.mdsal.listener.AbstractSyncDataTreeChangeListener;
@@ -80,13 +81,16 @@ public class TerminationPointStateListener extends
     public void update(@Nullable OvsdbTerminationPointAugmentation tpOld, OvsdbTerminationPointAugmentation tpNew) {
         LOG.debug("Received Update DataChange Notification for ovsdb termination point {}", tpNew.getName());
 
-        Pair<String, String> tpNewDetails = CoeUtils.getAttachedInterfaceAndMac(tpNew);
-        Pair<String, String> tpOldDetails = CoeUtils.getAttachedInterfaceAndMac(tpOld);
+        SouthboundInterfaceInfo tpNewDetails = CoeUtils.getSouthboundInterfaceDetails(tpNew);
+        SouthboundInterfaceInfo tpOldDetails = CoeUtils.getSouthboundInterfaceDetails(tpOld);
 
         if (!Objects.equals(tpNewDetails, tpOldDetails)) {
-            String interfaceName = tpNewDetails.getLeft();
-            String macAddress = tpNewDetails.getRight();
-            if (interfaceName != null && macAddress != null) {
+            Optional<String> interfaceNameOptional = tpNewDetails.getInterfaceName();
+            Optional<String> macAddressOptional = tpNewDetails.getMacAddress();
+            if (interfaceNameOptional.isPresent() && macAddressOptional.isPresent()) {
+                String interfaceName = interfaceNameOptional.get();
+                String macAddress =  macAddressOptional.get();
+                boolean isServiceGateway = tpNewDetails.isServiceGateway().orElse(false);
                 LOG.debug("Detected external interface-id {} and attached mac address {} for {}", interfaceName,
                         macAddress, tpNew.getName());
                 eventCallbacks.onAddOrUpdate(LogicalDatastoreType.OPERATIONAL,
@@ -100,12 +104,14 @@ public class TerminationPointStateListener extends
                                 Pods pods = podsCache.get(instanceIdentifier).get();
                                 if (pods != null) {
                                     IpAddress podIpAddress = pods.getInterface().get(0).getIpAddress();
-                                    CoeUtils.createVpnInterface(pods.getNetworkNS(), pods, interfaceName, macAddress,
-                                            false, tx);
                                     CoeUtils.updateElanInterfaceWithStaticMac(macAddress, podIpAddress,
                                             interfaceName, tx);
-                                    LOG.debug("Bind Kube Proxy Service for {}", interfaceName);
-                                    bindKubeProxyService(tx, interfaceName);
+                                    if (!isServiceGateway) {
+                                        CoeUtils.createVpnInterface(pods.getNetworkNS(), pods, interfaceName,
+                                                macAddress,false, tx);
+                                        LOG.debug("Bind Kube Proxy Service for {}", interfaceName);
+                                        bindKubeProxyService(tx, interfaceName);
+                                    }
                                 }
                             }), LOG, "Error handling pod configuration for termination-point");
                         return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
index c38e8cb3c0643fcd99a1d6c1b60640f947730be6..a6b22211dc9d5773f1200de167ebad62e60cdd83 100644 (file)
@@ -16,8 +16,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
-
-import org.apache.commons.lang3.tuple.Pair;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
@@ -27,6 +25,8 @@ import org.opendaylight.genius.infra.Datastore;
 import org.opendaylight.genius.infra.TypedReadWriteTransaction;
 import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.genius.mdsalutil.NwConstants;
+import org.opendaylight.netvirt.coe.api.SouthboundInterfaceInfo;
+import org.opendaylight.netvirt.coe.api.SouthboundInterfaceInfoBuilder;
 import org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice;
 import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInstances;
 import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInterfaces;
@@ -275,31 +275,35 @@ public final class CoeUtils {
         return elanInstance;
     }
 
-    public static Pair<String, String> getAttachedInterfaceAndMac(OvsdbTerminationPointAugmentation ovsdbTp) {
-        String interfaceName = null;
-        String macAddress = null;
+    public static SouthboundInterfaceInfo getSouthboundInterfaceDetails(OvsdbTerminationPointAugmentation ovsdbTp) {
+        SouthboundInterfaceInfoBuilder southboundInterfaceInfoBuilder = new SouthboundInterfaceInfoBuilder();
         if (ovsdbTp != null) {
             List<InterfaceExternalIds> ifaceExtIds = ovsdbTp.getInterfaceExternalIds();
             if (ifaceExtIds != null) {
                 Iterator var2 = ifaceExtIds.iterator();
                 while (var2.hasNext()) {
-                    if (interfaceName != null && macAddress != null) {
-                        break;
-                    }
                     InterfaceExternalIds entry = (InterfaceExternalIds)var2.next();
                     if (entry.getExternalIdKey().equals("iface-id")) {
-                        interfaceName = entry.getExternalIdValue();
+                        southboundInterfaceInfoBuilder.setInterfaceName(entry.getExternalIdValue());
                         continue;
                     }
                     if (entry.getExternalIdKey().equals("attached-mac")) {
-                        macAddress = entry.getExternalIdValue();
+                        southboundInterfaceInfoBuilder.setMacAddress(entry.getExternalIdValue());
+                        continue;
+                    }
+                    if (entry.getExternalIdKey().equals("ip-address")) {
+                        southboundInterfaceInfoBuilder.setNodeIp(entry.getExternalIdValue());
+                        continue;
+                    }
+                    if (entry.getExternalIdKey().equals("is-service-gateway")) {
+                        southboundInterfaceInfoBuilder.setIsServiceGateway(true);
                         continue;
                     }
                 }
             }
         }
 
-        return Pair.of(interfaceName, macAddress);
+        return southboundInterfaceInfoBuilder.build();
     }
 
     public static InstanceIdentifier<PodIdentifier> getPodMetaInstanceId(String externalInterfaceId) {
index bde598ccf8091846b0eb7a383ff89b62ef8c0014..b4a08a45cacac7191d5c822e714b2851a6b1cbc3 100644 (file)
@@ -1,3 +1,3 @@
 <coe-config xmlns="urn:opendaylight:netvirt:coe:config">
   <service-implementation-mode>kube-proxy</service-implementation-mode>
-</coe-config>
+</coe-config>
\ No newline at end of file