Ejemplo n.º 1
0
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

from oslo.config import cfg

from mistral.engine import states
from mistral import expressions
from mistral.openstack.common import log as logging


WORKFLOW_TRACE = logging.getLogger(cfg.CONF.workflow_trace_log_name)


def get_task_runtime(task_spec, state=states.IDLE, outbound_context=None,
                     task_runtime_context=None):
    """Computes the state and exec_flow_context runtime properties for a task
    based on the supplied properties. This method takes the retry nature of a
    task into consideration.

    :param task_spec: specification of the task
    :param state: suggested next state
    :param outbound_context: outbound_context to be used for computation
    :param task_runtime_context: current flow context
    :return: state, exec_flow_context tuple. Sample scenarios are,
    1. state = SUCCESS
       No need to move to next iteration.
Ejemplo n.º 2
0
# limitations under the License.

import mock
from oslo.config import cfg

from mistral.actions import std_actions
from mistral.db import api as db_api
from mistral import engine
from mistral.engine.drivers.default import engine as concrete_engine
from mistral.engine import states
from mistral import expressions
from mistral.openstack.common import log as logging
from mistral.tests import base


LOG = logging.getLogger(__name__)

WB_NAME = "my_workbook"
CONTEXT = None  # TODO(rakhmerov): Use a meaningful value.

# Use the set_default method to set value otherwise in certain test cases
# the change in value is not permanent.
cfg.CONF.set_default('auth_enable', False, group='pecan')

# TODO(rakhmerov): add more tests for errors, execution stop etc.


@mock.patch.object(
    engine.EngineClient, 'start_workflow_execution',
    mock.MagicMock(side_effect=base.EngineTestCase.mock_start_workflow))
@mock.patch.object(
Ejemplo n.º 3
0
from mistral.openstack.common.gettextutils import _  # noqa
from mistral.openstack.common import log as logging
from mistral.openstack.common import timeutils


periodic_opts = [
    cfg.BoolOpt('run_external_periodic_tasks',
                default=True,
                help=('Some periodic tasks can be run in a separate process. '
                      'Should we run them here?')),
]

CONF = cfg.CONF
CONF.register_opts(periodic_opts)

LOG = logging.getLogger(__name__)

DEFAULT_INTERVAL = 60.0


class InvalidPeriodicTaskArg(Exception):
    message = _("Unexpected argument for periodic task creation: %(arg)s.")


def periodic_task(*args, **kwargs):
    """Decorator to indicate that a method is a periodic task.

    This decorator can be used in two ways:

        1. Without arguments '@periodic_task', this will be run on every cycle
           of the periodic scheduler.
Ejemplo n.º 4
0
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

from oslo.config import cfg

from mistral import expressions
from mistral.engine import states
from mistral.openstack.common import log as logging


WORKFLOW_TRACE = logging.getLogger(cfg.CONF.workflow_trace_log_name)


def get_task_runtime(task_spec, state=states.IDLE, outbound_context=None,
                     task_runtime_context=None):
    """
    Computes the state and exec_flow_context runtime properties for a task
    based on the supplied properties. This method takes the retry nature of a
    task into consideration.

    :param task_spec: specification of the task
    :param state: suggested next state
    :param outbound_context: outbound_context to be used for computation
    :param task_runtime_context: current flow context
    :return: state, exec_flow_context tuple. Sample scenarios are,
    1. state = SUCCESS
Ejemplo n.º 5
0
                                   os.pardir,
                                   os.pardir))
if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'mistral', '__init__.py')):
    sys.path.insert(0, POSSIBLE_TOPDIR)


from oslo import messaging
from oslo.config import cfg

from mistral import config
from mistral.engine import engine
from mistral.engine.scalable.executor import server
from mistral.openstack.common import log as logging


LOG = logging.getLogger('mistral.cmd.task_executor')


def main():
    try:
        config.parse_args()
        logging.setup('Mistral')

        # TODO(rakhmerov): This is a temporary hack.
        # We have to initialize engine in executor process because
        # executor now calls engine.convey_task_result() directly.
        engine.load_engine()

        # Please refer to the oslo.messaging documentation for transport
        # configuration. The default transport for oslo.messaging is rabbitMQ.
        # The available transport drivers are listed under oslo.messaging at
Ejemplo n.º 6
0
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

from mistral.actions import std_actions
from mistral import exceptions
from mistral.openstack.common import log as logging

LOG = logging.getLogger('mistral.actions.solum')


class UpdateStackAction(std_actions.HTTPAction):
    def __init__(self, heat_service_url, action_context,
                 stack_name, stack_id, parameters, image_id, template):
        merged_parms = parameters or {}
        merged_parms['image'] = image_id
        super(UpdateStackAction, self).__init__(
            url='%s/stacks/%s/%s' % (heat_service_url, stack_name, stack_id),
            method='PUT',
            headers={'X-Auth-Token': action_context['openstack']['auth_token'],
                     'Content-Type': 'application/json',
                     'User-Agent': 'mistral-heat-plugin',
                     'Accept': 'application/json'},
            body={'stack_id': stack_id,
Ejemplo n.º 7
0
from wsgiref import simple_server

from oslo.config import cfg

from mistral.api import app
from mistral import config
from mistral.openstack.common import log as logging

eventlet.monkey_patch(
    os=True,
    select=True,
    socket=True,
    thread=False if '--use-debugger' in sys.argv else True,
    time=True)

LOG = logging.getLogger('mistral.cmd.api')


def main():
    try:
        config.parse_args()
        logging.setup('Mistral')

        host = cfg.CONF.api.host
        port = cfg.CONF.api.port

        server = simple_server.make_server(host, port, app.setup_app())

        LOG.info("Mistral API is serving on http://%s:%s (PID=%s)" %
                 (host, port, os.getpid()))