add ceilometer_url
diff --git a/xos/ceilometer/admin.py b/xos/ceilometer/admin.py
index a70032a..8644ab7 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',
- 'tenant_list_str',
+ 'ceilometer_url', 'tenant_list_str',
'sliver', 'creator'],
'classes':['suit-tab suit-tab-general']})]
- readonly_fields = ('backend_status_text', 'sliver', 'service_specific_attribute', 'tenant_list_str')
+ readonly_fields = ('backend_status_text', 'sliver', 'service_specific_attribute', 'ceilometer_url', 'tenant_list_str')
form = MonitoringChannelForm
suit_form_tabs = (('general','Details'),)
diff --git a/xos/ceilometer/models.py b/xos/ceilometer/models.py
index c276682..809494d 100644
--- a/xos/ceilometer/models.py
+++ b/xos/ceilometer/models.py
@@ -51,6 +51,25 @@
super(MonitoringChannel, self).delete(*args, **kwargs)
@property
+ def addresses(self):
+ if not self.sliver:
+ return {}
+
+ addresses = {}
+ for ns in self.sliver.ports.all():
+ if "private" in ns.network.name.lower():
+ addresses["private"] = (ns.ip, ns.mac)
+ elif "nat" in ns.network.name.lower():
+ addresses["nat"] = (ns.ip, ns.mac)
+ elif "hpc_client" in ns.network.name.lower():
+ addresses["hpc_client"] = (ns.ip, ns.mac)
+ return addresses
+
+ @property
+ def private_ip(self):
+ return self.addresses.get("nat", (None, None))[0]
+
+ @property
def site_tenant_list(self):
tenant_ids = Set()
for sp in SitePrivilege.objects.filter(user=self.creator):
@@ -82,8 +101,11 @@
def tenant_list_str(self):
return ", ".join(self.tenant_list)
-
-
+ @property
+ def ceilometer_url(self):
+ if not self.private_ip:
+ return None
+ return "http://" + self.private_ip + "/uri/to/ceilometer/api/"
def model_policy_monitoring_channel(pk):
# TODO: this should be made in to a real model_policy