Use config for hwvtepsouthbound
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / main / java / org / opendaylight / ovsdb / hwvtepsouthbound / HwvtepSouthboundProvider.java
index 622ca0364d4fba724d73d68dad5e121a49f4611a..44a278911b7ee950527ee95559c8ad8ca47641ab 100644 (file)
@@ -56,9 +56,12 @@ public class HwvtepSouthboundProvider implements BindingAwareProvider, AutoClose
     private HwvtepDataChangeListener hwvtepDTListener;
 
     public HwvtepSouthboundProvider(
-            EntityOwnershipService entityOwnershipServiceDependency) {
+            EntityOwnershipService entityOwnershipServiceDependency,
+            OvsdbConnection ovsdbConnection) {
         this.entityOwnershipService = entityOwnershipServiceDependency;
         registration = null;
+        this.ovsdbConnection = ovsdbConnection;
+        LOG.info("HwvtepSouthboundProvider ovsdbConnectionService: {}", ovsdbConnection);
     }
 
     @Override
@@ -82,11 +85,8 @@ public class HwvtepSouthboundProvider implements BindingAwareProvider, AutoClose
             if (ownershipStateOpt.isPresent()) {
                 EntityOwnershipState ownershipState = ownershipStateOpt.get();
                 if (ownershipState.hasOwner() && !ownershipState.isOwner()) {
-                    if (ovsdbConnection == null) {
-                        ovsdbConnection = new OvsdbConnectionService();
-                        ovsdbConnection.registerConnectionListener(cm);
-                        ovsdbConnection.startOvsdbManager(HwvtepSouthboundConstants.DEFAULT_OVSDB_PORT);
-                    }
+                    ovsdbConnection.registerConnectionListener(cm);
+                    ovsdbConnection.startOvsdbManager(HwvtepSouthboundConstants.DEFAULT_OVSDB_PORT);
                 }
             }
         } catch (CandidateAlreadyRegisteredException e) {
@@ -164,12 +164,8 @@ public class HwvtepSouthboundProvider implements BindingAwareProvider, AutoClose
         } else {
             LOG.info("*This* instance of HWVTEP southbound provider is set as a SLAVE instance");
         }
-        //TODO: How to make this co-exist with OvsdbSouthbound?
-        if (ovsdbConnection == null) {
-            ovsdbConnection = new OvsdbConnectionService();
-            ovsdbConnection.registerConnectionListener(cm);
-            ovsdbConnection.startOvsdbManager(HwvtepSouthboundConstants.DEFAULT_OVSDB_PORT);
-        }
+        ovsdbConnection.registerConnectionListener(cm);
+        ovsdbConnection.startOvsdbManager(HwvtepSouthboundConstants.DEFAULT_OVSDB_PORT);
     }
 
     private class HwvtepsbPluginInstanceEntityOwnershipListener implements EntityOwnershipListener {