Remove instances of _base_url

The variable _base_url was not really necessary since we are setting up
the endpoint_override variable which will eventually be used when making
a request through the keystoneclient's session.

This is a step in getting the client to use the keystoneclient's
API more wisely. A subsequent CR will remove the need for the
endpoint_override and make use of keystoneclient's endpoint_filters to
discover the Barbican endpoint.

Change-Id: Id589c76fb5fe481a3dd48ee1baa26f7d19d2d1a1
This commit is contained in:
Juan Antonio Osorio Robles 2015-05-19 21:41:17 +03:00
parent 988c1380ff
commit 4c4b8e8025
6 changed files with 12 additions and 16 deletions

View File

@ -52,8 +52,7 @@ class BaseEntityManager(object):
"""
Returns the total number of entities stored in Barbican.
"""
href = '{0}/{1}'.format(self._api._base_url, self._entity)
params = {'limit': 0, 'offset': 0}
resp = self._api.get(href, params=params)
resp = self._api.get(self._entity, params=params)
return resp['total']

View File

@ -47,8 +47,6 @@ class _HTTPClient(adapter.Adapter):
self.endpoint_override = '{0}/{1}'.format(endpoint,
_DEFAULT_API_VERSION)
self._base_url = self.endpoint_override
if project_id is None:
self._default_headers = dict()
else:

View File

@ -707,14 +707,13 @@ class ContainerManager(base.BaseEntityManager):
"""
LOG.debug('Listing containers - offset {0} limit {1} name {2} type {3}'
.format(offset, limit, name, type))
href = '{0}/{1}'.format(self._api._base_url, self._entity)
params = {'limit': limit, 'offset': offset}
if name:
params['name'] = name
if type:
params['type'] = type
response = self._api.get(href, params=params)
response = self._api.get(self._entity, params=params)
return [self._generate_typed_container(container)
for container in response.get('containers', [])]
@ -755,9 +754,8 @@ class ContainerManager(base.BaseEntityManager):
"""
LOG.debug('Deleting consumer registration for container '
'{0} as {1}: {2}'.format(container_ref, name, url))
href = '{0}/{1}/{2}/consumers'.format(self._api._base_url,
self._entity,
container_ref.split('/')[-1])
href = '{0}/{1}/consumers'.format(self._entity,
container_ref.split('/')[-1])
consumer_dict = {
'name': name,
'URL': url

View File

@ -41,7 +41,7 @@ class WhenTestingClientInit(TestClient):
c = client._HTTPClient(session=self.session,
endpoint=self.endpoint,
project_id=self.project_id)
self.assertEqual(c._base_url, 'http://localhost:9311/v1')
self.assertEqual(c.endpoint_override, 'http://localhost:9311/v1')
def test_default_headers_are_empty(self):
c = client._HTTPClient(session=self.session, endpoint=self.endpoint)
@ -63,17 +63,18 @@ class WhenTestingClientInit(TestClient):
self.assertRaises(ValueError, client.Client,
**{"endpoint": self.endpoint})
def test_base_url_starts_with_endpoint_url(self):
def test_endpoint_override_starts_with_endpoint_url(self):
c = client._HTTPClient(session=self.session,
endpoint=self.endpoint,
project_id=self.project_id)
self.assertTrue(c._base_url.startswith(self.endpoint))
self.assertTrue(c.endpoint_override.startswith(self.endpoint))
def test_base_url_ends_with_default_api_version(self):
def test_endpoint_override_ends_with_default_api_version(self):
c = client._HTTPClient(session=self.session,
endpoint=self.endpoint,
project_id=self.project_id)
self.assertTrue(c._base_url.endswith(client._DEFAULT_API_VERSION))
self.assertTrue(
c.endpoint_override.endswith(client._DEFAULT_API_VERSION))
class WhenTestingClientPost(TestClient):

View File

@ -23,7 +23,7 @@ class BaseBehaviors(object):
self.LOG = logging.getLogger(type(self).__name__)
self.client = client
self.created_entities = []
self.base_url = client.secrets._api._base_url
self.base_url = client.secrets._api.endpoint_override
def get_json(self, response):
json_data = dict()

View File

@ -186,7 +186,7 @@ class GenericContainersTestCase(BaseContainersTestCase):
This should return a 404.
"""
uuid = 'de305d54-75b4-431b-cccc-eb6b9e546013'
base_url = self.barbicanclient.secrets._api._base_url
base_url = self.behaviors.base_url
url = base_url + '/containers/' + uuid
e = self.assertRaises(