X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=hwvtepsouthbound%2Fhwvtepsouthbound-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fovsdb%2Fhwvtepsouthbound%2FHwvtepDataChangeListener.java;h=141b280822355c326e7d494d6c40c3109e87bf52;hb=28ccde75af029995636db9b2c744d5f1c70148db;hp=17590fce02d4c565df9a0bd13526f8da368eed8f;hpb=4b59538666814a66dcfe8dcd34656a8afee46f65;p=ovsdb.git diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListener.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListener.java index 17590fce0..141b28082 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListener.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListener.java @@ -22,6 +22,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.Mod import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; +import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.ovsdb.hwvtepsouthbound.transact.HwvtepOperationalState; import org.opendaylight.ovsdb.hwvtepsouthbound.transact.TransactCommandAggregator; @@ -37,6 +38,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.base.Optional; + public class HwvtepDataChangeListener implements DataTreeChangeListener, AutoCloseable { private ListenerRegistration registration; @@ -121,7 +124,8 @@ public class HwvtepDataChangeListener implements DataTreeChangeListener, A Node node = getCreated(mod); if (node != null) { HwvtepGlobalAugmentation hwvtepGlobal = node.getAugmentation(HwvtepGlobalAugmentation.class); - if (hwvtepGlobal != null) { + // We can only connect if user configured connection info + if (hwvtepGlobal != null && hwvtepGlobal.getConnectionInfo() != null) { ConnectionInfo connection = hwvtepGlobal.getConnectionInfo(); InstanceIdentifier iid = hcm.getInstanceIdentifier(connection); if (iid != null) { @@ -148,7 +152,8 @@ public class HwvtepDataChangeListener implements DataTreeChangeListener, A Node original = getOriginal(mod); HwvtepGlobalAugmentation hgUpdated = updated.getAugmentation(HwvtepGlobalAugmentation.class); HwvtepGlobalAugmentation hgOriginal = original.getAugmentation(HwvtepGlobalAugmentation.class); - if (hgUpdated != null && hgOriginal != null) { + // Check if user has updated connection information + if (hgUpdated != null && hgOriginal != null && hgUpdated.getConnectionInfo() != null) { OvsdbClient client = hcm.getClient(hgUpdated.getConnectionInfo()); if (client == null) { try { @@ -264,6 +269,16 @@ public class HwvtepDataChangeListener implements DataTreeChangeListener, A //From original node to get connection instance Node node = mod.getDataBefore()!=null ? mod.getDataBefore() : mod.getDataAfter(); HwvtepConnectionInstance connection = hcm.getConnectionInstance(node); + if(connection == null) { + //Let us try getting it from Operational DS + final ReadWriteTransaction transaction = db.newReadWriteTransaction(); + InstanceIdentifier connectionIid = HwvtepSouthboundMapper.createInstanceIdentifier(node.getNodeId()); + Optional optionalNode = HwvtepSouthboundUtil.readNode(transaction, connectionIid); + LOG.trace("Node in Operational DataStore for user node {} is {}", node, optionalNode); + if(optionalNode.isPresent()) { + connection = hcm.getConnectionInstance(optionalNode.get()); + } + } if (connection != null) { if (!result.containsKey(connection)) { List> tempChanges= new ArrayList>();