Merge "Use configured endpoint_type everywhere"

This commit is contained in:
Jenkins 2013-07-29 18:45:02 +00:00 committed by Gerrit Code Review
commit dbb8ca35fc
4 changed files with 11 additions and 13 deletions

View File

@ -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'

View File

@ -22,6 +22,7 @@ from __future__ import absolute_import
import itertools
import glanceclient
from oslo.config import cfg
from ceilometer import sample
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,

View File

@ -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):

View File

@ -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',