Remove useless event factory

Change-Id: I8442a26ebfcfe3c17c378b283ffbbc0810b7a067
This commit is contained in:
Jean-Emile DARTOIS
2015-12-16 11:35:02 +01:00
parent ac07f35dc7
commit 18549dc182
15 changed files with 45 additions and 235 deletions

View File

@@ -35,16 +35,16 @@ class DefaultActionPlanHandler(BaseActionPlanHandler):
self.action_plan_uuid = action_plan_uuid
self.manager_applier = manager_applier
def notify(self, uuid, event_type, status):
def notify(self, uuid, event_type, state):
action_plan = ActionPlan.get_by_uuid(self.ctx, uuid)
action_plan.state = status
action_plan.state = state
action_plan.save()
event = Event()
event.set_type(event_type)
event.set_data({})
event.type = event_type
event.data = {}
payload = {'action_plan__uuid': uuid,
'action_plan_status': status}
self.manager_applier.topic_status.publish_event(event.get_type().name,
'action_plan_state': state}
self.manager_applier.topic_status.publish_event(event.type.name,
payload)
def execute(self):

View File

@@ -42,11 +42,11 @@ class ActionPlanExecutor(object):
db_action.state = state
db_action.save()
event = Event()
event.set_type(Events.LAUNCH_ACTION)
event.set_data({})
event.type = Events.LAUNCH_ACTION
event.data = {}
payload = {'action_uuid': action.uuid,
'action_status': state}
self.manager_applier.topic_status.publish_event(event.get_type().name,
'action_state': state}
self.manager_applier.topic_status.publish_event(event.type.name,
payload)
def execute(self, actions):

View File

@@ -23,9 +23,6 @@ from oslo_log import log
from watcher.applier.messaging.trigger import TriggerActionPlan
from watcher.common.messaging.messaging_core import MessagingCore
from watcher.common.messaging.notification_handler import NotificationHandler
from watcher.decision_engine.messaging.events import Events
LOG = log.getLogger(__name__)
CONF = cfg.CONF
@@ -59,8 +56,6 @@ CONF.register_opts(APPLIER_MANAGER_OPTS, opt_group)
class ApplierManager(MessagingCore):
# todo(jed) need workflow
def __init__(self):
super(ApplierManager, self).__init__(
CONF.watcher_applier.publisher_id,
@@ -70,24 +65,9 @@ class ApplierManager(MessagingCore):
)
# shared executor of the workflow
self.executor = ThreadPoolExecutor(max_workers=1)
self.handler = NotificationHandler(self.publisher_id)
self.handler.register_observer(self)
self.add_event_listener(Events.ALL, self.event_receive)
# trigger action_plan
self.topic_control.add_endpoint(TriggerActionPlan(self))
def join(self):
self.topic_control.join()
self.topic_status.join()
def event_receive(self, event):
try:
request_id = event.get_request_id()
event_type = event.get_type()
data = event.get_data()
LOG.debug("request id => %s" % request_id)
LOG.debug("type_event => %s" % str(event_type))
LOG.debug("data => %s" % str(data))
except Exception as e:
LOG.exception(e)
raise