Ejemplo n.º 1
0
def register_models(options):
    """Register Models and create properties"""
    supported_memcache_models = ast.literal_eval(options["backend_entities"])
    for supported_memcache_model in supported_memcache_models:
        model = utils.import_module(MODEL_PREFIX + supported_memcache_model)
        top_models.set_value(supported_memcache_model, model)
        if model.__api__ != None:
            model_api = utils.import_module(API_PREFIX + model.__api__)
            top_api.set_value(model.__api__, model_api.get())
Ejemplo n.º 2
0
def register_models(options):
    """Register Models and create properties"""
    supported_memcache_models = ast.literal_eval(
                    options["backend_entities"])
    for supported_memcache_model in supported_memcache_models:
        model = utils.import_module(MODEL_PREFIX + supported_memcache_model)
        top_models.set_value(supported_memcache_model, model)
        if model.__api__ is not None:
            model_api = utils.import_module(API_PREFIX + model.__api__)
            top_api.set_value(model.__api__, model_api.get())
Ejemplo n.º 3
0
    def _init_models(self, model_list):
        for model in model_list:
            model_path = '.'.join([__package__, 'models', model])
            module = utils.import_module(model_path)

            top_models.set_value(model, module)

            if module.__api__ is not None:
                api_path = '.'.join([__package__, 'api', module.__api__])
                api_module = utils.import_module(api_path)
                top_api.set_value(module.__api__, api_module.get())
Ejemplo n.º 4
0
    def setUp(self, options=None):  # pylint: disable=W0221
        super(BackendTestCase, self).setUp()
        # Set up root options if missing
        if options is None:
            options = {
            'backends': None,
            "keystone-service-admin-role": "KeystoneServiceAdmin",
            "keystone-admin-role": "KeystoneAdmin",
            "hash-password": "******"
            }

        # set up default backend if none supplied
        if 'backends' not in options or options['backends'] is None:
            options['backends'] = 'keystone.backends.sqlalchemy'
            if 'keystone.backends.sqlalchemy' not in options:
                options['keystone.backends.sqlalchemy'] = {
                "sql_connection": "sqlite://",
                "backend_entities": "['UserRoleAssociation', 'Endpoints',\
                                     'Role', 'Tenant', 'User',\
                                     'Credentials', 'EndpointTemplates',\
                                     'Token', 'Service']",
                "sql_idle_timeout": "30"
                }

        # Init backends module constants (without initializing backends)
        no_backend_init = options.copy()
        no_backend_init['backends'] = None
        reload(backends)
        backends.configure_backends(no_backend_init)

        backend_list = options['backends']
        for backend in backend_list.split(','):
            backend_module = utils.import_module(backend)
            settings = options[backend]
            backend_module.configure_backend(settings)
Ejemplo n.º 5
0
    def setUp(self, options=None):  # pylint: disable=W0221
        super(BackendTestCase, self).setUp()
        # Set up root options if missing
        if options is None:
            options = {
                "backends": None,
                "keystone-service-admin-role": "KeystoneServiceAdmin",
                "keystone-admin-role": "KeystoneAdmin",
                "hash-password": "******",
            }

        # set up default backend if none supplied
        if "backends" not in options or options["backends"] is None:
            options["backends"] = "keystone.backends.sqlalchemy"
            if "keystone.backends.sqlalchemy" not in options:
                options["keystone.backends.sqlalchemy"] = {
                    "sql_connection": "sqlite://",
                    "backend_entities": "['UserRoleAssociation', 'Endpoints',\
                                     'Role', 'Tenant', 'User',\
                                     'Credentials', 'EndpointTemplates',\
                                     'Token', 'Service']",
                    "sql_idle_timeout": "30",
                }

        # Init backends module constants (without initializing backends)
        no_backend_init = options.copy()
        no_backend_init["backends"] = None
        reload(backends)
        backends.configure_backends(no_backend_init)

        backend_list = options["backends"]
        for backend in backend_list.split(","):
            backend_module = utils.import_module(backend)
            settings = options[backend]
            backend_module.configure_backend(settings)
Ejemplo n.º 6
0
def configure_backends(options):
    '''Load backends given in the 'backends' option.'''
    backend_names = options.get('backends', DEFAULT_BACKENDS)
    for backend in backend_names.split(','):
        backend_module = utils.import_module(backend)
        backend_module.configure_backend(options[backend])
        #Initialize common configs general to all backends.
        global KeyStoneAdminRole
        KeyStoneAdminRole = options["keystone-admin-role"]
Ejemplo n.º 7
0
def register_models(options):
    """Register Models and create properties"""
    global _ENGINE
    assert _ENGINE
    supported_alchemy_models = ast.literal_eval(
                    options["backend_entities"])
    supported_alchemy_tables = []
    for supported_alchemy_model in supported_alchemy_models:
        model = utils.import_module(MODEL_PREFIX + supported_alchemy_model)
        supported_alchemy_tables.append(model.__table__)
        top_models.set_value(supported_alchemy_model, model)
        if model.__api__ != None:
            model_api = utils.import_module(API_PREFIX + model.__api__)
            top_api.set_value(model.__api__, model_api.get())
    creation_tables = []
    for table in reversed(BASE.metadata.sorted_tables):
        if table in supported_alchemy_tables:
            creation_tables.append(table)
    BASE.metadata.create_all(_ENGINE, tables=creation_tables, checkfirst=True)
Ejemplo n.º 8
0
def configure_backends():
    """Load backends given in the 'backends' option."""
    global SHOULD_HASH_PASSWORD  # pylint: disable=W0603
    SHOULD_HASH_PASSWORD = CONF.hash_password

    backend_names = CONF.backends or DEFAULT_BACKENDS
    for module_name in backend_names.split(","):
        backend_module = utils.import_module(module_name)
        backend_conf = GroupConf(module_name)
        backend_module.configure_backend(backend_conf)
Ejemplo n.º 9
0
def configure_backends(options):
    """Load backends given in the 'backends' option."""
    backend_names = options.get("backends", DEFAULT_BACKENDS)
    for backend in backend_names.split(","):
        backend_module = utils.import_module(backend)
        backend_module.configure_backend(options[backend])
        # Initialize common configs general to all backends.
        global KEYSTONEADMINROLE
        KEYSTONEADMINROLE = options["keystone-admin-role"]
        global KEYSTONESERVICEADMINROLE
        KEYSTONESERVICEADMINROLE = options["keystone-service-admin-role"]
Ejemplo n.º 10
0
    def _init_models(self, model_list):
        for model in model_list:
            model_class = getattr(models, model)
            top_models.set_value(model, model_class)

            if model_class.__api__ is not None:
                api_path = '.'.join([__package__, 'api', model_class.__api__])
                api_module = sys.modules.get(api_path)
                if api_module is None:
                    api_module = utils.import_module(api_path)
                top_api.set_value(model_class.__api__, api_module.get())
Ejemplo n.º 11
0
def register_models(options):
    """Register Models and create properties"""
    global _ENGINE
    assert _ENGINE
    # Need to decide.Not This is missing
    # and prevents foreign key reference checks.
    # _ENGINE.execute('pragma foreign_keys=on')
    supported_alchemy_models = ast.literal_eval(options["backend_entities"])
    supported_alchemy_tables = []
    for supported_alchemy_model in supported_alchemy_models:
        model = utils.import_module(MODEL_PREFIX + supported_alchemy_model)
        supported_alchemy_tables.append(model.__table__)
        top_models.set_value(supported_alchemy_model, model)
        if model.__api__ != None:
            model_api = utils.import_module(API_PREFIX + model.__api__)
            top_api.set_value(model.__api__, model_api.get())
    creation_tables = []
    for table in reversed(BASE.metadata.sorted_tables):
        if table in supported_alchemy_tables:
            creation_tables.append(table)
    BASE.metadata.create_all(_ENGINE, tables=creation_tables, checkfirst=True)
Ejemplo n.º 12
0
def configure_backends(options):
    '''Load backends given in the 'backends' option.'''
    backend_names = options.get('backends', DEFAULT_BACKENDS)
    if backend_names:
        for backend in backend_names.split(','):
            backend_module = utils.import_module(backend)
            backend_module.configure_backend(options[backend])

    #Initialize common configs general to all backends.
    global SHOULD_HASH_PASSWORD
    if ("hash-password" in options
            and ast.literal_eval(options["hash-password"])):
        SHOULD_HASH_PASSWORD = options["hash-password"]
Ejemplo n.º 13
0
def configure_backends(options):
    '''Load backends given in the 'backends' option.'''
    backend_names = options.get('backends', DEFAULT_BACKENDS)
    for backend in backend_names.split(','):
        backend_module = utils.import_module(backend)
        backend_module.configure_backend(options[backend])

    #Initialize common configs general to all backends.
    global ADMIN_ROLE_NAME
    ADMIN_ROLE_NAME = options["keystone-admin-role"]

    global SERVICE_ADMIN_ROLE_NAME
    SERVICE_ADMIN_ROLE_NAME = options["keystone-service-admin-role"]
Ejemplo n.º 14
0
def register_models(options):
    """Register Models and create properties"""
    global _ENGINE
    assert _ENGINE
    # Need to decide.Not This is missing
    # and prevents foreign key reference checks.
    # _ENGINE.execute('pragma foreign_keys=on')
    supported_alchemy_models = ast.literal_eval(
                    options["backend_entities"])
    supported_alchemy_tables = []
    for supported_alchemy_model in supported_alchemy_models:
        model = utils.import_module(MODEL_PREFIX + supported_alchemy_model)
        supported_alchemy_tables.append(model.__table__)
        top_models.set_value(supported_alchemy_model, model)
        if model.__api__ != None:
            model_api = utils.import_module(API_PREFIX + model.__api__)
            top_api.set_value(model.__api__, model_api.get())
    creation_tables = []
    for table in reversed(BASE.metadata.sorted_tables):
        if table in supported_alchemy_tables:
            creation_tables.append(table)
    BASE.metadata.create_all(_ENGINE, tables=creation_tables, checkfirst=True)
Ejemplo n.º 15
0
def configure_backends(options):
    '''Load backends given in the 'backends' option.'''
    backend_names = options.get('backends', DEFAULT_BACKENDS)
    if backend_names:
        for backend in backend_names.split(','):
            backend_module = utils.import_module(backend)
            backend_module.configure_backend(options[backend])

    #Initialize common configs general to all backends.
    global SHOULD_HASH_PASSWORD
    if ("hash-password" in options
        and ast.literal_eval(options["hash-password"])):
        SHOULD_HASH_PASSWORD = options["hash-password"]
Ejemplo n.º 16
0
 def configure_extensions(self, extension_type, mapper, options):
     supported_extensions = options.get(CONFIG_EXTENSION_PROPERTY,
                                        DEFAULT_EXTENSIONS)
     for supported_extension in supported_extensions.split(','):
         self.extension_handlers = []
         supported_extension = EXTENSION_PREFIX\
         + extension_type + '.' + supported_extension.strip()\
         + '.ExtensionHandler'
         try:
             extenion_handler = utils.import_module(supported_extension)()
             extenion_handler.map_extension_methods(mapper, options)
             self.extension_handlers.append(extenion_handler)
         except Exception as err:
             logging.exception("Could not load extension for " +\
                 extension_type + ':' + supported_extension + str(err))
Ejemplo n.º 17
0
 def configure_extensions(self, extension_type, mapper, options):
     supported_extensions = options.get(CONFIG_EXTENSION_PROPERTY,
                                        DEFAULT_EXTENSIONS)
     for supported_extension in supported_extensions.split(','):
         self.extension_handlers = []
         supported_extension = "%s%s.%s" % (
             EXTENSION_PREFIX, extension_type, supported_extension.strip())
         try:
             extension_module = utils.import_module(supported_extension)
             if hasattr(extension_module, 'ExtensionHandler'):
                 extension_class = extension_module.ExtensionHandler()
                 extension_class.map_extension_methods(mapper, options)
                 self.extension_handlers.append(extension_class)
         except Exception as err:
             logger.exception("Could not load extension for %s:%s %s" %
                 (extension_type, supported_extension, err))
Ejemplo n.º 18
0
 def configure_extensions(self, extension_type,
     mapper, options):
     supported_extensions = options.get(
         CONFIG_EXTENSION_PROPERTY, DEFAULT_EXTENSIONS)
     for supported_extension in supported_extensions.split(','):
         self.extension_handlers = []
         supported_extension = EXTENSION_PREFIX\
         + extension_type + '.' + supported_extension.strip()\
         + '.ExtensionHandler'
         try:
             extenion_handler = utils.import_module(supported_extension)()
             extenion_handler.map_extension_methods(mapper, options)
             self.extension_handlers.append(extenion_handler)
         except Exception as err:
             logging.exception("Could not load extension for " +\
                 extension_type + ':' + supported_extension + str(err))
Ejemplo n.º 19
0
    def _init_tables(self, model_list):
        tables = []

        for model in model_list:
            model_path = '.'.join([__package__, 'models', model])
            module = utils.import_module(model_path)
            tables.append(module.__table__)

        tables_to_create = []
        for table in reversed(models.Base.metadata.sorted_tables):
            if table in tables:
                tables_to_create.append(table)

        logger.debug('Creating tables: %s' % \
                ','.join([table.name for table in tables_to_create]))
        models.Base.metadata.create_all(self._engine, tables=tables_to_create,
                                        checkfirst=True)
Ejemplo n.º 20
0
def configure_backends(options):
    '''Load backends given in the 'backends' option.'''
    backend_names = options.get('backends', DEFAULT_BACKENDS)
    for backend in backend_names.split(','):
        backend_module = utils.import_module(backend)
        backend_module.configure_backend(options[backend])

    #Initialize common configs general to all backends.
    global ADMIN_ROLE_NAME
    ADMIN_ROLE_NAME = options["keystone-admin-role"]

    global SERVICE_ADMIN_ROLE_NAME
    SERVICE_ADMIN_ROLE_NAME = options["keystone-service-admin-role"]

    global SHOULD_HASH_PASSWORD
    if "hash-password" in options\
        and ast.literal_eval(options["hash-password"]) == True:
        SHOULD_HASH_PASSWORD = options["hash-password"]