[med-svn] [Git][med-team/biomaj3-daemon][master] 3 commits: New upstream version 3.0.17

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


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


Commits:
cf36d55f by Olivier Sallou at 2018-10-25T09:23:33Z
New upstream version 3.0.17
- - - - -
b7f5ec3b by Olivier Sallou at 2018-10-25T09:23:37Z
Updated version 3.0.17 from 'upstream/3.0.17'

with Debian dir 33795086981658cb16eaf6d1da2b248d83943c44
- - - - -
fb7b94d7 by Olivier Sallou at 2018-10-25T09:24:48Z
new upstream release 3.0.17

- - - - -


8 changed files:

- CHANGES.txt
- biomaj_daemon/daemon/biomaj_daemon_web.py
- biomaj_daemon/daemon/daemon_service.py
- biomaj_daemon/daemon/utils.py
- debian/changelog
- debian/control
- 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)
 


=====================================
debian/changelog
=====================================
@@ -1,9 +1,13 @@
-biomaj3-daemon (3.0.14-2) UNRELEASED; urgency=medium
+biomaj3-daemon (3.0.17-1) unstable; urgency=medium
 
+  [ Jelmer Vernooij ]
   * Use secure copyright file specification URI.
   * Trim trailing whitespace.
 
- -- Jelmer Vernooij <jelmer at debian.org>  Sat, 20 Oct 2018 13:15:27 +0000
+  [ Olivier Sallou ]
+  * New upstream release
+
+ -- Olivier Sallou <osallou at debian.org>  Thu, 25 Oct 2018 09:23:42 +0000
 
 biomaj3-daemon (3.0.14-1) unstable; urgency=medium
 


=====================================
debian/control
=====================================
@@ -23,8 +23,8 @@ Build-Depends: debhelper (>= 9), dh-python,
                python3-biomaj3
 Standards-Version: 4.1.3
 Homepage: https://github.com/genouest/biomaj-daemon
-Vcs-Browser: https://anonscm.debian.org/cgit/debian-med/biomaj3-daemon.git
-Vcs-Git: https://anonscm.debian.org/git/debian-med/biomaj3-daemon.git
+Vcs-Browser: https://salsa.debian.org/med-team/biomaj3-daemon
+Vcs-Git: https://salsa.debian.org/med-team/biomaj3-daemon.git
 
 Package: python3-biomaj3-daemon
 Architecture: all


=====================================
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/compare/433773ba49ed787282e460d862da1515ea964e5a...fb7b94d764d121f120704485858fddba95d11aa7

-- 
View it on GitLab: https://salsa.debian.org/med-team/biomaj3-daemon/compare/433773ba49ed787282e460d862da1515ea964e5a...fb7b94d764d121f120704485858fddba95d11aa7
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/4a6cd007/attachment-0001.html>


More information about the debian-med-commit mailing list