Fixed constants and log syntax.
Change-Id: I21d339241607b4db2f0b9c4204afefdc3312c216
This commit is contained in:
parent
2ed0b6a737
commit
b69347f68c
@ -169,8 +169,8 @@ class TemplateController(RootRestController):
|
|||||||
LOG.exception('failed to add template file %s ', e)
|
LOG.exception('failed to add template file %s ', e)
|
||||||
abort(404, str(e))
|
abort(404, str(e))
|
||||||
|
|
||||||
@classmethod
|
@staticmethod
|
||||||
def _db_template_to_dict(cls, template):
|
def _db_template_to_dict(template):
|
||||||
return {
|
return {
|
||||||
"uuid": template.uuid,
|
"uuid": template.uuid,
|
||||||
"name": template.name,
|
"name": template.name,
|
||||||
|
@ -29,6 +29,8 @@ from vitrage.messaging import VitrageNotifier
|
|||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
TEMPLATE_ACTION = 'template_action'
|
TEMPLATE_ACTION = 'template_action'
|
||||||
|
ADD = 'add'
|
||||||
|
DELETE = 'delete'
|
||||||
|
|
||||||
|
|
||||||
class TemplateLoaderManager(base.GraphCloneManagerBase):
|
class TemplateLoaderManager(base.GraphCloneManagerBase):
|
||||||
@ -47,13 +49,13 @@ class TemplateLoaderManager(base.GraphCloneManagerBase):
|
|||||||
return tasks_queue
|
return tasks_queue
|
||||||
|
|
||||||
def handle_template_event(self, event):
|
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)
|
templates = self._db.templates.query(status=TStatus.LOADING)
|
||||||
new_status = TStatus.ACTIVE
|
new_status = TStatus.ACTIVE
|
||||||
action_mode = ActionMode.DO
|
action_mode = ActionMode.DO
|
||||||
elif template_action == 'delete':
|
elif template_action == DELETE:
|
||||||
templates = self._db.templates.query(status=TStatus.DELETING)
|
templates = self._db.templates.query(status=TStatus.DELETING)
|
||||||
new_status = TStatus.DELETED
|
new_status = TStatus.DELETED
|
||||||
action_mode = ActionMode.UNDO
|
action_mode = ActionMode.UNDO
|
||||||
|
@ -23,7 +23,6 @@ from vitrage.evaluator.template_validation.template_syntax_validator import \
|
|||||||
from vitrage.evaluator.template_validation.template_syntax_validator import \
|
from vitrage.evaluator.template_validation.template_syntax_validator import \
|
||||||
syntax_validation
|
syntax_validation
|
||||||
|
|
||||||
__author__ = 'stack'
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
@ -31,11 +30,11 @@ LOG = log.getLogger(__name__)
|
|||||||
def validate_template(template, def_templates):
|
def validate_template(template, def_templates):
|
||||||
result = syntax_validation(template)
|
result = syntax_validation(template)
|
||||||
if not result.is_valid_config:
|
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
|
return result
|
||||||
result = content_validation(template, def_templates)
|
result = content_validation(template, def_templates)
|
||||||
if not result.is_valid_config:
|
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
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ scenarios:
|
|||||||
state: SUBOPTIMAL
|
state: SUBOPTIMAL
|
||||||
- scenario:
|
- scenario:
|
||||||
condition: lack_of_available_memory_alarm_on_host
|
condition: lack_of_available_memory_alarm_on_host
|
||||||
actions:
|
actions:
|
||||||
- action:
|
- action:
|
||||||
action_type: set_state
|
action_type: set_state
|
||||||
action_target:
|
action_target:
|
||||||
target: host
|
target: host
|
||||||
|
Loading…
Reference in New Issue
Block a user