diff --git a/config_tempest/main.py b/config_tempest/main.py index 80acdf93..81a932d9 100755 --- a/config_tempest/main.py +++ b/config_tempest/main.py @@ -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 diff --git a/config_tempest/tests/test_config_tempest.py b/config_tempest/tests/test_config_tempest.py index 1a152e66..d0ef044d 100644 --- a/config_tempest/tests/test_config_tempest.py +++ b/config_tempest/tests/test_config_tempest.py @@ -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):