Keystone API endpoint discovery

Implements: blueprint Web ui should use keystone to discover api endpoint

Change-Id: I5caec5aff2f5d11d11a08c141e7536118d38bd65
This commit is contained in:
Memo Garcia 2015-07-02 13:58:43 +01:00
parent 5ba40fa4e0
commit a7470fd5dc
2 changed files with 47 additions and 11 deletions

View File

@ -21,18 +21,35 @@ To install the horizon web ui you need to do the following::
# /opt/stack/horizon/tools/with_venv.sh pip install parsedatetime
# In horizons local_settings.py add the variable FREEZER_API_URL and set it
to the url of the freezer api server. Example:
FREEZER_API_URL = 'http://127.0.0.1:9090'
# cd /opt/stack/horizon/
# ./run_tests.sh --runserver 0.0.0.0:8000
Now a new Tab is available in the dashboard lists on the left, called "Backup
Restore DR".
Now a new Tab is available in the dashboard lists on the left, called "Disaster Recovery".
API registration
================
keystone user-create --name freezer --pass <pass>
keystone user-role-add --user freezer --tenant service --role admin
keystone service-create --name Freezer \
--type "Disaster Recovery" \
--description "Disaster Recovery"
keystone endpoint-create \
--service-id <service-id> \
--publicurl <api-url> \
--internalurl <api-url> \
--adminurl <api-url> \
--region regionOne
If keystone service-create and endpoint-create are not available you can set as a fallback the following on::
# vim /opt/stack/horizon/openstack_dashboard/local/local_settings.py
# add FREEZER_API_URL = http://<api_url>:<port>
Running the unit tests
======================

View File

@ -16,7 +16,6 @@
from django.conf import settings
import warnings
import freezer.apiclient.client
from horizon.utils import functions as utils
@ -95,15 +94,35 @@ class ConfigClient(object):
self.last_backup = last_backup
@memoized
def get_service_url(request):
""" Get Freezer API url from keystone catalog.
if Freezer is not set in keystone, the fallback will be
'FREEZER_API_URL' in local_settings.py
"""
url = None
catalog = (getattr(request.user, "service_catalog", None))
if not catalog:
warnings.warn('Using hardcoded FREEZER_API_URL at {0}'
.format(settings.FREEZER_API_URL))
return getattr(settings, 'FREEZER_API_URL', None)
for c in catalog:
if c['name'] == 'Freezer':
for e in c['endpoints']:
url = e['publicURL']
return url
@memoized
def _freezerclient(request):
warnings.warn('Endpoint discovery not implemented yet. Using hard-coded: {'
'}'.format(settings.FREEZER_API_URL))
api_url = get_service_url(request)
return freezer.apiclient.client.Client(
token=request.user.token.id,
auth_url=getattr(settings, 'OPENSTACK_KEYSTONE_URL'),
endpoint=settings.FREEZER_API_URL)
endpoint=api_url)
def configuration_create(request, name=None, container_name=None,