diff options
-rw-r--r-- | .zuul.yaml | 6 | ||||
-rw-r--r-- | os_client_config/cloud_config.py | 8 | ||||
-rw-r--r-- | os_client_config/tests/test_cloud_config.py | 7 |
3 files changed, 12 insertions, 9 deletions
@@ -3,9 +3,3 @@ templates: - shade-functional-tips - shade-tox-tips - check: - jobs: - - osc-functional-devstack-tips - gate: - jobs: - - osc-functional-devstack-tips diff --git a/os_client_config/cloud_config.py b/os_client_config/cloud_config.py index d1a6983..0d82ebf 100644 --- a/os_client_config/cloud_config.py +++ b/os_client_config/cloud_config.py @@ -167,12 +167,14 @@ class CloudConfig(object): # What's even more amazing is that they did it AGAIN with cinder v3 # And then I learned that mistral copied it. if service_type == 'volume': - if self.get_api_version(service_type).startswith('2'): + vol_type = self.get_api_version(service_type) + if vol_type and vol_type.startswith('2'): service_type = 'volumev2' - elif self.get_api_version(service_type).startswith('3'): + elif vol_type and vol_type.startswith('3'): service_type = 'volumev3' elif service_type == 'workflow': - if self.get_api_version(service_type).startswith('2'): + wk_type = self.get_api_version(service_type) + if wk_type and wk_type.startswith('2'): service_type = 'workflowv2' return self.config.get(key, service_type) diff --git a/os_client_config/tests/test_cloud_config.py b/os_client_config/tests/test_cloud_config.py index 8135526..86a71e2 100644 --- a/os_client_config/tests/test_cloud_config.py +++ b/os_client_config/tests/test_cloud_config.py @@ -167,6 +167,13 @@ class TestCloudConfig(base.TestCase): cc.config['workflow_api_version'] = '2' self.assertEqual('workflowv2', cc.get_service_type('workflow')) + def test_no_override(self): + """Test no override happens when defaults are not configured""" + cc = cloud_config.CloudConfig("test1", "region-al", fake_services_dict) + self.assertEqual('volume', cc.get_service_type('volume')) + self.assertEqual('workflow', cc.get_service_type('workflow')) + self.assertEqual('not-exist', cc.get_service_type('not-exist')) + def test_get_session_no_auth(self): config_dict = defaults.get_defaults() config_dict.update(fake_services_dict) |