Set region_name from os-client-config to set identity.region

We don't seem to set idenity.region which may not work in certain
scenarios.

Change-Id: Iebd24700420883a8993881cd8392bed8c772353e
This commit is contained in:
Rabi Mishra 2018-10-23 10:05:26 +05:30
parent aab99ff6dd
commit ef2bc15127
2 changed files with 16 additions and 3 deletions

View File

@ -392,6 +392,8 @@ def set_cloud_config_values(non_admin, cloud_creds, conf):
conf.set('auth', 'admin_password', cloud_creds['password'])
conf.set('identity', 'uri', cloud_creds['auth_url'])
if 'region_name' in cloud_creds:
conf.set('identity', 'region', cloud_creds['region_name'])
except cfg.NoSuchOptError:
LOG.warning(
'Could not load some identity options from cloud config file')
@ -415,6 +417,9 @@ def get_cloud_creds(args_namespace):
cloud = os_client_config.OpenStackConfig()
cloud = cloud.get_one_cloud(argparse=args_namespace)
cloud_creds = cloud.config.get('auth')
region_name = cloud.config.get('region_name')
if region_name:
cloud_creds['region_name'] = region_name
return cloud_creds

View File

@ -58,13 +58,15 @@ class TestOsClientConfigSupport(BaseConfigTempestTest):
'get_project_by_name')
self.useFixture(MonkeyPatch(func2mock, mock_function))
def _obtain_client_config_data(self, non_admin):
def _obtain_client_config_data(self, non_admin=True, region_name=None):
cloud_args = {
'username': 'cloud_user',
'password': 'cloud_pass',
'project_name': 'cloud_project',
'auth_url': 'http://auth.url.com/'
}
if region_name:
cloud_args.update(region_name=region_name)
# create an empty conf
conf = tempest_conf.TempestConf()
conf.set('identity', 'uri', cloud_args['auth_url'], priority=True)
@ -84,12 +86,18 @@ class TestOsClientConfigSupport(BaseConfigTempestTest):
conf.get('auth', 'admin_password'))
self.assertEqual(cloud_args['project_name'],
conf.get('auth', 'admin_project_name'))
if region_name:
self.assertEqual(cloud_args['region_name'],
conf.get('identity', 'region'))
def test_init_manager_client_config(self):
self._obtain_client_config_data(True)
self._obtain_client_config_data()
def test_init_manager_client_config_as_admin(self):
self._obtain_client_config_data(False)
self._obtain_client_config_data(non_admin=False)
def test_init_manager_client_config_region_name(self):
self._obtain_client_config_data(region_name='regionOne')
@mock.patch('os_client_config.cloud_config.CloudConfig')
def test_init_manager_client_config_get_default(self, mock_args):