Skip to content

Commit 5d92fc0

Browse files
author
Dean Troyer
committed
Handle novaclient >2.20.0
As of 2.21.0 novaclient moved all of the v1_1 classes to v2 with a deprecation warning. The version-non-specific interfaces provided in novaclient.client are insufficient to support a few specific commands in OSC so we need to conditionally import directly from the correct classes. Closes-Bug: #1418024 Change-Id: I864b1908737803069dc1419c9cbca391b985c932
1 parent 9ce112f commit 5d92fc0

3 files changed

Lines changed: 19 additions & 11 deletions

File tree

openstackclient/compute/client.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515

1616
import logging
1717

18+
from novaclient import client as nova_client
1819
from novaclient import extension
19-
from novaclient.v1_1.contrib import list_extensions
20+
21+
try:
22+
from novaclient.v2.contrib import list_extensions
23+
except ImportError:
24+
from novaclient.v1_1.contrib import list_extensions
2025

2126
from openstackclient.common import utils
2227

@@ -25,19 +30,13 @@
2530
DEFAULT_COMPUTE_API_VERSION = '2'
2631
API_VERSION_OPTION = 'os_compute_api_version'
2732
API_NAME = 'compute'
28-
API_VERSIONS = {
29-
'1.1': 'novaclient.v1_1.client.Client',
30-
'1': 'novaclient.v1_1.client.Client',
31-
'2': 'novaclient.v1_1.client.Client',
32-
}
3333

3434

3535
def make_client(instance):
3636
"""Returns a compute service client."""
37-
compute_client = utils.get_client_class(
38-
API_NAME,
37+
compute_client = nova_client.get_client_class(
3938
instance._api_version[API_NAME],
40-
API_VERSIONS)
39+
)
4140
LOG.debug('Instantiating compute client: %s', compute_client)
4241

4342
# Set client http_log_debug to True if verbosity level is high enough

openstackclient/compute/v2/security_group.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
from cliff import show
2525

2626
from keystoneclient import exceptions as ksc_exc
27-
from novaclient.v1_1 import security_group_rules
27+
28+
try:
29+
from novaclient.v2 import security_group_rules
30+
except ImportError:
31+
from novaclient.v1_1 import security_group_rules
32+
2833
from openstackclient.common import parseractions
2934
from openstackclient.common import utils
3035

openstackclient/compute/v2/server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
from cliff import command
2727
from cliff import lister
2828
from cliff import show
29-
from novaclient.v1_1 import servers
29+
30+
try:
31+
from novaclient.v2 import servers
32+
except ImportError:
33+
from novaclient.v1_1 import servers
3034

3135
from openstackclient.common import exceptions
3236
from openstackclient.common import parseractions

0 commit comments

Comments
 (0)