Moving the connection manager NB-API from the network configuration APIs to connectio...
[controller.git] / opendaylight / connectionmanager / implementation / src / main / java / org / opendaylight / controller / connectionmanager / internal / ConnectionManager.java
index 2d5f80fb79f99365544680e77df45cb779f897d9..e5bf5258c5faa86fff78f5959692494f0049052f 100644 (file)
@@ -35,12 +35,12 @@ import org.eclipse.osgi.framework.console.CommandProvider;
 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
 import org.opendaylight.controller.clustering.services.ICoordinatorChangeAware;
-import org.opendaylight.controller.connectionmanager.ConnectionLocality;
 import org.opendaylight.controller.connectionmanager.ConnectionMgmtScheme;
 import org.opendaylight.controller.connectionmanager.IConnectionManager;
 import org.opendaylight.controller.connectionmanager.scheme.AbstractScheme;
 import org.opendaylight.controller.connectionmanager.scheme.SchemeFactory;
 import org.opendaylight.controller.sal.connection.ConnectionConstants;
+import org.opendaylight.controller.sal.connection.ConnectionLocality;
 import org.opendaylight.controller.sal.connection.IConnectionListener;
 import org.opendaylight.controller.sal.connection.IConnectionService;
 import org.opendaylight.controller.sal.core.Node;
@@ -235,19 +235,31 @@ public class ConnectionManager implements IConnectionManager, IConnectionListene
     @Override
     public Node connect(String connectionIdentifier, Map<ConnectionConstants, String> params) {
         if (connectionService == null) return null;
-        return connectionService.connect(connectionIdentifier, params);
+        Node node = connectionService.connect(connectionIdentifier, params);
+        AbstractScheme scheme = schemes.get(activeScheme);
+        if (scheme != null && node != null) scheme.addNode(node);
+        return node;
     }
 
     @Override
     public Node connect(String type, String connectionIdentifier, Map<ConnectionConstants, String> params) {
         if (connectionService == null) return null;
-        return connectionService.connect(type, connectionIdentifier, params);
+        Node node = connectionService.connect(connectionIdentifier, params);
+        AbstractScheme scheme = schemes.get(activeScheme);
+        if (scheme != null && node != null) scheme.addNode(node);
+        return node;
     }
 
     @Override
     public Status disconnect (Node node) {
+        if (node == null) return new Status(StatusCode.BADREQUEST);
         if (connectionService == null) return new Status(StatusCode.NOSERVICE);
-        return connectionService.disconnect(node);
+        Status status = connectionService.disconnect(node);
+        if (status.isSuccess()) {
+            AbstractScheme scheme = schemes.get(activeScheme);
+            if (scheme != null) scheme.removeNode(node);
+        }
+        return status;
     }
 
     @Override