From cda666d04cc1076b72d9f4a4e894167bb32203a9 Mon Sep 17 00:00:00 2001 From: Luka Peschke Date: Tue, 17 Apr 2018 14:49:34 +0200 Subject: [PATCH] Fix 400 on /v1/storage/dataframes Change-Id: I3bd072964d293ab36410691e840998e31a98da10 Task: 14322 Story: 2001868 --- cloudkitty/api/v1/datamodels/rating.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/cloudkitty/api/v1/datamodels/rating.py b/cloudkitty/api/v1/datamodels/rating.py index ad992551..4de4e818 100644 --- a/cloudkitty/api/v1/datamodels/rating.py +++ b/cloudkitty/api/v1/datamodels/rating.py @@ -18,30 +18,26 @@ import decimal from oslo_config import cfg +from oslo_log import log from wsme import types as wtypes from cloudkitty.api.v1 import types as cktypes from cloudkitty import utils as ck_utils +LOG = log.getLogger(__name__) + CONF = cfg.CONF METRICS_CONF = ck_utils.get_metrics_conf(CONF.collect.metrics_conf) try: - services_names = list(METRICS_CONF['services_objects'].keys()) -except Exception: - # TODO(mc): remove this hack once rated dataframes are based on metrics. - services_names = [ - 'compute', - 'volume', - 'image', - 'network.bw.in', - 'network.bw.out', - 'network.floating', - 'radosgw.usage', - ] + SERVICE_NAMES = list(METRICS_CONF['metrics'].keys()) +except KeyError: + LOG.error("No metrics specified in YAML configuration, " + "CloudKitty won't work as expected") + SERVICE_NAMES = ['compute', 'image'] -CLOUDKITTY_SERVICES = wtypes.Enum(wtypes.text, *services_names) +CLOUDKITTY_SERVICES = wtypes.Enum(wtypes.text, *SERVICE_NAMES) class CloudkittyResource(wtypes.Base):