From a70c29134ef0c426d4a28d41940ee661601dceec Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Fri, 21 Sep 2018 11:26:57 -0500 Subject: [PATCH] Set endpoint_override from endpoint with noauth When noauth is used via the 'none' auth_type, the endpoint given actually wants to get passed to keystoneauth as an endpoint_override for that service, otherwise discovery from keystoneauth no worky. Change-Id: I005a6d9b195a6cceae855d1392a29f12d6782a55 --- openstack/config/cloud_region.py | 5 +++++ .../tests/unit/cloud/test_operator_noauth.py | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/openstack/config/cloud_region.py b/openstack/config/cloud_region.py index 6ef1369d8..24b9ab789 100644 --- a/openstack/config/cloud_region.py +++ b/openstack/config/cloud_region.py @@ -278,6 +278,11 @@ class CloudRegion(object): value = self._get_config('endpoint_override', service_type) if not value: value = self._get_config('endpoint', service_type) + if not value and self.config.get('auth_type') == 'none': + # If endpoint is given and we're using the none auth type, + # then the endpoint value is the endpoint_override for every + # service. + value = self.config.get('auth', {}).get('endpoint') return value def get_connect_retries(self, service_type): diff --git a/openstack/tests/unit/cloud/test_operator_noauth.py b/openstack/tests/unit/cloud/test_operator_noauth.py index f62c44488..7630c805c 100644 --- a/openstack/tests/unit/cloud/test_operator_noauth.py +++ b/openstack/tests/unit/cloud/test_operator_noauth.py @@ -64,6 +64,26 @@ class TestOpenStackCloudOperatorNoAuth(base.TestCase): self.assert_calls() + def test_ironic_noauth_auth_endpoint(self): + """Test noauth selection for Ironic in OpenStackCloud + + Sometimes people also write clouds.yaml files that look like this: + + :: + clouds: + bifrost: + auth_type: "none" + endpoint: https://bare-metal.example.com + """ + self.cloud_noauth = openstack.connect( + auth_type='none', + endpoint='https://bare-metal.example.com/v1', + ) + + self.cloud_noauth.list_machines() + + self.assert_calls() + def test_ironic_noauth_admin_token_auth_type(self): """Test noauth selection for Ironic in OpenStackCloud