2 * Copyright (c) 2016 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.ovs.statehelpers;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.List;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
16 import org.opendaylight.genius.interfacemanager.IfmUtil;
17 import org.opendaylight.genius.interfacemanager.commons.InterfaceMetaUtils;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeRef;
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 public class OvsInterfaceTopologyStateRemoveHelper {
25 private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceTopologyStateRemoveHelper.class);
27 public static List<ListenableFuture<Void>> removePortFromBridge(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
28 OvsdbBridgeAugmentation bridgeOld, DataBroker dataBroker) {
29 List<ListenableFuture<Void>> futures = new ArrayList<>();
30 WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
31 BigInteger dpnId = IfmUtil.getDpnId(bridgeOld.getDatapathId());
34 LOG.warn("Got Null DPID for Bridge: {}", bridgeOld);
38 //delete bridge reference entry in interface meta operational DS
39 InterfaceMetaUtils.deleteBridgeRefEntry(dpnId, transaction);
41 // the bridge reference is copied to dpn-tunnel interfaces map, so that whenever a northbound delete
42 // happens when bridge is not connected, we need the bridge reference to clean up the topology config DS
43 InterfaceMetaUtils.addBridgeRefToBridgeInterfaceEntry(dpnId, new OvsdbBridgeRef(bridgeIid), transaction);
45 futures.add(transaction.submit());