BUG 5366: SB and hwvtep don't work together 27/35527/1
authorVishal Thapar <vishal.thapar@ericsson.com>
Fri, 26 Feb 2016 16:49:45 +0000 (22:19 +0530)
committerSam Hague <shague@redhat.com>
Mon, 29 Feb 2016 03:24:47 +0000 (03:24 +0000)
This is a follow up patch for
https://git.opendaylight.org/gerrit/#/c/34913/

That patch didn't seem to fully fix the issue. Refer bugzilla for more
details.

Change-Id: Ia746fb2a15207d386978d6c6515cc34e336328cc
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManagerTest.java

index 1869f49df48afac12111bf984363399c6bfe54b3..76832944cc17e7034909c639f24c93cb371faf4f 100644 (file)
@@ -96,7 +96,14 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo
                 client.getConnectionInfo().getRemotePort(),
                 client.getConnectionInfo().getLocalAddress(),
                 client.getConnectionInfo().getLocalPort());
-        if(client.getSchema(HwvtepSchemaConstants.HARDWARE_VTEP) != null) {
+        List<String> databases = new ArrayList<>();
+        try {
+            databases = client.getDatabases().get();
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.warn("Unable to fetch database list");
+        }
+
+        if(databases.contains(HwvtepSchemaConstants.HARDWARE_VTEP)) {
             HwvtepConnectionInstance hwClient = connectedButCallBacksNotRegistered(client);
             registerEntityForOwnership(hwClient);
         }
index 153bab5fc3fa3955d7f1582413b50c73c26fb840..acb665a98c23a6fa0e7c6fbba9ccd674ede58d9c 100644 (file)
@@ -94,7 +94,14 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos
                 externalClient.getConnectionInfo().getRemotePort(),
                 externalClient.getConnectionInfo().getLocalAddress(),
                 externalClient.getConnectionInfo().getLocalPort());
-        if(externalClient.getSchema(SouthboundConstants.OPEN_V_SWITCH) != null) {
+        List<String> databases = new ArrayList<>();
+        try {
+            databases = externalClient.getDatabases().get();
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.warn("Unable to fetch database list");
+        }
+
+        if(databases.contains(SouthboundConstants.OPEN_V_SWITCH)) {
             OvsdbConnectionInstance client = connectedButCallBacksNotRegistered(externalClient);
             // Register Cluster Ownership for ConnectionInfo
             registerEntityForOwnership(client);
index a5f805a4d7134e648afdff1c3c84f14186aac302..8d3f625121bf715a626302ffef54e1aeed5a6332 100644 (file)
@@ -18,6 +18,8 @@ import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.times;
 
 import java.net.InetAddress;
+import java.util.Arrays;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -85,6 +87,8 @@ public class OvsdbConnectionManagerTest {
         when(externalClient.getConnectionInfo().getRemotePort()).thenReturn(8080);
         when(externalClient.getConnectionInfo().getLocalAddress()).thenReturn(mock(InetAddress.class));
         when(externalClient.getConnectionInfo().getLocalPort()).thenReturn(8080);
+        List<String> databases = Arrays.asList("Open_vSwitch");
+        when(externalClient.getDatabases().get()).thenReturn(databases);
 
         PowerMockito.mockStatic(SouthboundUtil.class);
         when(SouthboundUtil.connectionInfoToString(any(ConnectionInfo.class))).thenReturn("192.18.120.31:8080");