From 922204cc8d9c91b3570c1fb1e3de483c231d3a19 Mon Sep 17 00:00:00 2001 From: Marc Koderer Date: Tue, 4 Aug 2015 10:56:28 +0200 Subject: [PATCH] Reduce dependency to tempest: exceptions In order to be independent from changes in Tempest Manila should use the tempest_lib as much as possible. Exception classes are already copied to tempest_lib. Closes-Bug: #1489299 Change-Id: I043be143d7d35614af1f6d7892b0a0bc71d73580 --- contrib/tempest/tempest/api/share/base.py | 25 +++++++++---------- .../tempest/scenario/test_share_basic_ops.py | 12 ++++----- .../services/share/json/shares_client.py | 15 ++++++----- contrib/tempest/tempest/share_exceptions.py | 2 +- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/contrib/tempest/tempest/api/share/base.py b/contrib/tempest/tempest/api/share/base.py index 9b56c4af24..e648816d1e 100644 --- a/contrib/tempest/tempest/api/share/base.py +++ b/contrib/tempest/tempest/api/share/base.py @@ -17,18 +17,17 @@ import copy import inspect import traceback -from oslo_concurrency import lockutils # noqa -from oslo_log import log # noqa -import six # noqa -from tempest_lib.common.utils import data_utils # noqa -from tempest_lib import exceptions as lib_exc # noqa +from oslo_concurrency import lockutils +from oslo_log import log +import six +from tempest_lib.common.utils import data_utils +from tempest_lib import exceptions -from tempest import clients_share as clients -from tempest.common import isolated_creds -from tempest import config_share as config -from tempest import exceptions -from tempest import share_exceptions -from tempest import test +from tempest import clients_share as clients # noqa +from tempest.common import isolated_creds # noqa +from tempest import config_share as config # noqa +from tempest import share_exceptions # noqa +from tempest import test # noqa CONF = config.CONF LOG = log.getLogger(__name__) @@ -37,7 +36,7 @@ LOG = log.getLogger(__name__) class handle_cleanup_exceptions(object): """Handle exceptions raised with cleanup operations. - Always suppress errors when lib_exc.NotFound or lib_exc.Forbidden + Always suppress errors when exceptions.NotFound or exceptions.Forbidden are raised. Suppress all other exceptions only in case config opt 'suppress_errors_in_cleanup' in config group 'share' is True. @@ -48,7 +47,7 @@ class handle_cleanup_exceptions(object): def __exit__(self, exc_type, exc_value, exc_traceback): if not (isinstance(exc_value, - (lib_exc.NotFound, lib_exc.Forbidden)) or + (exceptions.NotFound, exceptions.Forbidden)) or CONF.share.suppress_errors_in_cleanup): return False # Do not suppress error if any if exc_traceback: diff --git a/contrib/tempest/tempest/scenario/test_share_basic_ops.py b/contrib/tempest/tempest/scenario/test_share_basic_ops.py index 35a2d8e8f3..c3ee3efc3c 100644 --- a/contrib/tempest/tempest/scenario/test_share_basic_ops.py +++ b/contrib/tempest/tempest/scenario/test_share_basic_ops.py @@ -13,13 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_log import log as logging # noqa -from tempest_lib.common.utils import data_utils # noqa +from oslo_log import log as logging +from tempest_lib.common.utils import data_utils +from tempest_lib import exceptions -from tempest import config -from tempest import exceptions -from tempest.scenario import manager_share as manager -from tempest import test +from tempest import config # noqa +from tempest.scenario import manager_share as manager # noqa +from tempest import test # noqa CONF = config.CONF diff --git a/contrib/tempest/tempest/services/share/json/shares_client.py b/contrib/tempest/tempest/services/share/json/shares_client.py index 1ea78287b3..57d1c98153 100644 --- a/contrib/tempest/tempest/services/share/json/shares_client.py +++ b/contrib/tempest/tempest/services/share/json/shares_client.py @@ -17,14 +17,13 @@ import json import time import urllib -import six # noqa -from tempest_lib.common import rest_client # noqa -from tempest_lib.common.utils import data_utils # noqa -from tempest_lib import exceptions as lib_exc # noqa +import six +from tempest_lib.common import rest_client +from tempest_lib.common.utils import data_utils +from tempest_lib import exceptions -from tempest import config_share as config -from tempest import exceptions -from tempest import share_exceptions +from tempest import config_share as config # noqa +from tempest import share_exceptions # noqa CONF = config.CONF @@ -392,7 +391,7 @@ class SharesClient(rest_client.RestClient): def _is_resource_deleted(self, func, res_id): try: res = func(res_id) - except lib_exc.NotFound: + except exceptions.NotFound: return True if res.get('status') == 'error_deleting': # Resource has "error_deleting" status and can not be deleted. diff --git a/contrib/tempest/tempest/share_exceptions.py b/contrib/tempest/tempest/share_exceptions.py index 2815f9eaed..14b198a585 100644 --- a/contrib/tempest/tempest/share_exceptions.py +++ b/contrib/tempest/tempest/share_exceptions.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest import exceptions +from tempest_lib import exceptions class ShareBuildErrorException(exceptions.TempestException):