compute closure of tenant_ids for user
diff --git a/xos/ceilometer/admin.py b/xos/ceilometer/admin.py
index 48bf101..a70032a 100644
--- a/xos/ceilometer/admin.py
+++ b/xos/ceilometer/admin.py
@@ -74,10 +74,10 @@
list_display = ('backend_status_icon', 'id', )
list_display_links = ('backend_status_icon', 'id')
fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'service_specific_attribute',
- 'sliver',
- 'creator'],
+ 'tenant_list_str',
+ 'sliver', 'creator'],
'classes':['suit-tab suit-tab-general']})]
- readonly_fields = ('backend_status_text', 'sliver', 'service_specific_attribute')
+ readonly_fields = ('backend_status_text', 'sliver', 'service_specific_attribute', 'tenant_list_str')
form = MonitoringChannelForm
suit_form_tabs = (('general','Details'),)
diff --git a/xos/ceilometer/models.py b/xos/ceilometer/models.py
index 2b2e990..c276682 100644
--- a/xos/ceilometer/models.py
+++ b/xos/ceilometer/models.py
@@ -8,6 +8,8 @@
from operator import itemgetter, attrgetter, methodcaller
import traceback
from xos.exceptions import *
+from core.models import SlicePrivilege, SitePrivilege
+from sets import Set
CEILOMETER_KIND = "ceilometer"
@@ -48,6 +50,41 @@
self.cleanup_container()
super(MonitoringChannel, self).delete(*args, **kwargs)
+ @property
+ def site_tenant_list(self):
+ tenant_ids = Set()
+ for sp in SitePrivilege.objects.filter(user=self.creator):
+ site = sp.site
+ for cs in site.controllersite.all():
+ if cs.tenant_id:
+ tenant_ids.add(cs.tenant_id)
+ return tenant_ids
+
+ @property
+ def slice_tenant_list(self):
+ tenant_ids = Set()
+ for sp in SlicePrivilege.objects.filter(user=self.creator):
+ slice = sp.slice
+ for cs in slice.controllerslices.all():
+ if cs.tenant_id:
+ tenant_ids.add(cs.tenant_id)
+ for slice in Slice.objects.filter(creator=self.creator):
+ for cs in slice.controllerslices.all():
+ if cs.tenant_id:
+ tenant_ids.add(cs.tenant_id)
+ return tenant_ids
+
+ @property
+ def tenant_list(self):
+ return self.slice_tenant_list | self.site_tenant_list
+
+ @property
+ def tenant_list_str(self):
+ return ", ".join(self.tenant_list)
+
+
+
+
def model_policy_monitoring_channel(pk):
# TODO: this should be made in to a real model_policy
with transaction.atomic():