Merge "Fix a precedence problem with auth arguments"

This commit is contained in:
Jenkins 2016-01-13 20:21:57 +00:00 committed by Gerrit Code Review
commit 94ea0644e5
2 changed files with 13 additions and 1 deletions

View File

@ -448,7 +448,7 @@ class OpenStackConfig(object):
if 'cloud' in cloud:
del cloud['cloud']
return self._fix_backwards_madness(cloud)
return cloud
def _expand_vendor_profile(self, name, cloud, our_cloud):
# Expand a profile if it exists. 'cloud' is an old confusing name
@ -897,6 +897,8 @@ class OpenStackConfig(object):
if 'endpoint_type' in config:
config['interface'] = config.pop('endpoint_type')
config = self._fix_backwards_madness(config)
for key in BOOL_KEYS:
if key in config:
if type(config[key]) is not bool:

View File

@ -473,6 +473,16 @@ class TestConfigArgparse(base.TestCase):
opts, _remain = parser.parse_known_args(['--os-cloud', 'foo'])
self.assertEqual(opts.os_cloud, 'foo')
def test_env_argparse_precedence(self):
self.useFixture(fixtures.EnvironmentVariable(
'OS_TENANT_NAME', 'tenants-are-bad'))
c = config.OpenStackConfig(config_files=[self.cloud_yaml],
vendor_files=[self.vendor_yaml])
cc = c.get_one_cloud(
cloud='envvars', argparse=self.options)
self.assertEqual(cc.auth['project_name'], 'project')
def test_argparse_default_no_token(self):
c = config.OpenStackConfig(config_files=[self.cloud_yaml],
vendor_files=[self.vendor_yaml])