/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015 - 2016 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,
*/
package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers;
+import com.google.common.base.Optional;
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;
public static List<ListenableFuture<Void>> removePortFromBridge(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
OvsdbBridgeAugmentation bridgeOld, DataBroker dataBroker) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
- WriteTransaction t = dataBroker.newWriteOnlyTransaction();;
+ WriteTransaction transaction = 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<BridgeRefEntry> bridgeEntryId =
- InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
- t.delete(LogicalDatastoreType.OPERATIONAL, bridgeEntryId);
- // FIX for ovsdb bug for delete TEP
- SouthboundUtils.deleteBridge(bridgeIid, dataBroker, futures);
+ //delete bridge reference entry in interface meta operational DS
+ InterfaceMetaUtils.deleteBridgeRefEntry(dpnId, transaction);
- futures.add(t.submit());
+ // Workaround for ovsdb bug for delete TEP..
+ Optional<OvsdbBridgeAugmentation> bridgeNodeOptional =
+ IfmUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker);
+ if (!bridgeNodeOptional.isPresent()) {
+ SouthboundUtils.deleteBridge(bridgeIid, dataBroker, futures);
+ }
+
+ futures.add(transaction.submit());
return futures;
}
}
\ No newline at end of file