Exemplo n.º 1
0
    def create_datasource_service(self, datasource):
        """Create a new DataService on this node.

        :param: datasource: datsource object.
        """
        # get the driver info for the datasource
        ds_dict = self.make_datasource_dict(datasource)
        if not ds_dict['enabled']:
            LOG.info("datasource %s not enabled, skip loading",
                     ds_dict['name'])
            return
        driver = self.loaded_drivers.get(ds_dict['driver'])
        if not driver:
            raise exception.DriverNotFound(id=ds_dict['driver'])

        if ds_dict['config'] is None:
            args = {'ds_id': ds_dict['id']}
        else:
            args = dict(ds_dict['config'], ds_id=ds_dict['id'])
        kwargs = {'name': ds_dict['name'], 'args': args}
        LOG.info("creating service %s with class %s and args %s",
                 ds_dict['name'], driver.plugin,
                 strutils.mask_password(kwargs, "****"))
        try:
            service = driver.plugin(**kwargs)
        except Exception:
            msg = ("Error loading instance of module '%s'")
            LOG.exception(msg, driver.plugin)
            raise exception.DataServiceError(msg % driver.plugin)
        return service
Exemplo n.º 2
0
    def create_datasource_service(self, datasource):
        """Create a new DataService on this node.

        :param: name is the name of the service.  Must be unique across all
               services
        :param: classPath is a string giving the path to the class name, e.g.
               congress.datasources.fake_datasource.FakeDataSource
        :param: args is the list of arguments to give the DataService
               constructor
        :param: type\_ is the kind of service
        :param: id\_ is an optional parameter for specifying the uuid.
        """
        # get the driver info for the datasource
        ds_dict = self.make_datasource_dict(datasource)
        if not ds_dict['enabled']:
            LOG.info("datasource %s not enabled, skip loading",
                     ds_dict['name'])
            return
        driver = self.loaded_drivers.get(ds_dict['driver'])
        if not driver:
            raise exception.DriverNotFound(id=ds_dict['driver'])

        if ds_dict['config'] is None:
            args = {'ds_id': ds_dict['id']}
        else:
            args = dict(ds_dict['config'], ds_id=ds_dict['id'])
        kwargs = {'name': ds_dict['name'], 'args': args}
        LOG.info("creating service %s with class %s and args %s",
                 ds_dict['name'], driver.plugin,
                 strutils.mask_password(kwargs, "****"))
        try:
            service = driver.plugin(**kwargs)
        except Exception:
            msg = ("Error loading instance of module '%s'")
            LOG.exception(msg, driver.plugin)
            raise exception.DataServiceError(msg % driver.plugin)
        return service
Exemplo n.º 3
0
 def get_driver_info(cls, driver_name):
     driver = cls.loaded_drivers.get(driver_name)
     if not driver:
         raise exception.DriverNotFound(id=driver_name)
     return driver.plugin.get_datasource_info()
Exemplo n.º 4
0
 def get_driver_info(self, driver):
     driver = self.loaded_drivers.get(driver)
     if not driver:
         raise exception.DriverNotFound(id=driver)
     return driver