Fixed constants and log syntax.

Change-Id: I21d339241607b4db2f0b9c4204afefdc3312c216
This commit is contained in:
idan kinory 2018-01-24 14:29:24 +00:00
parent 2ed0b6a737
commit b69347f68c
4 changed files with 11 additions and 10 deletions

View File

@ -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,

View File

@ -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

View File

@ -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