summaryrefslogtreecommitdiff
path: root/os_client_config
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2015-11-15 11:34:41 -0500
committerMorgan Fainberg <morgan.fainberg@gmail.com>2015-11-24 18:28:26 -0500
commit0ea32e7dc011373c61e4d79d710a09e4ae404a9e (patch)
tree1d0e8fbdb1f33f689ca96631a0d77ac9f84cd093 /os_client_config
parent9c59002116e755d9ac7f14b11c3774c6848d4a3c (diff)
downloados-client-config-0ea32e7dc011373c61e4d79d710a09e4ae404a9e.tar.gz
Handle cinder v2
It turns out that cinder v2 has a service_type of volumev2 because nobody thought of the children. But that's ok - we actually care about user experience around here. SO - take the sane approach and return service_type = volumev2 if service_type == volume and volume_api_version == 2. This way user code can all safely say "please give me the endpoint for the volume service" and can use the api_version parameter to specify which version they want. We should all possess righteous indignation about this patch. Change-Id: I15fc5ddd92345d78b6928f11a8d77cecd0427f7d
Diffstat (limited to 'os_client_config')
-rw-r--r--os_client_config/cloud_config.py8
-rw-r--r--os_client_config/tests/test_cloud_config.py10
2 files changed, 17 insertions, 1 deletions
diff --git a/os_client_config/cloud_config.py b/os_client_config/cloud_config.py
index 3174f60..18ea4c1 100644
--- a/os_client_config/cloud_config.py
+++ b/os_client_config/cloud_config.py
@@ -113,6 +113,14 @@ class CloudConfig(object):
def get_service_type(self, service_type):
key = _make_key('service_type', service_type)
+ # Cinder did an evil thing where they defined a second service
+ # type in the catalog. Of course, that's insane, so let's hide this
+ # atrocity from the as-yet-unsullied eyes of our users.
+ # Of course, if the user requests a volumev2, that structure should
+ # still work.
+ if (service_type == 'volume' and
+ self.get_api_version(service_type).startswith('2')):
+ service_type = 'volumev2'
return self.config.get(key, service_type)
def get_service_name(self, service_type):
diff --git a/os_client_config/tests/test_cloud_config.py b/os_client_config/tests/test_cloud_config.py
index 45d262f..9e683d1 100644
--- a/os_client_config/tests/test_cloud_config.py
+++ b/os_client_config/tests/test_cloud_config.py
@@ -31,6 +31,7 @@ fake_services_dict = {
'image_service_type': 'mage',
'identity_interface': 'admin',
'identity_service_name': 'locks',
+ 'volume_api_version': '1',
'auth': {'password': 'hunter2', 'username': 'AzureDiamond'},
}
@@ -128,7 +129,7 @@ class TestCloudConfig(base.TestCase):
def test_getters(self):
cc = cloud_config.CloudConfig("test1", "region-al", fake_services_dict)
- self.assertEqual(['compute', 'identity', 'image'],
+ self.assertEqual(['compute', 'identity', 'image', 'volume'],
sorted(cc.get_services()))
self.assertEqual({'password': 'hunter2', 'username': 'AzureDiamond'},
cc.get_auth_args())
@@ -142,6 +143,8 @@ class TestCloudConfig(base.TestCase):
self.assertEqual('2', cc.get_api_version('compute'))
self.assertEqual('mage', cc.get_service_type('image'))
self.assertEqual('compute', cc.get_service_type('compute'))
+ self.assertEqual('1', cc.get_api_version('volume'))
+ self.assertEqual('volume', cc.get_service_type('volume'))
self.assertEqual('http://compute.example.com',
cc.get_endpoint('compute'))
self.assertEqual(None,
@@ -149,6 +152,11 @@ class TestCloudConfig(base.TestCase):
self.assertEqual(None, cc.get_service_name('compute'))
self.assertEqual('locks', cc.get_service_name('identity'))
+ def test_volume_override(self):
+ cc = cloud_config.CloudConfig("test1", "region-al", fake_services_dict)
+ cc.config['volume_api_version'] = '2'
+ self.assertEqual('volumev2', cc.get_service_type('volume'))
+
def test_get_session_no_auth(self):
config_dict = defaults.get_defaults()
config_dict.update(fake_services_dict)