From ef619437380f4cd383a6727ea1eae74f1592326c Mon Sep 17 00:00:00 2001 From: Faseela K Date: Tue, 7 Aug 2018 20:55:12 +0530 Subject: [PATCH] COE external ip ping failure JIRA: NETVIRT-1396 Change-Id: Ib2d1ce72f2382978b132aaeaab90e4156e9de98b Signed-off-by: Faseela K --- coe/api/pom.xml | 9 +++++++ .../coe/api/SouthboundInterfaceInfo.java | 27 +++++++++++++++++++ .../TerminationPointStateListener.java | 26 +++++++++++------- .../netvirt/coe/utils/CoeUtils.java | 26 ++++++++++-------- .../resources/initial/netvirt-coe-config.xml | 2 +- 5 files changed, 68 insertions(+), 22 deletions(-) create mode 100644 coe/api/src/main/java/org/opendaylight/netvirt/coe/api/SouthboundInterfaceInfo.java diff --git a/coe/api/pom.xml b/coe/api/pom.xml index dc3f4b2983..67bc98cf8c 100644 --- a/coe/api/pom.xml +++ b/coe/api/pom.xml @@ -34,5 +34,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.yangtools yang-common + + org.immutables + value + + + org.opendaylight.genius + mdsalutil-api + ${genius.version} + 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 index 0000000000..69947af146 --- /dev/null +++ b/coe/api/src/main/java/org/opendaylight/netvirt/coe/api/SouthboundInterfaceInfo.java @@ -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 getInterfaceName(); + + + Optional getMacAddress(); + + + Optional getNodeIp(); + + Optional isServiceGateway(); +} diff --git a/coe/impl/src/main/java/org/opendaylight/netvirt/coe/listeners/TerminationPointStateListener.java b/coe/impl/src/main/java/org/opendaylight/netvirt/coe/listeners/TerminationPointStateListener.java index 82db927882..c311b628ed 100644 --- a/coe/impl/src/main/java/org/opendaylight/netvirt/coe/listeners/TerminationPointStateListener.java +++ b/coe/impl/src/main/java/org/opendaylight/netvirt/coe/listeners/TerminationPointStateListener.java @@ -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 tpNewDetails = CoeUtils.getAttachedInterfaceAndMac(tpNew); - Pair 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 interfaceNameOptional = tpNewDetails.getInterfaceName(); + Optional 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; diff --git a/coe/impl/src/main/java/org/opendaylight/netvirt/coe/utils/CoeUtils.java b/coe/impl/src/main/java/org/opendaylight/netvirt/coe/utils/CoeUtils.java index c38e8cb3c0..a6b22211dc 100644 --- a/coe/impl/src/main/java/org/opendaylight/netvirt/coe/utils/CoeUtils.java +++ b/coe/impl/src/main/java/org/opendaylight/netvirt/coe/utils/CoeUtils.java @@ -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 getAttachedInterfaceAndMac(OvsdbTerminationPointAugmentation ovsdbTp) { - String interfaceName = null; - String macAddress = null; + public static SouthboundInterfaceInfo getSouthboundInterfaceDetails(OvsdbTerminationPointAugmentation ovsdbTp) { + SouthboundInterfaceInfoBuilder southboundInterfaceInfoBuilder = new SouthboundInterfaceInfoBuilder(); if (ovsdbTp != null) { List 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 getPodMetaInstanceId(String externalInterfaceId) { diff --git a/coe/impl/src/main/resources/initial/netvirt-coe-config.xml b/coe/impl/src/main/resources/initial/netvirt-coe-config.xml index bde598ccf8..b4a08a45ca 100644 --- a/coe/impl/src/main/resources/initial/netvirt-coe-config.xml +++ b/coe/impl/src/main/resources/initial/netvirt-coe-config.xml @@ -1,3 +1,3 @@ kube-proxy - + \ No newline at end of file -- 2.36.6