Modify vitrage api

Synchronize interface of event and topology's http code
 in vitrage_api.rst
Judge None type in get alarm interface

Change-Id: Ia1a7783a67e397c84ab042f091e6d0dbac6138bb
Signed-off-by: hewei <hewei@cmss.chinamobile.com>
This commit is contained in:
hewei 2019-03-26 20:27:06 +08:00
parent acea43a6f0
commit e272712bc4
2 changed files with 12 additions and 14 deletions

View File

@ -197,7 +197,8 @@ Response Status Code
====================
- 200 - OK
- 400 - Bad request
- 403 - Forbidden
- 404 - Not Found
Response Body
=============
@ -1247,7 +1248,7 @@ Response Status code
====================
- 200 - OK
- 400 - Bad request
- 404 - Not Found
Response Body
=============

21
vitrage/api/controllers/v1/alarm.py Executable file → Normal file
View File

@ -57,22 +57,19 @@ class AlarmsController(BaseAlarmsController):
LOG.info('returns show alarm with vitrage id %s', vitrage_id)
try:
return self._show_alarm(vitrage_id)
except Exception:
LOG.exception('Failed to load JSON.')
abort(404, "Failed to show alarm.")
return self._show_alarm(vitrage_id)
@staticmethod
def _show_alarm(vitrage_id):
alarm_json = pecan.request.client.call(pecan.request.context,
'show_alarm',
vitrage_id=vitrage_id)
LOG.info(alarm_json)
try:
alarms_list = json.loads(alarm_json)
return alarms_list
alarm_json = pecan.request.client.call(pecan.request.context,
'show_alarm',
vitrage_id=vitrage_id)
LOG.info(alarm_json)
if not alarm_json:
abort(404, "Failed to find alarm %s" % vitrage_id)
return json.loads(alarm_json)
except Exception:
LOG.exception('Failed to load JSON.')