Commit 19e751cc authored by PanFengyun's avatar PanFengyun Committed by gordon chung

abort alarms URLs when Aodh is unavailable

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

Change-Id: I6098f1949604a03aa4c2e36562519fd4792f4b13
Closes-Bug: #1562740
parent 7ee29aae
......@@ -62,6 +62,11 @@ def gnocchi_abort():
"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):
# NOTE(sileht): we use 307 and not 301 or 302 to allow
# client to redirect POST/PUT/DELETE/...
......@@ -82,7 +87,7 @@ class QueryController(object):
if kind == 'alarms' and self.aodh_url:
aodh_redirect(self.aodh_url)
elif kind == 'alarms':
return query.QueryAlarmsController(), remainder
aodh_abort()
elif kind == 'samples' and self.gnocchi_is_enabled:
gnocchi_abort()
elif kind == 'samples':
......@@ -176,6 +181,8 @@ class V2Controller(object):
gnocchi_is_enabled=self.gnocchi_is_enabled,
aodh_url=self.aodh_url,
), remainder
elif kind == 'alarms' and (not self.aodh_url):
aodh_abort()
elif kind == 'alarms' and self.aodh_url:
aodh_redirect(self.aodh_url)
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment