Merge "Add authentication to dashboard"
This commit is contained in:
@@ -17,13 +17,21 @@ The following should get you started::
|
||||
|
||||
$ git clone https://github.com/stackforge/python-mistralclient.git
|
||||
$ cd python-mistralclient/horizon_dashboard
|
||||
$ cp demo_dashboard/local/local_settings.py.example demo_dashboard/local/local_settings.py
|
||||
$ cp demo_dashboard/local/local_settings.py.example \
|
||||
demo_dashboard/local/local_settings.py
|
||||
|
||||
Edit the ``local_settings.py`` file as needed. Make sure you have changed
|
||||
OPENSTACK_HOST to point to your keystone server and also check all endpoints
|
||||
are accessible. You may want to change OPENSTACK_ENDPOINT_TYPE to "publicURL"
|
||||
if some of your endpoints are inaccessible.
|
||||
|
||||
You may also need to add a service and endpoints to keystone::
|
||||
|
||||
$ MISTRAL_URL="http://[host]:[port]/v1"
|
||||
$ keystone service-create --name mistral --type workflow
|
||||
$ keystone endpoint-create --service_id mistral --publicurl $MISTRAL_URL \
|
||||
--adminurl $MISTRAL_URL --internalurl $MISTRAL_URL
|
||||
|
||||
When you're ready to run the development server::
|
||||
|
||||
$ ./run_tests.sh --runserver
|
||||
|
@@ -1,5 +1,21 @@
|
||||
from django.conf import settings
|
||||
|
||||
from mistralclient.api import client as mistral_client
|
||||
|
||||
SERVICE_TYPE = 'workflow'
|
||||
|
||||
|
||||
def mistralclient(request):
|
||||
return mistral_client.Client()
|
||||
return mistral_client.Client(
|
||||
username=request.user.username,
|
||||
auth_token=request.user.token.id,
|
||||
project_id=request.user.tenant_id,
|
||||
# Ideally, we should get it from identity endpoint, but since
|
||||
# python-mistralclient is not supporting v2.0 API it might create
|
||||
# additional troubles for those who still rely on v2.0 stack-wise.
|
||||
auth_url=getattr(settings, 'OPENSTACK_KEYSTONE_URL'),
|
||||
# Todo: add SECONDARY_ENDPOINT_TYPE support
|
||||
endpoint_type=getattr(settings,
|
||||
'OPENSTACK_ENDPOINT_TYPE',
|
||||
'internalURL'),
|
||||
service_type=SERVICE_TYPE)
|
||||
|
@@ -96,11 +96,12 @@ class Client(object):
|
||||
project_id = keystone.project_id
|
||||
|
||||
if not mistral_url:
|
||||
catalog = keystone.service_catalog.get_endpoints(service_type)
|
||||
catalog = keystone.service_catalog.get_endpoints(
|
||||
service_type=service_type,
|
||||
endpoint_type=endpoint_type
|
||||
)
|
||||
if service_type in catalog:
|
||||
for e_type, endpoint in catalog.get[service_type][0].items():
|
||||
if str(e_type).lower() == str(endpoint_type).lower():
|
||||
mistral_url = endpoint
|
||||
break
|
||||
service = catalog.get(service_type)
|
||||
mistral_url = service[0].get('url') if service else None
|
||||
|
||||
return mistral_url, token, project_id, user_id
|
||||
|
Reference in New Issue
Block a user