diff options
Diffstat (limited to 'cinderclient')
-rw-r--r-- | cinderclient/client.py | 7 | ||||
-rw-r--r-- | cinderclient/shell.py | 14 | ||||
-rw-r--r-- | cinderclient/shell_utils.py | 2 | ||||
-rw-r--r-- | cinderclient/tests/unit/fakes.py | 2 | ||||
-rw-r--r-- | cinderclient/tests/unit/v2/test_limits.py | 4 | ||||
-rw-r--r-- | cinderclient/utils.py | 21 | ||||
-rw-r--r-- | cinderclient/v2/shell.py | 2 | ||||
-rw-r--r-- | cinderclient/v3/shell.py | 2 |
8 files changed, 24 insertions, 30 deletions
diff --git a/cinderclient/client.py b/cinderclient/client.py index 6193e95..b013c1e 100644 --- a/cinderclient/client.py +++ b/cinderclient/client.py @@ -16,8 +16,6 @@ # under the License. """OpenStack Client interface. Handles the REST calls and responses.""" -from __future__ import print_function - import glob import hashlib import imp @@ -35,7 +33,10 @@ from keystoneauth1.identity import base from oslo_utils import encodeutils from oslo_utils import importutils from oslo_utils import strutils -osprofiler_web = importutils.try_import("osprofiler.web") # noqa +try: + osprofiler_web = importutils.try_import("osprofiler.web") +except Exception: + pass import requests from six.moves import urllib import six.moves.urllib.parse as urlparse diff --git a/cinderclient/shell.py b/cinderclient/shell.py index acbccda..7722556 100644 --- a/cinderclient/shell.py +++ b/cinderclient/shell.py @@ -17,8 +17,6 @@ Command-line interface to the OpenStack Cinder API. """ -from __future__ import print_function - import argparse import collections import getpass @@ -33,7 +31,10 @@ from keystoneauth1 import loading from keystoneauth1 import session from oslo_utils import encodeutils from oslo_utils import importutils -osprofiler_profiler = importutils.try_import("osprofiler.profiler") # noqa +try: + osprofiler_profiler = importutils.try_import("osprofiler.profiler") +except Exception: + pass import requests import six import six.moves.urllib.parse as urlparse @@ -48,7 +49,6 @@ from cinderclient import utils DEFAULT_MAJOR_OS_VOLUME_API_VERSION = "3" DEFAULT_CINDER_ENDPOINT_TYPE = 'publicURL' -V1_SHELL = 'cinderclient.v1.shell' V2_SHELL = 'cinderclient.v2.shell' V3_SHELL = 'cinderclient.v3.shell' HINT_HELP_MSG = (" [hint: use '--os-volume-api-version' flag to show help " @@ -354,12 +354,10 @@ class OpenStackCinderShell(object): self.subcommands = {} subparsers = parser.add_subparsers(metavar='<subcommand>') - if version.ver_major == 2: - actions_module = importutils.import_module(V2_SHELL) - elif version.ver_major == 3: + if version.ver_major == 3: actions_module = importutils.import_module(V3_SHELL) else: - actions_module = importutils.import_module(V1_SHELL) + actions_module = importutils.import_module(V2_SHELL) self._find_actions(subparsers, actions_module, version, do_help, input_args) diff --git a/cinderclient/shell_utils.py b/cinderclient/shell_utils.py index 411dd17..b5db281 100644 --- a/cinderclient/shell_utils.py +++ b/cinderclient/shell_utils.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -from __future__ import print_function - import sys import time diff --git a/cinderclient/tests/unit/fakes.py b/cinderclient/tests/unit/fakes.py index 61d1904..018a75d 100644 --- a/cinderclient/tests/unit/fakes.py +++ b/cinderclient/tests/unit/fakes.py @@ -19,8 +19,6 @@ wrong the tests might raise AssertionError. I've indicated in comments the places where actual behavior differs from the spec. """ -from __future__ import print_function - def assert_has_keys(dict, required=None, optional=None): required = required or [] diff --git a/cinderclient/tests/unit/v2/test_limits.py b/cinderclient/tests/unit/v2/test_limits.py index 34ed1d2..d8fbdfe 100644 --- a/cinderclient/tests/unit/v2/test_limits.py +++ b/cinderclient/tests/unit/v2/test_limits.py @@ -177,5 +177,5 @@ class TestLimitsManager(utils.TestCase): api.client.get.assert_called_once_with('/limits%s' % query_str) self.assertIsInstance(lim, limits.Limits) - for l in lim.absolute: - self.assertEqual(l1, l) + for limit in lim.absolute: + self.assertEqual(l1, limit) diff --git a/cinderclient/utils.py b/cinderclient/utils.py index 28c458d..3b00967 100644 --- a/cinderclient/utils.py +++ b/cinderclient/utils.py @@ -12,18 +12,16 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - -from __future__ import print_function import collections import os -import pkg_resources import sys import uuid import prettytable import six from six.moves.urllib import parse +import stevedore from cinderclient import exceptions from oslo_utils import encodeutils @@ -199,7 +197,7 @@ def unicode_key_value_to_string(src): _encode(unicode_key_value_to_string(v))) for k, v in src.items()) if isinstance(src, list): - return [unicode_key_value_to_string(l) for l in src] + return [unicode_key_value_to_string(item) for item in src] return _encode(src) @@ -332,11 +330,16 @@ def safe_issubclass(*args): def _load_entry_point(ep_name, name=None): """Try to load the entry point ep_name that matches name.""" - for ep in pkg_resources.iter_entry_points(ep_name, name=name): - try: - return ep.load() - except (ImportError, pkg_resources.UnknownExtra, AttributeError): - continue + mgr = stevedore.NamedExtensionManager( + namespace=ep_name, + names=[name], + # Ignore errors on load + on_load_failure_callback=lambda mgr, entry_point, error: None, + ) + try: + return mgr[name].plugin + except KeyError: + pass def get_function_name(func): diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index b83175e..d41e014 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -14,8 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function - import argparse import collections import copy diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py index b3f69b0..1ccf02e 100644 --- a/cinderclient/v3/shell.py +++ b/cinderclient/v3/shell.py @@ -14,8 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function - import argparse import collections import os |