Ejemplo n.º 1
0
    def delete_missing_driver_datasources(self):
        removed = 0
        for datasource in datasources_db.get_datasources():
            try:
                self.get_driver_info(datasource.driver)
            except exception.DriverNotFound:
                datasources_db.delete_datasource_with_data(datasource.id)
                removed = removed+1
                LOG.debug("Datasource driver '%s' not found, deleting the "
                          "datasource '%s' from DB ", datasource.driver,
                          datasource.name)

        LOG.info("Datsource cleanup completed, removed %d datasources",
                 removed)
Ejemplo n.º 2
0
    def delete_missing_driver_datasources(self):
        removed = 0
        for datasource in datasources_db.get_datasources():
            try:
                self.get_driver_info(datasource.driver)
            except exception.DriverNotFound:
                datasources_db.delete_datasource_with_data(datasource.id)
                removed = removed+1
                LOG.debug("Datasource driver '%s' not found, deleting the "
                          "datasource '%s' from DB ", datasource.driver,
                          datasource.name)

        LOG.info("Datsource cleanup completed, removed %d datasources",
                 removed)
Ejemplo n.º 3
0
 def test_delete_datasource_with_data(self):
     id_ = uuidutils.generate_uuid()
     datasources.add_datasource(
         id_=id_, name="hiya", driver="foo", config="{user: foo}", description="hello", enabled=True
     )
     db_ds_table_data.store_ds_table_data(
         ds_id=id_, tablename="bar", tabledata=set([("a1", "b1"), ("a2", "b2"), ("a3", "a4")])
     )
     self.assertTrue(datasources.delete_datasource_with_data(id_))
     self.assertEqual(db_ds_table_data.get_ds_table_data(id_), [])
Ejemplo n.º 4
0
 def test_delete_datasource_with_data(self):
     id_ = uuidutils.generate_uuid()
     datasources.add_datasource(id_=id_,
                                name="hiya",
                                driver="foo",
                                config={'user': '******'},
                                description="hello",
                                enabled=True)
     db_ds_table_data.store_ds_table_data(ds_id=id_,
                                          tablename='bar',
                                          tabledata=set([('a1', 'b1'),
                                                         ('a2', 'b2'),
                                                         ('a3', 'a4')]))
     self.assertTrue(datasources.delete_datasource_with_data(id_))
     self.assertEqual(db_ds_table_data.get_ds_table_data(id_), [])
Ejemplo n.º 5
0
 def test_delete_datasource_with_data(self):
     id_ = uuidutils.generate_uuid()
     datasources.add_datasource(
         id_=id_,
         name="hiya",
         driver="foo",
         config={'user': '******'},
         description="hello",
         enabled=True)
     db_ds_table_data.store_ds_table_data(
         ds_id=id_,
         tablename='bar',
         tabledata=set([('a1', 'b1'), ('a2', 'b2'), ('a3', 'a4')])
         )
     self.assertTrue(datasources.delete_datasource_with_data(id_))
     self.assertEqual(db_ds_table_data.get_ds_table_data(id_), [])
Ejemplo n.º 6
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)
Ejemplo n.º 7
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)