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 9e5ed0d204b9183f8f94e84bd53a763c76a570b0 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Mar 12 16:22:04 2015 +0100 hostpage: remove this host => OK --- app/app.py | 3 ++- app/modules/storage_modules/shelve_db.py | 12 ++++++++---- app/process_monitoring.py | 9 +++++++-- static/js/controllers/headCtrl.js | 4 ---- static/js/controllers/hostPageCtrl.js | 6 ++++++ views/hostpage.html | 2 +- views/index.html | 1 - 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/app.py b/app/app.py index ea5f78c..bea6da4 100755 --- a/app/app.py +++ b/app/app.py @@ -130,6 +130,7 @@ def receive(ws): start_first_detection(msg["NMAP_SCAN_DEMAND"], ml, ws) elif code == "LAUNCH_FULL_DETECTION": ml.run_all_detection_modules(msg["LAUNCH_FULL_DETECTION"]) + ws.send(json_dumps({"SUCCESS_MODULE": "Full detection"})) elif code == "GET_HOSTS": db = ml.get_db() ws.send(json.dumps({"RES_GET_HOSTS": db.get_hosts()})) @@ -174,6 +175,6 @@ if __name__ == '__main__': ml.load_all_connection_modules() ml.load_all_detection_modules() wsc = WebSocketContainer(ml.get_db()) - #process_monitoring.init(ml, wsc) + process_monitoring.init(ml, wsc) port = int(os.environ.get('PORT', 1337)) run(host='0.0.0.0', port=port, debug=True, server=GeventWebSocketServer) \ No newline at end of file diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index ce7bf7a..87b47ff 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -391,14 +391,18 @@ class shelve_db: self.close_db() return json.dumps(res) - def remove_host(self, addr_host): + def remove_host(self, args): """ - Removes from the database the host at the adress on parameter. If the host is part of a group, it will be - removed of this group as well. - :param addr_host: the IP address of the host to delete + Removes a host from the database. All the monitoring intructions concerning this host will be deleted. + Finally, if the host is part of a group, it will be also removed from these groups. + :param args: A dictionary containing: + {'addr_host': val} """ + addr_host = args['addr_host'] self.open_db() try: + # removing monitoring instructions for this host + self.rem_to_monitoring_list(addr_host, None) # removing monitoring entries for this host if addr_host in self.db['hosts']: del self.db['hosts'][addr_host] diff --git a/app/process_monitoring.py b/app/process_monitoring.py index ffc51a8..357613b 100644 --- a/app/process_monitoring.py +++ b/app/process_monitoring.py @@ -80,8 +80,13 @@ def add_to_waiting_list(dict_mod): def remove_to_waiting_list(addr_host, modname): global waiting_list for i in range(len(waiting_list)): - if waiting_list[i]['addr'] == addr_host and waiting_list[i]['mod_name'] == modname: - waiting_list.pop(i) + if waiting_list[i]['addr'] == addr_host: + if modname is None: + # it was asked to remove all entries of this host + waiting_list.pop(i) + elif waiting_list[i]['mod_name'] == modname: + # we remove only the necessary module from the list + waiting_list.pop(i) class RunMonitoring(threading.Thread): def __init__(self, list_dict_mod, ml, wsc): diff --git a/static/js/controllers/headCtrl.js b/static/js/controllers/headCtrl.js index 65f331c..f1467c7 100644 --- a/static/js/controllers/headCtrl.js +++ b/static/js/controllers/headCtrl.js @@ -82,10 +82,6 @@ mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $r }; - $scope.toto = function(){ - $scope.pop_success("abwabwa", "trololo") - } - $scope.pop_success = function(title, msg){ toastr.success(msg, title); }; diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 8bb2a78..43771cc 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -79,6 +79,12 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $routeParams, $mo $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_custom_informations', 'args': args}})); }; + $scope.remove_host = function(){ + args = {}; + args['addr_host'] = $scope.addr_host; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'remove_host', 'args': args}})); + } + // creation of modals $scope.open_modal_conf = function (mod_name) { var modalInstance = $modal.open({ diff --git a/views/hostpage.html b/views/hostpage.html index ce79874..c2cf6e7 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -4,7 +4,7 @@ <button type="button" class="btn btn-primary btn-xs" ng-click="open_modal_block()">Activate/Deactivate</button> <button type="button" class="btn btn-primary btn-xs" ng-click="open_modal_conn()">Connection settings</button> <button type="button" class="btn btn-info btn-xs" ng-click="launch_detection()">Launch a full detection</button> - <button type="button" class="btn btn-danger btn-xs" ng-click="call_func('remove_host', [addr_host])">Remove this host</button> + <button type="button" class="btn btn-danger btn-xs" ng-click="remove_host()">Remove this host</button> <table class="table table-condensed table-hover"> <thead> diff --git a/views/index.html b/views/index.html index a4c5dab..1bb2ed5 100644 --- a/views/index.html +++ b/views/index.html @@ -55,7 +55,6 @@ <p class="navbar-text navbar-left"><a href="#dashboard/success" style="color:green">OK : {{stateNumber()[0]}}</a></p> <p class="navbar-text navbar-left"><a href="#dashboard/warning" style="color:orange">Warning : {{stateNumber()[1]}}</a></p> <p class="navbar-text navbar-left"><a href="#dashboard/danger" style="color:red">KO : {{stateNumber()[2]}}</a></p> - <button type="button" class="btn btn-primary btn-xs" ng-click="toto()">tut</button> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-right"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.