branch develop updated (112abc7 -> 40c8d67)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository mum. See http://git.chorem.org/mum.git from 112abc7 wen state available for hosts: idle. Monitoring can be idle on hostpage new 12096f1 hostpage: only fields for the current connection are shown in form new 40c8d67 navbar: current tasks running on the center of navbar (number of max tasks defined on headCtrl) The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 40c8d678e649aeb459a1891b03d877fdb9ddcda0 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Apr 16 18:03:42 2015 +0200 navbar: current tasks running on the center of navbar (number of max tasks defined on headCtrl) commit 12096f1de1124f0c77020ecb93263dcd30729f2a Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Apr 16 10:22:33 2015 +0200 hostpage: only fields for the current connection are shown in form Summary of changes: app/module_loader.py | 8 ++++ .../notification_modules/websocket_container.py | 6 ++- app/modules/storage_modules/shelve_db.py | 41 ++++++++++++++++++++ app/mum.py | 32 +++++++++------ bower.json | 1 - static/js/controllers/headCtrl.js | 25 +++++++++++- static/js/controllers/hostPageCtrl.js | 45 ++++++---------------- static/js/mumApp.js | 2 +- views/hostpage.html | 13 +++---- views/index.html | 8 ++++ 10 files changed, 124 insertions(+), 57 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 12096f1de1124f0c77020ecb93263dcd30729f2a Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Apr 16 10:22:33 2015 +0200 hostpage: only fields for the current connection are shown in form --- bower.json | 1 - static/js/controllers/hostPageCtrl.js | 42 +++++++++++++---------------------- static/js/mumApp.js | 2 +- views/hostpage.html | 13 +++++------ 4 files changed, 21 insertions(+), 37 deletions(-) diff --git a/bower.json b/bower.json index dfcc7f0..0e80c92 100644 --- a/bower.json +++ b/bower.json @@ -7,7 +7,6 @@ "angular-toastr": "0.4.2", "angular-route": "~1.2.28", "angular-bootstrap": "~0.12.1", - "angular-sanitize": "~1.2.28", "angular-file-upload": "~1.1.5" }, "resolutions": { diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 041632d..8376b82 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -404,7 +404,7 @@ mumApp.controller('ModalConnInstanceCtrl', function ($scope, $rootScope, $modalI }; }); -mumApp.controller('ModalConfConnInstanceCtrl', function ($scope, $rootScope, $modalInstance, $templateCache, $route, conf_conn_args, FileUploader) { +mumApp.controller('ModalConfConnInstanceCtrl', function ($scope, $rootScope, $modalInstance, $route, conf_conn_args, FileUploader) { $scope.uploader = new FileUploader({ url: '/upload' }); @@ -412,9 +412,14 @@ mumApp.controller('ModalConfConnInstanceCtrl', function ($scope, $rootScope, $mo $scope.conf_conn_args = conf_conn_args; /* {'addr_host': val, 'modname': val, 'current_config': val - 'loaded_conn_mods': ...} */ - - $scope.loaded_conn_mods = $scope.loaded_conn_mods; /* { + 'loaded_conn_mods': + { + modname:{param1:type ,param2:type}, + ... + } + } */ + + /*$scope.loaded_conn_mods = $scope.loaded_conn_mods; /* { mod_name: { 'class_name': val, => the name of the class to instanciate @@ -434,6 +439,11 @@ mumApp.controller('ModalConfConnInstanceCtrl', function ($scope, $rootScope, $mo $scope.keys_list = []; + $scope.show_form = function(param_name){ + //alert(JSON.stringify($scope.conf_conn_args.loaded_conn_mods[$scope.conf_conn_args.modname].params)); + return $scope.conf_conn_args.loaded_conn_mods[$scope.conf_conn_args.modname].hasOwnProperty(param_name); + } + $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_KEYS_LIST": ""})); $scope.$on("keysList", function (event, args) { @@ -551,26 +561,4 @@ mumApp.controller('ModalBlockInstanceCtrl', function ($scope, $rootScope, $modal $scope.cancel = function () { $modalInstance.close(); }; -}); -/* -mumApp.directive("formLoader", ['$compile', '$templateCache', function ($compile, $templateCache) { - - var getTemplate = function(data) { - // use data to determine which template to use - var templateid = 'foo'; - var template = $templateCache.get(templateid); - return template; - } - - return { - templateUrl: 'views/partials/template.html', - scope: {data: '='}, - restrict: 'E', - link: function(scope, element) { - var template = getTemplate(scope.data); - - element.html(template); - $compile(element.contents())(scope); - } - }; -}]);*/ \ No newline at end of file +}); \ No newline at end of file diff --git a/static/js/mumApp.js b/static/js/mumApp.js index 42bcc3d..c2e3afa 100644 --- a/static/js/mumApp.js +++ b/static/js/mumApp.js @@ -1,4 +1,4 @@ -var mumApp = angular.module('mumApp', ['angularFileUpload', 'ngSanitize', 'ngRoute', 'ui.bootstrap', 'toastr']); +var mumApp = angular.module('mumApp', ['angularFileUpload', 'ngRoute', 'ui.bootstrap', 'toastr']); mumApp.factory('DataHosts', function(){ return {Items: []}; diff --git a/views/hostpage.html b/views/hostpage.html index b56c6c0..a737f66 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -246,7 +246,7 @@ <button ng-click="item.upload(item, '\keys')">upload</button> </li> </ul>--> - <div class="row"> + <div class="row" ng-show="show_form('private_key')"> <div class="col-xs-3"> <label for="private_key">Select a private key</label> <select class="form-control input-sm" id="private_key" @@ -254,7 +254,7 @@ ng-options="key as key for key in keys_list"></select> </div> </div> - <div class="row"> + <div class="row" ng-show="show_form('private_key')"> <div class="col-xs-3"> <form action="/upload" method="post" enctype="multipart/form-data"> <label for="upload_key">Or upload a new key couple:</label> @@ -263,27 +263,24 @@ </form> </div> </div> - <div class="row"> + <div class="row" ng-show="show_form('port')"> <div class="col-xs-2"> <label for="port">Port used</label> <input type="number" id="port" min="0" ng-model="port"> </div> </div> - <div class="row"> + <div class="row" ng-show="show_form('username')"> <div class="col-xs-3"> <label for="usrname">Login</label> <input type="text" id="usrname" ng-model="username"/> </div> </div> - <div class="row"> + <div class="row" ng-show="show_form('password')"> <div class="col-xs-3"> <label for="password">Password</label> <input type="password" id="password" ng-model="password"/> </div> </div> - - - <!--<div ng-include=" 'templateForm.html' "></div>--> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancel()">Close</button> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 40c8d678e649aeb459a1891b03d877fdb9ddcda0 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Apr 16 18:03:42 2015 +0200 navbar: current tasks running on the center of navbar (number of max tasks defined on headCtrl) --- app/module_loader.py | 8 +++++ .../notification_modules/websocket_container.py | 6 +++- app/modules/storage_modules/shelve_db.py | 41 ++++++++++++++++++++++ app/mum.py | 32 ++++++++++------- static/js/controllers/headCtrl.js | 25 ++++++++++++- static/js/controllers/hostPageCtrl.js | 9 ----- views/index.html | 8 +++++ 7 files changed, 106 insertions(+), 23 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index 72e265a..1ab1618 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -52,6 +52,14 @@ class ModuleLoader: def get_websocket_container(self): return self.wsc + def create_task(self, task_id): + self.db.store_task(task_id) + self.wsc.notify_task_change() + + def remove_task(self, task_id): + self.db.remove_task(task_id) + self.wsc.notify_task_change() + @staticmethod def add_to_waiting_list(instr): process_monitoring.add_to_waiting_list(instr) diff --git a/app/modules/notification_modules/websocket_container.py b/app/modules/notification_modules/websocket_container.py index b23abed..98dfb60 100644 --- a/app/modules/notification_modules/websocket_container.py +++ b/app/modules/notification_modules/websocket_container.py @@ -16,4 +16,8 @@ class WebSocketContainer: def notify_state_change(self): for ws in self.ws_set: - ws.send(json.dumps({"RES_GET_HOSTS": self.db.get_hosts()})) \ No newline at end of file + ws.send(json.dumps({"RES_GET_HOSTS": self.db.get_hosts()})) + + def notify_task_change(self): + for ws in self.ws_set: + ws.send(json.dumps({"RES_TASK_LIST": self.db.get_task_list()})) \ 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 4c24929..acecdd2 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -36,6 +36,7 @@ class shelve_db: self.db["users"] = {} self.db["groups"] = {} self.db["global_conf"] = {} + self.db["tasks"] = [] except: print "Database initilalization error" self.db.close() @@ -1271,4 +1272,44 @@ class shelve_db: print traceback.format_exc() finally: self.close_db() + return res + + def store_task(self, task_id): + """ + Stores a new task into the database + :param task_id: the id of the task + """ + self.open_db() + try: + self.db['tasks'].append(task_id) + except Exception: + print traceback.format_exc() + finally: + self.close_db() + + def remove_task(self, task_id): + """ + Removes a new task into the database + :param task_id: the id of the task + """ + self.open_db() + try: + self.db['tasks'].remove(task_id) + except Exception: + print traceback.format_exc() + finally: + self.close_db() + + def get_task_list(self): + """ + :return: The list of current tasks + """ + res = [] + self.open_db() + try: + res = self.db['tasks'] + except Exception: + print traceback.format_exc() + finally: + self.close_db() return res \ No newline at end of file diff --git a/app/mum.py b/app/mum.py index a4a43e7..016306f 100755 --- a/app/mum.py +++ b/app/mum.py @@ -21,24 +21,30 @@ class ThreadDetect(threading.Thread): self.ws = ws # websocket connection def run(self): + task_name = "Scanning " + self.param + self.ml.create_task(task_name) scanned_ip = self.ml.run_nmap_detection(self.param, self.opt, self.ws) if scanned_ip is not None: - self.ws.send(json.dumps({"SUCCESS_MODULE": scanned_ip})) + try: + self.ws.send(json.dumps({"SUCCESS_MODULE": scanned_ip})) + except WebSocketError: + pass for ip in json.loads(scanned_ip): monitoring_intructions = ml.get_db().get_monitoring_instructions(ip) for instr in monitoring_intructions: ml.add_to_waiting_list(instr) - """ - # now launching full detection - for ip in json.loads(scanned_ip): - conn = module_loader.load_conn("ssh", ip, "aguilbaud", "/home/aguilbaud/.ssh/id_rsa") - module_loader.run_all_detection_modules(db.get_host_os(ip), conn, db, self.ws) - monitoring_intructions = db.get_monitoring_instructions(ip) - for instr in monitoring_intructions: - process_monitoring.add_to_waiting_list(instr) - #module_loader.run_all_monitoring_modules("unix", conn, db, self.ws) - # adding entries on process monitoring - """ + self.ml.remove_task(task_name) + """ + # now launching full detection + for ip in json.loads(scanned_ip): + conn = module_loader.load_conn("ssh", ip, "aguilbaud", "/home/aguilbaud/.ssh/id_rsa") + module_loader.run_all_detection_modules(db.get_host_os(ip), conn, db, self.ws) + monitoring_intructions = db.get_monitoring_instructions(ip) + for instr in monitoring_intructions: + process_monitoring.add_to_waiting_list(instr) + #module_loader.run_all_monitoring_modules("unix", conn, db, self.ws) + # adding entries on process monitoring + """ # Launching of the detection after getting a ip range. @@ -172,6 +178,8 @@ def receive(ws): ml.run_one_monitoring_module(args['mod_name'], args['addr_host'], None, None) elif code == "GET_KEYS_LIST": # asked from hostpage, at the connection configuration ws.send(json.dumps({"KEYS_LIST": ml.get_public_keys_list()})) + elif code == "TASK_LIST": + ws.send(json.dumps({"RES_TASK_LIST": ml.get_db().get_task_list()})) else: break except WebSocketError: # Should be WebSocketError when closing the connection diff --git a/static/js/controllers/headCtrl.js b/static/js/controllers/headCtrl.js index f162fd2..f21d1b8 100644 --- a/static/js/controllers/headCtrl.js +++ b/static/js/controllers/headCtrl.js @@ -5,6 +5,8 @@ mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $r $scope.items = DataHosts.Items; + $scope.task_list = []; + $scope.$on("hostsUpdate", function (event) { $scope.items = DataHosts.Items; }); @@ -15,8 +17,24 @@ mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $r ws.onopen = function() { var request = JSON.stringify({"GET_HOSTS": ""}); ws.send(request); + ws.send(JSON.stringify({"TASK_LIST": null})); }; + $scope.max_tasks = 2; + + $scope.format_task_list = function(task_list){ + res = ""; + var i = 0; + while(i<$scope.task_list.length && i<$scope.max_tasks){ + res += task_list[i] + ", "; + i++; + } + if($scope.task_list.length > $scope.max_tasks){ + res += "+ " + (task_list.length - $scope.max_tasks) + " other tasks"; + } + return res; + } + // instructions received from other controllers // args contains a json formatted string $scope.$on("sendViaWs", function (event, args) { @@ -89,7 +107,12 @@ mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $r break; case "KEYS_LIST": $rootScope.$broadcast("keysList", obj[key]); - break + break; + case "RES_TASK_LIST": + $scope.$apply(function(){ + $scope.task_list = obj[key]; + }); + break; case "ERROR": toastr.error(obj[key], "Server error"); break; diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 8376b82..858b796 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -419,14 +419,6 @@ mumApp.controller('ModalConfConnInstanceCtrl', function ($scope, $rootScope, $mo } } */ - /*$scope.loaded_conn_mods = $scope.loaded_conn_mods; /* { - mod_name: - { - 'class_name': val, => the name of the class to instanciate - 'imported': module, => the module imported - 'params': {param1: type1, param2: type2, ...} => the parameters necessary to create the connection - } - } */ $scope.conf_conn = {}; $scope.port = $scope.conf_conn_args["current_config"][$scope.conf_conn_args.modname]["port"]; @@ -440,7 +432,6 @@ mumApp.controller('ModalConfConnInstanceCtrl', function ($scope, $rootScope, $mo $scope.keys_list = []; $scope.show_form = function(param_name){ - //alert(JSON.stringify($scope.conf_conn_args.loaded_conn_mods[$scope.conf_conn_args.modname].params)); return $scope.conf_conn_args.loaded_conn_mods[$scope.conf_conn_args.modname].hasOwnProperty(param_name); } diff --git a/views/index.html b/views/index.html index c4c02a9..1025258 100644 --- a/views/index.html +++ b/views/index.html @@ -61,6 +61,14 @@ <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> <p class="navbar-text navbar-left"><a href="#dashboard/idling" style="color:grey">Idling : {{stateNumber()[3]}}</a></p> + <p class="navbar-text navbar-left" + style="colod:white" + ng-show="task_list.length > 0" + popover-placement="bottom" + popover="{{task_list}}" + popover-trigger="mouseenter">Current tasks: {{format_task_list(task_list)}} + <span class="glyphicon glyphicon-collapse-down"></span> + </p> </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>.
participants (1)
-
chorem.org scm