Merge "Make auth plugins dest save to os_"

This commit is contained in:
Jenkins
2014-08-19 18:00:18 +00:00
committed by Gerrit Code Review
2 changed files with 7 additions and 2 deletions

View File

@@ -151,7 +151,7 @@ class BaseAuthPlugin(object):
default=default, default=default,
metavar=opt.metavar, metavar=opt.metavar,
help=opt.help, help=opt.help,
dest=opt.dest) dest='os_%s' % opt.dest)
@classmethod @classmethod
def load_from_argparse_arguments(cls, namespace, **kwargs): def load_from_argparse_arguments(cls, namespace, **kwargs):
@@ -165,7 +165,7 @@ class BaseAuthPlugin(object):
:returns: An auth plugin, or None if a name is not provided. :returns: An auth plugin, or None if a name is not provided.
""" """
for opt in cls.get_options(): for opt in cls.get_options():
val = getattr(namespace, opt.dest) val = getattr(namespace, 'os_%s' % opt.dest)
if val is not None: if val is not None:
val = opt.type(val) val = opt.type(val)
kwargs.setdefault(opt.dest, val) kwargs.setdefault(opt.dest, val)

View File

@@ -62,6 +62,11 @@ class CliTests(utils.TestCase):
a = cli.load_from_argparse_arguments(opts) a = cli.load_from_argparse_arguments(opts)
self.assertTestVals(a) self.assertTestVals(a)
self.assertEqual(name, opts.os_auth_plugin)
self.assertEqual(str(self.a_int), opts.os_a_int)
self.assertEqual(str(self.a_float), opts.os_a_float)
self.assertEqual(str(self.a_bool), opts.os_a_bool)
@utils.mock_plugin @utils.mock_plugin
def test_default_options(self, m): def test_default_options(self, m):
name = uuid.uuid4().hex name = uuid.uuid4().hex