Merge "Liberalize version matching a bit"

This commit is contained in:
Jenkins 2014-11-21 14:38:14 +00:00 committed by Gerrit Code Review
commit a2450d85e0
5 changed files with 13 additions and 9 deletions

View File

@ -27,6 +27,7 @@ API_VERSION_OPTION = 'os_compute_api_version'
API_NAME = 'compute' API_NAME = 'compute'
API_VERSIONS = { API_VERSIONS = {
'1.1': 'novaclient.v1_1.client.Client', '1.1': 'novaclient.v1_1.client.Client',
'1': 'novaclient.v1_1.client.Client',
'2': 'novaclient.v1_1.client.Client', '2': 'novaclient.v1_1.client.Client',
} }

View File

@ -15,23 +15,25 @@
import logging import logging
from keystoneclient.v2_0 import client as identity_client_v2_0 from keystoneclient.v2_0 import client as identity_client_v2
from openstackclient.api import auth from openstackclient.api import auth
from openstackclient.common import utils from openstackclient.common import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
DEFAULT_IDENTITY_API_VERSION = '2.0' DEFAULT_IDENTITY_API_VERSION = '2'
API_VERSION_OPTION = 'os_identity_api_version' API_VERSION_OPTION = 'os_identity_api_version'
API_NAME = 'identity' API_NAME = 'identity'
API_VERSIONS = { API_VERSIONS = {
'2.0': 'openstackclient.identity.client.IdentityClientv2_0', '2.0': 'openstackclient.identity.client.IdentityClientv2',
'2': 'openstackclient.identity.client.IdentityClientv2',
'3': 'keystoneclient.v3.client.Client', '3': 'keystoneclient.v3.client.Client',
} }
# Translate our API version to auth plugin version prefix # Translate our API version to auth plugin version prefix
AUTH_VERSIONS = { AUTH_VERSIONS = {
'2.0': 'v2', '2.0': 'v2',
'2': 'v2',
'3': 'v3', '3': 'v3',
} }
@ -66,7 +68,7 @@ def build_option_parser(parser):
return auth.build_auth_plugins_option_parser(parser) return auth.build_auth_plugins_option_parser(parser)
class IdentityClientv2_0(identity_client_v2_0.Client): class IdentityClientv2(identity_client_v2.Client):
"""Tweak the earlier client class to deal with some changes""" """Tweak the earlier client class to deal with some changes"""
def __getattr__(self, name): def __getattr__(self, name):
# Map v3 'projects' back to v2 'tenants' # Map v3 'projects' back to v2 'tenants'

View File

@ -255,7 +255,8 @@ class OpenStackShell(app.App):
if version_opt: if version_opt:
api = mod.API_NAME api = mod.API_NAME
self.api_version[api] = version_opt self.api_version[api] = version_opt
version = '.v' + version_opt.replace('.', '_') # Command groups deal only with major versions
version = '.v' + version_opt.replace('.', '_').split('_')[0]
cmd_group = 'openstack.' + api.replace('-', '_') + version cmd_group = 'openstack.' + api.replace('-', '_') + version
self.command_manager.add_command_group(cmd_group) self.command_manager.add_command_group(cmd_group)
self.log.debug( self.log.debug(

View File

@ -38,13 +38,13 @@ DEFAULT_AUTH_PLUGIN = "v2password"
DEFAULT_COMPUTE_API_VERSION = "2" DEFAULT_COMPUTE_API_VERSION = "2"
DEFAULT_IDENTITY_API_VERSION = "2.0" DEFAULT_IDENTITY_API_VERSION = "2"
DEFAULT_IMAGE_API_VERSION = "v2" DEFAULT_IMAGE_API_VERSION = "2"
DEFAULT_VOLUME_API_VERSION = "1" DEFAULT_VOLUME_API_VERSION = "1"
DEFAULT_NETWORK_API_VERSION = "2" DEFAULT_NETWORK_API_VERSION = "2"
LIB_COMPUTE_API_VERSION = "2" LIB_COMPUTE_API_VERSION = "2"
LIB_IDENTITY_API_VERSION = "2.0" LIB_IDENTITY_API_VERSION = "2"
LIB_IMAGE_API_VERSION = "1" LIB_IMAGE_API_VERSION = "1"
LIB_VOLUME_API_VERSION = "1" LIB_VOLUME_API_VERSION = "1"
LIB_NETWORK_API_VERSION = "2" LIB_NETWORK_API_VERSION = "2"

View File

@ -131,7 +131,7 @@ openstack.compute.v2 =
server_unrescue = openstackclient.compute.v2.server:UnrescueServer server_unrescue = openstackclient.compute.v2.server:UnrescueServer
server_unset = openstackclient.compute.v2.server:UnsetServer server_unset = openstackclient.compute.v2.server:UnsetServer
openstack.identity.v2_0 = openstack.identity.v2 =
catalog_list = openstackclient.identity.v2_0.catalog:ListCatalog catalog_list = openstackclient.identity.v2_0.catalog:ListCatalog
catalog_show = openstackclient.identity.v2_0.catalog:ShowCatalog catalog_show = openstackclient.identity.v2_0.catalog:ShowCatalog