1616import argparse
1717import logging
1818
19- import stevedore
20-
21- from keystoneclient .auth import base
19+ from keystoneauth1 .loading import base
2220
2321from openstackclient .common import exceptions as exc
2422from openstackclient .common import utils
2523from openstackclient .i18n import _
2624
27-
2825LOG = logging .getLogger (__name__ )
2926
3027# Initialize the list of Authentication plugins early in order
3734
3835def get_plugin_list ():
3936 """Gather plugin list and cache it"""
40-
4137 global PLUGIN_LIST
4238
4339 if PLUGIN_LIST is None :
44- PLUGIN_LIST = stevedore .ExtensionManager (
45- base .PLUGIN_NAMESPACE ,
46- invoke_on_load = False ,
47- propagate_map_exceptions = True ,
48- )
40+ PLUGIN_LIST = base .get_available_plugin_names ()
4941 return PLUGIN_LIST
5042
5143
@@ -55,8 +47,9 @@ def get_options_list():
5547 global OPTIONS_LIST
5648
5749 if not OPTIONS_LIST :
58- for plugin in get_plugin_list ():
59- for o in plugin .plugin .get_options ():
50+ for plugin_name in get_plugin_list ():
51+ plugin_options = base .get_plugin_options (plugin_name )
52+ for o in plugin_options :
6053 os_name = o .dest .lower ().replace ('_' , '-' )
6154 os_env_name = 'OS_' + os_name .upper ().replace ('-' , '_' )
6255 OPTIONS_LIST .setdefault (
@@ -66,7 +59,7 @@ def get_options_list():
6659 # help texts if they vary from one auth plugin to another
6760 # also the text rendering is ugly in the CLI ...
6861 OPTIONS_LIST [os_name ]['help' ] += 'With %s: %s\n ' % (
69- plugin . name ,
62+ plugin_name ,
7063 o .help ,
7164 )
7265 return OPTIONS_LIST
@@ -83,7 +76,7 @@ def select_auth_plugin(options):
8376 if options .auth .get ('url' ) and options .auth .get ('token' ):
8477 # service token authentication
8578 auth_plugin_name = 'token_endpoint'
86- elif options .auth_type in [ plugin . name for plugin in PLUGIN_LIST ] :
79+ elif options .auth_type in PLUGIN_LIST :
8780 # A direct plugin name was given, use it
8881 auth_plugin_name = options .auth_type
8982 elif options .auth .get ('username' ):
@@ -115,7 +108,7 @@ def build_auth_params(auth_plugin_name, cmd_options):
115108 auth_params = dict (cmd_options .auth )
116109 if auth_plugin_name :
117110 LOG .debug ('auth_type: %s' , auth_plugin_name )
118- auth_plugin_class = base .get_plugin_class (auth_plugin_name )
111+ auth_plugin_loader = base .get_plugin_loader (auth_plugin_name )
119112 # grab tenant from project for v2.0 API compatibility
120113 if auth_plugin_name .startswith ("v2" ):
121114 if 'project_id' in auth_params :
@@ -127,12 +120,12 @@ def build_auth_params(auth_plugin_name, cmd_options):
127120 else :
128121 LOG .debug ('no auth_type' )
129122 # delay the plugin choice, grab every option
130- auth_plugin_class = None
123+ auth_plugin_loader = None
131124 plugin_options = set ([o .replace ('-' , '_' ) for o in get_options_list ()])
132125 for option in plugin_options :
133126 LOG .debug ('fetching option %s' , option )
134127 auth_params [option ] = getattr (cmd_options .auth , option , None )
135- return (auth_plugin_class , auth_params )
128+ return (auth_plugin_loader , auth_params )
136129
137130
138131def check_valid_auth_options (options , auth_plugin_name , required_scope = True ):
@@ -188,7 +181,7 @@ def build_auth_plugins_option_parser(parser):
188181 authentication plugin.
189182
190183 """
191- available_plugins = [ plugin . name for plugin in get_plugin_list ()]
184+ available_plugins = list ( get_plugin_list ())
192185 parser .add_argument (
193186 '--os-auth-type' ,
194187 metavar = '<auth-type>' ,
0 commit comments