2 * Copyright (c) 2015 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.vpnservice.interfacemgr.renderer.ovs.statehelpers;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
15 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntry;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntryKey;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 import java.math.BigInteger;
24 import java.util.ArrayList;
25 import java.util.List;
27 public class OvsInterfaceTopologyStateRemoveHelper {
28 private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceTopologyStateRemoveHelper.class);
30 public static List<ListenableFuture<Void>> removePortFromBridge(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
31 OvsdbBridgeAugmentation bridgeOld, DataBroker dataBroker) {
32 List<ListenableFuture<Void>> futures = new ArrayList<>();
33 WriteTransaction t = dataBroker.newWriteOnlyTransaction();;
34 BigInteger dpnId = IfmUtil.getDpnId(bridgeOld.getDatapathId());
37 LOG.warn("Got Null DPID for Bridge: {}", bridgeOld);
40 BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
41 InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
42 InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
43 t.delete(LogicalDatastoreType.OPERATIONAL, bridgeEntryId);
45 futures.add(t.submit());