hwvtep disconnect command support 19/91819/6
authorChetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Mon, 3 Aug 2020 07:14:01 +0000 (12:44 +0530)
committerChetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Mon, 24 Aug 2020 15:08:30 +0000 (15:08 +0000)
Description:
when the command is fired it flaps the connection to the tor. The usage
is as below ex:

hwvtep:disconnect -nodeid hwvtep://uuid/19277da8-f85c-4ac8-af1b-9cffda7ef73d

Signed-off-by: Chetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Change-Id: I6e51d4858eb8887ea91659e0171268be50e64f90
Signed-off-by: Chetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
17 files changed:
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListener.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDeviceInfo.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDisconnectCliCmd.java [new file with mode: 0644]
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepTableReader.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/AbstractTransactCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchUcastsRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/resources/OSGI-INF/blueprint/hwvtepsouthbound.xml

index bc51ccc1db724afdb504c91594d877dc09a3c3e1..03fa9a6b57e7081e9c82158e515f2b80d355156f 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.net.ConnectException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
@@ -153,6 +154,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
     }
 
     @Override
+    @SuppressFBWarnings("REC_CATCH_EXCEPTION")
     @SuppressWarnings("checkstyle:IllegalCatch")
     public void disconnected(final OvsdbClient client) {
         alreadyProcessedClients.remove(client);
@@ -181,9 +183,14 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
                 // HWVTEP device.
                 if (hwvtepConnectionInstance.getHasDeviceOwnership()) {
                     unregisterEntityForOwnership(hwvtepConnectionInstance);
+                    LOG.info("Client disconnected from the Leader. Delete the Hvtep Node {} ",
+                        hwvtepConnectionInstance.getInstanceIdentifier());
                     txInvoker.invoke(new HwvtepGlobalRemoveCommand(hwvtepConnectionInstance, null, null));
                 } else {
                     unregisterEntityForOwnership(hwvtepConnectionInstance);
+                    LOG.info("Client disconnected from the Follower. Not deleteing the Hvtep Node {} ",
+                        hwvtepConnectionInstance.getInstanceIdentifier());
+
                     //Do not delete if client disconnected from follower HwvtepGlobalRemoveCommand
                 }
 
@@ -246,10 +253,10 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
         // In such cases, we will see if the hwvtepConnectionInstance has same externalClient.
         if (hwvtepConnectionInstance != null) {
             if (hwvtepConnectionInstance.hasOvsdbClient(externalClient)) {
-                LOG.warn("HWVTEP Connection Instance {} already exists for client {}", key, externalClient);
+                LOG.info("HWVTEP Connection Instance {} already exists for client {}", key, externalClient);
                 return hwvtepConnectionInstance;
             }
-            LOG.warn("HWVTEP Connection Instance {} being replaced with client {}", key, externalClient);
+            LOG.info("HWVTEP Connection Instance {} being replaced with client {}", key, externalClient);
             hwvtepConnectionInstance.disconnect();
 
             // Unregister Cluster Ownership for ConnectionInfo
@@ -290,6 +297,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
         PhysicalSwitchAugmentation switchNode = node.augmentation(PhysicalSwitchAugmentation.class);
         if (hwvtepGlobal != null) {
             if (hwvtepGlobal.getConnectionInfo() != null) {
+                LOG.debug("Get the ConnectionInfo from HwvtepGlobal {}", hwvtepGlobal.getConnectionInfo());
                 return getConnectionInstance(hwvtepGlobal.getConnectionInfo());
             } else {
                 //TODO: Case of user configured connection for now
@@ -298,6 +306,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
             }
         }
         else if (switchNode != null) {
+            LOG.debug("Get the ConnectionInfo from PhysicalSwitch");
             return getConnectionInstance(switchNode);
         } else {
             LOG.warn("This is not a node that gives any hint how to find its OVSDB Manager: {}",node);
@@ -321,6 +330,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
         }
         InstanceIdentifier<Node> globalNodeIid = HwvtepSouthboundUtil.getGlobalNodeIid(nodeIid);
         if (globalNodeIid != null) {
+            LOG.debug("Get the ConnectionInfo from HwvtepGlobal : {}", globalNodeIid);
             return nodeIidVsConnectionInstance.get(globalNodeIid);
         }
         return null;
@@ -395,6 +405,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
         Entity candidateEntity = getEntityFromConnectionInstance(hwvtepConnectionInstance);
         if (entityConnectionMap.get(candidateEntity) != null) {
             InstanceIdentifier<Node> iid = hwvtepConnectionInstance.getInstanceIdentifier();
+            LOG.info("Calling disconnect before processing new connection for {}", candidateEntity);
             disconnected(entityConnectionMap.get(candidateEntity).getOvsdbClient());
             hwvtepConnectionInstance.setInstanceIdentifier(iid);
             putConnectionInstance(hwvtepConnectionInstance.getInstanceIdentifier(), hwvtepConnectionInstance);
@@ -469,7 +480,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
         } else {
             globalRow = null;
         }
-        LOG.trace("Fetched global {} from hardware_vtep schema", globalRow);
+        LOG.info("Fetched global {} from hardware_vtep schema", globalRow);
         return globalRow;
     }
 
@@ -481,7 +492,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
             iid = HwvtepSouthboundMapper.getInstanceIdentifier(hwvtepGlobalRow);
             /* Let's set the iid now */
             hwvtepConnectionInstance.setInstanceIdentifier(iid);
-            LOG.info("InstanceIdentifier {} generated for device "
+            LOG.trace("InstanceIdentifier {} generated for device "
                     + "connection {}",iid, hwvtepConnectionInstance.getConnectionInfo());
             controllerTxHistory.putIfAbsent(iid,
                     new TransactionHistory(TRANSACTION_HISTORY_CAPACITY, TRANSACTION_HISTORY_WATERMARK));
@@ -600,7 +611,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
             // If entity has no owner, clean up the operational data store (it's possible because owner controller
             // might went down abruptly and didn't get a chance to clean up the operational data store.
             if (!ownershipChange.getState().hasOwner()) {
-                LOG.debug("{} has no owner, cleaning up the operational data store", ownershipChange.getEntity());
+                LOG.info("{} has no owner, cleaning up the operational data store", ownershipChange.getEntity());
                 // Below code might look weird but it's required. We want to give first opportunity to the
                 // previous owner of the device to clean up the operational data store if there is no owner now.
                 // That way we will avoid lot of nasty md-sal exceptions because of concurrent delete.
index 6da333d6b5f1557e8e266e7256c2621216104815..232fdf56f3b2a3c66afc0df26d5d7608efc5f407 100644 (file)
@@ -16,12 +16,14 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.concurrent.ExecutionException;
 import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.DataObjectModification;
 import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
 import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transact.HwvtepOperationalState;
 import org.opendaylight.ovsdb.hwvtepsouthbound.transact.TransactCommandAggregator;
@@ -29,9 +31,11 @@ import org.opendaylight.ovsdb.lib.OvsdbClient;
 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.ConnectionInfo;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
@@ -81,33 +85,8 @@ public class HwvtepDataChangeListener implements ClusteredDataTreeChangeListener
         updateData(changes);
 
         disconnect(changes);
-        /*
-        for (DataTreeModification<Node> change : changes) {
-            final InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier();
-            final DataObjectModification<Node> mod = change.getRootNode();
-                switch (mod.getModificationType()) {
-                case DELETE:
-                    LOG.trace("Data deleted: {}", mod.getDataBefore());
-                    //disconnect(mod);
-                    break;
-                case SUBTREE_MODIFIED:
-                    LOG.trace("Data modified: {} to {}", mod.getDataBefore(),mod.getDataAfter());
-                    updateConnections(mod);
-                    break;
-                case WRITE:
-                    if (mod.getDataBefore() == null) {
-                        LOG.trace("Data added: {}", mod.getDataAfter());
-                        connect(mod.getDataAfter());
-                    } else {
-                        LOG.trace("Data modified: {} to {}", mod.getDataBefore(),mod.getDataAfter());
-                        updateConnections(mod);
-                    }
-                    break;
-                default:
-                    throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
-                }
-        }
-        */
+
+        disconnectViaCli(changes);
     }
 
     private void connect(Collection<DataTreeModification<Node>> changes) {
@@ -281,4 +260,37 @@ public class HwvtepDataChangeListener implements ClusteredDataTreeChangeListener
         LOG.trace("Connection Change Map: {}", result);
         return result;
     }
+
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    private void disconnectViaCli(Collection<DataTreeModification<Node>> changes) {
+        for (DataTreeModification<Node> change : changes) {
+            String nodeId = change.getRootPath().getRootIdentifier().firstKeyOf(Node.class).getNodeId().getValue();
+            if (!nodeId.contains("/disconnect")) {
+                continue;
+            }
+            int reconcileIndex = nodeId.indexOf("/disconnect");
+            String globalNodeId = nodeId.substring(0, reconcileIndex);
+            InstanceIdentifier<Node> globalNodeIid = change.getRootPath()
+                .getRootIdentifier().firstIdentifierOf(Topology.class)
+                .child(Node.class, new NodeKey(new NodeId(globalNodeId)));
+            HwvtepConnectionInstance connectionInstance = hcm.getConnectionInstanceFromNodeIid(globalNodeIid);
+            if (connectionInstance != null) {
+                LOG.error("Disconnecting from controller {}", nodeId);
+                new Thread(() -> {
+                    ReadWriteTransaction tx = db.newReadWriteTransaction();
+                    tx.delete(LogicalDatastoreType.CONFIGURATION, change.getRootPath().getRootIdentifier());
+                    try {
+                        tx.commit().get();
+                    } catch (ExecutionException | InterruptedException e) {
+                        LOG.error("Failed to delete the node {}", change.getRootPath().getRootIdentifier());
+                    }
+                }).start();
+                try {
+                    connectionInstance.disconnect();
+                } catch (Exception e) {
+                    LOG.debug("Failed to disconnect");
+                }
+            }
+        }
+    }
 }
index 6c846a9a9c766bfeb9e26a59fab6e471d3e5b205..d58d31ee8b414f8d325441036db4ee5ebb514681 100644 (file)
@@ -262,6 +262,7 @@ public class HwvtepDeviceInfo {
         if (deviceData != null) {
             uuid = deviceData.getUuid();
             data = deviceData.getData();
+            LOG.trace("Uuid already present for the key going in transit {}", key);
         }
         HwvtepSouthboundUtil.updateData(opKeyVsData, cls, key,
                 new DeviceData(key, uuid, data, DeviceDataStatus.IN_TRANSIT));
diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDisconnectCliCmd.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDisconnectCliCmd.java
new file mode 100644 (file)
index 0000000..af66d04
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2020 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.ovsdb.hwvtepsouthbound;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+@Command(scope = "hwvtep", name = "disconnect", description = "Disconnect a node")
+public class HwvtepDisconnectCliCmd extends OsgiCommandSupport {
+
+    private DataBroker dataBroker;
+
+    @Option(name = "-nodeid", description = "Node Id",
+        required = false, multiValued = false)
+    String nodeid;
+
+    public static final TopologyId HWVTEP_TOPOLOGY_ID = new TopologyId(new Uri("hwvtep:1"));
+
+    public void setDataBroker(DataBroker dataBroker) {
+        this.dataBroker = dataBroker;
+    }
+
+    @Override
+    @SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
+    protected Object doExecute() throws Exception {
+        ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
+        tx.put(LogicalDatastoreType.CONFIGURATION, getIid(),
+            new NodeBuilder().setNodeId(new NodeId(new Uri(nodeid + "/disconnect"))).build());
+        tx.commit().get();
+        session.getConsole().println("Successfully disconnected " + nodeid);
+        return "";
+    }
+
+    private InstanceIdentifier<Node> getIid() {
+        NodeId nodeId = new NodeId(new Uri(nodeid + "/disconnect"));
+        NodeKey nodeKey = new NodeKey(nodeId);
+        TopologyKey topoKey = new TopologyKey(HWVTEP_TOPOLOGY_ID);
+        return InstanceIdentifier.builder(NetworkTopology.class)
+            .child(Topology.class, topoKey)
+            .child(Node.class, nodeKey)
+            .build();
+    }
+}
index 9402402278633cb546b63b9cb95a21b9d960fca6..46bb1bfe729e6ed5ff31b5599fd6c83a35aae819 100644 (file)
@@ -61,6 +61,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hw
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.Identifiable;
@@ -166,7 +167,7 @@ public class HwvtepTableReader {
                     .getValue();
             UUID lsUUID = getLsUuid(lsIid);
             if (lsUUID == null) {
-                LOG.warn("Could not find uuid for ls key {}", lsIid);
+                LOG.warn("Could not find uuid for ls key {}", getNodeKeyStr(lsIid));
                 return null;
             }
 
@@ -176,6 +177,15 @@ public class HwvtepTableReader {
         }
     }
 
+    protected <T extends DataObject> String getNodeKeyStr(InstanceIdentifier<T> iid) {
+        return iid.firstKeyOf(Node.class).getNodeId().getValue() + "." + getLsKeyStr(iid);
+    }
+
+    protected <T extends DataObject> String getLsKeyStr(InstanceIdentifier<T> iid) {
+        return ((InstanceIdentifier<LogicalSwitches>)iid).firstKeyOf(LogicalSwitches.class)
+            .getHwvtepNodeName().getValue();
+    }
+
     public UUID getLsUuid(InstanceIdentifier lsIid) {
         UUID lsUUID = connectionInstance.getDeviceInfo().getUUID(LogicalSwitches.class, lsIid);
         if (lsUUID == null) {
index fc534ef5d4015398c976d25a76f6bfcf48ecdf36..ee23847342f5e565c77a26c77cba176c46f231d6 100644 (file)
@@ -36,13 +36,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hw
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.Identifiable;
 import org.opendaylight.yangtools.yang.binding.Identifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public abstract class AbstractTransactCommand<T extends Identifiable<I>, I extends Identifier<T>,
+public abstract class AbstractTransactCommand<T extends Identifiable<I> & DataObject, I extends Identifier<T>,
         A extends Augmentation<Node>> implements TransactCommand<T> {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractTransactCommand.class);
@@ -127,7 +128,7 @@ public abstract class AbstractTransactCommand<T extends Identifiable<I>, I exten
                 inTransitDependencies.put(classType, Lists.newArrayList(key));
             }
         }
-        LOG.info("Update received for key: {} txId: {}", key, getOperationalState().getTransactionId());
+        LOG.info("Update received for key: {} txId: {}", getNodeKeyStr(key), getOperationalState().getTransactionId());
         if (HwvtepSouthboundUtil.isEmptyMap(confingDependencies)
                 && HwvtepSouthboundUtil.isEmptyMap(inTransitDependencies)) {
             doDeviceTransaction(transaction, nodeIid, data, key, extraData);
@@ -205,7 +206,7 @@ public abstract class AbstractTransactCommand<T extends Identifiable<I>, I exten
                     clone.onSuccess(transaction);
                 }
             };
-            LOG.info("Update Adding to op wait queue for key: {} txId: {}", key, transactionId);
+            LOG.info("Update Adding to op wait queue for key: {} txId: {}", getNodeKeyStr(key), transactionId);
             addJobToQueue(opWaitingJob);
             return;
         }
@@ -441,24 +442,20 @@ public abstract class AbstractTransactCommand<T extends Identifiable<I>, I exten
             final InstanceIdentifier key) {
         HwvtepDeviceInfo.DeviceData deviceData  = getDeviceOpData(cls, key);
         if (deviceData == null) {
-            LOG.debug("Could not find data for key {}", key);
+            LOG.debug("Could not find data for key {}", getNodeKeyStr(key));
             java.util.Optional<TypedBaseTable> optional =
                     getTableReader().getHwvtepTableEntryUUID(cls, key, null);
             if (optional.isPresent()) {
-                LOG.debug("Found the data for key from device {} ", key);
+                LOG.debug("Found the data for key from device {} ", getNodeKeyStr(key));
                 getDeviceInfo().updateDeviceOperData(cls, key, optional.get().getUuid(), optional.get());
                 return getDeviceOpData(cls, key);
             } else {
-                LOG.info("Could not Find the data for key from device {} ", key);
+                LOG.info("Could not Find the data for key from device {} ", getNodeKeyStr(key));
             }
         }
         return deviceData;
     }
 
-    protected String getKeyStr(final InstanceIdentifier iid) {
-        return iid.toString();
-    }
-
     public <K extends Identifiable> void addJobToQueue(final DependentJob<K> job) {
         hwvtepOperationalState.getDeviceInfo().putKeyInDependencyQueue(job.getKey());
         hwvtepOperationalState.getDeviceInfo().addJobToQueue(job);
@@ -509,4 +506,18 @@ public abstract class AbstractTransactCommand<T extends Identifiable<I>, I exten
     public HwvtepOperationalState newOperState() {
         return new HwvtepOperationalState(getConnectionInstance());
     }
+
+    protected String getNodeKeyStr(InstanceIdentifier<T> iid) {
+        return getClassType().getTypeName() + "."
+            + iid.firstKeyOf(Node.class).getNodeId().getValue() + "." + getKeyStr(iid);
+    }
+
+    protected String getKeyStr(InstanceIdentifier<T> iid) {
+        return iid.toString();
+    }
+
+    protected String getLsKeyStr(InstanceIdentifier iid) {
+        return ((InstanceIdentifier<LogicalSwitches>)iid).firstKeyOf(LogicalSwitches.class)
+            .getHwvtepNodeName().getValue();
+    }
 }
index edc3a401c3dc2f430e64d127e9349a3a6ea7c0c1..5a3ad082e8f9e78d0f626acfe9846c903ac528af 100644 (file)
@@ -91,4 +91,9 @@ public class LogicalSwitchRemoveCommand
             getDeviceInfo().clearLogicalSwitchRefs(mdsalUpdate.getKey());
         }
     }
+
+    @Override
+    protected String getKeyStr(InstanceIdentifier<LogicalSwitches> iid) {
+        return iid.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue();
+    }
 }
index de480398606466b93cc47263af13851ac4afd88c..af926e39276194d6a679de950dc80f8fc3e6f7de 100644 (file)
@@ -211,4 +211,8 @@ public class LogicalSwitchUcastsRemoveCommand
         return true;
     }
 
+    @Override
+    protected String getKeyStr(InstanceIdentifier<LogicalSwitches> iid) {
+        return iid.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue();
+    }
 }
index 9cc3e24ba7865bb1d44e020d8c0f461efb50e39f..2538c0716c78fb3966bc0b066b88095769e92611 100644 (file)
@@ -150,4 +150,9 @@ public class LogicalSwitchUpdateCommand
     protected boolean areEqual(final LogicalSwitches sw1, final LogicalSwitches sw2) {
         return sw1.key().equals(sw2.key()) && Objects.equals(sw1.getTunnelKey(), sw2.getTunnelKey());
     }
+
+    @Override
+    protected String getKeyStr(InstanceIdentifier<LogicalSwitches> iid) {
+        return iid.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue();
+    }
 }
index 06a23fa6cce6d863a7b42da1525a78c7b33a5ba4..bd0488ed7349c873a9569e0bed5b8c2296cfc204 100644 (file)
@@ -103,4 +103,9 @@ public class McastMacsLocalRemoveCommand
     protected boolean isDeleteCmd() {
         return true;
     }
+
+    @Override
+    protected String getKeyStr(InstanceIdentifier<LocalMcastMacs> iid) {
+        return getLsKeyStr(iid.firstKeyOf(LocalMcastMacs.class).getLogicalSwitchRef().getValue());
+    }
 }
index cea7da1831cc043ec384cbbb202af8c544c11d97..dd345879c99728794b3ed5adf29fbd6bcdaf13c5 100644 (file)
@@ -133,4 +133,9 @@ public class McastMacsLocalUpdateCommand
     protected Map<LocalMcastMacsKey, LocalMcastMacs> getData(final HwvtepGlobalAugmentation augmentation) {
         return augmentation.getLocalMcastMacs();
     }
+
+    @Override
+    protected String getKeyStr(InstanceIdentifier<LocalMcastMacs> iid) {
+        return getLsKeyStr(iid.firstKeyOf(LocalMcastMacs.class).getLogicalSwitchRef().getValue());
+    }
 }
index bf162ea45812733fbff5b2a9439467e0f1919561..12db813a370365798b63e6de43a6759c8de6fa91 100644 (file)
@@ -149,4 +149,8 @@ public class McastMacsRemoteRemoveCommand
         return true;
     }
 
+    @Override
+    protected String getKeyStr(InstanceIdentifier<RemoteMcastMacs> iid) {
+        return getLsKeyStr(iid.firstKeyOf(RemoteMcastMacs.class).getLogicalSwitchRef().getValue());
+    }
 }
index 7b46ca84949e61e832930b8d9bad317c87d7204e..d519a53a7cbfe3280dfb3fffe9260182ef14dd9a 100644 (file)
@@ -247,4 +247,8 @@ public class McastMacsRemoteUpdateCommand
         }
     }
 
+    @Override
+    protected String getKeyStr(InstanceIdentifier<RemoteMcastMacs> iid) {
+        return getLsKeyStr(iid.firstKeyOf(RemoteMcastMacs.class).getLogicalSwitchRef().getValue());
+    }
 }
index 0e05daa7f11911077fc528e286161adaef6e0323..ccb71371e298910287c184f00fa78acce278758f 100644 (file)
@@ -122,7 +122,7 @@ public class PhysicalPortUpdateCommand
             LOG.warn("Port not present in opdata store {}", key);
         } else {
             if (deviceData.getData() == null || !(deviceData.getData() instanceof PhysicalPort)) {
-                LOG.error("Failed to get the device data for port {}", key);
+                LOG.error("Failed to get the device data for port {}", getKeyStr(key));
             }
             Map<Long, UUID> bindingMap = setVlanBindings(nodeIid, physicalPort, data, key, transaction);
             PhysicalPort tp = (PhysicalPort) deviceData.getData();
index 0e87fcc52eb340b4fbbf6f33743608662753d21a..8be5952fe9028ab60d11cdd1ed6eb3a8e9665b50 100644 (file)
@@ -154,4 +154,8 @@ public class UcastMacsRemoteRemoveCommand
         return true;
     }
 
+    @Override
+    protected String getKeyStr(InstanceIdentifier<RemoteUcastMacs> iid) {
+        return getLsKeyStr(iid.firstKeyOf(RemoteUcastMacs.class).getLogicalSwitchRef().getValue());
+    }
 }
index 58f353911812a547d485efa6005195c87d900775..ce418363c4a9a05b32ad632431a258e68e396293 100644 (file)
@@ -128,7 +128,7 @@ public class UcastMacsRemoteUpdateCommand
             addToUpdates(macKey, remoteUcastMac);
         } else {
             LOG.warn("Unable to update remoteUcastMacs {} because uuid not found in the operational store txId: {}",
-                    macKey, getOperationalState().getTransactionId());
+                getNodeKeyStr(macKey)   , getOperationalState().getTransactionId());
         }
         return;
     }
@@ -212,4 +212,9 @@ public class UcastMacsRemoteUpdateCommand
                     (InstanceIdentifier<LogicalSwitches>) mac.getLogicalSwitchRef().getValue(), macIid, mac);
         }
     }
+
+    @Override
+    protected String getKeyStr(InstanceIdentifier<RemoteUcastMacs> iid) {
+        return getLsKeyStr(iid.firstKeyOf(RemoteUcastMacs.class).getLogicalSwitchRef().getValue());
+    }
 }
index 7c6c2b53de46bfe8df1c7e1a6fba01097ef18f10..f9eabbb8e7265d5d5692fcb6ef7c525e77a9956b 100644 (file)
             <argument ref="hwvtepSouthboundProvider" />
         </action>
     </command>
+    <command>
+        <action class="org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepDisconnectCliCmd">
+            <property name="dataBroker" ref="dataBroker" />
+        </action>
+    </command>
     </command-bundle>
 </blueprint>