import static org.opendaylight.ovsdb.lib.operations.Operations.op;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepDeviceInfo;
import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundUtil;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.schema.hardwarevtep.McastMacsRemote;
import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsLocal;
import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsRemote;
+import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Optional;
-
public class LogicalSwitchRemoveCommand extends AbstractTransactCommand<LogicalSwitches, HwvtepGlobalAugmentation> {
private static final Logger LOG = LoggerFactory.getLogger(LogicalSwitchRemoveCommand.class);
if (removeds != null) {
for (Entry<InstanceIdentifier<Node>, List<LogicalSwitches>> created: removeds.entrySet()) {
if (!HwvtepSouthboundUtil.isEmpty(created.getValue())) {
- for (LogicalSwitches lswitch : created.getValue()) {
- InstanceIdentifier<LogicalSwitches> lsKey = created.getKey().augmentation(
- HwvtepGlobalAugmentation.class).child(LogicalSwitches.class, lswitch.getKey());
- updateCurrentTxDeleteData(LogicalSwitches.class, lsKey, lswitch);
- }
- getOperationalState().getDeviceInfo().scheduleTransaction(new TransactCommand() {
+ HwvtepConnectionInstance connectionInstance = getDeviceInfo().getConnectionInstance();
+ getDeviceInfo().scheduleTransaction(new TransactCommand() {
@Override
public void execute(TransactionBuilder transactionBuilder) {
+ HwvtepOperationalState operState = new HwvtepOperationalState(
+ connectionInstance.getDataBroker(), connectionInstance, Collections.EMPTY_LIST);
+ threadLocalOperationalState.set(operState);
+ threadLocalDeviceTransaction.set(transactionBuilder);
LOG.debug("Running delete logical switch in seperate tx {}", created.getKey());
removeLogicalSwitch(transactionBuilder, created.getKey(), created.getValue());
}
@Override
- public void onConfigUpdate(TransactionBuilder transaction, InstanceIdentifier nodeIid,
- Identifiable data, InstanceIdentifier key, Object... extraData) {
+ public void onSuccess(TransactionBuilder deviceTransaction) {
+ LogicalSwitchRemoveCommand.this.onSuccess(deviceTransaction);
}
@Override
- public void doDeviceTransaction(TransactionBuilder transaction, InstanceIdentifier nodeIid,
- Identifiable data, InstanceIdentifier key, Object... extraData) {
+ public void onFailure(TransactionBuilder deviceTransaction) {
+ LogicalSwitchRemoveCommand.this.onFailure(deviceTransaction);
}
});
}
McastMacsLocal.class, null);
transaction.add(op.delete(mcastMacsLocal.getSchema())
.where(mcastMacsLocal.getLogicalSwitchColumn().getSchema().opEqual(logicalSwitchUuid)).build());
- getOperationalState().getDeviceInfo().markKeyAsInTransit(RemoteMcastMacs.class, lsKey);
+ updateCurrentTxDeleteData(LogicalSwitches.class, lsKey, lswitch);
+ updateControllerTxHistory(TransactionType.DELETE, lswitch);
} else {
LOG.warn("Unable to delete logical switch {} because it was not found in the operational store",
lswitch.getHwvtepNodeName().getValue());
protected boolean isRemoveCommand() {
return true;
}
+
+ @Override
+ public void onCommandSucceeded() {
+ if (getDeviceTransaction() == null || !updates.containsKey(getDeviceTransaction())) {
+ return;
+ }
+ for (MdsalUpdate mdsalUpdate : updates.get(getDeviceTransaction())) {
+ getDeviceInfo().clearLogicalSwitchRefs((InstanceIdentifier<LogicalSwitches>) mdsalUpdate.getKey());
+ }
+ }
}