diff options
| author | Zuul <zuul@review.openstack.org> | 2018-10-15 22:07:43 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2018-10-15 22:07:43 +0000 |
| commit | 02f492ae4cc52ed2642f42bc0c1e5e417ebfe527 (patch) | |
| tree | 727dedeec375a966cccbcde0440dfa73372acdbd /openstackclient/volume/client.py | |
| parent | c19aee4c705e8d9070c6649a1fa522da2d0778cc (diff) | |
| parent | 651f0c38a1f364953dc3cb3f7458385410395fd8 (diff) | |
| download | python-openstackclient-02f492ae4cc52ed2642f42bc0c1e5e417ebfe527.tar.gz | |
Merge "Handle not having cinderclient.v1 available"
Diffstat (limited to 'openstackclient/volume/client.py')
| -rw-r--r-- | openstackclient/volume/client.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/openstackclient/volume/client.py b/openstackclient/volume/client.py index c4b0dfca..e0e670a9 100644 --- a/openstackclient/volume/client.py +++ b/openstackclient/volume/client.py @@ -37,13 +37,20 @@ def make_client(instance): # Defer client imports until we actually need them from cinderclient import extension - from cinderclient.v1.contrib import list_extensions - from cinderclient.v1 import volume_snapshots - from cinderclient.v1 import volumes - - # Monkey patch for v1 cinderclient - volumes.Volume.NAME_ATTR = 'display_name' - volume_snapshots.Snapshot.NAME_ATTR = 'display_name' + from cinderclient.v3.contrib import list_extensions + from cinderclient.v3 import volume_snapshots + from cinderclient.v3 import volumes + + # Try a small import to check if cinderclient v1 is supported + try: + from cinderclient.v1 import services # noqa + except Exception: + del API_VERSIONS['1'] + + if instance._api_version[API_NAME] == '1': + # Monkey patch for v1 cinderclient + volumes.Volume.NAME_ATTR = 'display_name' + volume_snapshots.Snapshot.NAME_ATTR = 'display_name' volume_client = utils.get_client_class( API_NAME, |
