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 1beb7fe0bb609860865ed52347f27bfe126aeb2e..e5bf5258c5faa86fff78f5959692494f0049052f 100644 (file)
@@ -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