Beispiel #1
0
 def get_datasource(cls, id_):
     """Return the created datasource."""
     # Note(thread-safety): blocking call
     result = datasources_db.get_datasource(id_)
     if not result:
         raise exception.DatasourceNotFound(id=id_)
     return cls.make_datasource_dict(result)
Beispiel #2
0
    def delete_datasource(self, datasource, update_db=True):
        LOG.debug("Deleting %s datasource ", datasource['name'])
        datasource_id = datasource['id']
        if update_db:
            # Note(thread-safety): blocking call
            result = datasources_db.delete_datasource_with_data(datasource_id)
            if not result:
                raise exception.DatasourceNotFound(id=datasource_id)

        # Note(thread-safety): blocking call
        try:
            self.synchronize_datasources()
        except Exception:
            msg = ('failed to synchronize_datasource after '
                   'deleting datasource: %s' % datasource_id)
            LOG.exception(msg)
            raise exception.DataServiceError(msg)
Beispiel #3
0
    def delete_datasource(self, datasource, update_db=True):
        LOG.debug("Deleting %s datasource ", datasource['name'])
        datasource_id = datasource['id']
        if update_db:
            # Note(thread-safety): blocking call
            result = datasources_db.delete_datasource_with_data(datasource_id)
            if not result:
                raise exception.DatasourceNotFound(id=datasource_id)

        # Note(thread-safety): blocking call
        try:
            self.synchronizer.sync_datasource(datasource['name'])
            # If local PE exists.. sync
            engine = self.node.service_object(api_base.ENGINE_SERVICE_ID)
            if engine:
                engine.synchronizer.sync_one_policy(datasource['name'])
        except Exception:
            msg = ('failed to synchronize_datasource after '
                   'deleting datasource: %s' % datasource_id)
            LOG.exception(msg)
            raise exception.DataServiceError(msg)