import eventlet from kombu import Connection from kombu.mixins import ConsumerMixin from oslo.config import cfg from st2common import log as logging from st2common.constants.action import LIVEACTION_STATUS_SUCCEEDED, LIVEACTION_STATUS_FAILED from st2common.constants.triggers import INTERNAL_TRIGGER_TYPES from st2common.models.system.common import ResourceReference from st2common.transport import liveaction, publishers from st2common.transport.reactor import TriggerDispatcher from st2common.util.greenpooldispatch import BufferedDispatcher LOG = logging.getLogger(__name__) ACTIONUPDATE_WORK_Q = liveaction.get_queue('st2.notifiers.work', routing_key=publishers.UPDATE_RK) ACTION_COMPLETE_STATES = [LIVEACTION_STATUS_FAILED, LIVEACTION_STATUS_SUCCEEDED] ACTION_SENSOR_ENABLED = cfg.CONF.action_sensor.enable # XXX: Fix this nasty positional dependency. ACTION_TRIGGER_TYPE = INTERNAL_TRIGGER_TYPES['action'][0] NOTIFY_TRIGGER_TYPE = INTERNAL_TRIGGER_TYPES['action'][1] class LiveActionUpdateQueueConsumer(ConsumerMixin): def __init__(self, connection, notifier): self.connection = connection self._dispatcher = BufferedDispatcher() self._notifier = notifier def shutdown(self): self._dispatcher.shutdown()
from kombu.mixins import ConsumerMixin from oslo.config import cfg from st2actions.container.base import RunnerContainer from st2common import log as logging from st2common.exceptions.db import StackStormDBObjectNotFoundError from st2common.constants.action import (LIVEACTION_STATUS_RUNNING, LIVEACTION_STATUS_FAILED) from st2common.exceptions.actionrunner import ActionRunnerException from st2common.transport import liveaction, publishers from st2common.util.action_db import (get_liveaction_by_id, update_liveaction_status) from st2common.util.greenpooldispatch import BufferedDispatcher LOG = logging.getLogger(__name__) ACTIONRUNNER_WORK_Q = liveaction.get_queue('st2.actionrunner.work', routing_key=publishers.CREATE_RK) class Worker(ConsumerMixin): def __init__(self, connection): self.connection = connection self.container = RunnerContainer() self._dispatcher = BufferedDispatcher() def shutdown(self): self._dispatcher.shutdown() def get_consumers(self, Consumer, channel): consumer = Consumer(queues=[ACTIONRUNNER_WORK_Q], accept=['pickle'],
from st2common.transport import consumers, liveaction, publishers from st2common.transport import utils as transport_utils from st2common.transport.reactor import TriggerDispatcher from st2common.util import isotime from st2common.util import jinja as jinja_utils from st2common.constants.action import ACTION_CONTEXT_KV_PREFIX from st2common.constants.action import ACTION_PARAMETERS_KV_PREFIX from st2common.constants.action import ACTION_RESULTS_KV_PREFIX from st2common.constants.keyvalue import SYSTEM_SCOPE from st2common.services.keyvalues import KeyValueLookup __all__ = ['Notifier', 'get_notifier'] LOG = logging.getLogger(__name__) ACTIONUPDATE_WORK_Q = liveaction.get_queue('st2.notifiers.work', routing_key=publishers.UPDATE_RK) ACTION_SENSOR_ENABLED = cfg.CONF.action_sensor.enable # XXX: Fix this nasty positional dependency. ACTION_TRIGGER_TYPE = INTERNAL_TRIGGER_TYPES['action'][0] NOTIFY_TRIGGER_TYPE = INTERNAL_TRIGGER_TYPES['action'][1] class Notifier(consumers.MessageHandler): message_type = LiveActionDB def __init__(self, connection, queues, trigger_dispatcher=None): super(Notifier, self).__init__(connection, queues) if not trigger_dispatcher: trigger_dispatcher = TriggerDispatcher(LOG) self._trigger_dispatcher = trigger_dispatcher
from st2common import log as logging from st2common.exceptions.db import StackStormDBObjectNotFoundError from st2common.constants.action import LIVEACTION_STATUS_RUNNING from st2common.constants.action import LIVEACTION_STATUS_SUCCEEDED from st2common.constants.action import LIVEACTION_STATUS_FAILED from st2common.exceptions.actionrunner import ActionRunnerException from st2common.services import executions from st2common.transport import liveaction, publishers from st2common.util import system_info from st2common.util.action_db import (get_liveaction_by_id, update_liveaction_status) from st2common.util.greenpooldispatch import BufferedDispatcher LOG = logging.getLogger(__name__) ACTIONRUNNER_WORK_Q = liveaction.get_queue('st2.actionrunner.work', routing_key=publishers.CREATE_RK) class Worker(ConsumerMixin): def __init__(self, connection): self.connection = connection self.container = RunnerContainer() self._dispatcher = BufferedDispatcher() def shutdown(self): self._dispatcher.shutdown() def get_consumers(self, Consumer, channel): consumer = Consumer(queues=[ACTIONRUNNER_WORK_Q], accept=['pickle'],