From f1a71b2889da3b49358b10b9a12ea5a512dd2743 Mon Sep 17 00:00:00 2001 From: rexlee8776 Date: Wed, 9 May 2018 09:52:27 +0000 Subject: Bugfix: openrc api dump should be safe_dump 1. fix safe_dump 2. fix pep8 problem, use flask_restapi custom error handling [1] [1] https://flask-restful.readthedocs.io/en/latest/extending.html#custom-error-handlers JIRA: YARDSTICK-1165 RestApi openrc dump clouds.yaml error it now use yarml.dump, should be yaml.safe_dump. dump would gererate !!python/unicode and cause error when upload openrc file in gui Change-Id: Id3e85f7ba7d4967277ef79109b07d7552179e5db Signed-off-by: rexlee8776 --- yardstick/common/constants.py | 15 +++++++++++++++ yardstick/common/exceptions.py | 12 ++++++++++++ 2 files changed, 27 insertions(+) (limited to 'yardstick') diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py index 8640afbae..f6e4ab7e9 100644 --- a/yardstick/common/constants.py +++ b/yardstick/common/constants.py @@ -145,6 +145,21 @@ BASE_URL = 'http://localhost:5000' ENV_ACTION_API = BASE_URL + '/yardstick/env/action' ASYNC_TASK_API = BASE_URL + '/yardstick/asynctask' +API_ERRORS = { + 'UploadOpenrcError': { + 'message': "Upload openrc ERROR!", + 'status': API_ERROR, + }, + 'UpdateOpenrcError': { + 'message': "Update openrc ERROR!", + 'status': API_ERROR, + }, + 'ApiServerError': { + 'message': "An unkown exception happened to Api Server!", + 'status': API_ERROR, + }, +} + # flags IS_EXISTING = 'is_existing' IS_PUBLIC = 'is_public' diff --git a/yardstick/common/exceptions.py b/yardstick/common/exceptions.py index c7ba56268..8a0c52d31 100644 --- a/yardstick/common/exceptions.py +++ b/yardstick/common/exceptions.py @@ -247,3 +247,15 @@ class ScenarioDeleteVolumeError(YardstickException): class ScenarioDetachVolumeError(YardstickException): message = 'Cinder Detach Volume Scenario failed' + + +class ApiServerError(YardstickException): + message = 'An unkown exception happened to Api Server!' + + +class UploadOpenrcError(ApiServerError): + message = 'Upload openrc ERROR!' + + +class UpdateOpenrcError(ApiServerError): + message = 'Update openrc ERROR!' -- cgit 1.2.3-korg