From b69347f68ce0b99b7a1fca25cac421567783ac7c Mon Sep 17 00:00:00 2001 From: idan kinory Date: Wed, 24 Jan 2018 14:29:24 +0000 Subject: [PATCH] Fixed constants and log syntax. Change-Id: I21d339241607b4db2f0b9c4204afefdc3312c216 --- vitrage/api/controllers/v1/template.py | 4 ++-- vitrage/evaluator/template_loader_service.py | 8 +++++--- vitrage/evaluator/template_validation/__init__.py | 5 ++--- .../templates/api/host_high_memory_usage_scenarios.yaml | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/vitrage/api/controllers/v1/template.py b/vitrage/api/controllers/v1/template.py index a28a8679f..b5eb54ed7 100644 --- a/vitrage/api/controllers/v1/template.py +++ b/vitrage/api/controllers/v1/template.py @@ -169,8 +169,8 @@ class TemplateController(RootRestController): LOG.exception('failed to add template file %s ', e) abort(404, str(e)) - @classmethod - def _db_template_to_dict(cls, template): + @staticmethod + def _db_template_to_dict(template): return { "uuid": template.uuid, "name": template.name, diff --git a/vitrage/evaluator/template_loader_service.py b/vitrage/evaluator/template_loader_service.py index 10b6f74d3..56711861e 100644 --- a/vitrage/evaluator/template_loader_service.py +++ b/vitrage/evaluator/template_loader_service.py @@ -29,6 +29,8 @@ from vitrage.messaging import VitrageNotifier LOG = log.getLogger(__name__) TEMPLATE_ACTION = 'template_action' +ADD = 'add' +DELETE = 'delete' class TemplateLoaderManager(base.GraphCloneManagerBase): @@ -47,13 +49,13 @@ class TemplateLoaderManager(base.GraphCloneManagerBase): return tasks_queue def handle_template_event(self, event): - template_action = event.get('template_action') + template_action = event.get(TEMPLATE_ACTION) - if template_action == 'add': + if template_action == ADD: templates = self._db.templates.query(status=TStatus.LOADING) new_status = TStatus.ACTIVE action_mode = ActionMode.DO - elif template_action == 'delete': + elif template_action == DELETE: templates = self._db.templates.query(status=TStatus.DELETING) new_status = TStatus.DELETED action_mode = ActionMode.UNDO diff --git a/vitrage/evaluator/template_validation/__init__.py b/vitrage/evaluator/template_validation/__init__.py index 8d77e8a6e..fd7685058 100644 --- a/vitrage/evaluator/template_validation/__init__.py +++ b/vitrage/evaluator/template_validation/__init__.py @@ -23,7 +23,6 @@ from vitrage.evaluator.template_validation.template_syntax_validator import \ from vitrage.evaluator.template_validation.template_syntax_validator import \ syntax_validation -__author__ = 'stack' LOG = log.getLogger(__name__) @@ -31,11 +30,11 @@ LOG = log.getLogger(__name__) def validate_template(template, def_templates): result = syntax_validation(template) if not result.is_valid_config: - LOG.error('Unable to load template, syntax err: %s' % result.comment) + LOG.error('Unable to load template, syntax error: %s' % result.comment) return result result = content_validation(template, def_templates) if not result.is_valid_config: - LOG.error('Unable to load template, content err: %s' % result.comment) + LOG.error('Unable to load template, content error:%s' % result.comment) return result return result diff --git a/vitrage_tempest_tests/tests/resources/templates/api/host_high_memory_usage_scenarios.yaml b/vitrage_tempest_tests/tests/resources/templates/api/host_high_memory_usage_scenarios.yaml index 1715bec54..d1c60a498 100644 --- a/vitrage_tempest_tests/tests/resources/templates/api/host_high_memory_usage_scenarios.yaml +++ b/vitrage_tempest_tests/tests/resources/templates/api/host_high_memory_usage_scenarios.yaml @@ -64,8 +64,8 @@ scenarios: state: SUBOPTIMAL - scenario: condition: lack_of_available_memory_alarm_on_host - actions: - - action: + actions: + - action: action_type: set_state action_target: target: host