summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2015-10-26 13:36:13 +0900
committerMonty Taylor <mordred@inaugust.com>2015-10-26 15:47:03 +0900
commitf39cb4b9330307eb363b2e1707f87c9d4d5e8539 (patch)
tree33c9a88b4e1a2013b970641af09390c2ae941b90
parent790fac98542ba303274180831cbd9a03604a84e8 (diff)
downloados-client-config-f39cb4b9330307eb363b2e1707f87c9d4d5e8539.tar.gz
Always pull regions from vendor profiles
Regions are special, since they're a driver for creating a cloud config object in the first place. We weren't syncing them from the vendor profile, so if the region wasn't set in the clouds.yaml, region name validation (and get_all_clouds) would fail. Change-Id: I5b8d6807a86b87a7f69f523f2fee2784389fab0a
-rw-r--r--os_client_config/config.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py
index 2e3644b..aa161e4 100644
--- a/os_client_config/config.py
+++ b/os_client_config/config.py
@@ -270,7 +270,17 @@ class OpenStackConfig(object):
" parameter in {0} instead.".format(self.config_filename))
return regions
else:
- return ['']
+ # crappit. we don't have a region defined.
+ new_cloud = dict()
+ our_cloud = self.cloud_config['clouds'].get(cloud, dict())
+ self._expand_vendor_profile(cloud, new_cloud, our_cloud)
+ if 'regions' in new_cloud and new_cloud['regions']:
+ return new_cloud['regions']
+ elif 'region_name' in new_cloud and new_cloud['region_name']:
+ return [new_cloud['region_name']]
+ else:
+ # Wow. We really tried
+ return ['']
def _get_region(self, cloud=None):
return self._get_regions(cloud)[0]
@@ -291,7 +301,18 @@ class OpenStackConfig(object):
# Get the defaults
cloud.update(self.defaults)
+ self._expand_vendor_profile(name, cloud, our_cloud)
+
+ if 'auth' not in cloud:
+ cloud['auth'] = dict()
+
+ _auth_update(cloud, our_cloud)
+ if 'cloud' in cloud:
+ del cloud['cloud']
+
+ return self._fix_backwards_madness(cloud)
+ def _expand_vendor_profile(self, name, cloud, our_cloud):
# Expand a profile if it exists. 'cloud' is an old confusing name
# for this.
profile_name = our_cloud.get('profile', our_cloud.get('cloud', None))
@@ -314,15 +335,6 @@ class OpenStackConfig(object):
" the cloud '{1}'".format(profile_name,
name))
- if 'auth' not in cloud:
- cloud['auth'] = dict()
-
- _auth_update(cloud, our_cloud)
- if 'cloud' in cloud:
- del cloud['cloud']
-
- return self._fix_backwards_madness(cloud)
-
def _fix_backwards_madness(self, cloud):
cloud = self._fix_backwards_project(cloud)
cloud = self._fix_backwards_auth_plugin(cloud)