Commit ab361c47 by Kálmán Viktor

dashboard: mccabe for VmGraphView

parent d4f0e64c
...@@ -1267,19 +1267,21 @@ class VmGraphView(LoginRequiredMixin, View): ...@@ -1267,19 +1267,21 @@ class VmGraphView(LoginRequiredMixin, View):
if not instance.has_level(request.user, 'user'): if not instance.has_level(request.user, 'user'):
raise PermissionDenied() raise PermissionDenied()
prefix = 'vm.%s' % instance.vm_name targets = {
if metric == 'cpu': 'cpu': ('cactiStyle(alias(derivative(%s.cpu.usage),'
target = ('cactiStyle(alias(derivative(%s.cpu.usage),' '"cpu usage (%%)"))'),
'"cpu usage (%%)"))') % prefix 'memory': ('cactiStyle(alias(%s.memory.usage,'
elif metric == 'memory': '"memory usage (%%)"))'),
target = ('cactiStyle(alias(%s.memory.usage,' 'network': ('cactiStyle(aliasByMetric('
'"memory usage (%%)"))') % prefix 'derivative(%s.network.bytes_*)))'),
elif metric == 'network': }
target = ('cactiStyle(aliasByMetric('
'derivative(%s.network.bytes_*)))') % prefix if metric not in targets.keys():
else:
raise SuspiciousOperation() raise SuspiciousOperation()
prefix = 'vm.%s' % instance.vm_name
target = targets[metric] % prefix
title = '%s (%s) - %s' % (instance.name, instance.vm_name, metric) title = '%s (%s) - %s' % (instance.name, instance.vm_name, metric)
params = urlencode({'target': target, params = urlencode({'target': target,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment