Esempio n. 1
0
 def __init__(self, **kwargs):
     super(GnocchiStorage, self).__init__(**kwargs)
     conf = kwargs.get('conf') or ck_utils.load_conf(
         CONF.collect.metrics_conf)
     self.conf = validate_conf(conf)
     self.auth = ks_loading.load_auth_from_conf_options(
         CONF,
         GNOCCHI_STORAGE_OPTS)
     self.session = ks_loading.load_session_from_conf_options(
         CONF,
         GNOCCHI_STORAGE_OPTS,
         auth=self.auth)
     self._conn = gclient.Client(
         '1',
         session=self.session,
         adapter_options={'connect_retries': 3,
                          'interface': CONF.storage_gnocchi.interface})
     self._archive_policy_name = (
         CONF.storage_gnocchi.archive_policy_name)
     self._archive_policy_definition = json.loads(
         CONF.storage_gnocchi.archive_policy_definition)
     self._period = kwargs.get('period') or CONF.collect.period
     self._measurements = dict()
     self._resource_type_data = dict()
     self._init_resource_types()
Esempio n. 2
0
def get_one_metric(metric_name):
    try:
        metrics_conf = collector.validate_conf(
            ck_utils.load_conf(CONF.collect.metrics_conf))
    except (voluptuous.Invalid, voluptuous.MultipleInvalid):
        msg = 'Invalid endpoint: no metrics in current configuration.'
        pecan.abort(405, msg)

    policy.authorize(pecan.request.context, 'info:get_metric_info', {})
    metric = _find_metric(metric_name, metrics_conf)
    if not metric:
        pecan.abort(404, str(metric_name))
    info = metric.copy()
    info['metric_id'] = info['alt_name']
    return info_models.CloudkittyMetricInfo(**info)
Esempio n. 3
0
def get_one_metric(metric_name):
    try:
        metrics_conf = collector.validate_conf(
            ck_utils.load_conf(CONF.collect.metrics_conf))
    except (voluptuous.Invalid, voluptuous.MultipleInvalid):
        msg = 'Invalid endpoint: no metrics in current configuration.'
        pecan.abort(405, msg)

    policy.authorize(pecan.request.context, 'info:get_metric_info', {})
    metric = _find_metric(metric_name, metrics_conf)
    if not metric:
        pecan.abort(404, six.text_type(metric_name))
    info = metric.copy()
    info['metric_id'] = info['alt_name']
    return info_models.CloudkittyMetricInfo(**info)
Esempio n. 4
0
def get_all_metrics():
    try:
        metrics_conf = collector.validate_conf(
            ck_utils.load_conf(CONF.collect.metrics_conf))
    except (voluptuous.Invalid, voluptuous.MultipleInvalid):
        msg = 'Invalid endpoint: no metrics in current configuration.'
        pecan.abort(405, msg)

    policy.authorize(pecan.request.context, 'info:list_metrics_info', {})
    metrics_info_list = []
    for metric_name, metric in metrics_conf.items():
        info = metric.copy()
        info['metric_id'] = info['alt_name']
        metrics_info_list.append(info_models.CloudkittyMetricInfo(**info))
    return info_models.CloudkittyMetricInfoCollection(
        metrics=metrics_info_list)
Esempio n. 5
0
def get_all_metrics():
    try:
        metrics_conf = collector.validate_conf(
            ck_utils.load_conf(CONF.collect.metrics_conf))
    except (voluptuous.Invalid, voluptuous.MultipleInvalid):
        msg = 'Invalid endpoint: no metrics in current configuration.'
        pecan.abort(405, msg)

    policy.authorize(pecan.request.context, 'info:list_metrics_info', {})
    metrics_info_list = []
    for metric_name, metric in metrics_conf.items():
        info = metric.copy()
        info['metric_id'] = info['alt_name']
        metrics_info_list.append(
            info_models.CloudkittyMetricInfo(**info))
    return info_models.CloudkittyMetricInfoCollection(
        metrics=metrics_info_list)