Esempio n. 1
0
File: api.py Progetto: B-Rich/sahara
 def _load_backend(self):
     with self._lock:
         if not self._backend:
             # Import the untranslated name if we don't have a mapping
             backend_path = self._backend_mapping.get(self._backend_name,
                                                      self._backend_name)
             backend_mod = importutils.import_module(backend_path)
             self._backend = backend_mod.get_backend()
Esempio n. 2
0
 def __init__(self, backend_mapping=None):
     if backend_mapping is None:
         backend_mapping = {}
     backend_name = CONF.database.backend
     # Import the untranslated name if we don't have a
     # mapping.
     backend_path = backend_mapping.get(backend_name, backend_name)
     backend_mod = importutils.import_module(backend_path)
     self.__backend = backend_mod.get_backend()
Esempio n. 3
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. 4
0
# limitations under the License.
#
# Based on Neutron's migration/cli.py

from __future__ import with_statement
from logging import config as c

from alembic import context
from sqlalchemy import create_engine
from sqlalchemy import pool

from sahara.db.sqlalchemy import model_base
from sahara.openstack.common import importutils


importutils.import_module('sahara.db.sqlalchemy.models')

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
sahara_config = config.sahara_config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
c.fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = model_base.SaharaBase.metadata
Esempio n. 5
0
 def __init__(self):
     self.db = importutils.import_module(CONF.db_driver)
Esempio n. 6
0
 def __init__(self, hashtype='SHA256'):
     self.hashfn = importutils.import_module('Crypto.Hash.' + hashtype)
     self.max_okm_length = 255 * self.hashfn.digest_size
Esempio n. 7
0
 def __init__(self, enctype='AES', hashtype='SHA256'):
     self.cipher = importutils.import_module('Crypto.Cipher.' + enctype)
     self.hashfn = importutils.import_module('Crypto.Hash.' + hashtype)
Esempio n. 8
0
 def __init__(self, hashtype='SHA256'):
     self.hashfn = importutils.import_module('Crypto.Hash.' + hashtype)
     self.max_okm_length = 255 * self.hashfn.digest_size
Esempio n. 9
0
 def __init__(self, enctype='AES', hashtype='SHA256'):
     self.cipher = importutils.import_module('Crypto.Cipher.' + enctype)
     self.hashfn = importutils.import_module('Crypto.Hash.' + hashtype)