blob: 58f33e5e30464925fbe93efc1902ca2bbe03fda2 [file] [log] [blame]
Sapan Bhatia11a32942015-01-07 01:09:02 -05001from django.http import HttpResponse
2from monitor import driver
Sapan Bhatiae999be82015-01-12 16:48:19 -05003from core.models import *
Sapan Bhatia11a32942015-01-07 01:09:02 -05004import json
5
6def Stats(request):
7 model = request.GET['model_name']
8 pk = int(request.GET['pk'])
Sapan Bhatia0255e202015-01-10 04:51:57 +00009 meter = request.GET['meter']
10 controller_name = request.GET['controller_name']
Sapan Bhatia11a32942015-01-07 01:09:02 -050011
Sapan Bhatiae999be82015-01-12 16:48:19 -050012 controller = Controller.objects.filter(name=controller_name)[0]
13 keystone = {'username':controller.admin_user, 'password':controller.admin_password, 'tenant_name':controller.admin_tenant, 'auth_url':controller.auth_url, 'cacert':'/etc/ssl/certs/ca-certificates.crt'}
14
15 for k,v in keystone.items():
16 keystone['os_'+k] = v
17
18 meters = driver.get_meter(meter, model, pk, keystone)
Sapan Bhatia0255e202015-01-10 04:51:57 +000019 return HttpResponse(json.dumps(meters))