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
This commit is contained in:
parent
9ce112f1a1
commit
5d92fc0d0a
@ -15,8 +15,13 @@
|
||||
|
||||
import logging
|
||||
|
||||
from novaclient import client as nova_client
|
||||
from novaclient import extension
|
||||
from novaclient.v1_1.contrib import list_extensions
|
||||
|
||||
try:
|
||||
from novaclient.v2.contrib import list_extensions
|
||||
except ImportError:
|
||||
from novaclient.v1_1.contrib import list_extensions
|
||||
|
||||
from openstackclient.common import utils
|
||||
|
||||
@ -25,19 +30,13 @@ LOG = logging.getLogger(__name__)
|
||||
DEFAULT_COMPUTE_API_VERSION = '2'
|
||||
API_VERSION_OPTION = 'os_compute_api_version'
|
||||
API_NAME = 'compute'
|
||||
API_VERSIONS = {
|
||||
'1.1': 'novaclient.v1_1.client.Client',
|
||||
'1': 'novaclient.v1_1.client.Client',
|
||||
'2': 'novaclient.v1_1.client.Client',
|
||||
}
|
||||
|
||||
|
||||
def make_client(instance):
|
||||
"""Returns a compute service client."""
|
||||
compute_client = utils.get_client_class(
|
||||
API_NAME,
|
||||
compute_client = nova_client.get_client_class(
|
||||
instance._api_version[API_NAME],
|
||||
API_VERSIONS)
|
||||
)
|
||||
LOG.debug('Instantiating compute client: %s', compute_client)
|
||||
|
||||
# Set client http_log_debug to True if verbosity level is high enough
|
||||
|
@ -24,7 +24,12 @@ from cliff import lister
|
||||
from cliff import show
|
||||
|
||||
from keystoneclient import exceptions as ksc_exc
|
||||
from novaclient.v1_1 import security_group_rules
|
||||
|
||||
try:
|
||||
from novaclient.v2 import security_group_rules
|
||||
except ImportError:
|
||||
from novaclient.v1_1 import security_group_rules
|
||||
|
||||
from openstackclient.common import parseractions
|
||||
from openstackclient.common import utils
|
||||
|
||||
|
@ -26,7 +26,11 @@ import sys
|
||||
from cliff import command
|
||||
from cliff import lister
|
||||
from cliff import show
|
||||
from novaclient.v1_1 import servers
|
||||
|
||||
try:
|
||||
from novaclient.v2 import servers
|
||||
except ImportError:
|
||||
from novaclient.v1_1 import servers
|
||||
|
||||
from openstackclient.common import exceptions
|
||||
from openstackclient.common import parseractions
|
||||
|
Loading…
x
Reference in New Issue
Block a user