This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit f27226f14d3b4949a18c7a29f37f7cd7c5dcae5f Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Fri Mar 27 11:13:44 2015 +0100 hostpage: bouton test de connection OK --- app/app.py | 8 ++++++++ app/module_loader.py | 12 ++++++++++++ static/js/controllers/headCtrl.js | 8 ++++++++ static/js/controllers/hostPageCtrl.js | 7 +++++++ views/hostpage.html | 3 ++- 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/app.py b/app/app.py index 7ec70c8..eca0266 100755 --- a/app/app.py +++ b/app/app.py @@ -11,6 +11,7 @@ import threading from module_loader import ModuleLoader import process_monitoring from modules.notification_modules.websocket_container import WebSocketContainer +import traceback # Pour lancer la detection nmap avec un nouveau thread class ThreadDetect(threading.Thread): @@ -149,6 +150,13 @@ def receive(ws): ws.send(json_dumps({"RES_GET_LOADED_NOTIF_MOD": ml.get_info_mod_notification()})) elif code == "SET_MOD_ACTIVATION": # asked from hostpage, at the block activation conf ml.update_activated_modules(msg["SET_MOD_ACTIVATION"]) + elif code == "TEST_CONN": + try: + ml.test_connection(msg["TEST_CONN"]["addr_host"], + msg["TEST_CONN"]["conn_mod_name"]) + ws.send(json_dumps({"RES_TEST_CONN": True})) + except Exception: + ws.send(json_dumps({"RES_TEST_CONN": False})) elif code == "SET_CONF_MOD": # asked from hostpage, at the monitoring module configuration ml.launch_db_function({'func': 'set_conf_mod', 'args': msg["SET_CONF_MOD"]}) process_monitoring.update_mod_on_waiting_list(msg["SET_CONF_MOD"]) diff --git a/app/module_loader.py b/app/module_loader.py index 4ad1949..f70696e 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -92,6 +92,18 @@ class ModuleLoader: print "Error: no connection have been configured yet" return mod_inst + def test_connection(self, addr_host, conn_mod_name): + avaliable_conn = self.db.get_conf_conn(addr_host) + conn = None + for i in range(len(avaliable_conn)): + if avaliable_conn[i]['conn_mod_name'] == conn_mod_name: + conn = avaliable_conn.pop(i) + getattr(self.loaded_mod_conn[conn['conn_mod_name']]['imported'], + self.loaded_mod_conn[conn['conn_mod_name']]['class_name'])(addr_host, + conn['args'], + self.conf['keys_location'], + modules.CommandNotFoundException) + def load_all_detection_modules(self): """ Instanciates and stores the informations about each monitoring modules avaliable on the loaded_mod_detect attribute diff --git a/static/js/controllers/headCtrl.js b/static/js/controllers/headCtrl.js index 1d87198..f70426a 100644 --- a/static/js/controllers/headCtrl.js +++ b/static/js/controllers/headCtrl.js @@ -53,6 +53,14 @@ mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $r case "RES_CALL_FUNC_DB": // Get a result after calling a funcion on the db $rootScope.$broadcast("resCall", obj[key]); break; + case "RES_TEST_CONN": + if(obj[key]){ // if success of the connection + $scope.pop_success("Connection test", "The connection is well configured."); + } + else{ + $scope.pop_danger("Connection test", "The connection could not have been established. Please verify its configuration."); + } + break; case "CURRENT_STATE_INFO": $scope.$apply(function(){ $scope.state = obj[key]; diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 3b475a8..61a3b01 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -307,6 +307,13 @@ mumApp.controller('ModalConnInstanceCtrl', function ($scope, $rootScope, $modalI } }); + $scope.testConn = function(connModName){ + var args = {}; + args['addr_host'] = $scope.conn_args["addr_host"]; + args['conn_mod_name'] = connModName; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"TEST_CONN": args})); + } + $scope.ok = function () { var args = {}; args['addr_host'] = $scope.conn_args.addr_host; diff --git a/views/hostpage.html b/views/hostpage.html index c579267..7359ec9 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -193,7 +193,8 @@ <td> <button type="button" class="btn btn-primary" ng-click="open_modal_conf_conn(modname)">Advanced configuration</button> - <button type="button" class="btn btn-success">Test</button> + <button type="button" class="btn btn-success" + ng-click="testConn(modname)">Test</button> </td> </tr> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.