Load ceilometer credentials from controller
diff --git a/planetstack/core/views/stats.py b/planetstack/core/views/stats.py
index 421fbfe..58f33e5 100644
--- a/planetstack/core/views/stats.py
+++ b/planetstack/core/views/stats.py
@@ -1,5 +1,6 @@
from django.http import HttpResponse
from monitor import driver
+from core.models import *
import json
def Stats(request):
@@ -8,5 +9,11 @@
meter = request.GET['meter']
controller_name = request.GET['controller_name']
- meters = driver.get_meter(meter, model, pk)
+ controller = Controller.objects.filter(name=controller_name)[0]
+ 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'}
+
+ for k,v in keystone.items():
+ keystone['os_'+k] = v
+
+ meters = driver.get_meter(meter, model, pk, keystone)
return HttpResponse(json.dumps(meters))
diff --git a/planetstack/openstack_observer/ceilometer.py b/planetstack/openstack_observer/ceilometer.py
index 00c1238..e34b000 100644
--- a/planetstack/openstack_observer/ceilometer.py
+++ b/planetstack/openstack_observer/ceilometer.py
@@ -13,9 +13,9 @@
def object_to_filter(model_name, pk):
from core.models import *
filter_dict = {
- 'Slice':[Slice, 'tenant_id', 'project_id'],
+ 'ControllerSlice':[ControllerSlice, 'tenant_id', 'project_id'],
'Sliver':[Sliver, 'instance_id', 'resource_id'],
- 'Site':[Site, 'tenant_id', 'project_id']
+ 'ControllerSite':[ControllerSite, 'tenant_id', 'project_id']
}
mod,field,tag = filter_dict[model_name]
@@ -86,20 +86,21 @@
class CeilometerDriver(MonitorDriver):
def get_meter(self, meter, obj, pk, keystone=None):
- keystone = {}
- keystone['os_username']=env['OS_USERNAME']
- keystone['os_password']=env['OS_PASSWORD']
- keystone['os_auth_url']=env['OS_AUTH_URL']
- keystone['os_tenant_name']=env['OS_TENANT_NAME']
- keystone['os_cacert']=env['OS_CACERT']
- keystone['os_region_name']=env['OS_REGION_NAME']
+ if (not keystone):
+ keystone={}
+ keystone['os_username']=env['OS_USERNAME']
+ keystone['os_password']=env['OS_PASSWORD']
+ keystone['os_auth_url']=env['OS_AUTH_URL']
+ keystone['os_tenant_name']=env['OS_TENANT_NAME']
+ keystone['os_cacert']=env['OS_CACERT']
+ keystone['os_region_name']=env['OS_REGION_NAME']
- keystone['username']=env['OS_USERNAME']
- keystone['password']=env['OS_PASSWORD']
- keystone['auth_url']=env['OS_AUTH_URL']
- keystone['tenant_name']=env['OS_TENANT_NAME']
- keystone['cacert']=env['OS_CACERT']
- keystone['region_name']=env['OS_REGION_NAME']
+ keystone['username']=env['OS_USERNAME']
+ keystone['password']=env['OS_PASSWORD']
+ keystone['auth_url']=env['OS_AUTH_URL']
+ keystone['tenant_name']=env['OS_TENANT_NAME']
+ keystone['cacert']=env['OS_CACERT']
+ keystone['region_name']=env['OS_REGION_NAME']
keystone['auth_plugin']=client.AuthPlugin(**keystone)