diff --git a/ceilometer/energy/kwapi.py b/ceilometer/energy/kwapi.py index e664f3d11..549b0473a 100644 --- a/ceilometer/energy/kwapi.py +++ b/ceilometer/energy/kwapi.py @@ -15,6 +15,7 @@ # under the License. import datetime +from oslo.config import cfg from keystoneclient import exceptions import requests @@ -56,9 +57,9 @@ class _Base(plugin.CentralPollster): @staticmethod def get_kwapi_client(ksclient): """Returns a KwapiClient configured with the proper url and token.""" - endpoint = ksclient.service_catalog.url_for(service_type='energy', - endpoint_type='internalURL' - ) + endpoint = ksclient.service_catalog.url_for( + service_type='energy', + endpoint_type=cfg.CONF.service_credentials.os_endpoint_type) return KwapiClient(endpoint, ksclient.auth_token) CACHE_KEY_PROBE = 'kwapi.probes' diff --git a/ceilometer/image/glance.py b/ceilometer/image/glance.py index 19f47ef8c..4541b9616 100644 --- a/ceilometer/image/glance.py +++ b/ceilometer/image/glance.py @@ -22,6 +22,7 @@ from __future__ import absolute_import import itertools import glanceclient +from oslo.config import cfg from ceilometer import counter from ceilometer.openstack.common import timeutils @@ -34,7 +35,7 @@ class _Base(plugin.PollsterBase): def get_glance_client(ksclient): endpoint = ksclient.service_catalog.url_for( service_type='image', - endpoint_type='internalURL') + endpoint_type=cfg.CONF.service_credentials.os_endpoint_type) # hard-code v1 glance API version selection while v2 API matures return glanceclient.Client('1', endpoint, diff --git a/ceilometer/objectstore/swift.py b/ceilometer/objectstore/swift.py index 595044b39..9b2943b24 100644 --- a/ceilometer/objectstore/swift.py +++ b/ceilometer/objectstore/swift.py @@ -62,7 +62,7 @@ class _Base(plugin.PollsterBase): try: endpoint = ksclient.service_catalog.url_for( service_type='object-store', - endpoint_type='adminURL') + endpoint_type=cfg.CONF.service_credentials.os_endpoint_type) except exceptions.EndpointNotFound: LOG.debug(_("Swift endpoint not found")) raise StopIteration() @@ -75,14 +75,7 @@ class _Base(plugin.PollsterBase): def _neaten_url(endpoint, tenant_id): """Transform the registered url to standard and valid format. """ - - path = 'v1/' + cfg.CONF.reseller_prefix + tenant_id - - # remove the tail '/' of the endpoint. - if endpoint.endswith('/'): - endpoint = endpoint[:-1] - - return urljoin(endpoint, path) + return urljoin(endpoint, '/v1/' + cfg.CONF.reseller_prefix + tenant_id) class ObjectsPollster(_Base): diff --git a/tests/objectstore/test_swift.py b/tests/objectstore/test_swift.py index c8dd8c345..dee050d80 100644 --- a/tests/objectstore/test_swift.py +++ b/tests/objectstore/test_swift.py @@ -120,6 +120,9 @@ class TestSwiftPollster(base.TestCase): self.assertEqual(standard_url, swift._Base._neaten_url(test_endpoint + '/v1', test_tenant_id)) + self.assertEqual(standard_url, + swift._Base._neaten_url(standard_url, + test_tenant_id)) def test_metering(self): self.stubs.Set(self.factory, '_iter_accounts',