Alarms History added
This commit is contained in:
parent
95d00a2ec2
commit
89c26d0606
@ -81,9 +81,16 @@ def show_host(data):
|
|||||||
class ShowAlarmHistory(tables.LinkAction):
|
class ShowAlarmHistory(tables.LinkAction):
|
||||||
name = 'history'
|
name = 'history'
|
||||||
verbose_name = _('Show History')
|
verbose_name = _('Show History')
|
||||||
url = constants.URL_PREFIX + 'history'
|
#url = constants.URL_PREFIX + 'history'
|
||||||
classes = ('btn-edit',)
|
classes = ('btn-edit',)
|
||||||
|
|
||||||
|
def get_link_url(self, datum):
|
||||||
|
return reverse(constants.URL_PREFIX + 'history',
|
||||||
|
args=(datum['name'], datum['id'], ))
|
||||||
|
|
||||||
|
def allowed(self, request, datum=None):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class ShowAlarmMeters(tables.LinkAction):
|
class ShowAlarmMeters(tables.LinkAction):
|
||||||
name = 'meters'
|
name = 'meters'
|
||||||
@ -187,18 +194,15 @@ class AlarmsTable(tables.DataTable):
|
|||||||
|
|
||||||
|
|
||||||
class AlarmHistoryTable(tables.DataTable):
|
class AlarmHistoryTable(tables.DataTable):
|
||||||
status = tables.Column('Status', verbose_name=_('Status'),
|
name = tables.Column('name', verbose_name=_('Name'))
|
||||||
status_choices={(show_status('OK'), True)},
|
old_state = tables.Column('old_state', verbose_name=_('Old State'))
|
||||||
filters=[show_status, template.defaultfilters.safe])
|
new_state = tables.Column('new_state', verbose_name=_('New State'))
|
||||||
target = tables.Column('Host', verbose_name=_('Host'))
|
timestamp = tables.Column('timestamp', verbose_name=_('Timestamp'))
|
||||||
name = tables.Column('Service', verbose_name=_('Service'))
|
reason = tables.Column('reason', verbose_name=_('Reason'))
|
||||||
lastCheck = tables.Column('Last_Check', verbose_name=_('Last Check'))
|
reason_data = tables.Column('reason_data', verbose_name=_('Reason Data'))
|
||||||
time = tables.Column('Duration', verbose_name=_('Duration'))
|
|
||||||
detail = tables.Column('Status_Information',
|
|
||||||
verbose_name=_('Status_Information'))
|
|
||||||
|
|
||||||
def get_object_id(self, obj):
|
def get_object_id(self, obj):
|
||||||
return obj['Last_Check'] + obj['Service']
|
return obj['alarm_id'] + obj['timestamp']
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
name = "users"
|
name = "users"
|
||||||
|
@ -25,7 +25,7 @@ urlpatterns = patterns(
|
|||||||
url(r'^alarm/(?P<service>[^/]+)/$',
|
url(r'^alarm/(?P<service>[^/]+)/$',
|
||||||
views.AlarmServiceView.as_view(),
|
views.AlarmServiceView.as_view(),
|
||||||
name='alarm'),
|
name='alarm'),
|
||||||
url(r'^history/(?P<service>[^/]+)$',
|
url(r'^history/(?P<name>[^/]+)/(?P<id>[^/]+)$',
|
||||||
views.AlarmHistoryView.as_view(),
|
views.AlarmHistoryView.as_view(),
|
||||||
name='history'),
|
name='history'),
|
||||||
url(r'^meters/(?P<service>[^/]+)$',
|
url(r'^meters/(?P<service>[^/]+)$',
|
||||||
|
@ -232,6 +232,21 @@ def transform_alarm_data(obj):
|
|||||||
'notifications': getattr(obj, 'alarm_actions', None), }
|
'notifications': getattr(obj, 'alarm_actions', None), }
|
||||||
|
|
||||||
|
|
||||||
|
def transform_alarm_history(results, name):
|
||||||
|
newlist = []
|
||||||
|
for item in results:
|
||||||
|
temp = {}
|
||||||
|
temp['alarm_id'] = item['alarm_id']
|
||||||
|
temp['name'] = name
|
||||||
|
temp['old_state'] = item['old_state']
|
||||||
|
temp['new_state'] = item['new_state']
|
||||||
|
temp['timestamp'] = item['timestamp']
|
||||||
|
temp['reason'] = item['reason']
|
||||||
|
temp['reason_data'] = item['reason_data']
|
||||||
|
newlist.append(temp)
|
||||||
|
return newlist
|
||||||
|
|
||||||
|
|
||||||
class AlarmDetailView(forms.ModalFormView):
|
class AlarmDetailView(forms.ModalFormView):
|
||||||
form_class = alarm_forms.DetailAlarmForm
|
form_class = alarm_forms.DetailAlarmForm
|
||||||
template_name = constants.TEMPLATE_PREFIX + 'alarms/detail.html'
|
template_name = constants.TEMPLATE_PREFIX + 'alarms/detail.html'
|
||||||
@ -344,10 +359,15 @@ class AlarmHistoryView(tables.DataTableView):
|
|||||||
return super(AlarmHistoryView, self).dispatch(*args, **kwargs)
|
return super(AlarmHistoryView, self).dispatch(*args, **kwargs)
|
||||||
|
|
||||||
def get_data(self):
|
def get_data(self):
|
||||||
# to be implemented
|
id = self.kwargs['id']
|
||||||
|
name = self.kwargs['name']
|
||||||
results = []
|
results = []
|
||||||
|
try:
|
||||||
return results
|
results = api.monitor.alarm_history(self.request, id)
|
||||||
|
except:
|
||||||
|
messages.error(self.request,
|
||||||
|
_("Could not retrieve alarm history for %s") % id)
|
||||||
|
return transform_alarm_history(results, name)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(AlarmHistoryView, self).get_context_data(**kwargs)
|
context = super(AlarmHistoryView, self).get_context_data(**kwargs)
|
||||||
|
@ -67,6 +67,10 @@ def alarm_delete(request, alarm_id):
|
|||||||
return monclient(request).alarms.delete(alarm_id=alarm_id)
|
return monclient(request).alarms.delete(alarm_id=alarm_id)
|
||||||
|
|
||||||
|
|
||||||
|
def alarm_history(request, alarm_id):
|
||||||
|
return monclient(request).alarms.history(alarm_id=alarm_id)
|
||||||
|
|
||||||
|
|
||||||
def alarm_get(request, alarm_id):
|
def alarm_get(request, alarm_id):
|
||||||
return monclient(request).alarms.get(alarm_id=alarm_id)
|
return monclient(request).alarms.get(alarm_id=alarm_id)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user