Skip to content

Commit

Permalink
openstack: load all available authentication plugins
Browse files Browse the repository at this point in the history
Instead of only loading the v3password authentication plugin, lets load
all the available keystoneauth plugins so that the user is able to use
their preferred authentication method.

Fixes #86
  • Loading branch information
alvarolopez committed Aug 17, 2018
1 parent 929f2b8 commit f810d52
Showing 1 changed file with 30 additions and 24 deletions.
54 changes: 30 additions & 24 deletions cloud_info/providers/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,34 +364,40 @@ def occify(term_name):

@staticmethod
def populate_parser(parser):
plugins = loading_base.get_available_plugin_names()
default_auth = "v3password"

parser.add_argument('--os-auth-type',
'--os-auth-plugin',
metavar='<name>',
default=default_auth,
help='Authentication type to use')

plugin = loading_base.get_plugin_loader(default_auth)

for opt in plugin.get_options():
# FIXME(aloga): the code below has been commented. This commit has
# been cherry picked from another branch that took into account the
# VOs and configured projects. The code below needs to be
# uncommented whenever Glue2.1 is in place.

# NOTE(aloga): we do not want a project to be passed from the CLI,
# as we will iterate over it for each configured VO and project.
# However, as the plugin is expecting them when parsing the
# arguments we need to set them to None before calling the
# load_auth_from_argparse_arguments method in the __init__ method
# of this class.
# if opt.name in ("project-name", "project-id"):
# continue
parser.add_argument(*opt.argparse_args,
default=opt.argparse_default,
metavar=opt.metavar,
help=opt.help,
dest='os_%s' % opt.dest)
default=utils.env('OS_AUTH_TYPE', default=default_auth),
choices=plugins,
help='Authentication type to use, available '
'types are: %s' % ", ".join(plugins))

for plugin_name in plugins:

plugin = loading_base.get_plugin_loader(plugin_name)

for opt in plugin.get_options():
# FIXME(aloga): the code below has been commented. This commit has
# been cherry picked from another branch that took into account the
# VOs and configured projects. The code below needs to be
# uncommented whenever Glue2.1 is in place.

# NOTE(aloga): we do not want a project to be passed from the CLI,
# as we will iterate over it for each configured VO and project.
# However, as the plugin is expecting them when parsing the
# arguments we need to set them to None before calling the
# load_auth_from_argparse_arguments method in the __init__ method
# of this class.
# if opt.name in ("project-name", "project-id"):
# continue
parser.add_argument(*opt.argparse_args,
default=opt.argparse_default,
metavar='<auth-%s>' % opt.name,
help=opt.help,
dest='os_%s' % opt.dest.replace("-", "_"))

parser.add_argument(
'--insecure',
Expand Down

0 comments on commit f810d52

Please sign in to comment.