Don't create envvars cloud if cloud or region are set

OS_CLOUD and OS_REGION_NAME are both selectors. If they are the only
values, we should not be creating an envvars cloud.

Change-Id: I1b7c8d7e3b6c300bd2c85ab482a22411370e4d5f
This commit is contained in:
Monty Taylor 2016-09-15 16:41:17 -05:00
parent 7d401cd5a6
commit c6d2aeada4
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594

View File

@ -105,12 +105,11 @@ def _get_os_environ(envvar_prefix=None):
for k in environkeys:
newkey = k.split('_', 1)[-1].lower()
ret[newkey] = os.environ[k]
# If the only environ key is region name, don't make a cloud, because
# it's being used as a cloud selector
if not environkeys or (
len(environkeys) == 1 and 'region_name' in ret):
return None
return ret
# If the only environ keys are cloud and region_name, don't return anything
# because they are cloud selectors
if set(environkeys) - set(['OS_CLOUD', 'OS_REGION_NAME']):
return ret
return None
def _merge_clouds(old_dict, new_dict):