abort alarms URLs when Aodh is unavailable

add adoh_abot() when query.QueryAlarmsController() is deprecated.

Change-Id: I6098f1949604a03aa4c2e36562519fd4792f4b13
Closes-Bug: #1562740
This commit is contained in:
PanFengyun 2016-03-28 17:35:41 +08:00
parent 2a6e4c9c2b
commit b934520902

View File

@ -62,6 +62,11 @@ def gnocchi_abort():
"the metric endpoint to retrieve data.")) "the metric endpoint to retrieve data."))
def aodh_abort():
pecan.abort(410, _("alarms URLs is unavailable when Aodh is "
"disabled or unavailable."))
def aodh_redirect(url): def aodh_redirect(url):
# NOTE(sileht): we use 307 and not 301 or 302 to allow # NOTE(sileht): we use 307 and not 301 or 302 to allow
# client to redirect POST/PUT/DELETE/... # client to redirect POST/PUT/DELETE/...
@ -82,7 +87,7 @@ class QueryController(object):
if kind == 'alarms' and self.aodh_url: if kind == 'alarms' and self.aodh_url:
aodh_redirect(self.aodh_url) aodh_redirect(self.aodh_url)
elif kind == 'alarms': elif kind == 'alarms':
return query.QueryAlarmsController(), remainder aodh_abort()
elif kind == 'samples' and self.gnocchi_is_enabled: elif kind == 'samples' and self.gnocchi_is_enabled:
gnocchi_abort() gnocchi_abort()
elif kind == 'samples': elif kind == 'samples':
@ -176,6 +181,8 @@ class V2Controller(object):
gnocchi_is_enabled=self.gnocchi_is_enabled, gnocchi_is_enabled=self.gnocchi_is_enabled,
aodh_url=self.aodh_url, aodh_url=self.aodh_url,
), remainder ), remainder
elif kind == 'alarms' and (not self.aodh_url):
aodh_abort()
elif kind == 'alarms' and self.aodh_url: elif kind == 'alarms' and self.aodh_url:
aodh_redirect(self.aodh_url) aodh_redirect(self.aodh_url)
else: else: