3434from openstackclient .common import restapi
3535from openstackclient .common import timing
3636from openstackclient .common import utils
37- from openstackclient .identity import client as identity_client
3837
3938
4039KEYRING_SERVICE = 'openstack'
@@ -76,6 +75,8 @@ def __init__(self):
7675 version = openstackclient .__version__ ,
7776 command_manager = commandmanager .CommandManager ('openstack.cli' ))
7877
78+ self .api_version = {}
79+
7980 # Until we have command line arguments parsed, dump any stack traces
8081 self .dump_stack_trace = True
8182
@@ -86,10 +87,14 @@ def __init__(self):
8687 # Assume TLS host certificate verification is enabled
8788 self .verify = True
8889
89- # Get list of extension modules
90+ # Get list of base modules
9091 self .ext_modules = clientmanager .get_extension_modules (
91- 'openstack.cli.extension ' ,
92+ 'openstack.cli.base ' ,
9293 )
94+ # Append list of extension modules
95+ self .ext_modules .extend (clientmanager .get_extension_modules (
96+ 'openstack.cli.extension' ,
97+ ))
9398
9499 # Loop through extensions to get parser additions
95100 for mod in self .ext_modules :
@@ -312,23 +317,6 @@ def build_option_parser(self, description, version):
312317 help = "Print API call timing info" ,
313318 )
314319
315- parser .add_argument (
316- '--os-identity-api-version' ,
317- metavar = '<identity-api-version>' ,
318- default = env (
319- 'OS_IDENTITY_API_VERSION' ,
320- default = identity_client .DEFAULT_IDENTITY_API_VERSION ),
321- help = 'Identity API version, default=' +
322- identity_client .DEFAULT_IDENTITY_API_VERSION +
323- ' (Env: OS_IDENTITY_API_VERSION)' )
324- parser .add_argument (
325- '--os-trust-id' ,
326- metavar = '<trust-id>' ,
327- default = utils .env ('OS_TRUST_ID' ),
328- help = 'Trust ID to use when authenticating. '
329- 'This can only be used with Keystone v3 API '
330- '(Env: OS_TRUST_ID)' )
331-
332320 return parser
333321
334322 def authenticate_user (self ):
@@ -437,24 +425,19 @@ def initialize_app(self, argv):
437425 # Save default domain
438426 self .default_domain = self .options .os_default_domain
439427
440- # Stash selected API versions for later
441- self .api_version = {
442- 'identity' : self .options .os_identity_api_version ,
443- }
444428 # Loop through extensions to get API versions
445429 for mod in self .ext_modules :
446- ver = getattr (self .options , mod .API_VERSION_OPTION , None )
447- if ver :
448- self .api_version [mod .API_NAME ] = ver
449- self .log .debug ('%(name)s API version %(version)s' ,
450- {'name' : mod .API_NAME , 'version' : ver })
451-
452- # Add the API version-specific commands
453- for api in self .api_version .keys ():
454- version = '.v' + self .api_version [api ].replace ('.' , '_' )
455- cmd_group = 'openstack.' + api .replace ('-' , '_' ) + version
456- self .log .debug ('command group %s' , cmd_group )
457- self .command_manager .add_command_group (cmd_group )
430+ version_opt = getattr (self .options , mod .API_VERSION_OPTION , None )
431+ if version_opt :
432+ api = mod .API_NAME
433+ self .api_version [api ] = version_opt
434+ version = '.v' + version_opt .replace ('.' , '_' )
435+ cmd_group = 'openstack.' + api .replace ('-' , '_' ) + version
436+ self .command_manager .add_command_group (cmd_group )
437+ self .log .debug (
438+ '%(name)s API version %(version)s, cmd group %(group)s' ,
439+ {'name' : api , 'version' : version_opt , 'group' : cmd_group }
440+ )
458441
459442 # Commands that span multiple APIs
460443 self .command_manager .add_command_group (
0 commit comments