[med-svn] [Git][med-team/biomaj3-daemon][upstream] New upstream version 3.0.17

Olivier Sallou gitlab at salsa.debian.org
Thu Oct 25 10:31:48 BST 2018


Olivier Sallou pushed to branch upstream at Debian Med / biomaj3-daemon


Commits:
cf36d55f by Olivier Sallou at 2018-10-25T09:23:33Z
New upstream version 3.0.17
- - - - -


6 changed files:

- CHANGES.txt
- biomaj_daemon/daemon/biomaj_daemon_web.py
- biomaj_daemon/daemon/daemon_service.py
- biomaj_daemon/daemon/utils.py
- requirements.txt
- setup.py


Changes:

=====================================
CHANGES.txt
=====================================
@@ -1,3 +1,14 @@
+3.0.17:
+  Allow use of env variables to override micro.x and rabbitmq variables in global.properties
+    like for config.yml.
+    Ex: WEB_LOCAL_ENDPOINT_DOWNLOAD defines proxy address for download web service,
+        WEB_LOCAL_ENDPOINT defines global proxy address for all web services, etc.
+    If not defined, will use values from global.properties
+3.0.16:
+  After migration checks, update db_schema to current version
+3.0.15:
+  Add --history option
+  Catch SIGTERM to cancel bank update for SIGKILL
 3.0.14:
   Fake version for Pypi re-upload
 3.0.13:


=====================================
biomaj_daemon/daemon/biomaj_daemon_web.py
=====================================
@@ -72,6 +72,7 @@ redis_client = redis.StrictRedis(
 
 logging.info("Check database schema and upgrade if necessary")
 SchemaVersion.migrate_pendings()
+SchemaVersion.set_version()
 
 app = Flask(__name__)
 
@@ -136,7 +137,9 @@ OPTIONS_PARAMS = {
     'userlogin': None,
     'userpassword': None,
     'proxy': None,
-    'schedule': False
+    'schedule': False,
+    'history': False,
+    'historyLimit': 20
 }
 
 
@@ -543,6 +546,26 @@ def biomaj_daemon_version():
     except Exception as e:
         abort(500, str(e))
 
+
+ at app.route('/api/daemon/history', methods=['GET'])
+def biomaj_daemon_history():
+    (http_code, options, error) = daemon_api_auth(request)
+    if error:
+        abort(http_code, error)
+
+    options.history = True
+    options.historyLimit = request.args.get('limit', 100)
+    try:
+        (res, msg) = biomaj_client_action(options, config)
+        if res:
+            if isinstance(msg, dict):
+                return jsonify(msg)
+            else:
+                return jsonify({'msg': msg})
+    except Exception as e:
+        abort(500, str(e))
+
+
 @app.route('/api/daemon/bank', methods=['GET'])
 def biomaj_daemon_banks_status():
     (http_code, options, error) = daemon_api_auth(request)


=====================================
biomaj_daemon/daemon/daemon_service.py
=====================================
@@ -6,6 +6,8 @@ import datetime
 import time
 import json
 import threading
+import signal
+import sys
 
 import redis
 import consul
@@ -82,6 +84,7 @@ class DaemonService(object):
 
     def __init__(self, config_file):
         self.logger = logging
+        self.curBank = None
         self.session = None
         self.executed_callback = None
         with open(config_file, 'r') as ymlfile:
@@ -91,6 +94,24 @@ class DaemonService(object):
         Zipkin.set_config(self.config)
 
         BiomajConfig.load_config(self.config['biomaj']['config'])
+        for svc in Utils.services:
+            service = svc.lower()
+            if self.config['web'].get('local_endpoint_' + service, None):
+                BiomajConfig.global_config.set('GENERAL', 'micro.biomaj.service.' + service , '1')
+                BiomajConfig.global_config.set('GENERAL', 'micro.biomaj.proxy.' + service , self.config['web']['local_endpoint_' + service])
+        if self.config['web'].get('local_endpoint', None):
+            BiomajConfig.global_config.set('GENERAL', 'micro.biomaj.proxy' , self.config['web']['local_endpoint'])
+        if self.config.get('rabbitmq', None):
+            if self.config['rabbitmq'].get('host', None):
+                BiomajConfig.global_config.set('GENERAL', 'micro.biomaj.rabbit_mq' , self.config['rabbitmq']['host'])
+            if self.config['rabbitmq'].get('port', None):
+                BiomajConfig.global_config.set('GENERAL', 'micro.biomaj.rabbit_mq_port' , str(self.config['rabbitmq']['port']))
+            if self.config['rabbitmq'].get('user', None):
+                BiomajConfig.global_config.set('GENERAL', 'micro.biomaj.rabbit_mq_user' , self.config['rabbitmq']['user'])
+            if self.config['rabbitmq'].get('password', None):
+                BiomajConfig.global_config.set('GENERAL', 'micro.biomaj.rabbit_mq_password' , self.config['rabbitmq']['password'])
+            if self.config['rabbitmq'].get('virtual_host', None):
+                BiomajConfig.global_config.set('GENERAL', 'micro.biomaj.rabbit_mq_virtual_host' , self.config['rabbitmq']['virtual_host'])
 
         if 'log_config' in self.config:
             for handler in list(self.config['log_config']['handlers'].keys()):
@@ -106,6 +127,16 @@ class DaemonService(object):
         )
 
         self.logger.info('Daemon service started')
+        signal.signal(signal.SIGTERM, self.catch)
+        signal.siginterrupt(signal.SIGTERM, False)
+
+    def catch(self, signum, frame):
+        self.logger.warn('SIGTERM signal received')
+        if self.curBank:
+            self.redis_client.set(self.config['redis']['prefix'] + ':' + self.curBank + ':action:cancel', 1)
+            self.logger.warn('SIGTERM signal received, cancelling update for ' + self.curBank)
+        else:
+            sys.exit(1)
 
     def close(self):
         if self.channel:
@@ -115,6 +146,7 @@ class DaemonService(object):
         self.executed_callback = func
 
     def __start_action(self, bank, action):
+        self.curBank = bank
         whatsup = bank + ':' + str(action)
         self.redis_client.hset(
             self.config['redis']['prefix'] + ':daemons:status',
@@ -133,6 +165,7 @@ class DaemonService(object):
             self.config['consul']['id'],
             'pending'
         )
+        self.curBank = None
 
     def execute(self, options):
         '''


=====================================
biomaj_daemon/daemon/utils.py
=====================================
@@ -810,11 +810,36 @@ def biomaj_stats(options, config):
         msg += tabulate(results, headers="firstrow", tablefmt="grid")
     return (True, msg)
 
+def biomaj_history(options, config):
+    history = Bank.get_history(options.historyLimit)
+    results = []
+    headers = ["Bank", "Action", "Start", "End", "Updated", "Error"]
+    if not options.json:
+        results.append(headers)
+    msg = 'BioMAJ history\n'
+    for h in history:
+        results.append([h['bank'],
+                        h['action'],
+                        datetime.datetime.utcfromtimestamp(h['start']),
+                        datetime.datetime.utcfromtimestamp(h['end']),
+                        str(h['updated']),
+                        str(h['error'])
+        ])
+    if options.json:
+        msg = {'headers': headers, 'history': results}
+    else:
+        msg += tabulate(results, headers="firstrow", tablefmt="grid")
+    return (True, msg)
+
+
 def biomaj_client_action(options, config=None):
     check_options(options, config)
     if options.version:
         return biomaj_version(options, config)
 
+    if options.history:
+        return biomaj_history(options, config)
+
     if options.stats:
         return biomaj_stats(options, config)
 


=====================================
requirements.txt
=====================================
@@ -8,3 +8,4 @@ python-consul
 prometheus_client>=0.0.18
 requests
 biomaj-core>=3.0.10
+biomaj>=3.1.6


=====================================
setup.py
=====================================
@@ -21,7 +21,7 @@ config = {
     'url': 'http://biomaj.genouest.org',
     'download_url': 'http://biomaj.genouest.org',
     'author_email': 'olivier.sallou at irisa.fr',
-    'version': '3.0.14',
+    'version': '3.0.17',
      'classifiers': [
         # How mature is this project? Common values are
         #   3 - Alpha



View it on GitLab: https://salsa.debian.org/med-team/biomaj3-daemon/commit/cf36d55f5afa45745d3051fbddc8f712ea9fe1ee

-- 
View it on GitLab: https://salsa.debian.org/med-team/biomaj3-daemon/commit/cf36d55f5afa45745d3051fbddc8f712ea9fe1ee
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20181025/dba1dc4d/attachment-0001.html>


More information about the debian-med-commit mailing list