vitrage alarms

Change-Id: I325862b9c972b92b5a358cb1ba837d419c1d4f9c
This commit is contained in:
Omer Etrog 2016-02-10 12:14:14 +02:00
parent 10812f5a86
commit 7aa6a788b8
16 changed files with 174 additions and 38 deletions

View File

@ -41,7 +41,7 @@ With Horizon
git clone https://github.com/openstack/vitrage-dashboard.git
git clone https://github.com/openstack/f.git
git clone https://github.com/openstack/python-vitrageclient.git
cd ../horizon

View File

@ -0,0 +1,20 @@
(function () {
'use strict';
angular
.module('horizon.dashboard.project.vitrage')
.controller('AlarmListController', AlarmListController);
AlarmListController.$inject = ['$scope', 'vitrageTopologySrv'];
function AlarmListController($scope, vitrageTopologySrv) {
var alarmList = this;
$scope.STATIC_URL = STATIC_URL;
alarmList.alarms = [];
vitrageTopologySrv.getAlarms('all').then(function(result){
alarmList.alarms = result.data;
});
}
})();

View File

@ -0,0 +1,25 @@
<div class="alarm-list" ng-controller="AlarmListController as alarmList">
<div class="panel panel-default" >
<table class="table table-striped table-hover table-bordered">
<thead>
<tr>
<th>{$ 'TimeStamp' | translate $}</th>
<th>{$ 'Name' | translate $}</th>
<th>{$ 'Severity' | translate $}</th>
<th>{$ 'Type' | translate $}</th>
<th>{$ 'RCA' | translate $}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="alarm in alarmList.alarms track by $index">
<td><i class="fa fa-clock-o"></i> {$alarm.update_timestamp | date:"h:mm a"$} </td>
<td>{$alarm.name$}</td>
<td>{$alarm.severity $}</td>
<td>{$alarm.type$}</td>
<td><i class="fa fa-sitemap"></i></td>
</tr>
</tbody>
</table>
</div>
</div>

View File

@ -0,0 +1,3 @@
.alarm-list {
}

View File

@ -3,13 +3,13 @@
{% block title %}{% trans "Topology" %}{% endblock %}
{% block page_header %}
<hz-page-header header="Alarms Vitrage" description="Alarms Vitrage Desc"></hz-page-header>
<hz-page-header header="Alarms Analysis" ></hz-page-header>
{% endblock page_header %}
{% block main %}
<!--<div ng-cloak ng-init='init({{ TOPOLOGY_VITRAGE_SETTINGS }})'>-->
<!--<ng-include src="'{{STATIC_URL}}dashboard/project/layout/system-health.html'"></ng-include>-->
<!--</div>-->
<div ng-cloak ng-init='init({{ TOPOLOGY_VITRAGE_SETTINGS }})'>
<ng-include src="'{{STATIC_URL}}alarms/project/layout/main/alarmList.html'"></ng-include>
</div>
{% endblock %}

View File

@ -39,3 +39,23 @@ class Topolgy(generic.View):
"""
return api.vitrage.topology(request)
@urls.register
class Alarms(generic.View):
"""API for vitrage alarms."""
url_regex = r'vitrage/alarms/(?P<vitrage_id>.+|default)/$'
@rest_utils.ajax()
def get(self, request, vitrage_id):
"""Get a single entity's alarm with the vitrage id.
The following get alarma may be passed in the GET
:param vitrage_id the id of the vitrage entity
The result is a alarms object.
"""
return api.vitrage.alarms(request, vitrage_id)

View File

@ -32,3 +32,7 @@ def vitrageclient(request, password=None):
def topology(request):
return vitrageclient(request).topology.get(graph_type='tree')
def alarms(request, vitrage_id='all'):
return vitrageclient(request).alarms.list(vitrage_id=vitrage_id)

View File

@ -1,4 +1,3 @@
(function () {
'use strict';
@ -15,7 +14,8 @@
function vitrageAPI(apiService, toastService) {
var service = {
getTopology: getTopology
getTopology: getTopology,
getAlarms: getAlarms
};
return service;
@ -29,6 +29,16 @@
});
}
function getAlarms(vitrage_id) {
if (vitrage_id == undefined){
vitrage_id = 'all';
}
return apiService.get('/api/vitrage/alarms/'+vitrage_id)
.error(function () {
toastService.add('error', gettext('Unable to fetch the Vitrage Alarms service.'));
});
}
}
}());

View File

@ -6,11 +6,29 @@ function hzAlarms() {
var directive = {
link: link,
templateUrl: STATIC_URL + 'dashboard/project/components/alarms/alarms.html',
restrict: 'E'
restrict: 'E',
scope:{
selected:'='
},
controller : AlarmsController,
controllerAs : 'alarmsCtrl'
};
AlarmsController.$inject = ['$scope', 'vitrageTopologySrv'];
return directive;
function link(scope, element, attrs) {
}
function AlarmsController($scope,vitrageTopologySrv){
var alarmsCtrl = this;
$scope.$watch('selected', function(newData,oldData) {
if (newData != oldData){
console.log('selected ',newData);
vitrageTopologySrv.getAlarms(newData.vitrage_id).then(function(result){
alarmsCtrl.computeAlarms = result.data;
});
}
});
}
}

View File

@ -1,3 +1,14 @@
<div class="vitrage-alarms">
<h1>{$ 'Alarms' | translate $}</h1>
<div class="panel panel-default alarm-list" >
<ul class="panel-body list-group" ng-repeat="alarm in alarmsCtrl.computeAlarms track by $index">
<li class="list-group-item">
<h4 class="list-group-item-heading">{$alarm.name$}</h4>
<p class="list-group-item-text">
{$alarm.update_timestamp | date:"h:mma"$} |
{$alarm.severity$}
</p>
</li>
</ul>
</div>
</div>

View File

@ -1,3 +1,11 @@
.vitrage-alarms {
.panel-body{
padding: 0;
}
.alarms-list{
max-height: 288px;
overflow-y: auto;
}
}

View File

@ -88,7 +88,7 @@ function hzSunburst() {
}
function cloneSelectedItem(d) {
scope.selected = {id: d.id, name: d.name, state: d.state, type: d.type};
scope.selected = {id: d.id, name: d.name, state: d.state,vitrage_id: d.vitrage_id};
}
// Interpolate the scales!

View File

@ -9,7 +9,7 @@
<div class="panel-body">
<hz-information selected="computeCtrl.model.selected"></hz-information>
<hz-stacks></hz-stacks>
<hz-alarms></hz-alarms>
<hz-alarms selected="computeCtrl.model.selected" ></hz-alarms>
</div>
</div>
</div>

View File

@ -10,20 +10,20 @@
</tab>
<tab>
<tab-heading>
<i class="fa fa-database"></i> {$ 'Storage' | translate $}
</tab-heading>
<div>
<hz-storage></hz-storage>
</div>
</tab>
<!--<tab>-->
<!--<tab-heading>-->
<!--<i class="fa fa-database"></i> {$ 'Storage' | translate $}-->
<!--</tab-heading>-->
<!--<div>-->
<!--<hz-storage></hz-storage>-->
<!--</div>-->
<!--</tab>-->
<tab>
<tab-heading>
<i class="fa fa-globe"></i> {$ 'Network' | translate $}
</tab-heading>
<hz-network></hz-network>
</tab>
<!--<tab>-->
<!--<tab-heading>-->
<!--<i class="fa fa-globe"></i> {$ 'Network' | translate $}-->
<!--</tab-heading>-->
<!--<hz-network></hz-network>-->
<!--</tab>-->
</tabset>
</div>

View File

@ -14,21 +14,37 @@
vitrageAPI = $injector.get('horizon.app.core.openstack-service-api.vitrage');
}
return {
getTopology: function getTopology() {
function getTopology() {
if (vitrageAPI) {
return vitrageAPI.getTopology()
.success(function(data) {
console.log("Success ", data);
return data;
})
.error(function(err) {
console.error(err);
}
)
}
if (vitrageAPI) {
return vitrageAPI.getTopology()
.success(function(data) {
return data;
})
.error(function(err) {
console.error(err);
}
)
}
}
function getAlarms(vitrage_id) {
if (vitrageAPI) {
return vitrageAPI.getAlarms(vitrage_id)
.success(function(data) {
return data;
})
.error(function(err) {
console.error(err);
}
)
}
}
return {
getTopology: getTopology,
getAlarms: getAlarms
}
}
})();

View File

@ -1,2 +1,3 @@
@import 'layout/main/compute/compute';
@import 'components/sunburst/sunburst';
@import 'components/sunburst/sunburst';
@import 'components/alarms/alarms';