Backport connect_as fix from openstacksdk

The connect_as method tried overlaying things directly on top of the
'defaults' cloud config, but things get all messed up and it's actually
never what you want.

Instead, pull the existing CloudRegion from the local config object and
pass it in.

Change-Id: I54593bd8f6dd2124df854e923456c390e0d6a147
This commit is contained in:
Monty Taylor 2018-04-26 15:41:52 -04:00
parent 3c3132285f
commit 94c1ac842d
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
1 changed files with 7 additions and 6 deletions

View File

@ -321,10 +321,13 @@ class OpenStackCloud(
that do not want to be overridden can be ommitted.
"""
config = os_client_config.OpenStackConfig(
app_name=self.cloud_config._app_name,
app_version=self.cloud_config._app_version,
load_yaml_config=False)
if self.cloud_config._openstack_config:
config = self.cloud_config._openstack_config
else:
config = os_client_config.OpenStackConfig(
app_name=self.cloud_config._app_name,
app_version=self.cloud_config._app_version,
load_yaml_config=False)
params = copy.deepcopy(self.cloud_config.config)
# Remove profile from current cloud so that overridding works
params.pop('profile', None)
@ -362,9 +365,7 @@ class OpenStackCloud(
# Constructor, otherwise the new auth plugin doesn't get used.
return keystoneauth1.session.Session(session=self.keystone_session)
# Use cloud='defaults' so that we overlay settings properly
cloud_config = config.get_one_cloud(
cloud='defaults',
session_constructor=session_constructor,
**params)
# Override the cloud name so that logging/location work right