Skip to content

Commit 2b02bea

Browse files
author
Dean Troyer
committed
Liberalize version matching a bit
For class-loading purposes we can just use the major version, so accept that. Only Identity and Compute were affected; Compute is included just to be pedantically complete. For command groups we also just use the major version so fix Compute and the version option handling. Change the internal default for Identity to a simple '2' so it is also consistent with the rest of the world. Then comes microversioning... Closes-Bug: #1292638 Change-Id: Ibaf823b31caa288a83de38d2c258860b128b87d8
1 parent f5a2811 commit 2b02bea

5 files changed

Lines changed: 13 additions & 9 deletions

File tree

openstackclient/compute/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
API_NAME = 'compute'
2828
API_VERSIONS = {
2929
'1.1': 'novaclient.v1_1.client.Client',
30+
'1': 'novaclient.v1_1.client.Client',
3031
'2': 'novaclient.v1_1.client.Client',
3132
}
3233

openstackclient/identity/client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,25 @@
1515

1616
import logging
1717

18-
from keystoneclient.v2_0 import client as identity_client_v2_0
18+
from keystoneclient.v2_0 import client as identity_client_v2
1919
from openstackclient.api import auth
2020
from openstackclient.common import utils
2121

2222
LOG = logging.getLogger(__name__)
2323

24-
DEFAULT_IDENTITY_API_VERSION = '2.0'
24+
DEFAULT_IDENTITY_API_VERSION = '2'
2525
API_VERSION_OPTION = 'os_identity_api_version'
2626
API_NAME = 'identity'
2727
API_VERSIONS = {
28-
'2.0': 'openstackclient.identity.client.IdentityClientv2_0',
28+
'2.0': 'openstackclient.identity.client.IdentityClientv2',
29+
'2': 'openstackclient.identity.client.IdentityClientv2',
2930
'3': 'keystoneclient.v3.client.Client',
3031
}
3132

3233
# Translate our API version to auth plugin version prefix
3334
AUTH_VERSIONS = {
3435
'2.0': 'v2',
36+
'2': 'v2',
3537
'3': 'v3',
3638
}
3739

@@ -66,7 +68,7 @@ def build_option_parser(parser):
6668
return auth.build_auth_plugins_option_parser(parser)
6769

6870

69-
class IdentityClientv2_0(identity_client_v2_0.Client):
71+
class IdentityClientv2(identity_client_v2.Client):
7072
"""Tweak the earlier client class to deal with some changes"""
7173
def __getattr__(self, name):
7274
# Map v3 'projects' back to v2 'tenants'

openstackclient/shell.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ def initialize_app(self, argv):
255255
if version_opt:
256256
api = mod.API_NAME
257257
self.api_version[api] = version_opt
258-
version = '.v' + version_opt.replace('.', '_')
258+
# Command groups deal only with major versions
259+
version = '.v' + version_opt.replace('.', '_').split('_')[0]
259260
cmd_group = 'openstack.' + api.replace('-', '_') + version
260261
self.command_manager.add_command_group(cmd_group)
261262
self.log.debug(

openstackclient/tests/test_shell.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838

3939

4040
DEFAULT_COMPUTE_API_VERSION = "2"
41-
DEFAULT_IDENTITY_API_VERSION = "2.0"
42-
DEFAULT_IMAGE_API_VERSION = "v2"
41+
DEFAULT_IDENTITY_API_VERSION = "2"
42+
DEFAULT_IMAGE_API_VERSION = "2"
4343
DEFAULT_VOLUME_API_VERSION = "1"
4444
DEFAULT_NETWORK_API_VERSION = "2"
4545

4646
LIB_COMPUTE_API_VERSION = "2"
47-
LIB_IDENTITY_API_VERSION = "2.0"
47+
LIB_IDENTITY_API_VERSION = "2"
4848
LIB_IMAGE_API_VERSION = "1"
4949
LIB_VOLUME_API_VERSION = "1"
5050
LIB_NETWORK_API_VERSION = "2"

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ openstack.compute.v2 =
131131
server_unrescue = openstackclient.compute.v2.server:UnrescueServer
132132
server_unset = openstackclient.compute.v2.server:UnsetServer
133133

134-
openstack.identity.v2_0 =
134+
openstack.identity.v2 =
135135
catalog_list = openstackclient.identity.v2_0.catalog:ListCatalog
136136
catalog_show = openstackclient.identity.v2_0.catalog:ShowCatalog
137137

0 commit comments

Comments
 (0)