Exemplo n.º 1
0
def setup_app(pecan_config=None, extra_hooks=None):

    app_conf = get_pecan_config()

    client = rpc.get_client()

    storage_backend = storage.get_storage()

    app_hooks = [
        hooks.RPCHook(client),
        hooks.StorageHook(storage_backend),
    ]

    if CONF.auth_strategy == 'keystone':
        app_hooks.append(hooks.ContextHook())

    app = pecan.make_app(app_conf.app.root,
                         static_root=app_conf.app.static_root,
                         template_path=app_conf.app.template_path,
                         debug=CONF.api.pecan_debug,
                         force_canonical=getattr(app_conf.app,
                                                 'force_canonical', True),
                         hooks=app_hooks,
                         guess_content_type_from_ext=False)

    return app
Exemplo n.º 2
0
 def setUp(self):
     super(StorageTest, self).setUp()
     self._tenant_id = samples.TENANT
     self._other_tenant_id = '8d3ae50089ea4142-9c6e1269db6a0b64'
     self.conf.set_override('backend', self.storage_backend, 'storage')
     self.storage = storage.get_storage()
     self.storage.init()
Exemplo n.º 3
0
def setup_app(pecan_config=None, extra_hooks=None):

    app_conf = get_pecan_config()

    client = rpc.get_client()

    storage_backend = storage.get_storage()

    app_hooks = [
        hooks.RPCHook(client),
        hooks.StorageHook(storage_backend),
    ]

    if CONF.auth_strategy == 'keystone':
        app_hooks.append(hooks.ContextHook())

    app = pecan.make_app(
        app_conf.app.root,
        static_root=app_conf.app.static_root,
        template_path=app_conf.app.template_path,
        debug=CONF.api.pecan_debug,
        force_canonical=getattr(app_conf.app, 'force_canonical', True),
        hooks=app_hooks,
        guess_content_type_from_ext=False
    )

    if CONF.auth_strategy == 'keystone':
        return middleware.AuthTokenMiddleware(app, dict(CONF),
                                              app_conf.app.acl_public_routes)
    else:
        return app
Exemplo n.º 4
0
 def __init__(self):
     self._coord = coordination.get_coordinator(
         CONF.orchestrator.coordination_url,
         uuidutils.generate_uuid().encode('ascii'))
     self._state = state.StateManager()
     self._storage = storage.get_storage()
     self._coord.start(start_heart=True)
Exemplo n.º 5
0
 def setUp(self):
     super(BaseHybridStorageTest, self).setUp()
     self.conf.set_override('backend', 'hybrid', 'storage')
     self.conf.set_override('version', '1', 'storage')
     self.storage = storage.get_storage(conf=test_utils.load_conf())
     with mock.patch.object(self.storage.storage._hybrid_backend, 'init'):
         self.storage.init()
Exemplo n.º 6
0
 def setUp(self):
     super(StorageTest, self).setUp()
     self._tenant_id = samples.TENANT
     self._other_tenant_id = '8d3ae50089ea4142-9c6e1269db6a0b64'
     self.conf.set_override('backend', self.storage_backend, 'storage')
     self.storage = storage.get_storage()
     self.storage.init()
Exemplo n.º 7
0
    def __init__(self, worker_id):
        self._worker_id = worker_id
        super(Orchestrator, self).__init__(self._worker_id)

        self.fetcher = driver.DriverManager(
            FETCHERS_NAMESPACE,
            CONF.fetcher.backend,
            invoke_on_load=True,
        ).driver

        transformers = transformer.get_transformers()
        self.collector = collector.get_collector(transformers)
        self.storage = storage.get_storage()
        self._state = state.StateManager()

        # RPC
        self.server = None
        self._rating_endpoint = RatingEndpoint(self)
        self._init_messaging()

        # DLM
        self.coord = coordination.get_coordinator(
            CONF.orchestrator.coordination_url,
            uuidutils.generate_uuid().encode('ascii'))
        self.coord.start(start_heart=True)
Exemplo n.º 8
0
    def __init__(self, worker_id):
        self._worker_id = worker_id
        super(CloudKittyProcessor, self).__init__(self._worker_id)

        self.tenants = []

        self.fetcher = driver.DriverManager(
            FETCHERS_NAMESPACE,
            CONF.fetcher.backend,
            invoke_on_load=True,
        ).driver

        self.collector = collector.get_collector()
        self.storage = storage.get_storage()
        self._state = state.StateManager()

        # RPC
        self.server = None
        self._rating_endpoint = RatingEndpoint(self)
        self._scope_endpoint = ScopeEndpoint()
        self._init_messaging()

        # DLM
        self.coord = coordination.get_coordinator(
            CONF.orchestrator.coordination_url,
            uuidutils.generate_uuid().encode('ascii'))
        self.coord.start(start_heart=True)
        self.next_timestamp_to_process = functools.partial(
            _check_state, self, CONF.collect.period)

        self.worker_class = Worker
        self.log_worker_initiated()
Exemplo n.º 9
0
 def setUp(self):
     super(BaseHybridStorageTest, self).setUp()
     self.conf.set_override('backend', 'hybrid', 'storage')
     hgnocchi.METRICS_CONF = samples.METRICS_CONF
     self.storage = storage.get_storage()
     with mock.patch.object(self.storage._hybrid_backend, 'init'):
         self.storage.init()
Exemplo n.º 10
0
 def setUp(self):
     super(BaseHybridStorageTest, self).setUp()
     self.conf.set_override('backend', 'hybrid', 'storage')
     self.conf.set_override('version', '1', 'storage')
     self.storage = storage.get_storage(conf=test_utils.load_conf())
     with mock.patch.object(
             self.storage.storage._hybrid_backend, 'init'):
         self.storage.init()
Exemplo n.º 11
0
 def setUp(self, gclient_mock):
     super(StorageTest, self).setUp()
     self._tenant_id = samples.TENANT
     self._other_tenant_id = '8d3ae50089ea4142-9c6e1269db6a0b64'
     self.conf.set_override('backend', self.storage_backend, 'storage')
     self.conf.set_override('version', '1', 'storage')
     self.storage = storage.get_storage(conf=test_utils.load_conf())
     self.storage.init()
Exemplo n.º 12
0
 def setUp(self, gclient_mock):
     super(StorageTest, self).setUp()
     self._tenant_id = samples.TENANT
     self._other_tenant_id = '8d3ae50089ea4142-9c6e1269db6a0b64'
     self.conf.set_override('backend', self.storage_backend, 'storage')
     self.conf.set_override('version', '1', 'storage')
     self.storage = storage.get_storage(conf=test_utils.load_conf())
     self.storage.init()
Exemplo n.º 13
0
 def setUp(self):
     super(StorageUnitTest, self).setUp()
     self._project_id = samples.TENANT
     self._other_project_id = samples.OTHER_TENANT
     self.conf.set_override('backend', self.storage_backend, 'storage')
     self.conf.set_override('version', '2', 'storage')
     self.storage = storage.get_storage(conf=test_utils.load_conf())
     self.storage.init()
     self.data = []
     self.init_data()
Exemplo n.º 14
0
 def start_fixture(self):
     auth = mock.patch('keystoneauth1.loading.load_auth_from_conf_options',
                       return_value=dict())
     session = mock.patch(
         'keystoneauth1.loading.load_session_from_conf_options',
         return_value=dict())
     with auth:
         with session:
             self.storage = storage.get_storage()
     self.storage.init()
     self.initialize_data()
Exemplo n.º 15
0
    def start_fixture(self):
        cli = influx_utils.FakeInfluxClient()
        st = storage.get_storage()
        st._conn = cli

        self._get_storage_patch = mock.patch(
            'cloudkitty.storage.get_storage',
            new=lambda **kw: st,
        )
        self._get_storage_patch.start()

        super(InfluxStorageDataFixture, self).start_fixture()
Exemplo n.º 16
0
 def start_fixture(self):
     auth = mock.patch(
         'keystoneauth1.loading.load_auth_from_conf_options',
         return_value=dict())
     session = mock.patch(
         'keystoneauth1.loading.load_session_from_conf_options',
         return_value=dict())
     with auth:
         with session:
             self.storage = storage.get_storage()
     self.storage.init()
     self.initialize_data()
Exemplo n.º 17
0
    def start_fixture(self):
        cli = influx_utils.FakeInfluxClient()
        st = storage.get_storage()
        st._conn = cli

        self._get_storage_patch = mock.patch(
            'cloudkitty.storage.get_storage',
            new=lambda **kw: st,
        )
        self._get_storage_patch.start()
        v2_api_summary.Summary.reload()
        v2_api_dataframes.DataFrameList.reload()

        super(InfluxStorageDataFixture, self).start_fixture()
Exemplo n.º 18
0
def get_api_app():
    app_conf = get_pecan_config()
    storage_backend = storage.get_storage()

    app_hooks = [
        hooks.RPCHook(),
        hooks.StorageHook(storage_backend),
        hooks.ContextHook(),
    ]

    return pecan.make_app(
        app_conf.app.root,
        static_root=app_conf.app.static_root,
        template_path=app_conf.app.template_path,
        debug=CONF.api.pecan_debug,
        force_canonical=getattr(app_conf.app, 'force_canonical', True),
        hooks=app_hooks,
        guess_content_type_from_ext=False,
    )
Exemplo n.º 19
0
def get_api_app():
    app_conf = get_pecan_config()
    storage_backend = storage.get_storage()

    app_hooks = [
        hooks.RPCHook(),
        hooks.StorageHook(storage_backend),
        hooks.ContextHook(),
    ]

    return pecan.make_app(
        app_conf.app.root,
        static_root=app_conf.app.static_root,
        template_path=app_conf.app.template_path,
        debug=CONF.api.pecan_debug,
        force_canonical=getattr(app_conf.app, 'force_canonical', True),
        hooks=app_hooks,
        guess_content_type_from_ext=False,
    )
Exemplo n.º 20
0
    def __init__(self):
        # Tenant fetcher
        self.fetcher = driver.DriverManager(FETCHERS_NAMESPACE,
                                            CONF.tenant_fetcher.backend,
                                            invoke_on_load=True).driver

        self.transformers = transformer.get_transformers()
        self.collector = collector.get_collector(self.transformers)
        self.storage = storage.get_storage(self.collector)

        # RPC
        self.server = None
        self._rating_endpoint = RatingEndpoint(self)
        self._init_messaging()

        # DLM
        self.coord = coordination.get_coordinator(
            CONF.orchestrator.coordination_url,
            str(uuid.uuid4()).encode('ascii'))
        self.coord.start()
Exemplo n.º 21
0
    def __init__(self):
        self.fetcher = driver.DriverManager(
            FETCHERS_NAMESPACE,
            METRICS_CONF['fetcher'],
            invoke_on_load=True
        ).driver

        transformers = transformer.get_transformers()
        self.collector = collector.get_collector(transformers)
        self.storage = storage.get_storage()

        # RPC
        self.server = None
        self._rating_endpoint = RatingEndpoint(self)
        self._init_messaging()

        # DLM
        self.coord = coordination.get_coordinator(
            CONF.orchestrator.coordination_url,
            uuidutils.generate_uuid().encode('ascii'))
        self.coord.start()
Exemplo n.º 22
0
    def __init__(self):
        # Tenant fetcher
        self.fetcher = driver.DriverManager(
            FETCHERS_NAMESPACE,
            CONF.tenant_fetcher.backend,
            invoke_on_load=True).driver

        self.transformers = transformer.get_transformers()
        self.collector = collector.get_collector(self.transformers)
        self.storage = storage.get_storage(self.collector)

        # RPC
        self.server = None
        self._rating_endpoint = RatingEndpoint(self)
        self._init_messaging()

        # DLM
        self.coord = coordination.get_coordinator(
            CONF.orchestrator.coordination_url,
            str(uuid.uuid4()).encode('ascii'))
        self.coord.start()
Exemplo n.º 23
0
    def setUpClass(cls):
        _init_conf()
        cls._conf_fixture = config_fixture.Config(conf=CONF)
        cls._conf_fixture.set_config_files(['/etc.cloudkitty/cloudkitty.conf'])
        cls.conf = cls._conf_fixture.conf
        cls.conf.set_override('version', cls.storage_version, 'storage')
        cls.conf.set_override('backend', cls.storage_backend, 'storage')
        cls.storage = storage.get_storage()
        cls.storage.init()
        cls.project_ids, cls.data = cls.gen_data_separate_projects(3)
        for i, project_data in enumerate(cls.data):
            cls.storage.push(project_data, cls.project_ids[i])

        # Appending data for the second tenant
        data_next_period = copy.deepcopy(cls.data[0])
        data_next_period['period']['begin'] += 3600
        data_next_period['period']['end'] += 3600
        cls.storage.push(data_next_period, cls.project_ids[0])
        cls.project_ids.append(cls.project_ids[0])
        cls.data.append(data_next_period)

        cls.wait_for_backend()
Exemplo n.º 24
0
    def __init__(self):
        # Tenant fetcher
        self.fetcher = driver.DriverManager(FETCHERS_NAMESPACE,
                                            CONF.tenant_fetcher.backend,
                                            invoke_on_load=True).driver

        self.transformers = transformer.get_transformers()
        self.collector = collector.get_collector(self.transformers)
        self.storage = storage.get_storage(self.collector)

        # RPC
        self.server = None
        self._rating_endpoint = RatingEndpoint(self)
        self._init_messaging()

        # DLM
        self.coord = coordination.get_coordinator(
            CONF.orchestrator.coordination_url,
            uuidutils.generate_uuid().encode('ascii'))
        self.coord.start()

        self._period = METRICS_CONF['period']
        self._wait_time = METRICS_CONF['wait_periods'] * self._period
Exemplo n.º 25
0
 def _load_storage_backend(self):
     self._storage = storage.get_storage()
Exemplo n.º 26
0
 def start_fixture(self):
     self.storage = storage.get_storage()
     self.storage.init()
     self.initialize_data()
Exemplo n.º 27
0
 def _load_storage_backend(self):
     self._storage = storage.get_storage()
Exemplo n.º 28
0
def init_storage_backend():
    backend = storage.get_storage()
    backend.init()
    state_manager = storage_state.StateManager()
    state_manager.init()
Exemplo n.º 29
0
 def start_fixture(self):
     self.storage = storage.get_storage()
     self.storage.init()
     self.initialize_data()
Exemplo n.º 30
0
 def __init__(self, *args, **kwargs):
     super(BaseResource, self).__init__(*args, **kwargs)
     self._storage = storage.get_storage()
Exemplo n.º 31
0
 def reload(cls):
     """Reloads all required drivers"""
     cls._storage = storage.get_storage()
Exemplo n.º 32
0
def init_storage_backend():
    backend = storage.get_storage()
    backend.init()