Grabbing the list_measurements when getting metrics_list

Change-Id: Ife32971ad0826aaa93d4a684f46c739f8ee774a3
This commit is contained in:
Michael James Hoppal 2015-04-07 16:58:48 -06:00
parent 7b4c0a78e8
commit f63a8930fc
3 changed files with 28 additions and 10 deletions

View File

@ -147,6 +147,11 @@ def metrics_list(request, **kwargs):
return result['elements'] if type(result) is dict else result
def metrics_measurement_list(request, **kwargs):
result = monascaclient(request).metrics.list_measurements(**kwargs)
return result['elements'] if type(result) is dict else result
def metrics_stat_list(request, **kwargs):
result = monascaclient(request).metrics.list_statistics(**kwargs)
return result['elements'] if type(result) is dict else result

View File

@ -16,6 +16,7 @@
import json
import logging
import urllib
from django.conf import settings # noqa
from django.core.urlresolvers import reverse_lazy
@ -146,11 +147,19 @@ class MonascaProxyView(TemplateView):
into a python dict that looks like
{"service": "monitoring"} (used by monasca api calls)
"""
if 'dimensions' in req_kwargs:
new_dimenstion_dict = {}
for dimension in req_kwargs['dimensions']:
key, value = dimension.split(":")
new_dimenstion_dict[key] = value
if 'dimensions' in req_kwargs:
dimensions_str = req_kwargs['dimensions'][0]
print(dimensions_str)
print(type(dimensions_str))
dimensions_str_array = dimensions_str.split(',')
for dimension in dimensions_str_array:
dimension_name_value = dimension.split(':')
if len(dimension_name_value) == 2:
new_dimenstion_dict[dimension_name_value[0]] = urllib.unquote(dimension_name_value[1]).decode('utf8')
else:
raise Exception('Dimensions are malformed')
req_kwargs['dimensions'] = new_dimenstion_dict
return req_kwargs
@ -163,13 +172,17 @@ class MonascaProxyView(TemplateView):
if "metrics" == parts[0]:
req_kwargs = dict(self.request.GET)
self._convert_dimensions(req_kwargs)
if "statistics" == parts[1]:
if len(parts) == 1:
results = {'elements': api.monitor.
metrics_list(request,
**req_kwargs)}
elif "statistics" == parts[1]:
results = {'elements': api.monitor.
metrics_stat_list(request,
**req_kwargs)}
if "measurements" == parts[1]:
elif "measurements" == parts[1]:
results = {'elements': api.monitor.
metrics_list(request,
metrics_measurement_list(request,
**req_kwargs)}
if not results:
LOG.warn("There was a request made for the path %s that"