/* * Copyright (c) 2015 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.vpnservice.interfacemgr.renderer.ovs.statehelpers; import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.vpnservice.interfacemgr.IfmUtil; import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils; import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.utilities.SouthboundUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntryKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; public class OvsInterfaceTopologyStateRemoveHelper { private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceTopologyStateRemoveHelper.class); public static List> removePortFromBridge(InstanceIdentifier bridgeIid, OvsdbBridgeAugmentation bridgeOld, DataBroker dataBroker) { List> futures = new ArrayList<>(); WriteTransaction t = dataBroker.newWriteOnlyTransaction();; BigInteger dpnId = IfmUtil.getDpnId(bridgeOld.getDatapathId()); if (dpnId == null) { LOG.warn("Got Null DPID for Bridge: {}", bridgeOld); return futures; } BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId); InstanceIdentifier bridgeEntryId = InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey); t.delete(LogicalDatastoreType.OPERATIONAL, bridgeEntryId); // FIX for ovsdb bug for delete TEP SouthboundUtils.deleteBridge(bridgeIid, dataBroker, futures); futures.add(t.submit()); return futures; } }