Core library requirements update
Rather than cap libraries at older versions, I'm updating the code to work with the newest libraries and methods. Now using KeystoneAuth and Keystone Middleware via a specific auth plugin and setting domain info. Also fixing a minor bug in "user_store.py" which cropped up due to issues when updating libraries. Change-Id: I3e9e2f4ff3b6a1be94857622f171425ce70de969
This commit is contained in:
parent
011fe06f15
commit
73e5018c9e
@ -1,12 +1,12 @@
|
||||
Django>=1.8.9,<1.9
|
||||
decorator>=3.4.0
|
||||
djangorestframework>=3.0.3
|
||||
keystonemiddleware>=1.3.1
|
||||
python-keystoneclient>=1.0.0
|
||||
python-neutronclient>=2.3.10
|
||||
jsonfield>=1.0.2
|
||||
django-rest-swagger>=0.3.3
|
||||
djangorestframework>=3.4.1
|
||||
keystoneauth1>=2.11.0
|
||||
keystonemiddleware>=4.7.0
|
||||
python-keystoneclient>=3.3.0
|
||||
python-neutronclient>=5.0.0
|
||||
jsonfield>=1.0.3
|
||||
django-rest-swagger>=2.0.3
|
||||
pyyaml>=3.11
|
||||
python-rtkit>=0.7.0
|
||||
mysqlclient>=1.3.7
|
||||
|
||||
|
@ -15,19 +15,25 @@
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from keystoneclient.v3 import client as client_v3
|
||||
from keystoneauth1.identity import v3
|
||||
from keystoneauth1 import session
|
||||
from keystoneclient import client as ks_client
|
||||
|
||||
from neutronclient.v2_0 import client as neutron_client
|
||||
|
||||
|
||||
def get_keystoneclient():
|
||||
auth = client_v3.Client(
|
||||
|
||||
auth = v3.Password(
|
||||
username=settings.KEYSTONE['username'],
|
||||
password=settings.KEYSTONE['password'],
|
||||
project_name=settings.KEYSTONE['project_name'],
|
||||
auth_url=settings.KEYSTONE['auth_url'],
|
||||
region_name=settings.DEFAULT_REGION
|
||||
user_domain_name="default",
|
||||
project_domain_name="default",
|
||||
)
|
||||
sess = session.Session(auth=auth)
|
||||
auth = ks_client.Client(session=sess)
|
||||
return auth
|
||||
|
||||
|
||||
|
@ -63,9 +63,11 @@ class IdentityManager(object):
|
||||
def list_users(self, project):
|
||||
"""
|
||||
Build a list of users for a given project using
|
||||
the v3 api. Less straightforward than the v2 api,
|
||||
but because we have the role data already, we add it
|
||||
to the user model so later roles fetching is not needed.
|
||||
the v3 api.
|
||||
|
||||
Rather than simply list users, we use the assignments
|
||||
endpoint so we can also fetch all the roles for those users
|
||||
in the given project. Saves further api calls later on.
|
||||
"""
|
||||
try:
|
||||
roles = self.ks_client.roles.list()
|
||||
@ -87,7 +89,7 @@ class IdentityManager(object):
|
||||
# Just means the assignment is a group, so ignore it.
|
||||
pass
|
||||
except ks_exceptions.NotFound:
|
||||
users = []
|
||||
return []
|
||||
return users.values()
|
||||
|
||||
def create_user(self, name, password, email, project_id):
|
||||
|
10
stacktask/api/docs.py
Normal file
10
stacktask/api/docs.py
Normal file
@ -0,0 +1,10 @@
|
||||
from rest_framework.decorators import api_view, renderer_classes
|
||||
from rest_framework import response, schemas
|
||||
from rest_framework_swagger.renderers import OpenAPIRenderer, SwaggerUIRenderer
|
||||
|
||||
|
||||
@api_view()
|
||||
@renderer_classes([OpenAPIRenderer, SwaggerUIRenderer])
|
||||
def docs_view(request):
|
||||
generator = schemas.SchemaGenerator(title='StackTask API')
|
||||
return response.Response(generator.get_schema(request=request))
|
@ -13,7 +13,13 @@
|
||||
# under the License.
|
||||
|
||||
from django.conf.urls import url, include
|
||||
from django.conf import settings
|
||||
|
||||
from stacktask.api import docs
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^v1/', include('stacktask.api.v1.urls')),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
urlpatterns.append(url(r'^docs/', docs.docs_view))
|
||||
|
@ -174,6 +174,7 @@ ROLES_MAPPING = {
|
||||
SHOW_ACTION_ENDPOINTS = True
|
||||
|
||||
conf_dict = {
|
||||
"DEBUG": True,
|
||||
"SECRET_KEY": SECRET_KEY,
|
||||
"ADDITIONAL_APPS": ADDITIONAL_APPS,
|
||||
"DATABASES": DATABASES,
|
||||
|
@ -13,11 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
from django.conf.urls import include, url
|
||||
from django.conf import settings
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^', include('stacktask.api.urls')),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
urlpatterns.append(url(r'^docs/', include('rest_framework_swagger.urls')))
|
||||
|
@ -36,13 +36,14 @@ application = get_wsgi_application()
|
||||
# the Keystone Auth Middleware.
|
||||
identity_url = urlparse(settings.KEYSTONE['auth_url'])
|
||||
conf = {
|
||||
'admin_user': settings.KEYSTONE['username'],
|
||||
'admin_password': settings.KEYSTONE['password'],
|
||||
'admin_tenant_name': settings.KEYSTONE['project_name'],
|
||||
'auth_host': identity_url.hostname,
|
||||
'auth_port': identity_url.port,
|
||||
'auth_protocol': identity_url.scheme,
|
||||
"auth_plugin": "password",
|
||||
'username': settings.KEYSTONE['username'],
|
||||
'password': settings.KEYSTONE['password'],
|
||||
'project_name': settings.KEYSTONE['project_name'],
|
||||
"project_domain_name": settings.KEYSTONE.get('domain_name', "default"),
|
||||
"user_domain_name": settings.KEYSTONE.get('domain_name', "default"),
|
||||
"auth_url": settings.KEYSTONE['auth_url'],
|
||||
'delay_auth_decision': True,
|
||||
'include_service_catalog': False
|
||||
'include_service_catalog': False,
|
||||
}
|
||||
application = AuthProtocol(application, conf)
|
||||
|
Loading…
x
Reference in New Issue
Block a user