Adding extensions to the app, and shell extensions for users & schema
This commit is contained in:
parent
abeb2cad81
commit
853cf39b54
@ -47,4 +47,9 @@ Until this is fixed you need to mod nova after its gets downloaded via devstack
|
||||
+ from nova.auth import manager
|
||||
self.auth = auth.manager.AuthManager()
|
||||
super(AuthMiddleware, self).__init__(application)
|
||||
###### END PATCH
|
||||
###### END PATCH
|
||||
|
||||
THREE:
|
||||
|
||||
funkyness w/ the extensions. the extensions url itself wont load. Seems to have to do with authorization & tenants.
|
||||
* mitigated in reddwarf/common/extensions.py, see for more information
|
@ -61,11 +61,11 @@ use = call:reddwarf.common.wsgi:versioned_urlmap
|
||||
paste.app_factory = reddwarf.versions:app_factory
|
||||
|
||||
[pipeline:reddwarfapi]
|
||||
pipeline = tokenauth authorization reddwarfapp
|
||||
pipeline = tokenauth authorization extensions reddwarfapp
|
||||
#pipeline = debug extensions reddwarfapp
|
||||
|
||||
#[filter:extensions]
|
||||
#paste.filter_factory = reddwarf.common.extensions:factory
|
||||
[filter:extensions]
|
||||
paste.filter_factory = reddwarf.common.extensions:factory
|
||||
|
||||
[filter:tokenauth]
|
||||
paste.filter_factory = keystone.middleware.auth_token:filter_factory
|
||||
@ -78,7 +78,6 @@ auth_protocol = http
|
||||
auth_uri = http://127.0.0.1:5000/
|
||||
admin_token = be19c524ddc92109a224
|
||||
|
||||
|
||||
[filter:authorization]
|
||||
paste.filter_factory = reddwarf.common.auth:AuthorizationMiddleware.factory
|
||||
|
||||
|
76
reddwarf/common/extensions.py
Normal file
76
reddwarf/common/extensions.py
Normal file
@ -0,0 +1,76 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2011 OpenStack LLC.
|
||||
# Copyright 2011 Justin Santa Barbara
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from reddwarf.openstack.common import extensions
|
||||
|
||||
ExtensionsDescriptor = extensions.ExtensionDescriptor
|
||||
ResourceExtension = extensions.ResourceExtension
|
||||
|
||||
def factory(global_config, **local_config):
|
||||
"""Paste factory."""
|
||||
def _factory(app):
|
||||
extensions.DEFAULT_XMLNS = "http://docs.openstack.org/reddwarf"
|
||||
ext_mgr = TenantExtensionManager(
|
||||
global_config.get('api_extensions_path', ''))
|
||||
return extensions.ExtensionMiddleware(app, global_config, ext_mgr)
|
||||
return _factory
|
||||
|
||||
|
||||
# Not sure if this is the way we should do it.
|
||||
# Might need to make openstack common more extensible for tenants
|
||||
# or any random values in the routes methods (index, show, etc...)
|
||||
class TenantExtensionManager(extensions.ExtensionManager):
|
||||
|
||||
def __init__(self, path):
|
||||
super(TenantExtensionManager, self).__init__(path)
|
||||
|
||||
#TODO(hub-cap): fix openstack-common.extensions to work with tenant ids
|
||||
def get_resources(self):
|
||||
"""Returns a list of ResourceExtension objects."""
|
||||
resources = []
|
||||
extension_resource = TenantExtensionsResource(self)
|
||||
res_ext = extensions.ResourceExtension('{tenant_id}/extensions',
|
||||
extension_resource,
|
||||
serializer=extension_resource.serializer)
|
||||
resources.append(res_ext)
|
||||
for alias, ext in self.extensions.iteritems():
|
||||
try:
|
||||
resources.extend(ext.get_resources())
|
||||
except AttributeError:
|
||||
# NOTE(dprince): Extension aren't required to have resource
|
||||
# extensions
|
||||
pass
|
||||
return resources
|
||||
|
||||
|
||||
class TenantExtensionsResource(extensions.ExtensionsResource):
|
||||
|
||||
def __init__(self, extension_manager):
|
||||
super(TenantExtensionsResource, self).__init__(extension_manager)
|
||||
|
||||
def index(self, req, tenant_id):
|
||||
return super(TenantExtensionsResource, self).index(req)
|
||||
|
||||
def show(self, req, id, tenant_id):
|
||||
return super(TenantExtensionsResource, self).show(req, id)
|
||||
|
||||
def delete(self, req, id, tenant_id):
|
||||
return super(TenantExtensionsResource, self).delete(req, id)
|
||||
|
||||
def create(self, req, tenant_id):
|
||||
return super(TenantExtensionsResource, self).create(req)
|
86
reddwarf/extensions/mysql.py
Normal file
86
reddwarf/extensions/mysql.py
Normal file
@ -0,0 +1,86 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2011 OpenStack LLC.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
|
||||
from novaclient.v1_1.client import Client
|
||||
from reddwarf.common import config
|
||||
from reddwarf.common import extensions
|
||||
|
||||
LOG = logging.getLogger('reddwarf.extensions.mysql')
|
||||
|
||||
|
||||
class BaseController(object):
|
||||
"""Base controller class."""
|
||||
|
||||
def __init__(self):
|
||||
self.proxy_admin_user = config.Config.get('reddwarf_proxy_admin_user', 'admin')
|
||||
self.proxy_admin_pass = config.Config.get('reddwarf_proxy_admin_pass', '3de4922d8b6ac5a1aad9')
|
||||
self.proxy_admin_tenant_name = config.Config.get('reddwarf_proxy_admin_tenant_name', 'admin')
|
||||
self.auth_url = config.Config.get('reddwarf_auth_url', 'http://0.0.0.0:5000/v2.0')
|
||||
|
||||
|
||||
def get_client(self, req):
|
||||
proxy_token = req.headers["X-Auth-Token"]
|
||||
client = Client(self.proxy_admin_user, self.proxy_admin_pass,
|
||||
self.proxy_admin_tenant_name, self.auth_url, token=proxy_token)
|
||||
client.authenticate()
|
||||
return client
|
||||
|
||||
class UserController(BaseController):
|
||||
"""Controller for instance functionality"""
|
||||
|
||||
def index(self, req, tenant_id):
|
||||
"""Return all users."""
|
||||
return "User List"
|
||||
|
||||
|
||||
class SchemaController(BaseController):
|
||||
"""Controller for instance functionality"""
|
||||
|
||||
def index(self, req, tenant_id):
|
||||
"""Return all schemas."""
|
||||
return "Schema list"
|
||||
|
||||
|
||||
class Mysql(extensions.ExtensionsDescriptor):
|
||||
|
||||
def get_name(self):
|
||||
return "Mysql"
|
||||
|
||||
def get_description(self):
|
||||
return "Non essential MySQL services such as users and schemas"
|
||||
|
||||
def get_alias(self):
|
||||
return "MYSQL"
|
||||
|
||||
def get_namespace(self):
|
||||
return "http://TBD"
|
||||
|
||||
def get_updated(self):
|
||||
return "2011-01-22T13:25:27-06:00"
|
||||
|
||||
def get_resources(self):
|
||||
resources = []
|
||||
resource = extensions.ResourceExtension('{tenant_id}/schemas',
|
||||
SchemaController())
|
||||
resources.append(resource)
|
||||
resource = extensions.ResourceExtension('{tenant_id}/users',
|
||||
UserController())
|
||||
resources.append(resource)
|
||||
|
||||
return resources
|
Loading…
x
Reference in New Issue
Block a user