Commit ab361c47 by Kálmán Viktor

dashboard: mccabe for VmGraphView

parent d4f0e64c
......@@ -1267,19 +1267,21 @@ class VmGraphView(LoginRequiredMixin, View):
if not instance.has_level(request.user, 'user'):
raise PermissionDenied()
prefix = 'vm.%s' % instance.vm_name
if metric == 'cpu':
target = ('cactiStyle(alias(derivative(%s.cpu.usage),'
'"cpu usage (%%)"))') % prefix
elif metric == 'memory':
target = ('cactiStyle(alias(%s.memory.usage,'
'"memory usage (%%)"))') % prefix
elif metric == 'network':
target = ('cactiStyle(aliasByMetric('
'derivative(%s.network.bytes_*)))') % prefix
else:
targets = {
'cpu': ('cactiStyle(alias(derivative(%s.cpu.usage),'
'"cpu usage (%%)"))'),
'memory': ('cactiStyle(alias(%s.memory.usage,'
'"memory usage (%%)"))'),
'network': ('cactiStyle(aliasByMetric('
'derivative(%s.network.bytes_*)))'),
}
if metric not in targets.keys():
raise SuspiciousOperation()
prefix = 'vm.%s' % instance.vm_name
target = targets[metric] % prefix
title = '%s (%s) - %s' % (instance.name, instance.vm_name, metric)
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