Esempio n. 1
0
def _import_module(mod_str):
    try:
        if mod_str.startswith("bin."):
            imp.load_source(mod_str[4:], os.path.join("bin", mod_str[4:]))
            return sys.modules[mod_str[4:]]
        else:
            return importutils.import_module(mod_str)
    except Exception as e:
        sys.stderr.write("Error importing module %s: %s\n" % (mod_str, str(e)))
        return None
Esempio n. 2
0
 def __get_backend(self):
     """Get the actual backend.  May be a module or an instance of
     a class.  Doesn't matter to us.  We do this synchronized as it's
     possible multiple greenthreads started very quickly trying to do
     DB calls and eventlet can switch threads before self.__backend gets
     assigned.
     """
     if self.__backend:
         # Another thread assigned it
         return self.__backend
     backend_name = CONF.database.backend
     self.__use_tpool = CONF.database.use_tpool
     if self.__use_tpool:
         from eventlet import tpool
         self.__tpool = tpool
     # Import the untranslated name if we don't have a
     # mapping.
     backend_path = self.__backend_mapping.get(backend_name,
                                               backend_name)
     backend_mod = importutils.import_module(backend_path)
     self.__backend = backend_mod.get_backend()
     return self.__backend
Esempio n. 3
0
    def __get_backend(self):
        """Get the actual backend.  May be a module or an instance of
        a class.  Doesn't matter to us.  We do this synchronized as it's
        possible multiple greenthreads started very quickly trying to do
        DB calls and eventlet can switch threads before self.__backend gets
        assigned.
        """
        if self.__backend:
            # Another thread assigned it
            return self.__backend
        backend_name = CONF.database.backend
        self.__use_tpool = CONF.database.use_tpool
        if self.__use_tpool:
            from eventlet import tpool

            self.__tpool = tpool
        # Import the untranslated name if we don't have a
        # mapping.
        backend_path = self.__backend_mapping.get(backend_name, backend_name)
        backend_mod = importutils.import_module(backend_path)
        self.__backend = backend_mod.get_backend()
        return self.__backend
Esempio n. 4
0
def load_engine():
    global _engine
    module_name = cfg.CONF.engine.engine
    module = importutils.import_module(module_name)
    _engine = module.get_engine()
Esempio n. 5
0
 def __init__(self, transport=None):
     module_name = cfg.CONF.engine.engine
     module = importutils.import_module(module_name)
     self.transport = get_transport(transport)
     self.backend = module.get_engine()
     self.backend.transport = self.transport
Esempio n. 6
0
from oslo.config import cfg

eventlet.monkey_patch()

from mistral.actions import std_actions
from mistral.db import api as db_api
from mistral import engine
from mistral.engine import executor
from mistral.engine import states
from mistral.openstack.common import importutils
from mistral.openstack.common import log as logging
from mistral.tests import base


# We need to make sure that all configuration properties are registered.
importutils.import_module("mistral.config")
LOG = logging.getLogger(__name__)

# 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')


WORKBOOK_NAME = 'my_workbook'
TASK_NAME = 'create-vms'

SAMPLE_WORKBOOK = {
    'id': str(uuid.uuid4()),
    'name': WORKBOOK_NAME,
    'description': 'my description',
    'definition': base.get_resource("test_rest.yaml"),
Esempio n. 7
0
#    limitations under the License.

import os
import tempfile
import unittest2

from oslo import messaging
from oslo.config import cfg
from oslo.messaging import transport
import pkg_resources as pkg
from stevedore import driver

from mistral.openstack.common import importutils

# We need to make sure that all configuration properties are registered.
importutils.import_module("mistral.config")

from mistral.db.sqlalchemy import api as db_api
from mistral.openstack.common import log as logging
from mistral.openstack.common.db.sqlalchemy import session
from mistral import version
from mistral.engine import client
from mistral.engine.scalable import engine
from mistral.engine.scalable.executor import server

RESOURCES_PATH = 'tests/resources/'
LOG = logging.getLogger(__name__)


def get_resource(resource_name):
    return open(
Esempio n. 8
0
 def __init__(self, transport=None):
     module_name = cfg.CONF.engine.engine
     module = importutils.import_module(module_name)
     self.transport = get_transport(transport)
     self.backend = module.get_engine()
     self.backend.transport = self.transport