Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixes LP Bug#861650 - Glance client deps
This patch addresses the dependency proliferation in the glance client stuff. It removes references to modules that contain non-client-necessary libraries (like eventlet, xattr, sqlalchemy-migrate and sqlalchemy) by restructuring the modules slightly. Note that the additional httplib2 dependency is because that is used in the authentication strategy stuff in glance.common.auth. This could be rewritten to use httplib instead, further reducing the dependencies of the client lib. IMPORTANT NOTE: This patch changes the default entrypoint for the Images API router application, and therefore this should be merged along with the packaging changes in this branch: https://code.launchpad.net/~jaypipes/glance/ubuntu/+merge/82318 Change-Id: I5dbc8584fb77e3e011fb6ff3532f792f5103e242
- Loading branch information
Showing
17 changed files
with
247 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# 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 | ||
|
||
import webob.exc | ||
|
||
from glance import registry | ||
from glance.common import exception | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class BaseController(object): | ||
def get_image_meta_or_404(self, request, image_id): | ||
""" | ||
Grabs the image metadata for an image with a supplied | ||
identifier or raises an HTTPNotFound (404) response | ||
:param request: The WSGI/Webob Request object | ||
:param image_id: The opaque image identifier | ||
:raises HTTPNotFound if image does not exist | ||
""" | ||
context = request.context | ||
try: | ||
return registry.get_image_metadata(context, image_id) | ||
except exception.NotFound: | ||
msg = _("Image with identifier %s not found") % image_id | ||
logger.debug(msg) | ||
raise webob.exc.HTTPNotFound( | ||
msg, request=request, content_type='text/plain') | ||
except exception.NotAuthorized: | ||
msg = _("Unauthorized image access") | ||
logger.debug(msg) | ||
raise webob.exc.HTTPForbidden(msg, request=request, | ||
content_type='text/plain') | ||
|
||
def get_active_image_meta_or_404(self, request, image_id): | ||
""" | ||
Same as get_image_meta_or_404 except that it will raise a 404 if the | ||
image isn't 'active'. | ||
""" | ||
image = self.get_image_meta_or_404(request, image_id) | ||
if image['status'] != 'active': | ||
msg = _("Image %s is not active") % image_id | ||
logger.debug(msg) | ||
raise webob.exc.HTTPNotFound( | ||
msg, request=request, content_type='text/plain') | ||
return image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# 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 | ||
|
||
import routes | ||
|
||
from glance.api.v1 import images | ||
from glance.api.v1 import members | ||
from glance.common import wsgi | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class API(wsgi.Router): | ||
|
||
"""WSGI router for Glance v1 API requests.""" | ||
|
||
def __init__(self, options): | ||
self.options = options | ||
mapper = routes.Mapper() | ||
|
||
images_resource = images.create_resource(options) | ||
|
||
mapper.resource("image", "images", controller=images_resource, | ||
collection={'detail': 'GET'}) | ||
mapper.connect("/", controller=images_resource, action="index") | ||
mapper.connect("/images/{id}", controller=images_resource, | ||
action="meta", conditions=dict(method=["HEAD"])) | ||
|
||
members_resource = members.create_resource(options) | ||
|
||
mapper.resource("member", "members", controller=members_resource, | ||
parent_resource=dict(member_name='image', | ||
collection_name='images')) | ||
mapper.connect("/shared-images/{id}", | ||
controller=members_resource, | ||
action="index_shared_images") | ||
mapper.connect("/images/{image_id}/members", | ||
controller=members_resource, | ||
action="update_all", | ||
conditions=dict(method=["PUT"])) | ||
|
||
super(API, self).__init__(mapper) | ||
|
||
|
||
def app_factory(global_conf, **local_conf): | ||
"""paste.deploy app factory for creating Glance API server apps""" | ||
conf = global_conf.copy() | ||
conf.update(local_conf) | ||
return API(conf) |
Oops, something went wrong.