2 * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.genius.interfacemanager.renderer.hwvtep.confighelpers;
10 import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
11 import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
13 import com.google.common.util.concurrent.ListenableFuture;
14 import java.util.ArrayList;
15 import java.util.List;
16 import org.opendaylight.genius.infra.Datastore.Configuration;
17 import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
18 import org.opendaylight.genius.infra.TypedWriteTransaction;
19 import org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils;
20 import org.opendaylight.genius.interfacemanager.commons.InterfaceMetaUtils;
21 import org.opendaylight.genius.interfacemanager.renderer.hwvtep.utilities.SouthboundUtils;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel;
24 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
25 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
26 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 public final class HwVTEPConfigRemoveHelper {
32 private static final Logger LOG = LoggerFactory.getLogger(HwVTEPConfigRemoveHelper.class);
34 private HwVTEPConfigRemoveHelper() {
37 public static List<ListenableFuture<Void>> removeConfiguration(ManagedNewTransactionRunner txRunner,
38 Interface interfaceOld,
39 InstanceIdentifier<Node> physicalSwitchNodeId,
40 InstanceIdentifier<Node> globalNodeId) {
41 List<ListenableFuture<Void>> futures = new ArrayList<>();
42 LOG.info("removing hwvtep configuration for {}", interfaceOld.getName());
43 if (globalNodeId != null) {
44 IfTunnel ifTunnel = interfaceOld.augmentation(IfTunnel.class);
45 //removeTunnelTableEntry(defaultOperShardTransaction, ifTunnel, physicalSwitchNodeId);
46 // Topology configuration shard
47 futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
48 tx -> removeTerminationEndPoint(tx, ifTunnel, globalNodeId)));
49 // Default operational shard
50 futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> {
51 InterfaceManagerCommonUtils.deleteStateEntry(tx, interfaceOld.getName());
52 InterfaceMetaUtils.removeTunnelToInterfaceMap(physicalSwitchNodeId, tx, ifTunnel);
59 private static void removeTerminationEndPoint(TypedWriteTransaction<Configuration> transaction, IfTunnel ifTunnel,
60 InstanceIdentifier<Node> globalNodeId) {
61 LOG.info("removing remote termination end point {}", ifTunnel.getTunnelDestination());
62 TerminationPointKey tpKey = SouthboundUtils
63 .getTerminationPointKey(ifTunnel.getTunnelDestination().getIpv4Address().getValue());
64 InstanceIdentifier<TerminationPoint> tpPath = SouthboundUtils.createInstanceIdentifier(globalNodeId, tpKey);
65 transaction.delete(tpPath);