BUG 8720: Add schema version information to Hwvtep node 09/59209/3
authorVishal Thapar <vishal.thapar@ericsson.com>
Tue, 20 Jun 2017 09:39:19 +0000 (15:09 +0530)
committerAnil Vishnoi <vishnoianil@gmail.com>
Thu, 29 Jun 2017 08:33:02 +0000 (08:33 +0000)
Schema version information now available in HwvtGlobalNode. Applications
can use this to determine version of Hwvtp schema DB on the device.

Change-Id: I3b6dd3b296c3b263520bb622f45dfdd7ee4c4e81
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
hwvtepsouthbound/hwvtepsouthbound-api/src/main/yang/hwvtep.yang
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/GlobalUpdateCommand.java

index 8f62a339c10dfc4edc1b1286021bcc156289492b..00ec9aa5f844c69f3e357b166c0633ad3b36fe77 100644 (file)
@@ -233,6 +233,10 @@ module hwvtep {
         container connection-info {
             uses hwvtep-connection-info-attributes;
         }
+        leaf db-version {
+            description "The database schema version";
+            type string;
+        }
         list managers {
             description "";
             key "target";
index db6796945ef644eb56c030df3645a6ea0d51f82c..9bb15b65a320f0094be7faafc6779b4ed550c6e9 100644 (file)
@@ -9,13 +9,15 @@
 package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
 
 import java.util.Map;
-
+import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSchemaConstants;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.notation.UUID;
+import org.opendaylight.ovsdb.lib.notation.Version;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.hardwarevtep.Global;
@@ -46,6 +48,13 @@ public class GlobalUpdateCommand extends AbstractTransactionCommand {
             LOG.trace("Processing hardware_vtep update for nodePath: {}", nodePath);
 
             HwvtepGlobalAugmentationBuilder hwvtepGlobalBuilder = new HwvtepGlobalAugmentationBuilder();
+            try {
+                Version version = getOvsdbConnectionInstance().getSchema(HwvtepSchemaConstants.HARDWARE_VTEP).get().getVersion();
+                hwvtepGlobalBuilder.setDbVersion(version.toString());
+            } catch (InterruptedException | ExecutionException e) {
+                LOG.debug("Failed to get schema version on {} due to {}",
+                        getOvsdbConnectionInstance().getConnectionInfo(), e.getMessage());
+            }
             hwvtepGlobalBuilder.setConnectionInfo(getConnectionInfo());
             NodeBuilder nodeBuilder = new NodeBuilder();
             nodeBuilder.setNodeId(getNodeId(hwvtepGlobal));