Skip to content

Commit b223156

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Remove python-novaclient"
2 parents 70fbf68 + 438e40d commit b223156

File tree

9 files changed

+19
-120
lines changed

9 files changed

+19
-120
lines changed

openstackclient/compute/client.py

Lines changed: 7 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -15,76 +15,28 @@
1515

1616
import logging
1717

18-
from osc_lib import exceptions
1918
from osc_lib import utils
2019

2120
from openstackclient.i18n import _
2221

23-
2422
LOG = logging.getLogger(__name__)
2523

2624
DEFAULT_API_VERSION = '2.1'
2725
API_VERSION_OPTION = 'os_compute_api_version'
2826
API_NAME = 'compute'
2927
API_VERSIONS = {
30-
"2": "novaclient.client",
31-
"2.1": "novaclient.client",
32-
}
33-
34-
COMPUTE_API_VERSIONS = {
35-
'2': 'openstackclient.api.compute_v2.APIv2',
28+
'2': 'openstack.connection.Connection',
29+
'2.1': 'openstack.connection.Connection',
3630
}
3731

38-
# Save the microversion if in use
39-
_compute_api_version = None
40-
4132

4233
def make_client(instance):
4334
"""Returns a compute service client."""
44-
45-
# Defer client import until we actually need them
46-
from novaclient import client as nova_client
47-
48-
if _compute_api_version is not None:
49-
version = _compute_api_version
50-
else:
51-
version = instance._api_version[API_NAME]
52-
from novaclient import api_versions
53-
54-
# convert to APIVersion object
55-
version = api_versions.get_api_version(version)
56-
57-
if version.is_latest():
58-
import novaclient
59-
60-
# NOTE(RuiChen): executing version discovery make sense, but that need
61-
# an initialized REST client, it's not available now,
62-
# fallback to use the max version of novaclient side.
63-
version = novaclient.API_MAX_VERSION
64-
65-
# Set client http_log_debug to True if verbosity level is high enough
66-
http_log_debug = utils.get_effective_log_level() <= logging.DEBUG
67-
68-
extensions = [
69-
ext
70-
for ext in nova_client.discover_extensions(version)
71-
if ext.name == "list_extensions"
72-
]
73-
74-
# Remember interface only if it is set
75-
kwargs = utils.build_kwargs_dict('endpoint_type', instance.interface)
76-
77-
client = nova_client.Client(
78-
version,
79-
session=instance.session,
80-
extensions=extensions,
81-
http_log_debug=http_log_debug,
82-
timings=instance.timing,
83-
region_name=instance.region_name,
84-
**kwargs
35+
LOG.debug(
36+
'Compute client initialized using OpenStack SDK: %s',
37+
instance.sdk_connection.compute,
8538
)
86-
87-
return client
39+
return instance.sdk_connection.compute
8840

8941

9042
def build_option_parser(parser):
@@ -93,48 +45,7 @@ def build_option_parser(parser):
9345
'--os-compute-api-version',
9446
metavar='<compute-api-version>',
9547
default=utils.env('OS_COMPUTE_API_VERSION'),
96-
help=_(
97-
"Compute API version, default=%s " "(Env: OS_COMPUTE_API_VERSION)"
98-
)
48+
help=_("Compute API version, default=%s (Env: OS_COMPUTE_API_VERSION)")
9949
% DEFAULT_API_VERSION,
10050
)
10151
return parser
102-
103-
104-
def check_api_version(check_version):
105-
"""Validate version supplied by user
106-
107-
Returns:
108-
109-
* True if version is OK
110-
* False if the version has not been checked and the previous plugin
111-
check should be performed
112-
* throws an exception if the version is no good
113-
114-
TODO(dtroyer): make the exception thrown a version-related one
115-
"""
116-
117-
# Defer client imports until we actually need them
118-
import novaclient
119-
from novaclient import api_versions
120-
121-
global _compute_api_version
122-
123-
# Copy some logic from novaclient 3.3.0 for basic version detection
124-
# NOTE(dtroyer): This is only enough to resume operations using API
125-
# version 2.0 or any valid version supplied by the user.
126-
_compute_api_version = api_versions.get_api_version(check_version)
127-
128-
# Bypass X.latest format microversion
129-
if not _compute_api_version.is_latest():
130-
if _compute_api_version > api_versions.APIVersion("2.0"):
131-
if not _compute_api_version.matches(
132-
novaclient.API_MIN_VERSION,
133-
novaclient.API_MAX_VERSION,
134-
):
135-
msg = _("versions supported by client: %(min)s - %(max)s") % {
136-
"min": novaclient.API_MIN_VERSION.get_string(),
137-
"max": novaclient.API_MAX_VERSION.get_string(),
138-
}
139-
raise exceptions.CommandError(msg)
140-
return True

openstackclient/compute/v2/hypervisor.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import json
1919
import re
2020

21-
from novaclient import exceptions as nova_exceptions
21+
from openstack import exceptions as sdk_exceptions
2222
from openstack import utils as sdk_utils
2323
from osc_lib.cli import format_columns
2424
from osc_lib.command import command
@@ -223,8 +223,9 @@ def take_action(self, parsed_args):
223223
hypervisor['uptime'] = m.group(2)
224224
hypervisor['users'] = m.group(3)
225225
hypervisor['load_average'] = m.group(4)
226-
except nova_exceptions.HTTPNotImplemented:
227-
pass
226+
except sdk_exceptions.HttpException as exc:
227+
if exc.status_code != 501:
228+
raise
228229

229230
hypervisor['service_id'] = service_details['id']
230231
hypervisor['service_host'] = service_details['host']

openstackclient/compute/v2/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def _find_service_by_host_and_binary(compute_client, host, binary):
198198
199199
:param host: the name of the compute service host
200200
:param binary: the compute service binary, e.g. nova-compute
201-
:returns: novaclient.v2.services.Service dict-like object
201+
:returns: The service.
202202
:raises: CommandError if no or multiple results were found
203203
"""
204204
services = list(compute_client.services(host=host, binary=binary))

openstackclient/image/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
1919

2020
from openstackclient.i18n import _
2121

22-
2322
LOG = logging.getLogger(__name__)
2423

2524
DEFAULT_API_VERSION = '2'
2625
API_VERSION_OPTION = 'os_image_api_version'
27-
API_NAME = "image"
26+
API_NAME = 'image'
2827
API_VERSIONS = {
29-
"1": "openstack.connection.Connection",
30-
"2": "openstack.connection.Connection",
28+
'1': 'openstack.connection.Connection',
29+
'2': 'openstack.connection.Connection',
3130
}
3231

3332

3433
def make_client(instance):
34+
"""Returns an image service client."""
3535
LOG.debug(
3636
'Image client initialized using OpenStack SDK: %s',
3737
instance.sdk_connection.image,

openstackclient/tests/functional/common/test_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class ModuleTest(base.TestCase):
1919
"""Functional tests for openstackclient module list output."""
2020

21-
CLIENTS = ['openstackclient', 'keystoneclient', 'novaclient', 'openstack']
21+
CLIENTS = ['openstackclient', 'keystoneclient', 'openstack']
2222

2323
LIBS = ['osc_lib', 'keystoneauth1']
2424

openstackclient/tests/unit/compute/v2/fakes.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import uuid
2121

2222
from keystoneauth1 import discover
23-
from novaclient import api_versions
2423
from openstack.compute.v2 import _proxy
2524
from openstack.compute.v2 import aggregate as _aggregate
2625
from openstack.compute.v2 import availability_zone as _availability_zone
@@ -105,12 +104,6 @@ class FakeClientMixin:
105104
def setUp(self):
106105
super().setUp()
107106

108-
self.app.client_manager.compute = FakeComputev2Client(
109-
endpoint=fakes.AUTH_URL,
110-
token=fakes.AUTH_TOKEN,
111-
)
112-
self.compute_client = self.app.client_manager.compute
113-
114107
# TODO(stephenfin): Rename to 'compute_client' once all commands are
115108
# migrated to SDK
116109
self.app.client_manager.sdk_connection.compute = mock.Mock(
@@ -130,8 +123,6 @@ def set_compute_api_version(self, version: str = '2.1'):
130123
"""
131124
assert re.match(r'2.\d+', version)
132125

133-
self.compute_client.api_version = api_versions.APIVersion(version)
134-
135126
self.compute_sdk_client.default_microversion = version
136127
self.compute_sdk_client.get_endpoint_data.return_value = (
137128
discover.EndpointData(

openstackclient/tests/unit/compute/v2/test_hypervisor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import json
1616

17-
from novaclient import exceptions as nova_exceptions
17+
from openstack import exceptions as sdk_exceptions
1818
from osc_lib.cli import format_columns
1919
from osc_lib import exceptions
2020

@@ -484,7 +484,7 @@ def test_hypervisor_show_uptime_not_implemented(self):
484484
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
485485

486486
self.compute_sdk_client.get_hypervisor_uptime.side_effect = (
487-
nova_exceptions.HTTPNotImplemented(501)
487+
sdk_exceptions.HttpException(http_status=501)
488488
)
489489

490490
# In base command class ShowOne in cliff, abstract method take_action()

openstackclient/tests/unit/compute/v2/test_server.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5452,9 +5452,6 @@ def test_server_list_v269_with_partial_constructs(self):
54525452
{"href": "http://fake/v2.1/", "rel": "self"},
54535453
{"href": "http://fake", "rel": "bookmark"},
54545454
],
5455-
# We need to pass networks as {} because its defined as a property
5456-
# of the novaclient Server class which gives {} by default. If not
5457-
# it will fail at formatting the networks info later on.
54585455
"networks": {},
54595456
}
54605457
fake_server = compute_fakes.fakes.FakeResource(

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ openstacksdk>=3.3.0 # Apache-2.0
1111
osc-lib>=2.3.0 # Apache-2.0
1212
oslo.i18n>=3.15.3 # Apache-2.0
1313
python-keystoneclient>=3.22.0 # Apache-2.0
14-
python-novaclient>=18.1.0 # Apache-2.0
1514
python-cinderclient>=3.3.0 # Apache-2.0
1615
requests>=2.14.2 # Apache-2.0
1716
stevedore>=2.0.1 # Apache-2.0

0 commit comments

Comments
 (0)