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 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)
 def test_delete_datasource(self):
     id_ = uuidutils.generate_uuid()
     datasources.add_datasource(
         id_=id_, name="hiya", driver="foo", config="{user: foo}", description="hello", enabled=True
     )
     self.assertTrue(datasources.delete_datasource(id_))
     self.assertIsNone(datasources.get_datasource(id_))
Beispiel #4
0
 def get_datasource_schema(cls, datasource_id):
     datasource = datasources_db.get_datasource(datasource_id)
     if not datasource:
         raise DatasourceNotFound(id=datasource_id)
     driver = cls.get_driver_info(datasource.driver)
     if driver:
         # NOTE(arosen): raises if not found
         driver = cls.get_driver_info(driver['id'])
         obj = importutils.import_class(driver['module'])
         return obj.get_schema()
Beispiel #5
0
 def test_delete_datasource(self):
     id_ = uuidutils.generate_uuid()
     datasources.add_datasource(id_=id_,
                                name="hiya",
                                driver="foo",
                                config={'user': '******'},
                                description="hello",
                                enabled=True)
     self.assertTrue(datasources.delete_datasource(id_))
     self.assertIsNone(datasources.get_datasource(id_))
Beispiel #6
0
 def get_datasource_schema(cls, datasource_id):
     datasource = datasources_db.get_datasource(datasource_id)
     if not datasource:
         raise DatasourceNotFound(id=datasource_id)
     driver = cls.get_driver_info(datasource.driver)
     if driver:
         # NOTE(arosen): raises if not found
         driver = cls.get_driver_info(
             driver['id'])
         obj = importutils.import_class(driver['module'])
         return obj.get_schema()
 def test_get_datasource_by_id(self):
     id_ = uuidutils.generate_uuid()
     datasources.add_datasource(
         id_=id_, name="hiya", driver="foo", config="{user: foo}", description="hello", enabled=True
     )
     source = datasources.get_datasource(id_)
     self.assertEqual(id_, source.id)
     self.assertEqual("hiya", source.name)
     self.assertEqual("foo", source.driver)
     self.assertEqual("hello", source.description)
     self.assertEqual('"{user: foo}"', source.config)
     self.assertTrue(source.enabled)
Beispiel #8
0
 def test_get_datasource_by_id(self):
     id_ = uuidutils.generate_uuid()
     datasources.add_datasource(id_=id_,
                                name="hiya",
                                driver="foo",
                                config={'user': '******'},
                                description="hello",
                                enabled=True)
     source = datasources.get_datasource(id_)
     self.assertEqual(id_, source.id)
     self.assertEqual("hiya", source.name)
     self.assertEqual("foo", source.driver)
     self.assertEqual("hello", source.description)
     self.assertEqual({'user': '******'}, json.loads(source.config))
     self.assertTrue(source.enabled)
Beispiel #9
0
 def test_get_datasource_by_id(self):
     id_ = uuidutils.generate_uuid()
     datasources.add_datasource(id_=id_,
                                name="hiya",
                                driver="foo",
                                config='{user: foo}',
                                description="hello",
                                enabled=True)
     source = datasources.get_datasource(id_)
     self.assertEqual(id_, source.id)
     self.assertEqual("hiya", source.name)
     self.assertEqual("foo", source.driver)
     self.assertEqual("hello", source.description)
     self.assertEqual('"{user: foo}"', source.config)
     self.assertEqual(True, source.enabled)
Beispiel #10
0
    def load_module_object(cls, datasource_id_or_name):
        datasource = datasources_db.get_datasource(datasource_id_or_name)
        # Ideally speaking, it should change datasource_db.get_datasource() to
        # be able to retrieve datasource info from db at once. The datasource
        # table and the method, however, will be removed in the new
        # architecture, so it use this way. Supporting both name and id is
        # a backward compatibility.
        if not datasource:
            datasource = (datasources_db.
                          get_datasource_by_name(datasource_id_or_name))
        if not datasource:
            return None

        driver = cls.get_driver_info(datasource.driver)
        obj = importutils.import_class(driver['module'])

        return obj
Beispiel #11
0
 def get_datasource(cls, id_):
     """Return the created datasource."""
     result = datasources_db.get_datasource(id_)
     if not result:
         raise DatasourceNotFound(id=id_)
     return cls.make_datasource_dict(result)
Beispiel #12
0
 def get_datasource(cls, id_):
     """Return the created datasource."""
     result = datasources_db.get_datasource(id_)
     if not result:
         raise DatasourceNotFound(id=id_)
     return cls.make_datasource_dict(result)