evaluator -support severity in vitrage alarm
Change-Id: I1a6561fdf7ed77933a5153d924d35e06280377cf
This commit is contained in:
@@ -57,7 +57,8 @@ class EvaluatorEventTransformer(transformer_base.TransformerBase):
|
||||
|
||||
metadata = {
|
||||
VProps.UPDATE_TIMESTAMP: event[VProps.UPDATE_TIMESTAMP],
|
||||
VProps.NAME: event[TFields.ALARM_NAME]
|
||||
VProps.NAME: event[TFields.ALARM_NAME],
|
||||
VProps.SEVERITY: event[TFields.SEVERITY]
|
||||
}
|
||||
return graph_utils.create_vertex(
|
||||
self.extract_key(event),
|
||||
|
||||
@@ -17,7 +17,6 @@ from vitrage.evaluator.actions.recipes.action_steps import NOTIFY
|
||||
from vitrage.evaluator.actions.recipes.action_steps import REMOVE_VERTEX
|
||||
from vitrage.evaluator.actions.recipes import base
|
||||
from vitrage.evaluator.actions.recipes.base import ActionStepWrapper
|
||||
from vitrage.evaluator.template_fields import TemplateFields as TFields
|
||||
|
||||
|
||||
class RaiseAlarm(base.Recipe):
|
||||
@@ -25,11 +24,8 @@ class RaiseAlarm(base.Recipe):
|
||||
@staticmethod
|
||||
def get_do_recipe(action_spec):
|
||||
|
||||
add_vertex_params = {
|
||||
TFields.TARGET: action_spec.targets[TFields.TARGET],
|
||||
TFields.ALARM_NAME: action_spec.properties[TFields.ALARM_NAME]
|
||||
}
|
||||
add_vertex_step = ActionStepWrapper(ADD_VERTEX, add_vertex_params)
|
||||
add_vertex_step = ActionStepWrapper(
|
||||
ADD_VERTEX, RaiseAlarm._get_vertex_params(action_spec))
|
||||
|
||||
notify_step = RaiseAlarm._get_notify_step()
|
||||
|
||||
@@ -38,12 +34,9 @@ class RaiseAlarm(base.Recipe):
|
||||
@staticmethod
|
||||
def get_undo_recipe(action_spec):
|
||||
|
||||
remove_vertex_params = {
|
||||
TFields.TARGET: action_spec.targets[TFields.TARGET],
|
||||
TFields.ALARM_NAME: action_spec.properties[TFields.ALARM_NAME]
|
||||
}
|
||||
remove_vertex_step = ActionStepWrapper(REMOVE_VERTEX,
|
||||
remove_vertex_params)
|
||||
remove_vertex_step = ActionStepWrapper(
|
||||
REMOVE_VERTEX, RaiseAlarm._get_vertex_params(action_spec))
|
||||
|
||||
notify_step = RaiseAlarm._get_notify_step()
|
||||
|
||||
return [remove_vertex_step, notify_step]
|
||||
@@ -53,3 +46,11 @@ class RaiseAlarm(base.Recipe):
|
||||
|
||||
# TODO(lhartal): add params
|
||||
return ActionStepWrapper(NOTIFY, {})
|
||||
|
||||
@staticmethod
|
||||
def _get_vertex_params(action_spec):
|
||||
|
||||
add_vertex_params = action_spec.targets.copy()
|
||||
add_vertex_params.update(action_spec.properties)
|
||||
|
||||
return add_vertex_params
|
||||
|
||||
@@ -33,6 +33,7 @@ class TemplateFields(object):
|
||||
RELATIONSHIPS = 'relationships'
|
||||
RELATIONSHIP = 'relationship'
|
||||
RELATIONSHIP_TYPE = 'relationship_type'
|
||||
SEVERITY = 'severity'
|
||||
SOURCE = 'source'
|
||||
SCENARIO = 'scenario'
|
||||
STATE = 'state'
|
||||
|
||||
@@ -141,7 +141,7 @@ class TestActionExecutor(TestEntityGraphFunctionalBase):
|
||||
self.assertIsNone(before_edge)
|
||||
self.assertIsNotNone(new_edge)
|
||||
|
||||
def test_execute_add_vertex(self):
|
||||
def test_execute_add_and_remove_vertex(self):
|
||||
|
||||
# Test Setup
|
||||
processor = self._create_processor_with_graph(self.conf)
|
||||
@@ -153,7 +153,10 @@ class TestActionExecutor(TestEntityGraphFunctionalBase):
|
||||
host = host_vertices[0]
|
||||
|
||||
targets = {TFields.TARGET: host.vertex_id}
|
||||
props = {TFields.ALARM_NAME: 'VM_CPU_SUBOPTIMAL_PERFORMANCE'}
|
||||
props = {
|
||||
TFields.ALARM_NAME: 'VM_CPU_SUBOPTIMAL_PERFORMANCE',
|
||||
TFields.SEVERITY: 'critical'
|
||||
}
|
||||
action_spec = ActionSpecs(ActionType.RAISE_ALARM, targets, props)
|
||||
|
||||
event_queue = multiprocessing.Queue()
|
||||
|
||||
@@ -42,6 +42,7 @@ scenarios:
|
||||
action_type: raise_alarm
|
||||
properties:
|
||||
alarm_name: VM_CPU_SUBOPTIMAL_PERFORMANCE
|
||||
severity: critical
|
||||
action_target:
|
||||
target: 4
|
||||
- action:
|
||||
|
||||
Reference in New Issue
Block a user