Remove python-novaclient
There are a few remnants left here but this is trivial to clean up now. Change-Id: I517d906796338e64a31afa08b9ee6909b08e0115 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
6127b44d0a
commit
438e40db36
@ -15,76 +15,28 @@
|
||||
|
||||
import logging
|
||||
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
|
||||
from openstackclient.i18n import _
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_API_VERSION = '2.1'
|
||||
API_VERSION_OPTION = 'os_compute_api_version'
|
||||
API_NAME = 'compute'
|
||||
API_VERSIONS = {
|
||||
"2": "novaclient.client",
|
||||
"2.1": "novaclient.client",
|
||||
'2': 'openstack.connection.Connection',
|
||||
'2.1': 'openstack.connection.Connection',
|
||||
}
|
||||
|
||||
COMPUTE_API_VERSIONS = {
|
||||
'2': 'openstackclient.api.compute_v2.APIv2',
|
||||
}
|
||||
|
||||
# Save the microversion if in use
|
||||
_compute_api_version = None
|
||||
|
||||
|
||||
def make_client(instance):
|
||||
"""Returns a compute service client."""
|
||||
|
||||
# Defer client import until we actually need them
|
||||
from novaclient import client as nova_client
|
||||
|
||||
if _compute_api_version is not None:
|
||||
version = _compute_api_version
|
||||
else:
|
||||
version = instance._api_version[API_NAME]
|
||||
from novaclient import api_versions
|
||||
|
||||
# convert to APIVersion object
|
||||
version = api_versions.get_api_version(version)
|
||||
|
||||
if version.is_latest():
|
||||
import novaclient
|
||||
|
||||
# NOTE(RuiChen): executing version discovery make sense, but that need
|
||||
# an initialized REST client, it's not available now,
|
||||
# fallback to use the max version of novaclient side.
|
||||
version = novaclient.API_MAX_VERSION
|
||||
|
||||
# Set client http_log_debug to True if verbosity level is high enough
|
||||
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG
|
||||
|
||||
extensions = [
|
||||
ext
|
||||
for ext in nova_client.discover_extensions(version)
|
||||
if ext.name == "list_extensions"
|
||||
]
|
||||
|
||||
# Remember interface only if it is set
|
||||
kwargs = utils.build_kwargs_dict('endpoint_type', instance.interface)
|
||||
|
||||
client = nova_client.Client(
|
||||
version,
|
||||
session=instance.session,
|
||||
extensions=extensions,
|
||||
http_log_debug=http_log_debug,
|
||||
timings=instance.timing,
|
||||
region_name=instance.region_name,
|
||||
**kwargs
|
||||
LOG.debug(
|
||||
'Compute client initialized using OpenStack SDK: %s',
|
||||
instance.sdk_connection.compute,
|
||||
)
|
||||
|
||||
return client
|
||||
return instance.sdk_connection.compute
|
||||
|
||||
|
||||
def build_option_parser(parser):
|
||||
@ -93,48 +45,7 @@ def build_option_parser(parser):
|
||||
'--os-compute-api-version',
|
||||
metavar='<compute-api-version>',
|
||||
default=utils.env('OS_COMPUTE_API_VERSION'),
|
||||
help=_(
|
||||
"Compute API version, default=%s " "(Env: OS_COMPUTE_API_VERSION)"
|
||||
)
|
||||
help=_("Compute API version, default=%s (Env: OS_COMPUTE_API_VERSION)")
|
||||
% DEFAULT_API_VERSION,
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
def check_api_version(check_version):
|
||||
"""Validate version supplied by user
|
||||
|
||||
Returns:
|
||||
|
||||
* True if version is OK
|
||||
* False if the version has not been checked and the previous plugin
|
||||
check should be performed
|
||||
* throws an exception if the version is no good
|
||||
|
||||
TODO(dtroyer): make the exception thrown a version-related one
|
||||
"""
|
||||
|
||||
# Defer client imports until we actually need them
|
||||
import novaclient
|
||||
from novaclient import api_versions
|
||||
|
||||
global _compute_api_version
|
||||
|
||||
# Copy some logic from novaclient 3.3.0 for basic version detection
|
||||
# NOTE(dtroyer): This is only enough to resume operations using API
|
||||
# version 2.0 or any valid version supplied by the user.
|
||||
_compute_api_version = api_versions.get_api_version(check_version)
|
||||
|
||||
# Bypass X.latest format microversion
|
||||
if not _compute_api_version.is_latest():
|
||||
if _compute_api_version > api_versions.APIVersion("2.0"):
|
||||
if not _compute_api_version.matches(
|
||||
novaclient.API_MIN_VERSION,
|
||||
novaclient.API_MAX_VERSION,
|
||||
):
|
||||
msg = _("versions supported by client: %(min)s - %(max)s") % {
|
||||
"min": novaclient.API_MIN_VERSION.get_string(),
|
||||
"max": novaclient.API_MAX_VERSION.get_string(),
|
||||
}
|
||||
raise exceptions.CommandError(msg)
|
||||
return True
|
||||
|
@ -18,7 +18,7 @@
|
||||
import json
|
||||
import re
|
||||
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
from openstack import exceptions as sdk_exceptions
|
||||
from openstack import utils as sdk_utils
|
||||
from osc_lib.cli import format_columns
|
||||
from osc_lib.command import command
|
||||
@ -223,8 +223,9 @@ class ShowHypervisor(command.ShowOne):
|
||||
hypervisor['uptime'] = m.group(2)
|
||||
hypervisor['users'] = m.group(3)
|
||||
hypervisor['load_average'] = m.group(4)
|
||||
except nova_exceptions.HTTPNotImplemented:
|
||||
pass
|
||||
except sdk_exceptions.HttpException as exc:
|
||||
if exc.status_code != 501:
|
||||
raise
|
||||
|
||||
hypervisor['service_id'] = service_details['id']
|
||||
hypervisor['service_host'] = service_details['host']
|
||||
|
@ -198,7 +198,7 @@ class SetService(command.Command):
|
||||
|
||||
:param host: the name of the compute service host
|
||||
:param binary: the compute service binary, e.g. nova-compute
|
||||
:returns: novaclient.v2.services.Service dict-like object
|
||||
:returns: The service.
|
||||
:raises: CommandError if no or multiple results were found
|
||||
"""
|
||||
services = list(compute_client.services(host=host, binary=binary))
|
||||
|
@ -19,19 +19,19 @@ from osc_lib import utils
|
||||
|
||||
from openstackclient.i18n import _
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_API_VERSION = '2'
|
||||
API_VERSION_OPTION = 'os_image_api_version'
|
||||
API_NAME = "image"
|
||||
API_NAME = 'image'
|
||||
API_VERSIONS = {
|
||||
"1": "openstack.connection.Connection",
|
||||
"2": "openstack.connection.Connection",
|
||||
'1': 'openstack.connection.Connection',
|
||||
'2': 'openstack.connection.Connection',
|
||||
}
|
||||
|
||||
|
||||
def make_client(instance):
|
||||
"""Returns an image service client."""
|
||||
LOG.debug(
|
||||
'Image client initialized using OpenStack SDK: %s',
|
||||
instance.sdk_connection.image,
|
||||
|
@ -18,7 +18,7 @@ from openstackclient.tests.functional import base
|
||||
class ModuleTest(base.TestCase):
|
||||
"""Functional tests for openstackclient module list output."""
|
||||
|
||||
CLIENTS = ['openstackclient', 'keystoneclient', 'novaclient', 'openstack']
|
||||
CLIENTS = ['openstackclient', 'keystoneclient', 'openstack']
|
||||
|
||||
LIBS = ['osc_lib', 'keystoneauth1']
|
||||
|
||||
|
@ -20,7 +20,6 @@ from unittest import mock
|
||||
import uuid
|
||||
|
||||
from keystoneauth1 import discover
|
||||
from novaclient import api_versions
|
||||
from openstack.compute.v2 import _proxy
|
||||
from openstack.compute.v2 import aggregate as _aggregate
|
||||
from openstack.compute.v2 import availability_zone as _availability_zone
|
||||
@ -105,12 +104,6 @@ class FakeClientMixin:
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
self.app.client_manager.compute = FakeComputev2Client(
|
||||
endpoint=fakes.AUTH_URL,
|
||||
token=fakes.AUTH_TOKEN,
|
||||
)
|
||||
self.compute_client = self.app.client_manager.compute
|
||||
|
||||
# TODO(stephenfin): Rename to 'compute_client' once all commands are
|
||||
# migrated to SDK
|
||||
self.app.client_manager.sdk_connection.compute = mock.Mock(
|
||||
@ -130,8 +123,6 @@ class FakeClientMixin:
|
||||
"""
|
||||
assert re.match(r'2.\d+', version)
|
||||
|
||||
self.compute_client.api_version = api_versions.APIVersion(version)
|
||||
|
||||
self.compute_sdk_client.default_microversion = version
|
||||
self.compute_sdk_client.get_endpoint_data.return_value = (
|
||||
discover.EndpointData(
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
import json
|
||||
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
from openstack import exceptions as sdk_exceptions
|
||||
from osc_lib.cli import format_columns
|
||||
from osc_lib import exceptions
|
||||
|
||||
@ -484,7 +484,7 @@ class TestHypervisorShow(compute_fakes.TestComputev2):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.compute_sdk_client.get_hypervisor_uptime.side_effect = (
|
||||
nova_exceptions.HTTPNotImplemented(501)
|
||||
sdk_exceptions.HttpException(http_status=501)
|
||||
)
|
||||
|
||||
# In base command class ShowOne in cliff, abstract method take_action()
|
||||
|
@ -5452,9 +5452,6 @@ class TestServerListV273(_TestServerList):
|
||||
{"href": "http://fake/v2.1/", "rel": "self"},
|
||||
{"href": "http://fake", "rel": "bookmark"},
|
||||
],
|
||||
# We need to pass networks as {} because its defined as a property
|
||||
# of the novaclient Server class which gives {} by default. If not
|
||||
# it will fail at formatting the networks info later on.
|
||||
"networks": {},
|
||||
}
|
||||
fake_server = compute_fakes.fakes.FakeResource(
|
||||
|
@ -11,7 +11,6 @@ openstacksdk>=3.3.0 # Apache-2.0
|
||||
osc-lib>=2.3.0 # Apache-2.0
|
||||
oslo.i18n>=3.15.3 # Apache-2.0
|
||||
python-keystoneclient>=3.22.0 # Apache-2.0
|
||||
python-novaclient>=18.1.0 # Apache-2.0
|
||||
python-cinderclient>=3.3.0 # Apache-2.0
|
||||
requests>=2.14.2 # Apache-2.0
|
||||
stevedore>=2.0.1 # Apache-2.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user