summaryrefslogtreecommitdiffstats
path: root/keystone/controllers.py
diff options
context:
space:
mode:
authorDolph Mathews <dolph.mathews@gmail.com>2013-01-18 22:30:12 -0600
committerDolph Mathews <dolph.mathews@gmail.com>2013-01-18 22:35:17 -0600
commit8eaa3ce990cd489899c1e64cf948cfe6fe70f3a6 (patch)
tree5e2db8ce5efa19fca7e6907c412d342ad15bf61e /keystone/controllers.py
parent8748cfa3a6b7573550e7ec8ced87e6fd2096a628 (diff)
downloadkeystone-8eaa3ce990cd489899c1e64cf948cfe6fe70f3a6.tar.gz
keystone-8eaa3ce990cd489899c1e64cf948cfe6fe70f3a6.tar.xz
keystone-8eaa3ce990cd489899c1e64cf948cfe6fe70f3a6.zip
public_endpoint & admin_endpoint configuration
Today we can use these configuration values to avoid having to guess keystone's own endpoint URL from the service catalog backend, which may contain more than one identity endpoint. This is also the first step towards adding self-relational links to the v3 API. Change-Id: I375ac0d1f9581592e437c67c17bf32022f652f66
Diffstat (limited to 'keystone/controllers.py')
-rw-r--r--keystone/controllers.py32
1 files changed, 14 insertions, 18 deletions
diff --git a/keystone/controllers.py b/keystone/controllers.py
index a1275c18..3aaa8f59 100644
--- a/keystone/controllers.py
+++ b/keystone/controllers.py
@@ -14,11 +14,16 @@
# License for the specific language governing permissions and limitations
# under the License.
-from keystone import catalog
from keystone.common import wsgi
+from keystone.common import logging
+from keystone import config
from keystone import exception
+LOG = logging.getLogger(__name__)
+CONF = config.CONF
+
+
class Extensions(wsgi.Application):
"""Base extensions controller to be extended by public and admin API's."""
@@ -70,28 +75,19 @@ class PublicExtensions(Extensions):
class Version(wsgi.Application):
def __init__(self, version_type):
- self.catalog_api = catalog.Manager()
- self.url_key = '%sURL' % version_type
+ self.endpoint_url_type = version_type
super(Version, self).__init__()
- def _get_identity_url(self, context):
- catalog_ref = self.catalog_api.get_catalog(context=context,
- user_id=None,
- tenant_id=None)
- for region, region_ref in catalog_ref.iteritems():
- for service, service_ref in region_ref.iteritems():
- if service == 'identity':
- return service_ref[self.url_key]
-
- raise exception.NotImplemented()
+ def _get_identity_url(self, version='v2.0'):
+ """Returns a URL to keystone's own endpoint."""
+ url = CONF['%s_endpoint' % self.endpoint_url_type] % CONF
+ if url[-1] != '/':
+ url += '/'
+ return '%s%s/' % (url, version)
def _get_versions_list(self, context):
"""The list of versions is dependent on the context."""
- identity_url = self._get_identity_url(context)
- if not identity_url.endswith('/'):
- identity_url = identity_url + '/'
-
versions = {}
versions['v2.0'] = {
'id': 'v2.0',
@@ -100,7 +96,7 @@ class Version(wsgi.Application):
'links': [
{
'rel': 'self',
- 'href': identity_url,
+ 'href': self._get_identity_url(version='v2.0'),
}, {
'rel': 'describedby',
'type': 'text/html',