package org.opendaylight.ovsdb.southbound.transactions.md;
+import com.google.common.base.Optional;
import java.util.List;
import java.util.Map;
-
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.ovsdb.lib.message.TableUpdates;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Optional;
-
public class OvsdbAutoAttachRemovedCommand extends AbstractTransactionCommand {
- private static final Logger LOG = LoggerFactory.getLogger(OvsdbQueueUpdateCommand.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OvsdbAutoAttachRemovedCommand.class);
private Map<UUID, AutoAttach> removedAutoAttachRows;
@Override
public void execute(ReadWriteTransaction transaction) {
+ if (removedAutoAttachRows == null || removedAutoAttachRows.isEmpty()) {
+ return;
+ }
+
final InstanceIdentifier<Node> nodeIId = getOvsdbConnectionInstance().getInstanceIdentifier();
final Optional<Node> ovsdbNode = SouthboundUtil.readNode(transaction, nodeIId);
- if (ovsdbNode.isPresent() && removedAutoAttachRows != null && !removedAutoAttachRows.isEmpty()) {
- InstanceIdentifier<Node> ovsdbNodeIid =
+ if (ovsdbNode.isPresent()) {
+ final InstanceIdentifier<Node> ovsdbNodeIid =
SouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance().getNodeId());
// FIXME: Iterate on external_ids instead of uuid when Open vSwitch supports external_ids column
- for (UUID autoAttachUuid : removedAutoAttachRows.keySet()) {
- AutoattachKey autoAttachKey = getAutoAttachKeyToRemove(ovsdbNode.get(), autoAttachUuid);
+ for (final UUID autoAttachUuid : removedAutoAttachRows.keySet()) {
+ final AutoattachKey autoAttachKey = getAutoAttachKeyToRemove(ovsdbNode.get(), autoAttachUuid);
if (autoAttachKey != null) {
- InstanceIdentifier<Autoattach> iid = ovsdbNodeIid
+ final InstanceIdentifier<Autoattach> iid = ovsdbNodeIid
.augmentation(OvsdbNodeAugmentation.class)
.child(Autoattach.class, autoAttachKey);
transaction.delete(LogicalDatastoreType.OPERATIONAL, iid);
}
private AutoattachKey getAutoAttachKeyToRemove(Node node, UUID autoAttachUuid) {
- List<Autoattach> autoAttachList = node.getAugmentation(OvsdbNodeAugmentation.class).getAutoattach();
+ final List<Autoattach> autoAttachList = node.getAugmentation(OvsdbNodeAugmentation.class).getAutoattach();
if (autoAttachList == null || autoAttachList.isEmpty()) {
return null;
}
- for (Autoattach autoAttach : autoAttachList) {
+ for (final Autoattach autoAttach : autoAttachList) {
if (autoAttach.getAutoattachUuid()
.equals(new Uuid(autoAttachUuid.toString()))) {
return autoAttach.getKey();