<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>
--- /dev/null
+/*
+ * 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();
+}
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;
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;
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,
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;
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;
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;
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) {
<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