adding active and inactive states to deduced alarm

Change-Id: I56e1befa1da18bcf783fbf09a0f1297b225e127d
This commit is contained in:
Liat Har-Tal
2016-03-16 06:18:20 +00:00
parent b1f4a53166
commit 42107075ad
7 changed files with 13 additions and 13 deletions

View File

@@ -28,10 +28,8 @@ class RaiseAlarm(base.Recipe):
def get_do_recipe(action_spec):
params = RaiseAlarm._get_vertex_params(action_spec)
params[VProps.STATE] = AlarmProps.ALARM_STATE
add_vertex_step = ActionStepWrapper(
ADD_VERTEX, RaiseAlarm._get_vertex_params(action_spec))
params[VProps.STATE] = AlarmProps.ALARM_ACTIVE_STATE
add_vertex_step = ActionStepWrapper(ADD_VERTEX, params)
notify_step = RaiseAlarm._get_notify_step()
@@ -40,8 +38,9 @@ class RaiseAlarm(base.Recipe):
@staticmethod
def get_undo_recipe(action_spec):
remove_vertex_step = ActionStepWrapper(
REMOVE_VERTEX, RaiseAlarm._get_vertex_params(action_spec))
params = RaiseAlarm._get_vertex_params(action_spec)
params[VProps.STATE] = AlarmProps.ALARM_INACTIVE_STATE
remove_vertex_step = ActionStepWrapper(REMOVE_VERTEX, params)
notify_step = RaiseAlarm._get_notify_step()

View File

@@ -59,7 +59,7 @@ class AodhTransformer(BaseAlarmTransformer):
entity_id=entity_event[AodhProps.ALARM_ID],
entity_category=EntityCategory.ALARM,
entity_type=entity_event[SyncProps.SYNC_TYPE],
entity_state=AlarmProps.ALARM_STATE,
entity_state=AlarmProps.ALARM_ACTIVE_STATE,
update_timestamp=AodhTransformer._timestamp(entity_event),
metadata=metadata)

View File

@@ -15,4 +15,5 @@ __author__ = 'stack'
class AlarmProperties(object):
ALARM_STATE = 'Active'
ALARM_ACTIVE_STATE = 'Active'
ALARM_INACTIVE_STATE = 'Inactive'

View File

@@ -54,7 +54,7 @@ class NagiosTransformer(BaseAlarmTransformer):
self.extract_key(entity_event),
entity_category=EntityCategory.ALARM,
entity_type=entity_event[SyncProps.SYNC_TYPE],
entity_state=AlarmProps.ALARM_STATE,
entity_state=AlarmProps.ALARM_ACTIVE_STATE,
update_timestamp=timestamp,
metadata=metadata)

View File

@@ -159,7 +159,7 @@ class TestActionExecutor(TestEntityGraphFunctionalBase):
props = {
TFields.ALARM_NAME: 'VM_CPU_SUBOPTIMAL_PERFORMANCE',
TFields.SEVERITY: 'critical',
VProps.STATE: AlarmProps.ALARM_STATE
VProps.STATE: AlarmProps.ALARM_ACTIVE_STATE
}
action_spec = ActionSpecs(ActionType.RAISE_ALARM, targets, props)

View File

@@ -46,7 +46,7 @@ class RaiseAlarmRecipeTest(base.BaseTest):
self.assertEqual(ADD_VERTEX, action_steps[0].type)
add_vertex_step_params = action_steps[0].params
self.assertEqual(2, len(add_vertex_step_params))
self.assertEqual(3, len(add_vertex_step_params))
alarm_name = add_vertex_step_params[TFields.ALARM_NAME]
self.assertEqual(props[TFields.ALARM_NAME], alarm_name)
@@ -74,7 +74,7 @@ class RaiseAlarmRecipeTest(base.BaseTest):
self.assertEqual(REMOVE_VERTEX, action_steps[0].type)
remove_vertex_step_params = action_steps[0].params
self.assertEqual(2, len(remove_vertex_step_params))
self.assertEqual(3, len(remove_vertex_step_params))
alarm_name = remove_vertex_step_params[TFields.ALARM_NAME]
self.assertEqual(props[TFields.ALARM_NAME], alarm_name)

View File

@@ -104,7 +104,7 @@ class NagiosTransformerTest(base.BaseTest):
self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY])
self.assertEqual(event[SyncProps.SYNC_TYPE], vertex[VProps.TYPE])
self.assertEqual(event[NagiosProperties.SERVICE], vertex[VProps.NAME])
self.assertEqual(AlarmProps.ALARM_STATE, vertex[VProps.STATE])
self.assertEqual(AlarmProps.ALARM_ACTIVE_STATE, vertex[VProps.STATE])
self.assertEqual(event[NagiosProperties.STATUS],
vertex[VProps.SEVERITY])