cloudkitty  13.0.0
About: OpenStack CloudKitty provides Rating-as-a-Service for OpenStack.
The "Victoria" series (maintained release).
  Fossies Dox: cloudkitty-13.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

monasca.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # Copyright 2019 Objectif Libre
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
14 # under the License.
15 #
16 from keystoneauth1 import loading as ks_loading
17 from oslo_config import cfg
18 
19 from cloudkitty.common import monasca_client as mon_client_utils
20 from cloudkitty import fetcher
21 
22 MONASCA_API_VERSION = '2_0'
23 
24 FETCHER_MONASCA_OPTS = 'fetcher_monasca'
25 
26 fetcher_monasca_opts = [
27  cfg.StrOpt('dimension_name',
28  default='project_id',
29  help='Monasca dimension from which scope_ids should be'
30  ' collected.'),
31  cfg.StrOpt('monasca_tenant_id',
32  default=None,
33  help='If specified, monasca client will use this ID instead of'
34  ' the default one.'),
35  cfg.StrOpt(
36  'monasca_service_name',
37  default='monasca',
38  help='Name of the Monasca service (defaults to monasca)',
39  ),
40  cfg.StrOpt(
41  'interface',
42  default='internal',
43  help='Endpoint URL type (defaults to internal).',
44  ),
45 ]
46 
47 CONF = cfg.CONF
48 
49 cfg.CONF.register_opts(fetcher_monasca_opts, FETCHER_MONASCA_OPTS)
50 ks_loading.register_auth_conf_options(CONF, FETCHER_MONASCA_OPTS)
51 ks_loading.register_session_conf_options(CONF, FETCHER_MONASCA_OPTS)
52 
53 
55  """Monasca fetcher"""
56 
57  name = 'monasca'
58 
59  def __init__(self):
60  self._conn = mon_client_utils.get_monasca_client(CONF,
61  FETCHER_MONASCA_OPTS)
62 
63  def get_tenants(self):
64  kwargs = {
65  "tenant_id": CONF.fetcher_monasca.monasca_tenant_id,
66  "dimension_name": CONF.fetcher_monasca.dimension_name,
67  }
68  if kwargs['tenant_id'] is None:
69  del kwargs['tenant_id']
70  values = self._conn.metrics.list_dimension_values(**kwargs)
71  return [v['dimension_value'] for v in values]
cloudkitty.fetcher.monasca.MonascaFetcher.get_tenants
def get_tenants(self)
Definition: monasca.py:63
cloudkitty.fetcher.monasca.MonascaFetcher
Definition: monasca.py:54
cloudkitty.common
Definition: __init__.py:1
cloudkitty.fetcher.BaseFetcher
Definition: __init__.py:31
cloudkitty.fetcher.monasca.MonascaFetcher._conn
_conn
Definition: monasca.py:60
cloudkitty.fetcher.monasca.MonascaFetcher.__init__
def __init__(self)
Definition: monasca.py:59