summaryrefslogtreecommitdiff
path: root/os_client_config/config.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-08-03 14:44:03 +0000
committerGerrit Code Review <review@openstack.org>2016-08-03 14:44:03 +0000
commit9d4a1d81dc0fb3388d0c0de6fa8d0e4b4f6a7bb3 (patch)
tree5f63b13db86ec349bd7ef31cee6dd9df1079b151 /os_client_config/config.py
parentae864d49bea45a61e3ba7fafa4f509d937a3aac1 (diff)
parent891fa1c60fc948aac158ea939c5a10bd1cab04d9 (diff)
downloados-client-config-9d4a1d81dc0fb3388d0c0de6fa8d0e4b4f6a7bb3.tar.gz
Merge "Refactor fix magic in get_one_cloud()"
Diffstat (limited to 'os_client_config/config.py')
-rw-r--r--os_client_config/config.py71
1 files changed, 37 insertions, 34 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py
index f9b2de5..beea4c4 100644
--- a/os_client_config/config.py
+++ b/os_client_config/config.py
@@ -486,14 +486,6 @@ class OpenStackConfig(object):
" the cloud '{1}'".format(profile_name,
name))
- def _fix_backwards_madness(self, cloud):
- cloud = self._fix_backwards_auth_plugin(cloud)
- cloud = self._fix_backwards_project(cloud)
- cloud = self._fix_backwards_interface(cloud)
- cloud = self._fix_backwards_networks(cloud)
- cloud = self._handle_domain_id(cloud)
- return cloud
-
def _project_scoped(self, cloud):
return ('project_id' in cloud or 'project_name' in cloud
or 'project_id' in cloud['auth']
@@ -823,7 +815,7 @@ class OpenStackConfig(object):
def auth_config_hook(self, config):
"""Allow examination of config values before loading auth plugin
- OpenStackClient will override this to perform additional chacks
+ OpenStackClient will override this to perform additional checks
on auth_type.
"""
return config
@@ -922,6 +914,41 @@ class OpenStackConfig(object):
return config
+ def magic_fixes(self, config):
+ """Perform the set of magic argument fixups"""
+
+ # Infer token plugin if a token was given
+ if (('auth' in config and 'token' in config['auth']) or
+ ('auth_token' in config and config['auth_token']) or
+ ('token' in config and config['token'])):
+ config.setdefault('token', config.pop('auth_token', None))
+
+ # These backwards compat values are only set via argparse. If it's
+ # there, it's because it was passed in explicitly, and should win
+ config = self._fix_backwards_api_timeout(config)
+ if 'endpoint_type' in config:
+ config['interface'] = config.pop('endpoint_type')
+
+ config = self._fix_backwards_auth_plugin(config)
+ config = self._fix_backwards_project(config)
+ config = self._fix_backwards_interface(config)
+ config = self._fix_backwards_networks(config)
+ config = self._handle_domain_id(config)
+
+ for key in BOOL_KEYS:
+ if key in config:
+ if type(config[key]) is not bool:
+ config[key] = get_boolean(config[key])
+
+ # TODO(mordred): Special casing auth_url here. We should
+ # come back to this betterer later so that it's
+ # more generalized
+ if 'auth' in config and 'auth_url' in config['auth']:
+ config['auth']['auth_url'] = config['auth']['auth_url'].format(
+ **config)
+
+ return config
+
def get_one_cloud(self, cloud=None, validate=True,
argparse=None, **kwargs):
"""Retrieve a single cloud configuration and merge additional options
@@ -972,31 +999,7 @@ class OpenStackConfig(object):
else:
config[key] = val
- # Infer token plugin if a token was given
- if (('auth' in config and 'token' in config['auth']) or
- ('auth_token' in config and config['auth_token']) or
- ('token' in config and config['token'])):
- config.setdefault('token', config.pop('auth_token', None))
-
- # These backwards compat values are only set via argparse. If it's
- # there, it's because it was passed in explicitly, and should win
- config = self._fix_backwards_api_timeout(config)
- 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:
- config[key] = get_boolean(config[key])
-
- # TODO(mordred): Special casing auth_url here. We should
- # come back to this betterer later so that it's
- # more generalized
- if 'auth' in config and 'auth_url' in config['auth']:
- config['auth']['auth_url'] = config['auth']['auth_url'].format(
- **config)
+ config = self.magic_fixes(config)
# NOTE(dtroyer): OSC needs a hook into the auth args before the
# plugin is loaded in order to maintain backward-