Make Identity client load like the others
This does a couple of things: * Loads the Identity client module in the same manner as the other 'base' clients (where 'base' == 'included in the OSC repo') * Changes the entry point group name for the base clients to 'openstack.cli.base'. The extension group name remains the same. * Loads the base modules first followed by the extension modules. This load order ensures that the extension module commands are all loaded _after_ the base commands, allowing extensions to now override the base commands. Change-Id: I4b9ca7f1df6eb8bbe8e3f663f3065c2ed80ce20b
This commit is contained in:
parent
7a8c9a7a8a
commit
1ab38679b6
@ -70,6 +70,27 @@ def make_client(instance):
|
|||||||
return client
|
return client
|
||||||
|
|
||||||
|
|
||||||
|
def build_option_parser(parser):
|
||||||
|
"""Hook to add global options"""
|
||||||
|
parser.add_argument(
|
||||||
|
'--os-identity-api-version',
|
||||||
|
metavar='<identity-api-version>',
|
||||||
|
default=utils.env(
|
||||||
|
'OS_IDENTITY_API_VERSION',
|
||||||
|
default=DEFAULT_IDENTITY_API_VERSION),
|
||||||
|
help='Identity API version, default=' +
|
||||||
|
DEFAULT_IDENTITY_API_VERSION +
|
||||||
|
' (Env: OS_IDENTITY_API_VERSION)')
|
||||||
|
parser.add_argument(
|
||||||
|
'--os-trust-id',
|
||||||
|
metavar='<trust-id>',
|
||||||
|
default=utils.env('OS_TRUST_ID'),
|
||||||
|
help='Trust ID to use when authenticating. '
|
||||||
|
'This can only be used with Keystone v3 API '
|
||||||
|
'(Env: OS_TRUST_ID)')
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
class IdentityClientv2_0(identity_client_v2_0.Client):
|
class IdentityClientv2_0(identity_client_v2_0.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):
|
||||||
|
@ -34,7 +34,6 @@ from openstackclient.common import exceptions as exc
|
|||||||
from openstackclient.common import restapi
|
from openstackclient.common import restapi
|
||||||
from openstackclient.common import timing
|
from openstackclient.common import timing
|
||||||
from openstackclient.common import utils
|
from openstackclient.common import utils
|
||||||
from openstackclient.identity import client as identity_client
|
|
||||||
|
|
||||||
|
|
||||||
KEYRING_SERVICE = 'openstack'
|
KEYRING_SERVICE = 'openstack'
|
||||||
@ -76,6 +75,8 @@ class OpenStackShell(app.App):
|
|||||||
version=openstackclient.__version__,
|
version=openstackclient.__version__,
|
||||||
command_manager=commandmanager.CommandManager('openstack.cli'))
|
command_manager=commandmanager.CommandManager('openstack.cli'))
|
||||||
|
|
||||||
|
self.api_version = {}
|
||||||
|
|
||||||
# Until we have command line arguments parsed, dump any stack traces
|
# Until we have command line arguments parsed, dump any stack traces
|
||||||
self.dump_stack_trace = True
|
self.dump_stack_trace = True
|
||||||
|
|
||||||
@ -86,10 +87,14 @@ class OpenStackShell(app.App):
|
|||||||
# Assume TLS host certificate verification is enabled
|
# Assume TLS host certificate verification is enabled
|
||||||
self.verify = True
|
self.verify = True
|
||||||
|
|
||||||
# Get list of extension modules
|
# Get list of base modules
|
||||||
self.ext_modules = clientmanager.get_extension_modules(
|
self.ext_modules = clientmanager.get_extension_modules(
|
||||||
'openstack.cli.extension',
|
'openstack.cli.base',
|
||||||
)
|
)
|
||||||
|
# Append list of extension modules
|
||||||
|
self.ext_modules.extend(clientmanager.get_extension_modules(
|
||||||
|
'openstack.cli.extension',
|
||||||
|
))
|
||||||
|
|
||||||
# Loop through extensions to get parser additions
|
# Loop through extensions to get parser additions
|
||||||
for mod in self.ext_modules:
|
for mod in self.ext_modules:
|
||||||
@ -312,23 +317,6 @@ class OpenStackShell(app.App):
|
|||||||
help="Print API call timing info",
|
help="Print API call timing info",
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
'--os-identity-api-version',
|
|
||||||
metavar='<identity-api-version>',
|
|
||||||
default=env(
|
|
||||||
'OS_IDENTITY_API_VERSION',
|
|
||||||
default=identity_client.DEFAULT_IDENTITY_API_VERSION),
|
|
||||||
help='Identity API version, default=' +
|
|
||||||
identity_client.DEFAULT_IDENTITY_API_VERSION +
|
|
||||||
' (Env: OS_IDENTITY_API_VERSION)')
|
|
||||||
parser.add_argument(
|
|
||||||
'--os-trust-id',
|
|
||||||
metavar='<trust-id>',
|
|
||||||
default=utils.env('OS_TRUST_ID'),
|
|
||||||
help='Trust ID to use when authenticating. '
|
|
||||||
'This can only be used with Keystone v3 API '
|
|
||||||
'(Env: OS_TRUST_ID)')
|
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def authenticate_user(self):
|
def authenticate_user(self):
|
||||||
@ -437,24 +425,19 @@ class OpenStackShell(app.App):
|
|||||||
# Save default domain
|
# Save default domain
|
||||||
self.default_domain = self.options.os_default_domain
|
self.default_domain = self.options.os_default_domain
|
||||||
|
|
||||||
# Stash selected API versions for later
|
|
||||||
self.api_version = {
|
|
||||||
'identity': self.options.os_identity_api_version,
|
|
||||||
}
|
|
||||||
# Loop through extensions to get API versions
|
# Loop through extensions to get API versions
|
||||||
for mod in self.ext_modules:
|
for mod in self.ext_modules:
|
||||||
ver = getattr(self.options, mod.API_VERSION_OPTION, None)
|
version_opt = getattr(self.options, mod.API_VERSION_OPTION, None)
|
||||||
if ver:
|
if version_opt:
|
||||||
self.api_version[mod.API_NAME] = ver
|
api = mod.API_NAME
|
||||||
self.log.debug('%(name)s API version %(version)s',
|
self.api_version[api] = version_opt
|
||||||
{'name': mod.API_NAME, 'version': ver})
|
version = '.v' + version_opt.replace('.', '_')
|
||||||
|
cmd_group = 'openstack.' + api.replace('-', '_') + version
|
||||||
# Add the API version-specific commands
|
self.command_manager.add_command_group(cmd_group)
|
||||||
for api in self.api_version.keys():
|
self.log.debug(
|
||||||
version = '.v' + self.api_version[api].replace('.', '_')
|
'%(name)s API version %(version)s, cmd group %(group)s',
|
||||||
cmd_group = 'openstack.' + api.replace('-', '_') + version
|
{'name': api, 'version': version_opt, 'group': cmd_group}
|
||||||
self.log.debug('command group %s', cmd_group)
|
)
|
||||||
self.command_manager.add_command_group(cmd_group)
|
|
||||||
|
|
||||||
# Commands that span multiple APIs
|
# Commands that span multiple APIs
|
||||||
self.command_manager.add_command_group(
|
self.command_manager.add_command_group(
|
||||||
|
@ -30,8 +30,9 @@ console_scripts =
|
|||||||
openstack.cli =
|
openstack.cli =
|
||||||
module_list = openstackclient.common.module:ListModule
|
module_list = openstackclient.common.module:ListModule
|
||||||
|
|
||||||
openstack.cli.extension =
|
openstack.cli.base =
|
||||||
compute = openstackclient.compute.client
|
compute = openstackclient.compute.client
|
||||||
|
identity = openstackclient.identity.client
|
||||||
image = openstackclient.image.client
|
image = openstackclient.image.client
|
||||||
network = openstackclient.network.client
|
network = openstackclient.network.client
|
||||||
object_store = openstackclient.object.client
|
object_store = openstackclient.object.client
|
||||||
|
Loading…
x
Reference in New Issue
Block a user