diff options
author | Tomoki Sekiyama <tomoki.sekiyama@gmail.com> | 2018-07-09 15:42:10 +0000 |
---|---|---|
committer | Tomoki Sekiyama <tomoki.sekiyama@gmail.com> | 2018-07-09 15:42:10 +0000 |
commit | d50ab63e138d58ef96b302fc1a1cf56923a26c76 (patch) | |
tree | 637c3da48390655dacff90ddb852e5b74787565e | |
parent | 92114fb679ba45af6517e4ea8961de48dbfb22a4 (diff) | |
download | glance_store-d50ab63e138d58ef96b302fc1a1cf56923a26c76.tar.gz |
specify region on creating cinderclient
If cinder_store_{user_name,password,project_name} are provided,
cinder client will be created without region information.
It may cause wrong region access on some multi-region setup.
This fixes the issue by always passing `cinder_os_region_name`
value to cinderclient.
Change-Id: I835b2f0da03f29245c26c9c531b04de737d8ef5b
Closes-Bug: #1764200
-rw-r--r-- | glance_store/_drivers/cinder.py | 1 | ||||
-rw-r--r-- | glance_store/tests/unit/test_cinder_store.py | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/glance_store/_drivers/cinder.py b/glance_store/_drivers/cinder.py index dab944d..604705c 100644 --- a/glance_store/_drivers/cinder.py +++ b/glance_store/_drivers/cinder.py @@ -352,6 +352,7 @@ def get_cinderclient(conf, context=None): password, project, auth_url=url, + region_name=glance_store.cinder_os_region_name, insecure=glance_store.cinder_api_insecure, retries=glance_store.cinder_http_retries, cacert=glance_store.cinder_ca_certificates_file) diff --git a/glance_store/tests/unit/test_cinder_store.py b/glance_store/tests/unit/test_cinder_store.py index 36a4db5..3747386 100644 --- a/glance_store/tests/unit/test_cinder_store.py +++ b/glance_store/tests/unit/test_cinder_store.py @@ -24,6 +24,7 @@ import tempfile import time import uuid +from cinderclient.v2 import client as cinderclient from os_brick.initiator import connector from oslo_concurrency import processutils from oslo_utils import units @@ -75,6 +76,17 @@ class TestCinderStore(base.StoreBaseTest, self.assertIsNone(cc.client.auth_token) self.assertEqual('test_address', cc.client.management_url) + def test_get_cinderclient_with_user_overriden_and_region(self): + self.config(cinder_os_region_name='test_region') + fake_client = FakeObject(client=FakeObject(auth_token=None)) + with mock.patch.object(cinderclient, 'Client', + return_value=fake_client) as mock_client: + self.test_get_cinderclient_with_user_overriden() + mock_client.assert_called_once_with( + 'test_user', 'test_password', 'test_project', + auth_url='test_address', cacert=None, insecure=False, + region_name='test_region', retries=3) + def test_temporary_chown(self): class fake_stat(object): st_uid = 1 |