Skip to content

Commit dc49707

Browse files
author
Matt Riedemann
committed
Set DEFAULT_OS_COMPUTE_API_VERSION to 2.5
The client currently implements support for microversions 2.2, 2.4 and 2.11. According the nova API microversion history: http://docs.openstack.org/developer/nova/api_microversion_history.html 2.3 just returns extra attributes in the response so it's not a problem for the client. We should expose those at some point but it's not a breaking change. 2.5 is a server-side only change since the client allows filtering servers by IPv6 address but the server wasn't honoring that until 2.5. There are no client side changes for that microversion. 2.6 is the first backwards incompatible microversion since it replaces the old specific console APIs (RDP/serial/SPICE/VNC) with a new generic remote-consoles API. The client must be updated to handle this since requesting any microversion >=2.6 for consoles will fail right now. This is exposed on the CLI right now because the CLI defaults to the 2.latest microversion. So even though the client actually supports the 2.11 microversion, we shouldn't default to higher than 2.5 because we have gaps in handling 2.6->2.10. This change fixes the default for the CLI by setting DEFAULT_OS_COMPUTE_API_VERSION=2.5. Partial-Bug: #1500688 Change-Id: I52074f9a3e7faa6a7a51c3fa9766100acf25dee2 (cherry picked from commit d045019) ------------------------------------------------------------------------ The first change introduced a regression which is fixed in the following squashed change to make the complete fix. ------------------------------------------------------------------------ Correct usage of API_MAX_VERSION and DEFAULT_OS_COMPUTE_API_VERSION Commit d045019 use the variables API_MAX_VERSION and DEFAULT_OS_COMPUTE_API_VERSION with wrong way. API_MAX_VERSION means the max version of client supported. This variable only be changed when client support the new version. And it's must bumped sequentially. DEFAULT_OS_COMPUTE_API_VERSION is default value of option '--os-compute-api-version', this value decided the default behaviour of nova client. The nova client CLI behaviour should be that client negotiate with server side to find out most recent version betweeyn client and server. So the value should be '2.latest'. And it won't be changed except we decided to change the default behaviour of nova client CLI. Change-Id: Iba9bfa136245bd2899c427ac0c231a30c00bd7f3 Closes-Bug: #1508244 (cherry picked from commit 28bf8dd)
1 parent 3636685 commit dc49707

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

novaclient/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@
2020
__version__ = pbr.version.VersionInfo('python-novaclient').version_string()
2121

2222
API_MIN_VERSION = api_versions.APIVersion("2.1")
23-
API_MAX_VERSION = api_versions.APIVersion("2.11")
23+
# The max version should be the latest version that is supported in the client,
24+
# not necessarily the latest that the server can provide. This is only bumped
25+
# when client supported the max version, and bumped sequentially, otherwise
26+
# the client may break due to server side new version may include some
27+
# backward incompatible change.
28+
API_MAX_VERSION = api_versions.APIVersion("2.5")

novaclient/shell.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
from novaclient import utils
5252

5353
DEFAULT_MAJOR_OS_COMPUTE_API_VERSION = "2.0"
54-
DEFAULT_OS_COMPUTE_API_VERSION = "2.latest"
54+
# The default behaviour of nova client CLI is that CLI negotiates with server
55+
# to find out the most recent version between client and server, and
56+
# '2.latest' means to that. This value never be changed until we decided to
57+
# change the default behaviour of nova client CLI.
58+
DEFAULT_OS_COMPUTE_API_VERSION = '2.latest'
5559
DEFAULT_NOVA_ENDPOINT_TYPE = 'publicURL'
5660
DEFAULT_NOVA_SERVICE_TYPE = "compute"
5761

novaclient/tests/unit/test_shell.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
'OS_COMPUTE_API_VERSION': '2',
6666
'OS_AUTH_SYSTEM': 'rackspace'}
6767

68+
FAKE_ENV6 = {'OS_USERNAME': 'username',
69+
'OS_PASSWORD': 'password',
70+
'OS_TENANT_NAME': 'tenant_name',
71+
'OS_AUTH_URL': 'http://no.where/v2.0',
72+
'OS_AUTH_SYSTEM': 'rackspace'}
73+
6874

6975
def _create_ver_list(versions):
7076
return {'versions': {'values': versions}}
@@ -424,6 +430,25 @@ def test_keyring_saver_helper(self, mock_client,
424430
keyring_saver = mock_client_instance.client.keyring_saver
425431
self.assertIsInstance(keyring_saver, novaclient.shell.SecretsHelper)
426432

433+
@mock.patch('novaclient.client.Client')
434+
def test_microversion_with_default_behaviour(self, mock_client):
435+
self.make_env(fake_env=FAKE_ENV6)
436+
self.mock_server_version_range.return_value = (
437+
api_versions.APIVersion("2.1"), api_versions.APIVersion("2.3"))
438+
self.shell('list')
439+
client_args = mock_client.call_args_list[1][0]
440+
self.assertEqual(api_versions.APIVersion("2.3"), client_args[0])
441+
442+
@mock.patch('novaclient.client.Client')
443+
def test_microversion_with_default_behaviour_with_legacy_server(
444+
self, mock_client):
445+
self.make_env(fake_env=FAKE_ENV6)
446+
self.mock_server_version_range.return_value = (
447+
api_versions.APIVersion(), api_versions.APIVersion())
448+
self.shell('list')
449+
client_args = mock_client.call_args_list[1][0]
450+
self.assertEqual(api_versions.APIVersion("2.0"), client_args[0])
451+
427452
@mock.patch('novaclient.client.Client')
428453
def test_microversion_with_latest(self, mock_client):
429454
self.make_env()

0 commit comments

Comments
 (0)