diff options
-rw-r--r-- | os_client_config/cloud_config.py | 9 | ||||
-rw-r--r-- | os_client_config/config.py | 8 | ||||
-rw-r--r-- | os_client_config/defaults.yaml | 2 | ||||
-rw-r--r-- | os_client_config/tests/test_cloud_config.py | 10 | ||||
-rw-r--r-- | os_client_config/tests/test_config.py | 21 |
5 files changed, 40 insertions, 10 deletions
diff --git a/os_client_config/cloud_config.py b/os_client_config/cloud_config.py index 5ac0612..fd35aea 100644 --- a/os_client_config/cloud_config.py +++ b/os_client_config/cloud_config.py @@ -74,11 +74,12 @@ class CloudConfig(object): def get_auth_args(self): return self.config['auth'] - def get_endpoint_type(self, service_type=None): + def get_interface(self, service_type=None): + interface = self.config.get('interface') if not service_type: - return self.config['endpoint_type'] - key = '{service_type}_endpoint_type'.format(service_type=service_type) - return self.config.get(key, self.config['endpoint_type']) + return interface + key = '{service_type}_interface'.format(service_type=service_type) + return self.config.get(key, interface) def get_region_name(self, service_type=None): if not service_type: diff --git a/os_client_config/config.py b/os_client_config/config.py index 89503e7..25fbf64 100644 --- a/os_client_config/config.py +++ b/os_client_config/config.py @@ -278,6 +278,7 @@ class OpenStackConfig(object): def _fix_backwards_madness(self, cloud): cloud = self._fix_backwards_project(cloud) cloud = self._fix_backwards_auth_plugin(cloud) + cloud = self._fix_backwards_interface(cloud) return cloud def _fix_backwards_project(self, cloud): @@ -315,6 +316,13 @@ class OpenStackConfig(object): cloud[target_key] = target return cloud + def _fix_backwards_interface(self, cloud): + for key in cloud.keys(): + if key.endswith('endpoint_type'): + target_key = key.replace('endpoint_type', 'interface') + cloud[target_key] = cloud.pop(key) + return cloud + def get_all_clouds(self): clouds = [] diff --git a/os_client_config/defaults.yaml b/os_client_config/defaults.yaml index e4c9000..9130228 100644 --- a/os_client_config/defaults.yaml +++ b/os_client_config/defaults.yaml @@ -4,7 +4,7 @@ compute_api_version: '2' database_api_version: '1.0' disable_vendor_agent: {} dns_api_version: '2' -endpoint_type: public +interface: public floating_ip_source: neutron identity_api_version: '2' image_api_use_tasks: false diff --git a/os_client_config/tests/test_cloud_config.py b/os_client_config/tests/test_cloud_config.py index 2af568f..29cbba0 100644 --- a/os_client_config/tests/test_cloud_config.py +++ b/os_client_config/tests/test_cloud_config.py @@ -20,9 +20,9 @@ fake_config_dict = {'a': 1, 'os_b': 2, 'c': 3, 'os_c': 4} fake_services_dict = { 'compute_api_version': 2, 'compute_region_name': 'region-bl', - 'endpoint_type': 'public', + 'interface': 'public', 'image_service_type': 'mage', - 'identity_endpoint_type': 'admin', + 'identity_interface': 'admin', 'identity_service_name': 'locks', 'auth': {'password': 'hunter2', 'username': 'AzureDiamond'}, } @@ -125,9 +125,9 @@ class TestCloudConfig(base.TestCase): sorted(cc.get_services())) self.assertEqual({'password': 'hunter2', 'username': 'AzureDiamond'}, cc.get_auth_args()) - self.assertEqual('public', cc.get_endpoint_type()) - self.assertEqual('public', cc.get_endpoint_type('image')) - self.assertEqual('admin', cc.get_endpoint_type('identity')) + self.assertEqual('public', cc.get_interface()) + self.assertEqual('public', cc.get_interface('compute')) + self.assertEqual('admin', cc.get_interface('identity')) self.assertEqual('region-al', cc.get_region_name()) self.assertEqual('region-al', cc.get_region_name('image')) self.assertEqual('region-bl', cc.get_region_name('compute')) diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py index 1444ed5..6bb65fc 100644 --- a/os_client_config/tests/test_config.py +++ b/os_client_config/tests/test_config.py @@ -275,3 +275,24 @@ class TestConfigDefault(base.TestCase): vendor_files=[self.vendor_yaml]) cc = c.get_one_cloud(cloud='_test-cloud_', argparse=None) self.assertEqual('token', cc.auth_type) + + +class TestBackwardsCompatibility(base.TestCase): + + def test_set_no_default(self): + c = config.OpenStackConfig(config_files=[self.cloud_yaml], + vendor_files=[self.vendor_yaml]) + cloud = { + 'identity_endpoint_type': 'admin', + 'compute_endpoint_type': 'private', + 'endpoint_type': 'public', + 'auth_type': 'v3password', + } + result = c._fix_backwards_interface(cloud) + expected = { + 'identity_interface': 'admin', + 'compute_interface': 'private', + 'interface': 'public', + 'auth_type': 'v3password', + } + self.assertEqual(expected, result) |