diff options
author | Monty Taylor <mordred@inaugust.com> | 2015-12-03 07:34:23 -0800 |
---|---|---|
committer | Monty Taylor <mordred@inaugust.com> | 2015-12-03 07:36:01 -0800 |
commit | eea460d5917a1536025d66ce3e2b3f9094d46e7c (patch) | |
tree | 171be401b2c9b6a28a2de46cf8d688ceeb17b804 | |
parent | 026a17c9eb9d8ebad8c56f8d1b7946bd4694519e (diff) | |
download | os-client-config-eea460d5917a1536025d66ce3e2b3f9094d46e7c.tar.gz |
Make sure that cloud always has a name
If we don't ask for a cloud, and we fall through to the envvars cloud or
the defaults cloud, the cloud that is returned winds up not being named
- even though we know what cloud it is. Set the name of the cloud we're
working with.
This is important for the next patch, where we need to peek at the
config to get some default values, but in a fallthrough case we do not
know which cloud to request.
Change-Id: Ie56e490d4384f2d680450bc956e4b7b5b8099f0e
-rw-r--r-- | os_client_config/config.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py index 19cfa35..ea3f6a1 100644 --- a/os_client_config/config.py +++ b/os_client_config/config.py @@ -177,6 +177,8 @@ class OpenStackConfig(object): envvars = _get_os_environ(envvar_prefix=envvar_prefix) if envvars: self.cloud_config['clouds'][self.envvar_key] = envvars + if not self.default_cloud: + self.default_cloud = self.envvar_key # Finally, fall through and make a cloud that starts with defaults # because we need somewhere to put arguments, and there are neither @@ -184,6 +186,7 @@ class OpenStackConfig(object): if not self.cloud_config['clouds']: self.cloud_config = dict( clouds=dict(defaults=dict(self.defaults))) + self.default_cloud = 'defaults' self._cache_expiration_time = 0 self._cache_path = CACHE_PATH @@ -604,14 +607,14 @@ class OpenStackConfig(object): on missing required auth parameters """ - if cloud is None and self.default_cloud: - cloud = self.default_cloud - - if cloud is None and self.envvar_key in self.get_cloud_names(): - cloud = self.envvar_key - args = self._fix_args(kwargs, argparse=argparse) + if cloud is None: + if 'cloud' in args: + cloud = args['cloud'] + else: + cloud = self.default_cloud + if 'region_name' not in args or args['region_name'] is None: args['region_name'] = self._get_region(cloud) |