diff --git a/tools/test/bin/onos-distributed-manager b/tools/test/bin/onos-distributed-manager
new file mode 100755
index 0000000..dade54f
--- /dev/null
+++ b/tools/test/bin/onos-distributed-manager
@@ -0,0 +1,145 @@
+#!/usr/bin/env python
+"""
+ Copyright 2017-present Open Networking Laboratory
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+"""
+
+from flask import Flask, jsonify, request
+
+app = Flask(__name__)
+controller_list = {}
+
+"""
+Onos Distributed Manager
+this app handles controller information in system
+
+Message Samples :
+--Adding node
+curl  -H "Content-Type: application/json" -X POST
+     --data '{"Id":"1.2.3.4","IpAddress":"1.2.3.4","Port":3456,"IsEnable":true}' http://localhost:5000
+--Updating node
+curl  -H "Content-Type: application/json" -X PUT --data '{"Id":"1.2.3.4","IsEnable":false}' http://localhost:5000
+--Deleting node
+curl  -H "Content-Type: application/json" -X DELETE --data '{"Id":"1.2.3.4","IsEnable":false}' http://localhost:5000
+--Getting node data
+curl  -X GET  http://10.15.176.228:5000/cluster.json
+
+"""
+
+httpStatusOK = 200
+httpStatusNotFound = 404
+httpStatusBadRequest = 400
+
+@app.route('/', methods=['GET'])
+def data_get_handler():
+
+    pagereturn = "<h2> Onos Distributed Controller Manager2 </h2>"
+    pagereturn += "<br><h3> Status of Added controllers  </h3><br>"
+    pagereturn += " Id,&emsp; Ip,&emsp; Port,&emsp; Is Active <br> "
+
+    for key in controller_list.keys():
+        pagereturn += controller_list[key]["Id"] + ",&emsp; " + \
+                      controller_list[key]["IpAddress"] + ",&emsp; " + \
+                      str(controller_list[key]["Port"]) + ",&emsp; " + \
+                      str(controller_list[key]["IsEnable"])
+        pagereturn += " <br>"
+
+    return pagereturn, httpStatusOK
+
+
+@app.route('/', methods=['POST'])
+def data_post_handler():
+
+    if request.is_json:
+        content = dict(request.json)
+
+        if content["Id"] in controller_list:
+            return "Content Id is already in the list", httpStatusBadRequest
+
+        else:
+            controller_list[content["Id"]] = content
+
+    else:
+        return "json required", httpStatusBadRequest
+
+    return "POST called with content", httpStatusOK
+
+
+@app.route('/', methods=['PUT'])
+def data_put_handler():
+
+    if request.is_json:
+        content = dict(request.json)
+
+        if content["Id"] in controller_list:
+            controller_list[content["Id"]] = content
+            return "Update succeeded", httpStatusOK
+
+        else:
+            return "Id %s is not found " %(content["Id"]), httpStatusNotFound
+    else:
+        return "json data is missing", httpStatusBadRequest
+
+
+@app.route('/', methods=['DELETE'])
+def data_delete_handler():
+
+    if request.is_json:
+        content = dict(request.json)
+
+    else:
+        return "No json is found", httpStatusBadRequest
+
+    if content["Id"] in controller_list:
+        del controller_list[content["Id"]]
+        return "Deletion succeed.", httpStatusOK
+
+    else:
+        return "Id is not found", httpStatusNotFound
+
+"""
+This function returns onos cluster information
+based on data in memory
+"""
+
+
+@app.route('/cluster.json', methods=['GET'])
+def cluster_responder():
+
+    cluster_info = dict()
+    nodes = list()
+    partition = dict()
+    # Todo: For first release , only 1 partition implemented
+    cluster_members = list()
+
+    # "nodes" array
+    for controller_id in controller_list:
+        controller_node = controller_list[controller_id]
+        if controller_node["IsEnable"]:
+            node_data = dict()
+            node_data["ip"] = controller_node["IpAddress"]
+            node_data["id"] = controller_node["Id"]
+            node_data["port"] = controller_node["Port"]
+            nodes.append(node_data)
+            cluster_members.append(controller_node["Id"])
+
+    partition["id"] = 1  # Todo: this will be updated .
+    partition["members"] = cluster_members
+
+    cluster_info["nodes"] = nodes
+    cluster_info["name"] = -1394421542720337000
+    cluster_info["partitions"] = partition
+    return jsonify(cluster_info), httpStatusOK
+
+if __name__ == '__main__':
+    app.run(host="0.0.0.0", debug=True)
