Use configured endpoint_type everywhere
It seems there has been some usage forgotten in pollsters. Change-Id: I19c3b05377d484a7c50cd4534f26405ea67f1232
This commit is contained in:
parent
a4b1b54a48
commit
2c0dd5d079
@ -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'
|
||||
|
@ -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,
|
||||
|
@ -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):
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user