diff options
author | Jan Provaznik <jprovazn@redhat.com> | 2013-07-15 14:48:38 +0200 |
---|---|---|
committer | Tomas Sedovic <tomas@sedovic.cz> | 2013-08-01 16:18:57 +0200 |
commit | 5d62091db1bdfebb296b669c710cfdcb5d62834c (patch) | |
tree | 8a8a644aebe88c319923aa1f24fc309daff5ac6e | |
parent | 5a5b93ff563171737191e569b51b021d5c7e6435 (diff) | |
download | tuskar-ui-5d62091db1bdfebb296b669c710cfdcb5d62834c.tar.gz |
Added alerts
Alerts data are now mocked in local db. There are precreated 3 alerts
for rack and node - it expects that there will exist rack with id 1 and
nodes with ids 1 and 2. This is for demo purpose.
Currently nodes alerts are not displayed because nodes-related API logic
is not there yet (we return empty array of nodes for each rack).
Change-Id: Ic8a16db2f13909dceb700f2c99269960253da88b
7 files changed, 102 insertions, 10 deletions
diff --git a/openstack_dashboard/api/tuskar.py b/openstack_dashboard/api/tuskar.py index 12b4c393..0f86cadf 100644 --- a/openstack_dashboard/api/tuskar.py +++ b/openstack_dashboard/api/tuskar.py @@ -82,6 +82,13 @@ class StringIdAPIResourceWrapper(base.APIResourceWrapper): setattr(self, '_request', value) +class Alert(StringIdAPIResourceWrapper): + """Wrapper for the Alert object returned by the + dummy model. + """ + _attrs = ['message', 'time'] + + class Capacity(StringIdAPIResourceWrapper): """Wrapper for the Capacity object returned by the dummy model. @@ -246,6 +253,15 @@ class Node(StringIdAPIResourceWrapper): def is_provisioned(self): return False + @property + def alerts(self): + if not hasattr(self, '_alerts'): + self._alerts = [Alert(a) for a in + dummymodels.Alert.objects + .filter(object_type='node') + .filter(object_id=int(self.id))] + return self._alerts + class Rack(StringIdAPIResourceWrapper): """Wrapper for the Rack object returned by the @@ -304,6 +320,13 @@ class Rack(StringIdAPIResourceWrapper): def delete(cls, request, rack_id): tuskarclient(request).racks.delete(rack_id) + @property + def node_ids(self): + """ List of unicode ids of nodes added to rack""" + return [ + unicode(node['id']) for node in ( + self._apiresource.nodes)] + ## FIXME: this will have to be rewritten to ultimately ## fetch nodes from nova baremetal @property @@ -372,6 +395,21 @@ class Rack(StringIdAPIResourceWrapper): self._vm_capacity = Capacity(vm_capacity) return self._vm_capacity + @property + def alerts(self): + if not hasattr(self, '_alerts'): + self._alerts = [Alert(a) for a in + dummymodels.Alert.objects + .filter(object_type='rack') + .filter(object_id=int(self.id))] + return self._alerts + + @property + def aggregated_alerts(self): + # FIXME: for now return only list of nodes (particular alerts are not + # used) + return [node for node in self.list_nodes if node.alerts] + class ResourceClass(StringIdAPIResourceWrapper): """Wrapper for the ResourceClass object returned by the @@ -626,6 +664,13 @@ class ResourceClass(StringIdAPIResourceWrapper): racks = [{'id': rid} for rid in racks_ids] tuskarclient(request).resource_classes.update(self.id, racks=racks) + @property + def aggregated_alerts(self): + # FIXME: for now return only list of racks (particular alerts are not + # used) + return [rack for rack in self.list_racks if (rack.alerts + + rack.aggregated_alerts)] + class FlavorTemplate(StringIdAPIResourceWrapper): """Wrapper for the Flavor object returned by the diff --git a/openstack_dashboard/dashboards/infrastructure/fixtures/initial_data.json b/openstack_dashboard/dashboards/infrastructure/fixtures/initial_data.json index 870f3dc5..5cbd8e2c 100644 --- a/openstack_dashboard/dashboards/infrastructure/fixtures/initial_data.json +++ b/openstack_dashboard/dashboards/infrastructure/fixtures/initial_data.json @@ -87,5 +87,8 @@ {"pk": 52, "model": "infrastructure.capacity", "fields": {"value": 16384, "unit": "MB", "object_id": 7, "content_type": ["infrastructure", "flavortemplate"], "name": "memory"}}, {"pk": 53, "model": "infrastructure.capacity", "fields": {"value": 160, "unit": "GB", "object_id": 7, "content_type": ["infrastructure", "flavortemplate"], "name": "storage"}}, {"pk": 54, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 7, "content_type": ["infrastructure", "flavortemplate"], "name": "ephemeral_disk"}}, - {"pk": 55, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 7, "content_type": ["infrastructure", "flavortemplate"], "name": "swap_disk"}} + {"pk": 55, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 7, "content_type": ["infrastructure", "flavortemplate"], "name": "swap_disk"}}, + {"pk": 1, "model": "infrastructure.alert", "fields": {"message": "Switch is not accessible.", "object_id": 1, "object_type": "rack", "time": "2011-09-01T13:20:30+03:00"}}, + {"pk": 2, "model": "infrastructure.alert", "fields": {"message": "Nova service is not running.", "object_id": 1, "object_type": "node", "time": "2011-09-01T13:20:30+03:00"}}, + {"pk": 3, "model": "infrastructure.alert", "fields": {"message": "Disk usage is over 90%.", "object_id": 1, "object_type": "node", "time": "2011-09-01T13:20:30+03:00"}} ] diff --git a/openstack_dashboard/dashboards/infrastructure/models.py b/openstack_dashboard/dashboards/infrastructure/models.py index f552ce9a..513e463d 100644 --- a/openstack_dashboard/dashboards/infrastructure/models.py +++ b/openstack_dashboard/dashboards/infrastructure/models.py @@ -30,6 +30,16 @@ class Capacity(models.Model): unit = models.CharField(max_length=10) +class Alert(models.Model): + class Meta: + db_table = 'infrastructure_alerts' + + object_id = models.PositiveIntegerField() + object_type = models.CharField(max_length=20) + message = models.CharField(max_length=250) + time = models.DateTimeField() + + class FlavorTemplate(models.Model): class Meta: db_table = 'infrastructure_flavortemplate' diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/nodes/_detail_overview.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/nodes/_detail_overview.html index 22510e53..e6823ed0 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/nodes/_detail_overview.html +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/nodes/_detail_overview.html @@ -159,7 +159,11 @@ <h4>{% trans "Active alerts" %}</h4> <hr class="header_rule"> {% if node.is_provisioned %} - + <ul> + {% for alert in node.alerts %} + <li><i class="icon-warning-sign"></i>{{ alert.message }}</li> + {% endfor %} + </ul> {% else %} <p>{% trans "No data available yet." %}</p> {% endif %} diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/racks/_detail_overview.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/racks/_detail_overview.html index 78e8ea11..9f3aebe2 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/racks/_detail_overview.html +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/racks/_detail_overview.html @@ -53,6 +53,30 @@ </div> </div> +<div class="info row-fluid detail"> + <div class="span6"> + <h4>{% trans "Summary of instances and Usage" %}</h4> + <hr class="header_rule"> + TODO + </div> + + <div class="span6 alerts"> + <h4>{% trans "Active Alerts" %}</h4> + <hr class="header_rule"> + <ul> + {% for alert in rack.alerts %} + <li><i class="icon-warning-sign"></i>{{ alert.message }}</li> + {% endfor %} + {% for node in rack.aggregated_alerts %} + <li> + <i class="icon-warning-sign"></i> + Node <a href="{% url 'horizon:infrastructure:resource_management:nodes:detail' node.id %}">{{ node.name }}</a> has some problems + </li> + {% endfor %} + </ul> + </div> +</div> + <div class="row-fluid"> <div class="span6"> <div class="circles_chart_time_picker"> diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html index 0c8fbb2e..9921ace8 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html @@ -103,15 +103,17 @@ <div data-chart-type="line_chart" data-url="/infrastructure/resource_management/racks/usage_data" data-series="cpu,ram,storage,network"></div> </div> - <div class="span6"> - <h4>{% trans "Virtual Capacity" %}</h4> + <div class="span6 alerts"> + <h4>{% trans "Active Alerts" %}</h4> <hr class="header_rule"> - <dl> - {% for flavor_count in resource_class.list_flavors %} - <dt>{{ flavor_count.flavor.name }}</dt> - <dd>{{ flavor_count.max_vms }}</dd> - {% endfor %} - </dl> + <ul> + {% for rack in resource_class.aggregated_alerts %} + <li> + <i class="icon-warning-sign"></i> + Rack <a href="{% url 'horizon:infrastructure:resource_management:racks:detail' rack.id %}">{{ rack.name }}</a> has some problems + </li> + {% endfor %} + </ul> </div> </div> diff --git a/openstack_dashboard/dashboards/infrastructure/static/infrastructure/less/infrastructure.less b/openstack_dashboard/dashboards/infrastructure/static/infrastructure/less/infrastructure.less index 7fe8cba5..cc4c9204 100644 --- a/openstack_dashboard/dashboards/infrastructure/static/infrastructure/less/infrastructure.less +++ b/openstack_dashboard/dashboards/infrastructure/static/infrastructure/less/infrastructure.less @@ -370,3 +370,7 @@ svg { input { border-radius: 2px; } + +.alerts .icon-warning-sign { + padding-right: 5px; +} |