BUG 5549: HWVTEP exception when connecting to older devices 43/36743/1
authorVishal Thapar <vishal.thapar@ericsson.com>
Thu, 17 Mar 2016 15:41:23 +0000 (21:11 +0530)
committerSam Hague <shague@redhat.com>
Thu, 24 Mar 2016 13:53:51 +0000 (13:53 +0000)
Add a schema check for Tunnel table and columns.

Change-Id: I76a865589a1e685915f15fdf4acd859048cf4f02
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/PhysicalSwitchUpdateCommand.java

index 838ae9c8dac610a3cddd4b24fa0ce681bc894b26..f9c20e7272e37b68c42f5b486f31ca65a3776ce0 100644 (file)
@@ -21,6 +21,7 @@ import java.util.Set;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
+import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException;
 import org.opendaylight.ovsdb.lib.notation.Mutator;
 import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
@@ -84,8 +85,12 @@ public class PhysicalSwitchUpdateCommand extends AbstractTransactCommand {
         setDescription(physicalSwitch, physicalSwitchAugmentation);
         setManagementIps(physicalSwitch, physicalSwitchAugmentation);
         setTunnuleIps(physicalSwitch, physicalSwitchAugmentation);
-        setTunnels(transaction, iid, physicalSwitch, physicalSwitchAugmentation,
-                        operationalPhysicalSwitchOptional.isPresent());
+        try {
+            setTunnels(transaction, iid, physicalSwitch, physicalSwitchAugmentation,
+                            operationalPhysicalSwitchOptional.isPresent());
+        } catch (SchemaVersionMismatchException e) {
+            LOG.debug("tunnels table unsupported for this version of HWVTEP schema", e);
+        }
         if (!operationalPhysicalSwitchOptional.isPresent()) {
             //create a physical switch
             setName(physicalSwitch, physicalSwitchAugmentation, operationalPhysicalSwitchOptional);
index f474c8131093829498f51bb13921b2ca6f350d9e..992fb89aface3994f17919ce91f784c393220247 100644 (file)
@@ -73,8 +73,12 @@ public class PhysicalSwitchUpdateCommand extends AbstractTransactionCommand {
     public PhysicalSwitchUpdateCommand(HwvtepConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema) {
         super(key, updates, dbSchema);
         updatedPSRows = TyperUtils.extractRowsUpdated(PhysicalSwitch.class, getUpdates(), getDbSchema());
-        updatedTunnelRows = TyperUtils.extractRowsUpdated(Tunnel.class, getUpdates(), getDbSchema());
         updatedPLocRows = TyperUtils.extractRowsUpdated(PhysicalLocator.class, getUpdates(), getDbSchema());
+        try {
+            updatedTunnelRows = TyperUtils.extractRowsUpdated(Tunnel.class, getUpdates(), getDbSchema());
+        } catch (IllegalArgumentException e) {
+            LOG.debug("Tunnel Table not supported on this HWVTEP device", e.getMessage());
+        }
     }
 
     @Override
@@ -124,7 +128,7 @@ public class PhysicalSwitchUpdateCommand extends AbstractTransactionCommand {
 
     private void setTunnels(Node node, PhysicalSwitchAugmentationBuilder psAugmentationBuilder,
             PhysicalSwitch pSwitch) {
-        if (pSwitch.getTunnels() != null && pSwitch.getTunnels().getData() != null
+        if (updatedTunnelRows != null && pSwitch.getTunnels() != null && pSwitch.getTunnels().getData() != null
                 && !pSwitch.getTunnels().getData().isEmpty()) {
             Set<UUID> uuidList = pSwitch.getTunnels().getData();
             List<Tunnels> tunnelList = new ArrayList<>();