Provide default limit and offset for alarm_list
Also display error instead of swallowing it Change-Id: If3f569920ea9bfaa12b32af368e83a93f61a2ec9 Closes-Bug: #1472372
This commit is contained in:
parent
65f321190a
commit
ca3607231a
@ -79,7 +79,9 @@ def get_status(alarms):
|
||||
def generate_status(request):
|
||||
try:
|
||||
alarms = api.monitor.alarm_list(request)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
messages.error(request,
|
||||
_('Unable to list alarms: %s') % str(e))
|
||||
alarms = []
|
||||
alarms_by_service = {}
|
||||
for a in alarms:
|
||||
|
@ -60,7 +60,7 @@ def monascaclient(request, password=None):
|
||||
return client
|
||||
|
||||
|
||||
def alarm_list(request, offset, limit, marker=None, paginate=False):
|
||||
def alarm_list(request, offset=0, limit=10000, marker=None, paginate=False):
|
||||
result = monascaclient(request).alarms.list(offset=offset, limit=limit)
|
||||
return result['elements'] if type(result) is dict else result
|
||||
|
||||
|
@ -19,6 +19,7 @@ import logging
|
||||
import urllib
|
||||
|
||||
from django.conf import settings # noqa
|
||||
from django.contrib import messages
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.http import HttpResponse # noqa
|
||||
from django.views.generic import TemplateView # noqa
|
||||
@ -91,7 +92,9 @@ def get_status(alarms):
|
||||
def generate_status(request):
|
||||
try:
|
||||
alarms = api.monitor.alarm_list(request)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
messages.error(request,
|
||||
_('Unable to list alarms: %s') % str(e))
|
||||
alarms = []
|
||||
alarms_by_service = {}
|
||||
for a in alarms:
|
||||
|
Loading…
x
Reference in New Issue
Block a user