From 47c796ceadd84b4556271da4cccfe71fbd0b4ad7 Mon Sep 17 00:00:00 2001 From: Juha-Matti Lehtinen Date: Mon, 23 Jul 2018 15:09:46 +0300 Subject: [PATCH 1/2] CSCMETAX-61: [REF] Redis config key updates --- src/metax_api/settings.py | 10 ++++++---- src/metax_api/utils/redis.py | 28 +++++++++++++++------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/metax_api/settings.py b/src/metax_api/settings.py index aeee7837..6083d4ff 100755 --- a/src/metax_api/settings.py +++ b/src/metax_api/settings.py @@ -337,11 +337,8 @@ if not executing_in_travis: # settings for custom redis-py cache helper in utils/redis.py - REDIS_SENTINEL = { - # at least three are required - 'HOSTS': app_config_dict['REDIS']['HOSTS'], + REDIS = { 'PASSWORD': app_config_dict['REDIS']['PASSWORD'], - 'SERVICE': app_config_dict['REDIS']['SERVICE'], 'LOCALHOST_PORT': app_config_dict['REDIS']['LOCALHOST_PORT'], # https://github.com/andymccurdy/redis-py/issues/485#issuecomment-44555664 @@ -352,6 +349,11 @@ # enables extra logging to console during cache usage 'DEBUG': False, + + 'SENTINEL': { + 'HOSTS': app_config_dict['REDIS']['SENTINEL']['HOSTS'], + 'SERVICE': app_config_dict['REDIS']['SENTINEL']['SERVICE'] + } } if executing_in_travis: diff --git a/src/metax_api/utils/redis.py b/src/metax_api/utils/redis.py index 7a390b1b..cb81e97c 100644 --- a/src/metax_api/utils/redis.py +++ b/src/metax_api/utils/redis.py @@ -44,19 +44,21 @@ def __init__(self, db=0, master_only=False, settings=django_settings): settings: override redis settings in settings.py. easier to use class from outside context of django (i.e. cron) """ if not isinstance(settings, dict): - if hasattr(settings, 'REDIS_SENTINEL'): - settings = settings.REDIS_SENTINEL + if hasattr(settings, 'REDIS'): + settings = settings.REDIS else: - raise Exception('Missing configuration from settings.py: REDIS_SENTINEL') - - if not settings.get('HOSTS', None): - raise Exception('Missing configuration from settings for REDIS_SENTINEL: HOSTS') - if not settings.get('SERVICE', None): - raise Exception('Missing configuration from settings for REDIS_SENTINEL: SERVICE') + raise Exception('Missing configuration from settings.py: REDIS') + + if not settings.get('SENTINEL', None): + raise Exception('Missing configuration from settings for REDIS: SENTINEL') + if not settings['SENTINEL'].get('HOSTS', None): + raise Exception('Missing configuration from settings for REDIS.SENTINEL: HOSTS') + if not settings['SENTINEL'].get('SERVICE', None): + raise Exception('Missing configuration from settings for REDIS.SENTINEL: SERVICE') if not settings.get('TEST_DB', None): - raise Exception('Missing configuration from settings for REDIS_SENTINEL: TEST_DB') - if len(settings['HOSTS']) < 3: - raise Exception('Invalid configuration in settings for REDIS_SENTINEL: HOSTS minimum number of hosts is 3') + raise Exception('Missing configuration from settings for REDIS: TEST_DB') + if len(settings['SENTINEL']['HOSTS']) < 3: + raise Exception('Invalid configuration in settings for REDIS.SENTINEL: HOSTS minimum number of hosts is 3') if executing_test_case(): db = settings['TEST_DB'] @@ -72,13 +74,13 @@ def __init__(self, db=0, master_only=False, settings=django_settings): ) self._sentinel = Sentinel( - settings['HOSTS'], + settings['SENTINEL']['HOSTS'], password=settings['PASSWORD'], socket_timeout=settings.get('SOCKET_TIMEOUT', 0.1), db=db ) - self._service_name = settings['SERVICE'] + self._service_name = settings['SENTINEL']['SERVICE'] self._DEBUG = settings.get('DEBUG', False) self._read_from_master_only = master_only self._node_count = self._count_nodes() From d453a16ecd599976840969644dc719a2722e714c Mon Sep 17 00:00:00 2001 From: Juha-Matti Lehtinen Date: Wed, 25 Jul 2018 10:12:06 +0300 Subject: [PATCH 2/2] CSCMETAX-61: [REF] access_type is again compulsory in harvester dataset schema. --- .../api/rest/base/schemas/harvester_dataset_schema.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/metax_api/api/rest/base/schemas/harvester_dataset_schema.json b/src/metax_api/api/rest/base/schemas/harvester_dataset_schema.json index a7bdcb36..ec6b7f95 100644 --- a/src/metax_api/api/rest/base/schemas/harvester_dataset_schema.json +++ b/src/metax_api/api/rest/base/schemas/harvester_dataset_schema.json @@ -1424,7 +1424,10 @@ "type":"object", "$ref":"#/definitions/Document" } - } + }, + "required":[ + "access_type" + ] }, "StructuredIdentifier":{ "title":"Identifier",