summaryrefslogtreecommitdiffstats
path: root/qtip/api/controllers/metric.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-03-14 10:06:41 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-03-21 09:09:51 +0000
commit1899d336b7172809b8ff8439bec2038d83e976a0 (patch)
treeb2b3c958a48578831aede8a64665527847d40179 /qtip/api/controllers/metric.py
parent695a881515c40e29fc12eb5003e0f3682bc4d64b (diff)
provide get_one_exceptions to unify get_xx process
add refactor get_metric() Change-Id: I972c77e63a654eeb286c573d75efe842b2887c1d Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn> (cherry picked from commit 9f87878becc36b19110e151e802180aa5f7fb305)
Diffstat (limited to 'qtip/api/controllers/metric.py')
-rw-r--r--qtip/api/controllers/metric.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/qtip/api/controllers/metric.py b/qtip/api/controllers/metric.py
index 86bf70f9..dd4c8ac6 100644
--- a/qtip/api/controllers/metric.py
+++ b/qtip/api/controllers/metric.py
@@ -9,9 +9,7 @@
import httplib
-import connexion
-
-from qtip.base import error
+from qtip.api.controllers import common
from qtip.loader import metric
@@ -20,13 +18,9 @@ def list_metrics():
return metric_list, httplib.OK
+@common.get_one_exceptions(resource='metric')
def get_metric(name):
- try:
metric_spec = metric.MetricSpec(name)
return {'name': metric_spec.name,
'abspath': metric_spec.abspath,
- 'content': metric_spec.content}, httplib.OK
- except error.NotFoundError:
- return connexion.problem(httplib.NOT_FOUND,
- 'Metric Not Found',
- 'Requested metric `' + name + '` not found.')
+ 'content': metric_spec.content}