Exemplo n.º 1
0
def load_storage_driver(conf, cache, control_mode=False):
    """Loads a storage driver and returns it.

    The driver's initializer will be passed conf and cache as
    its positional args.

    :param conf: Configuration instance to use for loading the
        driver. Must include a 'drivers' group.
    :param cache: Cache instance that the driver can (optionally)
        use to reduce latency for some operations.
    :param control_mode: (Default False). Determines which
        driver type to load; if False, the data driver is
        loaded. If True, the control driver is loaded.
    """

    mode = 'control' if control_mode else 'data'
    driver_type = 'marconi.queues.{0}.storage'.format(mode)

    try:
        mgr = driver.DriverManager(driver_type,
                                   conf['drivers'].storage,
                                   invoke_on_load=True,
                                   invoke_args=[conf, cache])

        return mgr.driver

    except RuntimeError as exc:
        LOG.exception(exc)
        raise errors.InvalidDriver(exc)
Exemplo n.º 2
0
 def cache(self):
     LOG.debug(_(u'Loading proxy cache driver'))
     try:
         oslo_cache.register_oslo_configs(self.conf)
         mgr = oslo_cache.get_cache(self.conf.cache_url)
         return mgr
     except RuntimeError as exc:
         LOG.exception(exc)
         raise errors.InvalidDriver(exc)
Exemplo n.º 3
0
    def transport(self):
        transport_name = self.driver_conf.transport
        LOG.debug(_(u'Loading transport driver: %s'), transport_name)

        args = [
            self.conf,
            self.storage,
            self.cache,
            self.control,
        ]

        try:
            mgr = driver.DriverManager('marconi.queues.transport',
                                       transport_name,
                                       invoke_on_load=True,
                                       invoke_args=args)
            return mgr.driver
        except RuntimeError as exc:
            LOG.exception(exc)
            raise errors.InvalidDriver(exc)