Merge "remove notifier call from evaluator"
This commit is contained in:
commit
4c040fd5d0
@ -21,9 +21,4 @@ OPTS = [
|
||||
default='/etc/vitrage/templates',
|
||||
help='A path for the templates used by the evaluator'
|
||||
),
|
||||
|
||||
cfg.StrOpt('notifier_topic',
|
||||
default='vitrage.evaluator',
|
||||
help='The topic that vitrage-evaluator uses for alarm '
|
||||
'notifications messages.'),
|
||||
]
|
||||
|
@ -26,7 +26,6 @@ from vitrage.evaluator.actions.base import ActionType
|
||||
from vitrage.evaluator.actions.evaluator_event_transformer import VITRAGE_TYPE
|
||||
from vitrage.evaluator.actions.recipes.action_steps import ADD_EDGE
|
||||
from vitrage.evaluator.actions.recipes.action_steps import ADD_VERTEX
|
||||
from vitrage.evaluator.actions.recipes.action_steps import NOTIFY
|
||||
from vitrage.evaluator.actions.recipes.action_steps import REMOVE_EDGE
|
||||
from vitrage.evaluator.actions.recipes.action_steps import REMOVE_VERTEX
|
||||
from vitrage.evaluator.actions.recipes.action_steps import UPDATE_VERTEX
|
||||
@ -42,10 +41,9 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class ActionExecutor(object):
|
||||
|
||||
def __init__(self, event_queue, notifier=None):
|
||||
def __init__(self, event_queue):
|
||||
self.event_queue = event_queue
|
||||
self.action_recipes = ActionExecutor._register_action_recipes()
|
||||
self.notifier = notifier
|
||||
|
||||
self.action_step_defs = {
|
||||
ADD_VERTEX: self.add_vertex,
|
||||
@ -53,7 +51,6 @@ class ActionExecutor(object):
|
||||
UPDATE_VERTEX: self.update_vertex,
|
||||
ADD_EDGE: self.add_edge,
|
||||
REMOVE_EDGE: self.remove_edge,
|
||||
NOTIFY: self.notify
|
||||
}
|
||||
|
||||
def execute(self, action_spec, action_mode):
|
||||
@ -106,12 +103,6 @@ class ActionExecutor(object):
|
||||
|
||||
self.event_queue.put(event)
|
||||
|
||||
def notify(self, params):
|
||||
if self.notifier:
|
||||
event_type = params['event_type']
|
||||
del params['event_type']
|
||||
self.notifier.notify(event_type, params)
|
||||
|
||||
@staticmethod
|
||||
def _add_default_properties(event):
|
||||
|
||||
|
@ -17,4 +17,3 @@ REMOVE_VERTEX = 'remove_vertex'
|
||||
UPDATE_VERTEX = 'update_vertex'
|
||||
ADD_EDGE = 'add_edge'
|
||||
REMOVE_EDGE = 'remove_edge'
|
||||
NOTIFY = 'notify'
|
||||
|
@ -12,15 +12,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from vitrage.common.constants import NotifierEventTypes
|
||||
from vitrage.common.constants import VertexProperties as VProps
|
||||
from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps
|
||||
from vitrage.evaluator.actions.recipes.action_steps import ADD_VERTEX
|
||||
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):
|
||||
@ -43,11 +40,7 @@ class RaiseAlarm(base.Recipe):
|
||||
params[VProps.STATE] = AlarmProps.ALARM_ACTIVE_STATE
|
||||
add_vertex_step = ActionStepWrapper(ADD_VERTEX, params)
|
||||
|
||||
notify_step = RaiseAlarm._get_notify_step(
|
||||
action_spec,
|
||||
NotifierEventTypes.ACTIVATE_DEDUCED_ALARM_EVENT)
|
||||
|
||||
return [add_vertex_step, notify_step]
|
||||
return [add_vertex_step]
|
||||
|
||||
@staticmethod
|
||||
def get_undo_recipe(action_spec):
|
||||
@ -56,22 +49,7 @@ class RaiseAlarm(base.Recipe):
|
||||
params[VProps.STATE] = AlarmProps.ALARM_INACTIVE_STATE
|
||||
remove_vertex_step = ActionStepWrapper(REMOVE_VERTEX, params)
|
||||
|
||||
notify_step = RaiseAlarm._get_notify_step(
|
||||
action_spec,
|
||||
NotifierEventTypes.DEACTIVATE_DEDUCED_ALARM_EVENT)
|
||||
|
||||
return [remove_vertex_step, notify_step]
|
||||
|
||||
@staticmethod
|
||||
def _get_notify_step(action_spec, event_type):
|
||||
|
||||
notify_params = {
|
||||
'affected_resource_id': action_spec.targets[TFields.TARGET],
|
||||
'name': action_spec.properties[TFields.ALARM_NAME],
|
||||
'event_type': event_type,
|
||||
}
|
||||
notify_step = ActionStepWrapper(NOTIFY, notify_params)
|
||||
return notify_step
|
||||
return [remove_vertex_step]
|
||||
|
||||
@staticmethod
|
||||
def _get_vertex_params(action_spec):
|
||||
|
@ -25,7 +25,6 @@ from vitrage.graph.algo_driver.algorithm import Mapping
|
||||
from vitrage.graph import create_algorithm
|
||||
from vitrage.graph import create_graph
|
||||
from vitrage.graph.driver import Vertex
|
||||
from vitrage.messaging import VitrageNotifier
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
@ -43,10 +42,7 @@ class ScenarioEvaluator(object):
|
||||
self._entity_graph = entity_graph
|
||||
self._graph_algs = create_algorithm(entity_graph)
|
||||
self._scenario_repo = scenario_repo
|
||||
self._notifier = VitrageNotifier(conf,
|
||||
'vitrage.evaluator',
|
||||
conf.evaluator.notifier_topic)
|
||||
self._action_executor = ActionExecutor(event_queue, self._notifier)
|
||||
self._action_executor = ActionExecutor(event_queue)
|
||||
self._entity_graph.subscribe(self.process_event)
|
||||
self.enabled = enabled
|
||||
|
||||
|
@ -30,7 +30,7 @@ class VitrageNotifierService(os_service.Service):
|
||||
self.conf = conf
|
||||
self.notifiers = [AodhNotifier(conf)]
|
||||
transport = messaging.get_transport(conf)
|
||||
target = oslo_messaging.Target(topic=conf.evaluator.notifier_topic)
|
||||
target = oslo_messaging.Target(topic='stam')
|
||||
self.listener = messaging.get_notification_listener(
|
||||
transport, [target],
|
||||
[VitrageEventEndpoint(self.notifiers)])
|
||||
|
@ -13,11 +13,9 @@
|
||||
# under the License.
|
||||
from oslo_log import log as logging
|
||||
|
||||
from vitrage.common.constants import NotifierEventTypes
|
||||
from vitrage.datasources.alarm_properties import AlarmProperties
|
||||
from vitrage.evaluator.actions.base import ActionType
|
||||
from vitrage.evaluator.actions.recipes.action_steps import ADD_VERTEX
|
||||
from vitrage.evaluator.actions.recipes.action_steps import NOTIFY
|
||||
from vitrage.evaluator.actions.recipes.action_steps import REMOVE_VERTEX
|
||||
from vitrage.evaluator.actions.recipes.raise_alarm import RaiseAlarm
|
||||
from vitrage.evaluator.template import ActionSpecs
|
||||
@ -49,8 +47,8 @@ class RaiseAlarmRecipeTest(base.BaseTest):
|
||||
|
||||
# Test Assertions
|
||||
|
||||
# expecting for two steps: [add_vertex, notify]
|
||||
self.assertEqual(2, len(action_steps))
|
||||
# expecting for one step: [add_vertex]
|
||||
self.assertEqual(1, len(action_steps))
|
||||
|
||||
self.assertEqual(ADD_VERTEX, action_steps[0].type)
|
||||
add_vertex_step_params = action_steps[0].params
|
||||
@ -65,19 +63,6 @@ class RaiseAlarmRecipeTest(base.BaseTest):
|
||||
alarm_state = add_vertex_step_params[TFields.STATE]
|
||||
self.assertEqual(alarm_state, AlarmProperties.ALARM_ACTIVE_STATE)
|
||||
|
||||
self.assertEqual(NOTIFY, action_steps[1].type)
|
||||
notify_params = action_steps[1].params
|
||||
|
||||
affected_resource_id = notify_params['affected_resource_id']
|
||||
self.assertEqual(self.target_vertex_id, affected_resource_id)
|
||||
|
||||
event_type = notify_params['event_type']
|
||||
self.assertEqual(NotifierEventTypes.ACTIVATE_DEDUCED_ALARM_EVENT,
|
||||
event_type)
|
||||
|
||||
name = notify_params['name']
|
||||
self.assertEqual(self.props[TFields.ALARM_NAME], name)
|
||||
|
||||
def test_get_undo_recipe(self):
|
||||
|
||||
# Test Action
|
||||
@ -85,8 +70,8 @@ class RaiseAlarmRecipeTest(base.BaseTest):
|
||||
|
||||
# Test Assertions
|
||||
|
||||
# expecting for two steps: [remove_vertex, notify]
|
||||
self.assertEqual(2, len(action_steps))
|
||||
# expecting for one step: [remove_vertex]
|
||||
self.assertEqual(1, len(action_steps))
|
||||
|
||||
self.assertEqual(REMOVE_VERTEX, action_steps[0].type)
|
||||
remove_vertex_step_params = action_steps[0].params
|
||||
@ -102,19 +87,3 @@ class RaiseAlarmRecipeTest(base.BaseTest):
|
||||
|
||||
alarm_state = remove_vertex_step_params[TFields.STATE]
|
||||
self.assertEqual(alarm_state, AlarmProperties.ALARM_INACTIVE_STATE)
|
||||
|
||||
self.assertEqual(NOTIFY, action_steps[1].type)
|
||||
notify_params = action_steps[1].params
|
||||
|
||||
# notify expects 3 params: name, event_type and affected_resource_id
|
||||
self.assertEqual(3, len(notify_params))
|
||||
|
||||
affected_resource_id = notify_params['affected_resource_id']
|
||||
self.assertEqual(self.target_vertex_id, affected_resource_id)
|
||||
|
||||
event_type = notify_params['event_type']
|
||||
self.assertEqual(NotifierEventTypes.DEACTIVATE_DEDUCED_ALARM_EVENT,
|
||||
event_type)
|
||||
|
||||
name = notify_params['name']
|
||||
self.assertEqual(self.props[TFields.ALARM_NAME], name)
|
||||
|
Loading…
Reference in New Issue
Block a user