hacking: upgrade to 0.9.x serie

Change-Id: I252758fd633662de9659a402c5e3d7e3ce1fae0f
This commit is contained in:
Julien Danjou 2014-06-12 15:36:21 +02:00
parent 353ae24d34
commit fadbef8511
107 changed files with 571 additions and 672 deletions

View File

@ -787,8 +787,8 @@ class MetadefPropertyFactoryProxy(glance.domain.proxy.MetadefPropertyFactory):
"owned by '%s'") "owned by '%s'")
raise exception.Forbidden(message % (owner)) raise exception.Forbidden(message % (owner))
return super(MetadefPropertyFactoryProxy, self).\ return super(MetadefPropertyFactoryProxy, self).new_namespace_property(
new_namespace_property(**kwargs) **kwargs)
class MetadefPropertyRepoProxy(glance.domain.proxy.MetadefPropertyRepo): class MetadefPropertyRepoProxy(glance.domain.proxy.MetadefPropertyRepo):

View File

@ -93,9 +93,11 @@ def image_send_notification(bytes_written, expected_size, image_meta, request,
def get_remaining_quota(context, db_api, image_id=None): def get_remaining_quota(context, db_api, image_id=None):
""" """Method called to see if the user is allowed to store an image.
This method is called to see if the user is allowed to store an image
of the given size in glance based on their quota and current usage. Checks if it is allowed based on the given size in glance based on their
quota and current usage.
:param context: :param context:
:param db_api: The db_api in use for this configuration :param db_api: The db_api in use for this configuration
:param image_id: The image that will be replaced with this new data size :param image_id: The image that will be replaced with this new data size
@ -135,9 +137,11 @@ def get_remaining_quota(context, db_api, image_id=None):
def check_quota(context, image_size, db_api, image_id=None): def check_quota(context, image_size, db_api, image_id=None):
""" """Method called to see if the user is allowed to store an image.
This method is called to see if the user is allowed to store an image
of the given size in glance based on their quota and current usage. Checks if it is allowed based on the given size in glance based on their
quota and current usage.
:param context: :param context:
:param image_size: The size of the image we hope to store :param image_size: The size of the image we hope to store
:param db_api: The db_api in use for this configuration :param db_api: The db_api in use for this configuration

View File

@ -39,8 +39,8 @@ class ProtectedImageFactoryProxy(glance.domain.proxy.ImageFactory):
extra_properties[key] = extra_props[key] extra_properties[key] = extra_props[key]
else: else:
raise exception.ReservedProperty(property=key) raise exception.ReservedProperty(property=key)
return super(ProtectedImageFactoryProxy, self).\ return super(ProtectedImageFactoryProxy, self).new_image(
new_image(extra_properties=extra_properties, **kwargs) extra_properties=extra_properties, **kwargs)
class ProtectedImageRepoProxy(glance.domain.proxy.Repo): class ProtectedImageRepoProxy(glance.domain.proxy.Repo):

View File

@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import webob.exc
import glance_store as store import glance_store as store
import webob.exc
from glance.common import exception from glance.common import exception
import glance.openstack.common.log as logging import glance.openstack.common.log as logging

View File

@ -268,8 +268,8 @@ class Controller(controller.BaseController):
key, 'read', req.context) is False): key, 'read', req.context) is False):
# NOTE(bourke): if read protected, re-add to image_meta to # NOTE(bourke): if read protected, re-add to image_meta to
# prevent deletion # prevent deletion
image_meta['properties'][key] = \ image_meta['properties'][key] = orig_meta[
orig_meta['properties'][key] 'properties'][key]
elif (self.prop_enforcer.check_property_rules( elif (self.prop_enforcer.check_property_rules(
key, 'delete', req.context) is False): key, 'delete', req.context) is False):
msg = "Property '%s' is protected" % key msg = "Property '%s' is protected" % key
@ -1073,7 +1073,7 @@ class Controller(controller.BaseController):
content_type="text/plain") content_type="text/plain")
except exception.InUseByStore as e: except exception.InUseByStore as e:
msg = (_LI("Image %s could not be deleted because it is in use: " msg = (_LI("Image %s could not be deleted because it is in use: "
"%s") % (id, utils.exception_to_str(e))) "%s") % (id, utils.exception_to_str(e))) # noqa
for line in msg.split('\n'): for line in msg.split('\n'):
LOG.info(line) LOG.info(line)
raise HTTPConflict(explanation=msg, raise HTTPConflict(explanation=msg,

View File

@ -12,12 +12,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import glance_store as store_api
from oslo.config import cfg from oslo.config import cfg
import webob.exc import webob.exc
import glance_store as store_api
from glance.common import exception from glance.common import exception
from glance.common import store_utils from glance.common import store_utils
from glance.common import utils from glance.common import utils

View File

@ -12,10 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import webob.exc
import glance_store import glance_store
import webob.exc
import glance.api.policy import glance.api.policy
from glance.common import exception from glance.common import exception
@ -95,8 +93,8 @@ class ImageDataController(object):
LOG.debug("Cannot save data for image %(id)s: %(e)s", LOG.debug("Cannot save data for image %(id)s: %(e)s",
{'id': image_id, 'e': utils.exception_to_str(e)}) {'id': image_id, 'e': utils.exception_to_str(e)})
self._restore(image_repo, image) self._restore(image_repo, image)
raise webob.exc.HTTPBadRequest(explanation= raise webob.exc.HTTPBadRequest(
utils.exception_to_str(e)) explanation=utils.exception_to_str(e))
except exception.InvalidImageStatusTransition as e: except exception.InvalidImageStatusTransition as e:
msg = utils.exception_to_str(e) msg = utils.exception_to_str(e)

View File

@ -14,10 +14,10 @@
# under the License. # under the License.
import copy import copy
import six
import webob
import glance_store import glance_store
import six
import webob
from glance.api import policy from glance.api import policy
from glance.common import exception from glance.common import exception
@ -58,8 +58,8 @@ class ImageMembersController(object):
""" """
image_repo = self.gateway.get_repo(req.context) image_repo = self.gateway.get_repo(req.context)
image_member_factory = self.gateway\ image_member_factory = self.gateway.get_image_member_factory(
.get_image_member_factory(req.context) req.context)
try: try:
image = image_repo.get(image_id) image = image_repo.get(image_id)
member_repo = image.get_member_repo() member_repo = image.get_member_repo()
@ -106,8 +106,8 @@ class ImageMembersController(object):
except exception.Forbidden as e: except exception.Forbidden as e:
raise webob.exc.HTTPForbidden(explanation=e.msg) raise webob.exc.HTTPForbidden(explanation=e.msg)
except ValueError as e: except ValueError as e:
raise webob.exc.HTTPBadRequest(explanation= raise webob.exc.HTTPBadRequest(
utils.exception_to_str(e)) explanation=utils.exception_to_str(e))
def index(self, req, image_id): def index(self, req, image_id):
""" """

View File

@ -12,10 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import webob.exc
import glance_store import glance_store
import webob.exc
from glance.api import policy from glance.api import policy
from glance.common import exception from glance.common import exception

View File

@ -211,7 +211,7 @@ class ImagesController(object):
raise webob.exc.HTTPNotFound(explanation=msg) raise webob.exc.HTTPNotFound(explanation=msg)
except exception.InUseByStore as e: except exception.InUseByStore as e:
msg = (_LI("Image %s could not be deleted " msg = (_LI("Image %s could not be deleted "
"because it is in use: %s") % (image_id, e.msg)) "because it is in use: %s") % (image_id, e.msg)) # noqa
LOG.info(msg) LOG.info(msg)
raise webob.exc.HTTPConflict(explanation=msg) raise webob.exc.HTTPConflict(explanation=msg)
@ -246,8 +246,8 @@ class ImagesController(object):
except (exception.BadStoreUri, exception.DuplicateLocation) as bse: except (exception.BadStoreUri, exception.DuplicateLocation) as bse:
raise webob.exc.HTTPBadRequest(explanation=bse.msg) raise webob.exc.HTTPBadRequest(explanation=bse.msg)
except ValueError as ve: # update image status failed. except ValueError as ve: # update image status failed.
raise webob.exc.HTTPBadRequest(explanation= raise webob.exc.HTTPBadRequest(
utils.exception_to_str(ve)) explanation=utils.exception_to_str(ve))
def _do_add_locations(self, image, path_pos, value): def _do_add_locations(self, image, path_pos, value):
pos = self._get_locations_op_pos(path_pos, pos = self._get_locations_op_pos(path_pos,
@ -262,8 +262,8 @@ class ImagesController(object):
except (exception.BadStoreUri, exception.DuplicateLocation) as bse: except (exception.BadStoreUri, exception.DuplicateLocation) as bse:
raise webob.exc.HTTPBadRequest(explanation=bse.msg) raise webob.exc.HTTPBadRequest(explanation=bse.msg)
except ValueError as ve: # update image status failed. except ValueError as ve: # update image status failed.
raise webob.exc.HTTPBadRequest(explanation= raise webob.exc.HTTPBadRequest(
utils.exception_to_str(ve)) explanation=utils.exception_to_str(ve))
def _do_remove_locations(self, image, path_pos): def _do_remove_locations(self, image, path_pos):
pos = self._get_locations_op_pos(path_pos, pos = self._get_locations_op_pos(path_pos,
@ -276,8 +276,8 @@ class ImagesController(object):
# from the backend store. # from the backend store.
image.locations.pop(pos) image.locations.pop(pos)
except Exception as e: except Exception as e:
raise webob.exc.HTTPInternalServerError(explanation= raise webob.exc.HTTPInternalServerError(
utils.exception_to_str(e)) explanation=utils.exception_to_str(e))
if (len(image.locations) == 0) and (image.status == 'active'): if (len(image.locations) == 0) and (image.status == 'active'):
image.status = 'queued' image.status = 'queued'
@ -312,8 +312,8 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
for key in cls._disallowed_properties: for key in cls._disallowed_properties:
if key in image: if key in image:
msg = _("Attribute '%s' is read-only.") % key msg = _("Attribute '%s' is read-only.") % key
raise webob.exc.HTTPForbidden(explanation= raise webob.exc.HTTPForbidden(
utils.exception_to_str(msg)) explanation=utils.exception_to_str(msg))
def create(self, request): def create(self, request):
body = self._get_request_body(request) body = self._get_request_body(request)

View File

@ -15,12 +15,12 @@
# under the License. # under the License.
import copy import copy
import webob.exc
import glance_store import glance_store
from oslo.config import cfg from oslo.config import cfg
import six import six
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
import webob.exc
from glance.api import policy from glance.api import policy
from glance.common import exception from glance.common import exception
@ -228,8 +228,8 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
def __init__(self, task_schema=None, partial_task_schema=None): def __init__(self, task_schema=None, partial_task_schema=None):
super(ResponseSerializer, self).__init__() super(ResponseSerializer, self).__init__()
self.task_schema = task_schema or get_task_schema() self.task_schema = task_schema or get_task_schema()
self.partial_task_schema = partial_task_schema \ self.partial_task_schema = (partial_task_schema
or _get_partial_task_schema() or _get_partial_task_schema())
def _inject_location_header(self, response, task): def _inject_location_header(self, response, task):
location = self._get_task_location(task) location = self._get_task_location(task)

View File

@ -21,10 +21,11 @@
Glance API Server Glance API Server
""" """
import eventlet
import os import os
import sys import sys
import eventlet
from glance.common import utils from glance.common import utils
# Monkey patch socket, time, select, threads # Monkey patch socket, time, select, threads

View File

@ -65,8 +65,8 @@ And command is one of:
{1} {1}
And CONFPATH is the optional configuration file to use.""".\ And CONFPATH is the optional configuration file to use.""".format(
format(', '.join(ALL_SERVERS), ', '.join(ALL_COMMANDS)) ', '.join(ALL_SERVERS), ', '.join(ALL_COMMANDS))
exitcode = 0 exitcode = 0

View File

@ -21,10 +21,11 @@
Reference implementation server for Glance Registry Reference implementation server for Glance Registry
""" """
import eventlet
import os import os
import sys import sys
import eventlet
# Monkey patch socket and time # Monkey patch socket and time
eventlet.patcher.monkey_patch(all=False, socket=True, time=True, thread=True) eventlet.patcher.monkey_patch(all=False, socket=True, time=True, thread=True)

View File

@ -444,7 +444,7 @@ def replication_load(options, args):
updated.append(meta['id']) updated.append(meta['id'])
except ImageAlreadyPresentException: except ImageAlreadyPresentException:
LOG.error(_LE(IMAGE_ALREADY_PRESENT_MESSAGE) LOG.error(_LE(IMAGE_ALREADY_PRESENT_MESSAGE)
% image_uuid) % image_uuid) # noqa
return updated return updated
@ -515,7 +515,7 @@ def replication_livecopy(options, args):
_check_upload_response_headers(headers, body) _check_upload_response_headers(headers, body)
updated.append(image['id']) updated.append(image['id'])
except ImageAlreadyPresentException: except ImageAlreadyPresentException:
LOG.error(_LE(IMAGE_ALREADY_PRESENT_MESSAGE) % image['id']) LOG.error(_LE(IMAGE_ALREADY_PRESENT_MESSAGE) % image['id']) # noqa
return updated return updated
@ -736,10 +736,10 @@ def main():
try: try:
command(options, args) command(options, args)
except TypeError as e: except TypeError as e:
LOG.error(_LE(command.__doc__) % {'prog': command.__name__}) LOG.error(_LE(command.__doc__) % {'prog': command.__name__}) # noqa
sys.exit("ERROR: %s" % e) sys.exit("ERROR: %s" % e)
except ValueError as e: except ValueError as e:
LOG.error(_LE(command.__doc__) % {'prog': command.__name__}) LOG.error(_LE(command.__doc__) % {'prog': command.__name__}) # noqa
sys.exit("ERROR: %s" % e) sys.exit("ERROR: %s" % e)

View File

@ -29,7 +29,6 @@ Keystone (an identity management system).
http://service_endpoint/ http://service_endpoint/
""" """
import httplib2 import httplib2
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
from glance.common import exception from glance.common import exception

View File

@ -70,10 +70,10 @@ def _execute(t_id, task_repo, image_repo, image_factory):
# necessary # necessary
err_msg = ("Error: " + six.text_type(type(e)) + ': ' + err_msg = ("Error: " + six.text_type(type(e)) + ': ' +
common_utils.exception_to_str(e)) common_utils.exception_to_str(e))
log_msg = _LE(err_msg + ("Task ID %s" % task.task_id)) log_msg = _LE(err_msg + ("Task ID %s" % task.task_id)) # noqa
LOG.exception(log_msg) LOG.exception(log_msg)
task.fail(_LE(err_msg)) task.fail(_LE(err_msg)) # noqa
finally: finally:
task_repo.save(task) task_repo.save(task)

View File

@ -67,8 +67,8 @@ class SwiftParams(object):
def _form_default_params(self): def _form_default_params(self):
default = {} default = {}
if CONF.swift_store_user and CONF.swift_store_key \ if (CONF.swift_store_user and CONF.swift_store_key
and CONF.swift_store_auth_address: and CONF.swift_store_auth_address):
default['user'] = CONF.swift_store_user default['user'] = CONF.swift_store_user
default['key'] = CONF.swift_store_key default['key'] = CONF.swift_store_key
default['auth_address'] = CONF.swift_store_auth_address default['auth_address'] = CONF.swift_store_auth_address

View File

@ -38,9 +38,8 @@ import uuid
import netaddr import netaddr
from OpenSSL import crypto from OpenSSL import crypto
from oslo.config import cfg from oslo.config import cfg
from webob import exc
import six import six
from webob import exc
from glance.common import exception from glance.common import exception
from glance.openstack.common import excutils from glance.openstack.common import excutils

View File

@ -433,7 +433,7 @@ class Debug(Middleware):
sys.stdout.write(part) sys.stdout.write(part)
sys.stdout.flush() sys.stdout.flush()
yield part yield part
print print()
class APIMapper(routes.Mapper): class APIMapper(routes.Mapper):

View File

@ -20,9 +20,11 @@ from glance.openstack.common import local
class RequestContext(object): class RequestContext(object):
""" """Stores information about the security context.
Stores information about the security context under which the user
accesses the system, as well as additional request information. Stores how the user accesses the system, as well as additional request
information.
""" """
user_idt_format = '{user} {tenant} {domain} {user_domain} {p_domain}' user_idt_format = '{user} {tenant} {domain} {user_domain} {p_domain}'
@ -47,8 +49,7 @@ class RequestContext(object):
self.user_domain = user_domain self.user_domain = user_domain
self.project_domain = project_domain self.project_domain = project_domain
if not self.is_admin: if not self.is_admin:
self.is_admin = \ self.is_admin = self.policy_enforcer.check_is_admin(self)
self.policy_enforcer.check_is_admin(self)
if not hasattr(local.store, 'context'): if not hasattr(local.store, 'context'):
self.update_store() self.update_store()

View File

@ -34,11 +34,6 @@ import sqlalchemy.orm as sa_orm
import sqlalchemy.sql as sa_sql import sqlalchemy.sql as sa_sql
from glance.common import exception from glance.common import exception
from glance.db.sqlalchemy import models
from glance import i18n
import glance.openstack.common.log as os_logging
from glance.openstack.common import timeutils
from glance.db.sqlalchemy.metadef_api import namespace as metadef_namespace_api from glance.db.sqlalchemy.metadef_api import namespace as metadef_namespace_api
from glance.db.sqlalchemy.metadef_api import object as metadef_object_api from glance.db.sqlalchemy.metadef_api import object as metadef_object_api
from glance.db.sqlalchemy.metadef_api import property as metadef_property_api from glance.db.sqlalchemy.metadef_api import property as metadef_property_api
@ -46,6 +41,10 @@ from glance.db.sqlalchemy.metadef_api\
import resource_type as metadef_resource_type_api import resource_type as metadef_resource_type_api
from glance.db.sqlalchemy.metadef_api\ from glance.db.sqlalchemy.metadef_api\
import resource_type_association as metadef_association_api import resource_type_association as metadef_association_api
from glance.db.sqlalchemy import models
from glance import i18n
import glance.openstack.common.log as os_logging
from glance.openstack.common import timeutils
BASE = models.BASE BASE = models.BASE
sa_logger = None sa_logger = None
@ -201,8 +200,8 @@ def _check_image_id(image_id):
:param image_id: The id of the image we want to check :param image_id: The id of the image we want to check
:return: Raise NoFound exception if given image id is invalid :return: Raise NoFound exception if given image id is invalid
""" """
if image_id and \ if (image_id and
len(image_id) > models.Image.id.property.columns[0].type.length: len(image_id) > models.Image.id.property.columns[0].type.length):
raise exception.NotFound() raise exception.NotFound()
@ -212,10 +211,10 @@ def _image_get(context, image_id, session=None, force_show_deleted=False):
session = session or get_session() session = session or get_session()
try: try:
query = session.query(models.Image)\ query = session.query(models.Image).options(
.options(sa_orm.joinedload(models.Image.properties))\ sa_orm.joinedload(models.Image.properties)).options(
.options(sa_orm.joinedload(models.Image.locations))\ sa_orm.joinedload(
.filter_by(id=image_id) models.Image.locations)).filter_by(id=image_id)
# filter out deleted images if context disallows it # filter out deleted images if context disallows it
if not force_show_deleted and not _can_show_deleted(context): if not force_show_deleted and not _can_show_deleted(context):
@ -396,7 +395,8 @@ def _paginate_query(query, model, limit, sort_keys, marker=None,
def _make_conditions_from_filters(filters, is_public=None): def _make_conditions_from_filters(filters, is_public=None):
#NOTE(venkatesh) make copy of the filters are to be altered in this method. # NOTE(venkatesh) make copy of the filters are to be altered in this
# method.
filters = filters.copy() filters = filters.copy()
image_conditions = [] image_conditions = []
@ -485,9 +485,8 @@ def _select_images_query(context, image_conditions, admin_as_user,
regular_user = (not context.is_admin) or admin_as_user regular_user = (not context.is_admin) or admin_as_user
query_member = session.query(models.Image) \ query_member = session.query(models.Image).join(
.join(models.Image.members) \ models.Image.members).filter(img_conditional_clause)
.filter(img_conditional_clause)
if regular_user: if regular_user:
member_filters = [models.ImageMember.deleted == False] member_filters = [models.ImageMember.deleted == False]
if context.owner is not None: if context.owner is not None:
@ -502,15 +501,14 @@ def _select_images_query(context, image_conditions, admin_as_user,
if visibility is not None and visibility == 'shared': if visibility is not None and visibility == 'shared':
return query_member return query_member
query_image = session.query(models.Image)\ query_image = session.query(models.Image).filter(img_conditional_clause)
.filter(img_conditional_clause)
if regular_user: if regular_user:
query_image = query_image.filter(models.Image.is_public == True) query_image = query_image.filter(models.Image.is_public == True)
query_image_owner = None query_image_owner = None
if context.owner is not None: if context.owner is not None:
query_image_owner = session.query(models.Image) \ query_image_owner = session.query(models.Image).filter(
.filter(models.Image.owner == context.owner) \ models.Image.owner == context.owner).filter(
.filter(img_conditional_clause) img_conditional_clause)
if query_image_owner is not None: if query_image_owner is not None:
query = query_image.union(query_image_owner, query_member) query = query_image.union(query_image_owner, query_member)
else: else:
@ -552,11 +550,11 @@ def image_get_all(context, filters=None, marker=None, limit=None,
showing_deleted = 'changes-since' in filters or filters.get('deleted', showing_deleted = 'changes-since' in filters or filters.get('deleted',
False) False)
img_conditions, prop_conditions, tag_conditions = \ img_cond, prop_cond, tag_cond = _make_conditions_from_filters(
_make_conditions_from_filters(filters, is_public) filters, is_public)
query = _select_images_query(context, query = _select_images_query(context,
img_conditions, img_cond,
admin_as_user, admin_as_user,
member_status, member_status,
visibility) visibility)
@ -567,15 +565,15 @@ def image_get_all(context, filters=None, marker=None, limit=None,
elif visibility == 'private': elif visibility == 'private':
query = query.filter(models.Image.is_public == False) query = query.filter(models.Image.is_public == False)
if prop_conditions: if prop_cond:
for prop_condition in prop_conditions: for prop_condition in prop_cond:
query = query.join(models.ImageProperty, aliased=True)\ query = query.join(models.ImageProperty, aliased=True).filter(
.filter(sa_sql.and_(*prop_condition)) sa_sql.and_(*prop_condition))
if tag_conditions: if tag_cond:
for tag_condition in tag_conditions: for tag_condition in tag_cond:
query = query.join(models.ImageTag, aliased=True)\ query = query.join(models.ImageTag, aliased=True).filter(
.filter(sa_sql.and_(*tag_condition)) sa_sql.and_(*tag_condition))
marker_image = None marker_image = None
if marker is not None: if marker is not None:
@ -591,8 +589,9 @@ def image_get_all(context, filters=None, marker=None, limit=None,
marker=marker_image, marker=marker_image,
sort_dir=sort_dir) sort_dir=sort_dir)
query = query.options(sa_orm.joinedload(models.Image.properties))\ query = query.options(sa_orm.joinedload(
.options(sa_orm.joinedload(models.Image.locations)) models.Image.properties)).options(
sa_orm.joinedload(models.Image.locations))
if return_tag: if return_tag:
query = query.options(sa_orm.joinedload(models.Image.tags)) query = query.options(sa_orm.joinedload(models.Image.tags))
@ -792,10 +791,8 @@ def image_location_update(context, image_id, location, session=None):
try: try:
session = session or get_session() session = session or get_session()
location_ref = session.query(models.ImageLocation)\ location_ref = session.query(models.ImageLocation).filter_by(
.filter_by(id=loc_id)\ id=loc_id).filter_by(image_id=image_id).one()
.filter_by(image_id=image_id)\
.one()
deleted = location['status'] in ('deleted', 'pending_delete') deleted = location['status'] in ('deleted', 'pending_delete')
updated_time = timeutils.utcnow() updated_time = timeutils.utcnow()
@ -824,10 +821,8 @@ def image_location_delete(context, image_id, location_id, status,
try: try:
session = session or get_session() session = session or get_session()
location_ref = session.query(models.ImageLocation)\ location_ref = session.query(models.ImageLocation).filter_by(
.filter_by(id=location_id)\ id=location_id).filter_by(image_id=image_id).one()
.filter_by(image_id=image_id)\
.one()
delete_time = delete_time or timeutils.utcnow() delete_time = delete_time or timeutils.utcnow()
@ -846,10 +841,10 @@ def image_location_delete(context, image_id, location_id, status,
def _image_locations_set(context, image_id, locations, session=None): def _image_locations_set(context, image_id, locations, session=None):
# NOTE(zhiyan): 1. Remove records from DB for deleted locations # NOTE(zhiyan): 1. Remove records from DB for deleted locations
session = session or get_session() session = session or get_session()
query = session.query(models.ImageLocation) \ query = session.query(models.ImageLocation).filter_by(
.filter_by(image_id=image_id) \ image_id=image_id).filter_by(
.filter_by(deleted=False) \ deleted=False).filter(~models.ImageLocation.id.in_(
.filter(~models.ImageLocation.id.in_([loc['id'] [loc['id']
for loc in locations for loc in locations
if loc.get('id')])) if loc.get('id')]))
for loc_id in [loc_ref.id for loc_ref in query.all()]: for loc_id in [loc_ref.id for loc_ref in query.all()]:
@ -868,10 +863,8 @@ def _image_locations_delete_all(context, image_id,
delete_time=None, session=None): delete_time=None, session=None):
"""Delete all image locations for given image""" """Delete all image locations for given image"""
session = session or get_session() session = session or get_session()
location_refs = session.query(models.ImageLocation) \ location_refs = session.query(models.ImageLocation).filter_by(
.filter_by(image_id=image_id) \ image_id=image_id).filter_by(deleted=False).all()
.filter_by(deleted=False) \
.all()
for loc_id in [loc_ref.id for loc_ref in location_refs]: for loc_id in [loc_ref.id for loc_ref in location_refs]:
image_location_delete(context, image_id, loc_id, 'deleted', image_location_delete(context, image_id, loc_id, 'deleted',
@ -933,9 +926,8 @@ def _image_child_entry_delete_all(child_model_cls, image_id, delete_time=None,
""" """
session = session or get_session() session = session or get_session()
query = session.query(child_model_cls) \ query = session.query(child_model_cls).filter_by(
.filter_by(image_id=image_id) \ image_id=image_id).filter_by(deleted=False)
.filter_by(deleted=False)
delete_time = delete_time or timeutils.utcnow() delete_time = delete_time or timeutils.utcnow()
@ -1143,10 +1135,9 @@ def image_tag_delete(context, image_id, value, session=None):
"""Delete an image tag.""" """Delete an image tag."""
_check_image_id(image_id) _check_image_id(image_id)
session = session or get_session() session = session or get_session()
query = session.query(models.ImageTag)\ query = session.query(models.ImageTag).filter_by(
.filter_by(image_id=image_id)\ image_id=image_id).filter_by(
.filter_by(value=value)\ value=value).filter_by(deleted=False)
.filter_by(deleted=False)
try: try:
tag_ref = query.one() tag_ref = query.one()
except sa_orm.exc.NoResultFound: except sa_orm.exc.NoResultFound:
@ -1168,10 +1159,8 @@ def image_tag_get_all(context, image_id, session=None):
"""Get a list of tags for a specific image.""" """Get a list of tags for a specific image."""
_check_image_id(image_id) _check_image_id(image_id)
session = session or get_session() session = session or get_session()
tags = session.query(models.ImageTag.value)\ tags = session.query(models.ImageTag.value).filter_by(
.filter_by(image_id=image_id)\ image_id=image_id).filter_by(deleted=False).all()
.filter_by(deleted=False)\
.all()
return [tag[0] for tag in tags] return [tag[0] for tag in tags]
@ -1319,8 +1308,8 @@ def task_get_all(context, filters=None, marker=None, limit=None,
session = get_session() session = get_session()
query = session.query(models.Task) query = session.query(models.Task)
if not (context.is_admin or admin_as_user == True) and \ if (not (context.is_admin or admin_as_user == True)
context.owner is not None: and context.owner is not None):
query = query.filter(models.Task.owner == context.owner) query = query.filter(models.Task.owner == context.owner)
showing_deleted = False showing_deleted = False

View File

@ -287,8 +287,9 @@ def _export_data_to_file(meta, path):
json_file.write(json.dumps(values)) json_file.write(json.dumps(values))
except Exception as e: except Exception as e:
LOG.exception(utils.exception_to_str(e)) LOG.exception(utils.exception_to_str(e))
LOG.info(_LI("Namespace %s saved in %s"), msg = _LI("Namespace %(namespace_file_name)s saved in %(file_name)s")
namespace_file_name, file_name) LOG.info(msg % {'namespace_file_name': namespace_file_name,
'file_name': file_name})
def db_load_metadefs(engine, metadata_path=None): def db_load_metadefs(engine, metadata_path=None):

View File

@ -86,8 +86,8 @@ def _get(context, namespace_id, session):
.filter_by(id=namespace_id) .filter_by(id=namespace_id)
namespace_rec = query.one() namespace_rec = query.one()
except sa_orm.exc.NoResultFound: except sa_orm.exc.NoResultFound:
LOG.warn(_LW("Metadata definition namespace not found for id=%s", msg = _LW("Metadata definition namespace not found for id=%s")
namespace_id)) LOG.warn(msg % namespace_id)
raise exc.MetadefRecordNotFound(record_type='namespace', raise exc.MetadefRecordNotFound(record_type='namespace',
id=namespace_id) id=namespace_id)

View File

@ -34,8 +34,8 @@ def _get(context, object_id, session):
.filter_by(id=object_id) .filter_by(id=object_id)
metadef_object = query.one() metadef_object = query.one()
except sa_orm.exc.NoResultFound: except sa_orm.exc.NoResultFound:
LOG.warn(_LW("Metadata definition object not found for id %s", msg = _LW("Metadata definition object not found for id %s")
object_id)) LOG.warn(msg % object_id)
raise exc.MetadefRecordNotFound(record_type='object', id=object_id) raise exc.MetadefRecordNotFound(record_type='object', id=object_id)
return metadef_object return metadef_object

View File

@ -36,8 +36,8 @@ def _get(context, property_id, session):
property_rec = query.one() property_rec = query.one()
except sa_orm.exc.NoResultFound: except sa_orm.exc.NoResultFound:
LOG.warn(_LW("Metadata definition property not found for id=%s", msg = _LW("Metadata definition property not found for id=%s")
property_id)) LOG.warn(msg % property_id)
raise exc.MetadefRecordNotFound( raise exc.MetadefRecordNotFound(
record_type='property', id=property_id) record_type='property', id=property_id)

View File

@ -1 +0,0 @@
# template repository default module

View File

@ -251,7 +251,7 @@ def _add_db2_constraints():
def _remove_db2_constraints(): def _remove_db2_constraints():
#remove the foreign keys constraints # Remove the foreign keys constraints
sql_commands = [ sql_commands = [
"""ALTER TABLE image_members DROP CONSTRAINT member_image_id;""", """ALTER TABLE image_members DROP CONSTRAINT member_image_id;""",
"""ALTER TABLE image_properties DROP CONSTRAINT property_image_id;""" """ALTER TABLE image_properties DROP CONSTRAINT property_image_id;"""
@ -536,23 +536,22 @@ def _update_all_ids_to_uuids(t_images, t_image_members, t_image_properties):
old_id = image["id"] old_id = image["id"]
new_id = str(uuid.uuid4()) new_id = str(uuid.uuid4())
t_images.update().\ t_images.update().where(
where(t_images.c.id == old_id).\ t_images.c.id == old_id).values(id=new_id).execute()
values(id=new_id).execute()
t_image_members.update().\ t_image_members.update().where(
where(t_image_members.c.image_id == old_id).\ t_image_members.c.image_id == old_id).values(
values(image_id=new_id).execute() image_id=new_id).execute()
t_image_properties.update().\ t_image_properties.update().where(
where(t_image_properties.c.image_id == old_id).\ t_image_properties.c.image_id == old_id).values(
values(image_id=new_id).execute() image_id=new_id).execute()
t_image_properties.update().\ t_image_properties.update().where(
where(and_(or_(t_image_properties.c.name == 'kernel_id', and_(or_(t_image_properties.c.name == 'kernel_id',
t_image_properties.c.name == 'ramdisk_id'), t_image_properties.c.name == 'ramdisk_id'),
t_image_properties.c.value == old_id)).\ t_image_properties.c.value == old_id)).values(
values(value=new_id).execute() value=new_id).execute()
def _update_all_uuids_to_ids(t_images, t_image_members, t_image_properties): def _update_all_uuids_to_ids(t_images, t_image_members, t_image_properties):
@ -563,22 +562,22 @@ def _update_all_uuids_to_ids(t_images, t_image_members, t_image_properties):
for image in images: for image in images:
old_id = image["id"] old_id = image["id"]
t_images.update().\ t_images.update().where(
where(t_images.c.id == old_id).\ t_images.c.id == old_id).values(
values(id=str(new_id)).execute() id=str(new_id)).execute()
t_image_members.update().\ t_image_members.update().where(
where(t_image_members.c.image_id == old_id).\ t_image_members.c.image_id == old_id).values(
values(image_id=str(new_id)).execute() image_id=str(new_id)).execute()
t_image_properties.update().\ t_image_properties.update().where(
where(t_image_properties.c.image_id == old_id).\ t_image_properties.c.image_id == old_id).values(
values(image_id=str(new_id)).execute() image_id=str(new_id)).execute()
t_image_properties.update().\ t_image_properties.update().where(
where(and_(or_(t_image_properties.c.name == 'kernel_id', and_(or_(t_image_properties.c.name == 'kernel_id',
t_image_properties.c.name == 'ramdisk_id'), t_image_properties.c.name == 'ramdisk_id'),
t_image_properties.c.value == old_id)).\ t_image_properties.c.value == old_id)).values(
values(value=str(new_id)).execute() value=str(new_id)).execute()
new_id += 1 new_id += 1

View File

@ -54,9 +54,9 @@ def migrate_location_credentials(migrate_engine, to_quoted):
for image in images: for image in images:
try: try:
fixed_uri = legacy_parse_uri(image['location'], to_quoted) fixed_uri = legacy_parse_uri(image['location'], to_quoted)
images_table.update()\ images_table.update().where(
.where(images_table.c.id == image['id'])\ images_table.c.id == image['id']).values(
.values(location=fixed_uri).execute() location=fixed_uri).execute()
except exception.BadStoreUri as e: except exception.BadStoreUri as e:
reason = utils.exception_to_str(e) reason = utils.exception_to_str(e)
msg = _LE("Invalid store uri for image: %(image_id)s. " msg = _LE("Invalid store uri for image: %(image_id)s. "

View File

@ -84,9 +84,9 @@ def migrate_location_credentials(migrate_engine, to_quoted):
for image in images: for image in images:
try: try:
fixed_uri = fix_uri_credentials(image['location'], to_quoted) fixed_uri = fix_uri_credentials(image['location'], to_quoted)
images_table.update()\ images_table.update().where(
.where(images_table.c.id == image['id'])\ images_table.c.id == image['id']).values(
.values(location=fixed_uri).execute() location=fixed_uri).execute()
except exception.Invalid: except exception.Invalid:
msg = _LW("Failed to decrypt location value for image" msg = _LW("Failed to decrypt location value for image"
" %(image_id)s") % {'image_id': image['id']} " %(image_id)s") % {'image_id': image['id']}

View File

@ -53,6 +53,6 @@ def downgrade(migrate_engine):
image_records = image_locations_table.select().execute().fetchall() image_records = image_locations_table.select().execute().fetchall()
for image_location in image_records: for image_location in image_records:
images_table.update(values={'location': image_location.value})\ images_table.update(
.where(images_table.c.id == image_location.image_id)\ values={'location': image_location.value}).where(
.execute() images_table.c.id == image_location.image_id).execute()

View File

@ -29,8 +29,8 @@ def upgrade(migrate_engine):
new_meta_data.create(image_locations) new_meta_data.create(image_locations)
noe = pickle.dumps({}) noe = pickle.dumps({})
s = sqlalchemy.sql.select([image_locations]).\ s = sqlalchemy.sql.select([image_locations]).where(
where(image_locations.c.meta_data != noe) image_locations.c.meta_data != noe)
conn = migrate_engine.connect() conn = migrate_engine.connect()
res = conn.execute(s) res = conn.execute(s)
@ -38,9 +38,8 @@ def upgrade(migrate_engine):
meta_data = row['meta_data'] meta_data = row['meta_data']
x = pickle.loads(meta_data) x = pickle.loads(meta_data)
if x != {}: if x != {}:
stmt = image_locations.update().\ stmt = image_locations.update().where(
where(image_locations.c.id == row['id']).\ image_locations.c.id == row['id']).values(storage_meta_data=x)
values(storage_meta_data=x)
conn.execute(stmt) conn.execute(stmt)
conn.close() conn.close()
image_locations.columns['meta_data'].drop() image_locations.columns['meta_data'].drop()
@ -55,8 +54,8 @@ def downgrade(migrate_engine):
old_meta_data.create(image_locations) old_meta_data.create(image_locations)
noj = json.dumps({}) noj = json.dumps({})
s = sqlalchemy.sql.select([image_locations]).\ s = sqlalchemy.sql.select([image_locations]).where(
where(image_locations.c.meta_data != noj) image_locations.c.meta_data != noj)
conn = migrate_engine.connect() conn = migrate_engine.connect()
res = conn.execute(s) res = conn.execute(s)
@ -64,9 +63,9 @@ def downgrade(migrate_engine):
x = row['meta_data'] x = row['meta_data']
meta_data = json.loads(x) meta_data = json.loads(x)
if meta_data != {}: if meta_data != {}:
stmt = image_locations.update().\ stmt = image_locations.update().where(
where(image_locations.c.id == row['id']).\ image_locations.c.id == row['id']).values(
values(old_meta_data=meta_data) old_meta_data=meta_data)
conn.execute(stmt) conn.execute(stmt)
conn.close() conn.close()
image_locations.columns['meta_data'].drop() image_locations.columns['meta_data'].drop()

View File

@ -86,9 +86,7 @@ def downgrade(migrate_engine):
'message': task_info.message 'message': task_info.message
} }
tasks_table\ tasks_table.update(values=values).where(
.update(values=values)\ tasks_table.c.id == task_info.task_id).execute()
.where(tasks_table.c.id == task_info.task_id)\
.execute()
drop_tables([task_info_table]) drop_tables([task_info_table])

View File

@ -35,11 +35,10 @@ def upgrade(migrate_engine):
mapping = {'active': 'active', 'pending_delete': 'pending_delete', mapping = {'active': 'active', 'pending_delete': 'pending_delete',
'deleted': 'deleted', 'killed': 'deleted'} 'deleted': 'deleted', 'killed': 'deleted'}
for src, dst in six.iteritems(mapping): for src, dst in six.iteritems(mapping):
subq = sqlalchemy.sql.select([images_table.c.id])\ subq = sqlalchemy.sql.select([images_table.c.id]).where(
.where(images_table.c.status == src) images_table.c.status == src)
image_locations_table.update(values={'status': dst})\ image_locations_table.update(values={'status': dst}).where(
.where(image_locations_table.c.image_id.in_(subq))\ image_locations_table.c.image_id.in_(subq)).execute()
.execute()
def downgrade(migrate_engine): def downgrade(migrate_engine):

View File

@ -1 +0,0 @@
# template repository default versions module

View File

@ -13,6 +13,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import glance_store
from glance.api import authorization from glance.api import authorization
from glance.api import policy from glance.api import policy
@ -24,7 +25,6 @@ import glance.domain
import glance.location import glance.location
import glance.notifier import glance.notifier
import glance.quota import glance.quota
import glance_store
class Gateway(object): class Gateway(object):
@ -48,11 +48,10 @@ class Gateway(object):
policy_image_factory, context, self.notifier) policy_image_factory, context, self.notifier)
if property_utils.is_property_protection_enabled(): if property_utils.is_property_protection_enabled():
property_rules = property_utils.PropertyRules(self.policy) property_rules = property_utils.PropertyRules(self.policy)
protected_image_factory = property_protections.\ pif = property_protections.ProtectedImageFactoryProxy(
ProtectedImageFactoryProxy(notifier_image_factory, context, notifier_image_factory, context, property_rules)
property_rules)
authorized_image_factory = authorization.ImageFactoryProxy( authorized_image_factory = authorization.ImageFactoryProxy(
protected_image_factory, context) pif, context)
else: else:
authorized_image_factory = authorization.ImageFactoryProxy( authorized_image_factory = authorization.ImageFactoryProxy(
notifier_image_factory, context) notifier_image_factory, context)
@ -80,11 +79,10 @@ class Gateway(object):
policy_image_repo, context, self.notifier) policy_image_repo, context, self.notifier)
if property_utils.is_property_protection_enabled(): if property_utils.is_property_protection_enabled():
property_rules = property_utils.PropertyRules(self.policy) property_rules = property_utils.PropertyRules(self.policy)
protected_image_repo = property_protections.\ pir = property_protections.ProtectedImageRepoProxy(
ProtectedImageRepoProxy(notifier_image_repo, context, notifier_image_repo, context, property_rules)
property_rules)
authorized_image_repo = authorization.ImageRepoProxy( authorized_image_repo = authorization.ImageRepoProxy(
protected_image_repo, context) pir, context)
else: else:
authorized_image_repo = authorization.ImageRepoProxy( authorized_image_repo = authorization.ImageRepoProxy(
notifier_image_repo, context) notifier_image_repo, context)
@ -165,20 +163,16 @@ class Gateway(object):
resource_type_factory = glance.domain.MetadefResourceTypeFactory() resource_type_factory = glance.domain.MetadefResourceTypeFactory()
policy_resource_type_factory = policy.MetadefResourceTypeFactoryProxy( policy_resource_type_factory = policy.MetadefResourceTypeFactoryProxy(
resource_type_factory, context, self.policy) resource_type_factory, context, self.policy)
authorized_resource_type_factory = \ return authorization.MetadefResourceTypeFactoryProxy(
authorization.MetadefResourceTypeFactoryProxy(
policy_resource_type_factory, context) policy_resource_type_factory, context)
return authorized_resource_type_factory
def get_metadef_resource_type_repo(self, context): def get_metadef_resource_type_repo(self, context):
resource_type_repo = glance.db.MetadefResourceTypeRepo( resource_type_repo = glance.db.MetadefResourceTypeRepo(
context, self.db_api) context, self.db_api)
policy_object_repo = policy.MetadefResourceTypeRepoProxy( policy_object_repo = policy.MetadefResourceTypeRepoProxy(
resource_type_repo, context, self.policy) resource_type_repo, context, self.policy)
authorized_resource_type_repo = \ return authorization.MetadefResourceTypeRepoProxy(policy_object_repo,
authorization.MetadefResourceTypeRepoProxy(policy_object_repo,
context) context)
return authorized_resource_type_repo
def get_metadef_property_factory(self, context): def get_metadef_property_factory(self, context):
prop_factory = glance.domain.MetadefPropertyFactory() prop_factory = glance.domain.MetadefPropertyFactory()

View File

@ -20,13 +20,13 @@ Cache driver that uses SQLite to store information about cached images
from __future__ import absolute_import from __future__ import absolute_import
from contextlib import contextmanager from contextlib import contextmanager
import os import os
import sqlite3
import stat import stat
import time import time
from eventlet import sleep from eventlet import sleep
from eventlet import timeout from eventlet import timeout
from oslo.config import cfg from oslo.config import cfg
import sqlite3
from glance.common import exception from glance.common import exception
from glance.image_cache.drivers import base from glance.image_cache.drivers import base
@ -473,7 +473,7 @@ class Driver(base.Driver):
items.append((mtime, os.path.basename(path))) items.append((mtime, os.path.basename(path)))
items.sort() items.sort()
return [image_id for (mtime, image_id) in items] return [image_id for (modtime, image_id) in items]
def get_cache_files(self, basepath): def get_cache_files(self, basepath):
""" """

View File

@ -376,7 +376,7 @@ class Driver(base.Driver):
items.append((mtime, os.path.basename(path))) items.append((mtime, os.path.basename(path)))
items.sort() items.sort()
return [image_id for (mtime, image_id) in items] return [image_id for (modtime, image_id) in items]
def _reap_old_files(self, dirpath, entry_type, grace=None): def _reap_old_files(self, dirpath, entry_type, grace=None):
now = time.time() now = time.time()

View File

@ -16,9 +16,7 @@
""" """
Prefetches images into the Image Cache Prefetches images into the Image Cache
""" """
import eventlet import eventlet
import glance_store import glance_store
from glance.common import exception from glance.common import exception

View File

@ -211,8 +211,8 @@ class ImageProxy(glance.domain.proxy.Image):
{'image_id': self.image.image_id, {'image_id': self.image.image_id,
'error': utils.exception_to_str(e)}) 'error': utils.exception_to_str(e)})
self.notifier.error('image.upload', msg) self.notifier.error('image.upload', msg)
raise webob.exc.HTTPBadRequest(explanation= raise webob.exc.HTTPBadRequest(
utils.exception_to_str(e)) explanation=utils.exception_to_str(e))
except exception.Duplicate as e: except exception.Duplicate as e:
msg = (_("Unable to upload duplicate image data for image" msg = (_("Unable to upload duplicate image data for image"
"%(image_id)s: %(error)s") % "%(image_id)s: %(error)s") %
@ -260,8 +260,7 @@ class TaskRepoProxy(glance.domain.proxy.TaskRepo):
self.context = context self.context = context
self.notifier = notifier self.notifier = notifier
proxy_kwargs = {'context': self.context, 'notifier': self.notifier} proxy_kwargs = {'context': self.context, 'notifier': self.notifier}
super(TaskRepoProxy, self) \ super(TaskRepoProxy, self).__init__(task_repo,
.__init__(task_repo,
task_proxy_class=TaskProxy, task_proxy_class=TaskProxy,
task_proxy_kwargs=proxy_kwargs) task_proxy_kwargs=proxy_kwargs)
@ -285,8 +284,8 @@ class TaskStubRepoProxy(glance.domain.proxy.TaskStubRepo):
self.context = context self.context = context
self.notifier = notifier self.notifier = notifier
proxy_kwargs = {'context': self.context, 'notifier': self.notifier} proxy_kwargs = {'context': self.context, 'notifier': self.notifier}
super(TaskStubRepoProxy, self) \ super(TaskStubRepoProxy, self).__init__(
.__init__(task_stub_repo, task_stub_repo,
task_stub_proxy_class=TaskStubProxy, task_stub_proxy_class=TaskStubProxy,
task_stub_proxy_kwargs=proxy_kwargs) task_stub_proxy_kwargs=proxy_kwargs)

View File

@ -23,12 +23,6 @@ __all__ = [
import copy import copy
import itertools import itertools
from glance.openstack.common import gettextutils
# TODO(zhiyan): Remove translation from in-line
# help message of option definition code.
gettextutils.install('glance', lazy=False)
import glance.api.middleware.context import glance.api.middleware.context
import glance.api.policy import glance.api.policy
import glance.common.config import glance.common.config
@ -40,6 +34,7 @@ import glance.common.wsgi
import glance.image_cache import glance.image_cache
import glance.image_cache.drivers.sqlite import glance.image_cache.drivers.sqlite
import glance.notifier import glance.notifier
from glance.openstack.common import gettextutils
import glance.openstack.common.lockutils import glance.openstack.common.lockutils
import glance.openstack.common.log import glance.openstack.common.log
import glance.registry import glance.registry
@ -47,6 +42,10 @@ import glance.registry.client
import glance.registry.client.v1.api import glance.registry.client.v1.api
import glance.scrubber import glance.scrubber
# TODO(zhiyan): Remove translation from in-line
# help message of option definition code.
gettextutils.install('glance', lazy=False)
_global_opt_lists = [ _global_opt_lists = [
glance.openstack.common.log.common_cli_opts, glance.openstack.common.log.common_cli_opts,

View File

@ -14,10 +14,9 @@
import copy import copy
import six
import glance_store as store import glance_store as store
from oslo.config import cfg from oslo.config import cfg
import six
import glance.api.common import glance.api.common
import glance.common.exception as exception import glance.common.exception as exception

View File

@ -15,10 +15,10 @@
import abc import abc
import calendar import calendar
import eventlet
import os import os
import time import time
import eventlet
from oslo.config import cfg from oslo.config import cfg
import six import six
@ -125,6 +125,7 @@ class ScrubQueue(object):
@abc.abstractmethod @abc.abstractmethod
def has_image(self, image_id): def has_image(self, image_id):
"""Returns whether the queue contains an image or not. """Returns whether the queue contains an image or not.
:param image_id: The opaque image identifier :param image_id: The opaque image identifier
:retval a boolean value to inform including or not :retval a boolean value to inform including or not

View File

@ -549,8 +549,7 @@ class FunctionalTest(test_utils.BaseTestCase):
self.api_protocol = 'http' self.api_protocol = 'http'
self.api_port, api_sock = test_utils.get_unused_port_and_socket() self.api_port, api_sock = test_utils.get_unused_port_and_socket()
self.registry_port, registry_sock = \ self.registry_port, reg_sock = test_utils.get_unused_port_and_socket()
test_utils.get_unused_port_and_socket()
conf_dir = os.path.join(self.test_dir, 'etc') conf_dir = os.path.join(self.test_dir, 'etc')
utils.safe_mkdirs(conf_dir) utils.safe_mkdirs(conf_dir)
@ -572,7 +571,7 @@ class FunctionalTest(test_utils.BaseTestCase):
self.registry_server = RegistryServer(self.test_dir, self.registry_server = RegistryServer(self.test_dir,
self.registry_port, self.registry_port,
sock=registry_sock) sock=reg_sock)
self.scrubber_daemon = ScrubberDaemon(self.test_dir) self.scrubber_daemon = ScrubberDaemon(self.test_dir)

View File

@ -894,7 +894,8 @@ class DriverTests(object):
auth_tok='user:%s:user' % TENANT2, auth_tok='user:%s:user' % TENANT2,
owner_is_tenant=False) owner_is_tenant=False)
UUIDX = str(uuid.uuid4()) UUIDX = str(uuid.uuid4())
#we need private image and context.owner should not match image owner # We need private image and context.owner should not match image
# owner
self.db_api.image_create(ctxt1, {'id': UUIDX, self.db_api.image_create(ctxt1, {'id': UUIDX,
'status': 'queued', 'status': 'queued',
'is_public': False, 'is_public': False,
@ -946,7 +947,8 @@ class DriverTests(object):
auth_tok='user:%s:user' % TENANT2, auth_tok='user:%s:user' % TENANT2,
owner_is_tenant=False) owner_is_tenant=False)
UUIDX = str(uuid.uuid4()) UUIDX = str(uuid.uuid4())
#we need private image and context.owner should not match image owner # We need private image and context.owner should not match image
# owner
image = self.db_api.image_create(ctxt1, {'id': UUIDX, image = self.db_api.image_create(ctxt1, {'id': UUIDX,
'status': 'queued', 'status': 'queued',
'is_public': False, 'is_public': False,
@ -1699,7 +1701,7 @@ class TestVisibility(test_utils.BaseTestCase):
'is_public': is_public, 'is_public': is_public,
} }
fixtures.append(fixture) fixtures.append(fixture)
return [build_image_fixture(**fixture) for fixture in fixtures] return [build_image_fixture(**f) for f in fixtures]
def create_images(self, images): def create_images(self, images):
for fixture in images: for fixture in images:

View File

@ -14,11 +14,10 @@
import copy import copy
from glance import context
import glance.tests.functional.db as db_tests
from glance.common import config from glance.common import config
from glance.common import exception from glance.common import exception
from glance import context
import glance.tests.functional.db as db_tests
from glance.tests import utils as test_utils from glance.tests import utils as test_utils

View File

@ -21,7 +21,7 @@ Utility methods to set testcases up for Swift and/or S3 tests.
from __future__ import print_function from __future__ import print_function
import BaseHTTPServer import BaseHTTPServer
import thread import threading
from glance.openstack.common import units from glance.openstack.common import units
@ -76,7 +76,7 @@ def setup_http(test):
def serve_requests(httpd): def serve_requests(httpd):
httpd.serve_forever() httpd.serve_forever()
thread.start_new_thread(serve_requests, (remote_server,)) threading.Thread(target=serve_requests, args=(remote_server,)).start()
test.http_server = remote_server test.http_server = remote_server
test.http_ip = remote_ip test.http_ip = remote_ip
test.http_port = remote_port test.http_port = remote_port

View File

@ -17,10 +17,10 @@
import datetime import datetime
import hashlib import hashlib
import httplib2
import os import os
import sys import sys
import httplib2
from six.moves import xrange from six.moves import xrange
from glance.openstack.common import jsonutils from glance.openstack.common import jsonutils

View File

@ -32,14 +32,13 @@ from six.moves import xrange
from glance.openstack.common import jsonutils from glance.openstack.common import jsonutils
from glance.openstack.common import units from glance.openstack.common import units
from glance.tests import functional from glance.tests import functional
from glance.tests.functional.store_utils import get_http_uri
from glance.tests.functional.store_utils import setup_http
from glance.tests.utils import execute from glance.tests.utils import execute
from glance.tests.utils import minimal_headers from glance.tests.utils import minimal_headers
from glance.tests.utils import skip_if_disabled from glance.tests.utils import skip_if_disabled
from glance.tests.utils import xattr_writes_supported from glance.tests.utils import xattr_writes_supported
from glance.tests.functional.store_utils import get_http_uri
from glance.tests.functional.store_utils import setup_http
FIVE_KB = 5 * units.Ki FIVE_KB = 5 * units.Ki

View File

@ -15,10 +15,11 @@
"""Functional test case that tests logging output""" """Functional test case that tests logging output"""
import httplib2
import os import os
import stat import stat
import httplib2
from glance.tests import functional from glance.tests import functional

View File

@ -433,8 +433,8 @@ class TestApi(functional.FunctionalTest):
# 21. GET /images with filter on user-defined property 'distro'. # 21. GET /images with filter on user-defined property 'distro'.
# Verify both images are returned # Verify both images are returned
path = "http://%s:%d/v1/images?property-distro=Ubuntu" % \ path = "http://%s:%d/v1/images?property-distro=Ubuntu" % (
("127.0.0.1", self.api_port) "127.0.0.1", self.api_port)
http = httplib2.Http() http = httplib2.Http()
response, content = http.request(path, 'GET') response, content = http.request(path, 'GET')
self.assertEqual(response.status, 200) self.assertEqual(response.status, 200)
@ -445,8 +445,8 @@ class TestApi(functional.FunctionalTest):
# 22. GET /images with filter on user-defined property 'distro' but # 22. GET /images with filter on user-defined property 'distro' but
# with non-existent value. Verify no images are returned # with non-existent value. Verify no images are returned
path = "http://%s:%d/v1/images?property-distro=fedora" % \ path = "http://%s:%d/v1/images?property-distro=fedora" % (
("127.0.0.1", self.api_port) "127.0.0.1", self.api_port)
http = httplib2.Http() http = httplib2.Http()
response, content = http.request(path, 'GET') response, content = http.request(path, 'GET')
self.assertEqual(response.status, 200) self.assertEqual(response.status, 200)

View File

@ -20,10 +20,10 @@ based storage backend.
""" """
import hashlib import hashlib
import httplib2
import tempfile import tempfile
import time import time
import httplib2
from six.moves import xrange from six.moves import xrange
from glance.openstack.common import jsonutils from glance.openstack.common import jsonutils

View File

@ -12,11 +12,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import hashlib import hashlib
import httplib2
import os import os
import httplib2
from glance.openstack.common import jsonutils from glance.openstack.common import jsonutils
from glance.openstack.common import units from glance.openstack.common import units
from glance.tests import functional from glance.tests import functional

View File

@ -27,18 +27,17 @@ test accounts only.
If a connection cannot be established, all the test cases are If a connection cannot be established, all the test cases are
skipped. skipped.
""" """
import datetime import datetime
import hashlib import hashlib
import httplib2
import os import os
import tempfile import tempfile
import uuid import uuid
import httplib2
from glance.openstack.common import jsonutils from glance.openstack.common import jsonutils
from glance.openstack.common import timeutils from glance.openstack.common import timeutils
from glance.openstack.common import units from glance.openstack.common import units
from glance.tests import functional from glance.tests import functional
from glance.tests.utils import minimal_headers from glance.tests.utils import minimal_headers
from glance.tests.utils import skip_if_disabled from glance.tests.utils import skip_if_disabled

View File

@ -887,7 +887,7 @@ class TestImages(functional.FunctionalTest):
images = jsonutils.loads(response.text)['images'] images = jsonutils.loads(response.text)['images']
self.assertEqual(0, len(images)) self.assertEqual(0, len(images))
## Create an image for role member with extra props # Create an image for role member with extra props
# Raises 403 since user is not allowed to set 'foo' # Raises 403 since user is not allowed to set 'foo'
path = self._url('/v2/images') path = self._url('/v2/images')
headers = self._headers({'content-type': 'application/json', headers = self._headers({'content-type': 'application/json',
@ -899,7 +899,7 @@ class TestImages(functional.FunctionalTest):
response = requests.post(path, headers=headers, data=data) response = requests.post(path, headers=headers, data=data)
self.assertEqual(403, response.status_code) self.assertEqual(403, response.status_code)
## Create an image for role member without 'foo' # Create an image for role member without 'foo'
path = self._url('/v2/images') path = self._url('/v2/images')
headers = self._headers({'content-type': 'application/json', headers = self._headers({'content-type': 'application/json',
'X-Roles': 'member'}) 'X-Roles': 'member'})
@ -1037,7 +1037,7 @@ class TestImages(functional.FunctionalTest):
images = jsonutils.loads(response.text)['images'] images = jsonutils.loads(response.text)['images']
self.assertEqual(0, len(images)) self.assertEqual(0, len(images))
## Create an image for role member with extra props # Create an image for role member with extra props
# Raises 403 since user is not allowed to set 'foo' # Raises 403 since user is not allowed to set 'foo'
path = self._url('/v2/images') path = self._url('/v2/images')
headers = self._headers({'content-type': 'application/json', headers = self._headers({'content-type': 'application/json',
@ -1049,7 +1049,7 @@ class TestImages(functional.FunctionalTest):
response = requests.post(path, headers=headers, data=data) response = requests.post(path, headers=headers, data=data)
self.assertEqual(403, response.status_code) self.assertEqual(403, response.status_code)
## Create an image for role member without 'foo' # Create an image for role member without 'foo'
path = self._url('/v2/images') path = self._url('/v2/images')
headers = self._headers({'content-type': 'application/json', headers = self._headers({'content-type': 'application/json',
'X-Roles': 'member'}) 'X-Roles': 'member'})

View File

@ -154,8 +154,8 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
for key in cls._disallowed_properties: for key in cls._disallowed_properties:
if key in image: if key in image:
msg = _("Attribute '%s' is read-only.") % key msg = _("Attribute '%s' is read-only.") % key
raise webob.exc.HTTPForbidden(explanation= raise webob.exc.HTTPForbidden(
utils.exception_to_str(msg)) explanation=utils.exception_to_str(msg))
def create(self, request): def create(self, request):
body = self._get_request_body(request) body = self._get_request_body(request)

View File

@ -14,6 +14,7 @@ import datetime
import hashlib import hashlib
import os import os
import tempfile import tempfile
import testtools import testtools
from glance.openstack.common import jsonutils from glance.openstack.common import jsonutils

View File

@ -78,9 +78,9 @@ class FakeRegistryConnection(object):
def stub_out_registry_and_store_server(stubs, base_dir, **kwargs): def stub_out_registry_and_store_server(stubs, base_dir, **kwargs):
""" """Mocks calls to 127.0.0.1 on 9191 and 9292 for testing.
Mocks calls to 127.0.0.1 on 9191 and 9292 for testing so
that a real Glance server does not need to be up and Done so that a real Glance server does not need to be up and
running running
""" """
@ -132,9 +132,10 @@ def stub_out_registry_and_store_server(stubs, base_dir, **kwargs):
def endheaders(self): def endheaders(self):
hl = [i.lower() for i in self.req.headers.keys()] hl = [i.lower() for i in self.req.headers.keys()]
assert not ('content-length' in hl and assert(not ('content-length' in hl and
'transfer-encoding' in hl), \ 'transfer-encoding' in hl),
'Content-Length and Transfer-Encoding are mutually exclusive' 'Content-Length and Transfer-Encoding '
'are mutually exclusive')
def send(self, data): def send(self, data):
# send() is called during chunked-transfer encoding, and # send() is called during chunked-transfer encoding, and
@ -163,9 +164,7 @@ def stub_out_registry_and_store_server(stubs, base_dir, **kwargs):
return res return res
def fake_get_connection_type(client): def fake_get_connection_type(client):
""" """Returns the proper connection type."""
Returns the proper connection type
"""
DEFAULT_REGISTRY_PORT = 9191 DEFAULT_REGISTRY_PORT = 9191
DEFAULT_API_PORT = 9292 DEFAULT_API_PORT = 9292
@ -199,15 +198,13 @@ def stub_out_registry_and_store_server(stubs, base_dir, **kwargs):
def stub_out_registry_server(stubs, **kwargs): def stub_out_registry_server(stubs, **kwargs):
""" """Mocks calls to 127.0.0.1 on 9191 for testing.
Mocks calls to 127.0.0.1 on 9191 for testing so
that a real Glance Registry server does not need to be up and Done so that a real Glance Registry server does not need to be up and
running running.
""" """
def fake_get_connection_type(client): def fake_get_connection_type(client):
""" """Returns the proper connection type."""
Returns the proper connection type
"""
DEFAULT_REGISTRY_PORT = 9191 DEFAULT_REGISTRY_PORT = 9191
if (client.port == DEFAULT_REGISTRY_PORT and if (client.port == DEFAULT_REGISTRY_PORT and

View File

@ -9,11 +9,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock
import sys import sys
import glance_store as store import glance_store as store
import mock
from oslo.config import cfg from oslo.config import cfg
import six import six

View File

@ -14,7 +14,6 @@
# under the License. # under the License.
import testtools import testtools
import webob import webob
import glance.api.common import glance.api.common

View File

@ -12,9 +12,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import urllib2
import mock import mock
import urllib2
from glance.common.scripts.image_import import main as image_import_script from glance.common.scripts.image_import import main as image_import_script
import glance.tests.utils as test_utils import glance.tests.utils as test_utils

View File

@ -12,9 +12,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import urllib2
import mock import mock
import urllib2
from glance.common import exception from glance.common import exception
from glance.common.scripts import utils as script_utils from glance.common.scripts import utils as script_utils

View File

@ -15,12 +15,12 @@
# under the License. # under the License.
import datetime import datetime
import gettext
import socket import socket
from babel import localedata from babel import localedata
import eventlet.patcher import eventlet.patcher
import fixtures import fixtures
import gettext
import mock import mock
import routes import routes
import six import six

View File

@ -29,7 +29,6 @@ from glance.db.sqlalchemy import api
import glance.tests.unit.utils as unit_test_utils import glance.tests.unit.utils as unit_test_utils
import glance.tests.utils as test_utils import glance.tests.utils as test_utils
CONF = cfg.CONF CONF = cfg.CONF
CONF.import_opt('metadata_encryption_key', 'glance.common.config') CONF.import_opt('metadata_encryption_key', 'glance.common.config')
@ -547,8 +546,8 @@ class TestImageMemberRepo(test_utils.BaseTestCase):
def test_remove_image_member_does_not_exist(self): def test_remove_image_member_does_not_exist(self):
fake_uuid = str(uuid.uuid4()) fake_uuid = str(uuid.uuid4())
image = self.image_repo.get(UUID2) image = self.image_repo.get(UUID2)
fake_member = glance.domain.ImageMemberFactory()\ fake_member = glance.domain.ImageMemberFactory().new_image_member(
.new_image_member(image, TENANT4) image, TENANT4)
fake_member.id = fake_uuid fake_member.id = fake_uuid
exc = self.assertRaises(exception.NotFound, exc = self.assertRaises(exception.NotFound,
self.image_member_repo.remove, self.image_member_repo.remove,

View File

@ -423,6 +423,6 @@ class TestMetadefRepo(test_utils.BaseTestCase):
object) object)
def test_list_resource_type(self): def test_list_resource_type(self):
resource_type = self.resource_type_repo.list(filters= resource_type = self.resource_type_repo.list(
{'namespace': NAMESPACE1}) filters={'namespace': NAMESPACE1})
self.assertEqual(len(resource_type), 0) self.assertEqual(len(resource_type), 0)

View File

@ -195,8 +195,8 @@ class TestImageMember(test_utils.BaseTestCase):
self.image_member_factory = domain.ImageMemberFactory() self.image_member_factory = domain.ImageMemberFactory()
self.image_factory = domain.ImageFactory() self.image_factory = domain.ImageFactory()
self.image = self.image_factory.new_image() self.image = self.image_factory.new_image()
self.image_member = self.image_member_factory\ self.image_member = self.image_member_factory.new_image_member(
.new_image_member(image=self.image, image=self.image,
member_id=TENANT1) member_id=TENANT1)
def test_status_enumerated(self): def test_status_enumerated(self):

View File

@ -215,8 +215,8 @@ class ImageServiceTestCase(test_utils.BaseTestCase):
image_meta_with_proto['Content-Length'] = len(image_body) image_meta_with_proto['Content-Length'] = len(image_body)
for key in IMG_RESPONSE_ACTIVE: for key in IMG_RESPONSE_ACTIVE:
image_meta_with_proto['x-image-meta-%s' % key] = \ image_meta_with_proto[
IMG_RESPONSE_ACTIVE[key] 'x-image-meta-%s' % key] = IMG_RESPONSE_ACTIVE[key]
c.conn.prime_request('POST', 'v1/images', c.conn.prime_request('POST', 'v1/images',
image_body, image_meta_with_proto, image_body, image_meta_with_proto,
@ -230,8 +230,8 @@ class ImageServiceTestCase(test_utils.BaseTestCase):
c = glance_replicator.ImageService(FakeHTTPConnection(), 'noauth') c = glance_replicator.ImageService(FakeHTTPConnection(), 'noauth')
image_meta = {'id': '5dcddce0-cba5-4f18-9cf4-9853c7b207a6'} image_meta = {'id': '5dcddce0-cba5-4f18-9cf4-9853c7b207a6'}
image_meta_headers = \ image_meta_headers = glance_replicator.ImageService._dict_to_headers(
glance_replicator.ImageService._dict_to_headers(image_meta) image_meta)
image_meta_headers['x-auth-token'] = 'noauth' image_meta_headers['x-auth-token'] = 'noauth'
image_meta_headers['Content-Type'] = 'application/octet-stream' image_meta_headers['Content-Type'] = 'application/octet-stream'
c.conn.prime_request('PUT', 'v1/images/%s' % image_meta['id'], c.conn.prime_request('PUT', 'v1/images/%s' % image_meta['id'],

View File

@ -152,8 +152,8 @@ class ImageCacheTestCase(object):
incomplete_file.close() incomplete_file.close()
mtime = os.path.getmtime(incomplete_file_path_1) mtime = os.path.getmtime(incomplete_file_path_1)
pastday = datetime.datetime.fromtimestamp(mtime) - \ pastday = (datetime.datetime.fromtimestamp(mtime) -
datetime.timedelta(days=1) datetime.timedelta(days=1))
atime = int(time.mktime(pastday.timetuple())) atime = int(time.mktime(pastday.timetuple()))
mtime = atime mtime = atime
os.utime(incomplete_file_path_1, (atime, mtime)) os.utime(incomplete_file_path_1, (atime, mtime))

View File

@ -12,9 +12,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import os
import mock import mock
import os
from glance.common import exception from glance.common import exception
from glance.image_cache import client from glance.image_cache import client
@ -35,22 +35,22 @@ class CacheClientTestCase(utils.BaseTestCase):
def test_get_cached_images(self): def test_get_cached_images(self):
expected_data = '{"cached_images": "some_images"}' expected_data = '{"cached_images": "some_images"}'
self.client.do_request.return_value = \ self.client.do_request.return_value = utils.FakeHTTPResponse(
utils.FakeHTTPResponse(data=expected_data) data=expected_data)
self.assertEqual(self.client.get_cached_images(), "some_images") self.assertEqual(self.client.get_cached_images(), "some_images")
self.client.do_request.assert_called_with("GET", "/cached_images") self.client.do_request.assert_called_with("GET", "/cached_images")
def test_get_queued_images(self): def test_get_queued_images(self):
expected_data = '{"queued_images": "some_images"}' expected_data = '{"queued_images": "some_images"}'
self.client.do_request.return_value = \ self.client.do_request.return_value = utils.FakeHTTPResponse(
utils.FakeHTTPResponse(data=expected_data) data=expected_data)
self.assertEqual(self.client.get_queued_images(), "some_images") self.assertEqual(self.client.get_queued_images(), "some_images")
self.client.do_request.assert_called_with("GET", "/queued_images") self.client.do_request.assert_called_with("GET", "/queued_images")
def test_delete_all_cached_images(self): def test_delete_all_cached_images(self):
expected_data = '{"num_deleted": 4}' expected_data = '{"num_deleted": 4}'
self.client.do_request.return_value = \ self.client.do_request.return_value = utils.FakeHTTPResponse(
utils.FakeHTTPResponse(data=expected_data) data=expected_data)
self.assertEqual(self.client.delete_all_cached_images(), 4) self.assertEqual(self.client.delete_all_cached_images(), 4)
self.client.do_request.assert_called_with("DELETE", "/cached_images") self.client.do_request.assert_called_with("DELETE", "/cached_images")
@ -68,8 +68,8 @@ class CacheClientTestCase(utils.BaseTestCase):
def test_delete_all_queued_images(self): def test_delete_all_queued_images(self):
expected_data = '{"num_deleted": 4}' expected_data = '{"num_deleted": 4}'
self.client.do_request.return_value = \ self.client.do_request.return_value = utils.FakeHTTPResponse(
utils.FakeHTTPResponse(data=expected_data) data=expected_data)
self.assertEqual(self.client.delete_all_queued_images(), 4) self.assertEqual(self.client.delete_all_queued_images(), 4)
self.client.do_request.assert_called_with("DELETE", "/queued_images") self.client.do_request.assert_called_with("DELETE", "/queued_images")

View File

@ -49,6 +49,7 @@ from glance.db.sqlalchemy import models
from glance.openstack.common import jsonutils from glance.openstack.common import jsonutils
from glance.openstack.common import timeutils from glance.openstack.common import timeutils
CONF = cfg.CONF CONF = cfg.CONF
CONF.import_opt('metadata_encryption_key', 'glance.common.config') CONF.import_opt('metadata_encryption_key', 'glance.common.config')
@ -319,9 +320,8 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
uuids = {} uuids = {}
for name in ('kernel', 'ramdisk', 'normal'): for name in ('kernel', 'ramdisk', 'normal'):
image_name = '%s migration 012 test' % name image_name = '%s migration 012 test' % name
rows = images.select()\ rows = images.select().where(
.where(images.c.name == image_name)\ images.c.name == image_name).execute().fetchall()
.execute().fetchall()
self.assertEqual(len(rows), 1) self.assertEqual(len(rows), 1)
@ -331,19 +331,16 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
uuids[name] = row['id'] uuids[name] = row['id']
# Find all image_members to ensure image_id has been updated # Find all image_members to ensure image_id has been updated
results = image_members.select()\ results = image_members.select().where(
.where(image_members.c.image_id == image_members.c.image_id == uuids['normal']).execute().fetchall()
uuids['normal'])\
.execute().fetchall()
self.assertEqual(len(results), 1) self.assertEqual(len(results), 1)
# Find all image_properties to ensure image_id has been updated # Find all image_properties to ensure image_id has been updated
# as well as ensure kernel_id and ramdisk_id values have been # as well as ensure kernel_id and ramdisk_id values have been
# updated too # updated too
results = image_properties.select()\ results = image_properties.select().where(
.where(image_properties.c.image_id == image_properties.c.image_id == uuids['normal']
uuids['normal'])\ ).execute().fetchall()
.execute().fetchall()
self.assertEqual(len(results), 2) self.assertEqual(len(results), 2)
for row in results: for row in results:
self.assertIn(row['name'], ('kernel_id', 'ramdisk_id')) self.assertIn(row['name'], ('kernel_id', 'ramdisk_id'))
@ -363,9 +360,8 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
ids = {} ids = {}
for name in ('kernel', 'ramdisk', 'normal'): for name in ('kernel', 'ramdisk', 'normal'):
image_name = '%s migration 012 test' % name image_name = '%s migration 012 test' % name
rows = images.select()\ rows = images.select().where(
.where(images.c.name == image_name)\ images.c.name == image_name).execute().fetchall()
.execute().fetchall()
self.assertEqual(len(rows), 1) self.assertEqual(len(rows), 1)
row = rows[0] row = rows[0]
@ -374,19 +370,15 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
ids[name] = row['id'] ids[name] = row['id']
# Find all image_members to ensure image_id has been updated # Find all image_members to ensure image_id has been updated
results = image_members.select()\ results = image_members.select().where(
.where(image_members.c.image_id == image_members.c.image_id == ids['normal']).execute().fetchall()
ids['normal'])\
.execute().fetchall()
self.assertEqual(len(results), 1) self.assertEqual(len(results), 1)
# Find all image_properties to ensure image_id has been updated # Find all image_properties to ensure image_id has been updated
# as well as ensure kernel_id and ramdisk_id values have been # as well as ensure kernel_id and ramdisk_id values have been
# updated too # updated too
results = image_properties.select()\ results = image_properties.select().where(
.where(image_properties.c.image_id == image_properties.c.image_id == ids['normal']).execute().fetchall()
ids['normal'])\
.execute().fetchall()
self.assertEqual(len(results), 2) self.assertEqual(len(results), 2)
for row in results: for row in results:
self.assertIn(row['name'], ('kernel_id', 'ramdisk_id')) self.assertIn(row['name'], ('kernel_id', 'ramdisk_id'))
@ -670,8 +662,8 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
def _check_026(self, engine, data): def _check_026(self, engine, data):
image_locations = db_utils.get_table(engine, 'image_locations') image_locations = db_utils.get_table(engine, 'image_locations')
results = image_locations.select()\ results = image_locations.select().where(
.where(image_locations.c.image_id == data).execute() image_locations.c.image_id == data).execute()
r = list(results) r = list(results)
self.assertEqual(len(r), 1) self.assertEqual(len(r), 1)
@ -756,8 +748,8 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
image_id = data[1] image_id = data[1]
image_locations = db_utils.get_table(engine, 'image_locations') image_locations = db_utils.get_table(engine, 'image_locations')
records = image_locations.select().\ records = image_locations.select().where(
where(image_locations.c.image_id == image_id).execute().fetchall() image_locations.c.image_id == image_id).execute().fetchall()
for r in records: for r in records:
d = jsonutils.loads(r['meta_data']) d = jsonutils.loads(r['meta_data'])
@ -768,8 +760,8 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
image_locations = db_utils.get_table(engine, 'image_locations') image_locations = db_utils.get_table(engine, 'image_locations')
records = image_locations.select().\ records = image_locations.select().where(
where(image_locations.c.image_id == image_id).execute().fetchall() image_locations.c.image_id == image_id).execute().fetchall()
for r in records: for r in records:
md = r['meta_data'] md = r['meta_data']
@ -855,9 +847,8 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
def _check_031(self, engine, image_id): def _check_031(self, engine, image_id):
locations_table = db_utils.get_table(engine, 'image_locations') locations_table = db_utils.get_table(engine, 'image_locations')
result = locations_table.select()\ result = locations_table.select().where(
.where(locations_table.c.image_id == image_id)\ locations_table.c.image_id == image_id).execute().fetchall()
.execute().fetchall()
locations = set([(x['value'], x['meta_data']) for x in result]) locations = set([(x['value'], x['meta_data']) for x in result])
actual_locations = set([ actual_locations = set([
@ -980,8 +971,8 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
'deleted', 'pending_delete', 'deleted'] 'deleted', 'pending_delete', 'deleted']
for (idx, image_id) in enumerate(data): for (idx, image_id) in enumerate(data):
results = image_locations.select()\ results = image_locations.select().where(
.where(image_locations.c.image_id == image_id).execute() image_locations.c.image_id == image_id).execute()
r = list(results) r = list(results)
self.assertEqual(len(r), 1) self.assertEqual(len(r), 1)
self.assertIn('status', r[0]) self.assertIn('status', r[0])

View File

@ -12,11 +12,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import uuid
import mock import mock
from mock import patch from mock import patch
import uuid
import six import six
from glance.common import exception from glance.common import exception
@ -592,16 +591,16 @@ class TestImageMemberQuotas(test_utils.BaseTestCase):
self.image_member_factory.new_image_member(self.image, self.image_member_factory.new_image_member(self.image,
'fake_id') 'fake_id')
self.base_image_member_factory.new_image_member\ nim = self.base_image_member_factory.new_image_member
.assert_called_once_with(self.image.base, 'fake_id') nim .assert_called_once_with(self.image.base, 'fake_id')
def test_new_image_member_unlimited_members(self): def test_new_image_member_unlimited_members(self):
self.config(image_member_quota=-1) self.config(image_member_quota=-1)
self.image_member_factory.new_image_member(self.image, self.image_member_factory.new_image_member(self.image,
'fake_id') 'fake_id')
self.base_image_member_factory.new_image_member\ nim = self.base_image_member_factory.new_image_member
.assert_called_once_with(self.image.base, 'fake_id') nim.assert_called_once_with(self.image.base, 'fake_id')
def test_new_image_member_too_many_members(self): def test_new_image_member_too_many_members(self):
self.config(image_member_quota=0) self.config(image_member_quota=0)

View File

@ -12,9 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mox
import glance_store import glance_store
import mox
from glance.common import exception from glance.common import exception
import glance.location import glance.location

View File

@ -12,10 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock
import glance_store import glance_store
import mock
import glance.location import glance.location
from glance.tests.unit import base from glance.tests.unit import base

View File

@ -38,7 +38,6 @@ from glance.db.sqlalchemy import api as db_api
from glance.db.sqlalchemy import models as db_models from glance.db.sqlalchemy import models as db_models
from glance.openstack.common import jsonutils from glance.openstack.common import jsonutils
from glance.openstack.common import timeutils from glance.openstack.common import timeutils
import glance.registry.client.v1.api as registry import glance.registry.client.v1.api as registry
from glance.tests.unit import base from glance.tests.unit import base
import glance.tests.unit.utils as unit_test_utils import glance.tests.unit.utils as unit_test_utils
@ -1406,20 +1405,19 @@ class TestGlanceAPI(base.IsolatedUnitTest):
req = webob.Request.blank("/images/%s" % image_id) req = webob.Request.blank("/images/%s" % image_id)
req.method = 'PUT' req.method = 'PUT'
req.headers['Content-Type'] = \ req.headers['Content-Type'] = 'application/octet-stream'
'application/octet-stream'
req.body = "chunk00000remainder" req.body = "chunk00000remainder"
with mock.patch.object(upload_utils, 'initiate_deletion') as \ with mock.patch.object(
mock_init_del: upload_utils, 'initiate_deletion') as mock_init_del:
mock_init_del.side_effect = mock_initiate_deletion mock_init_del.side_effect = mock_initiate_deletion
with mock.patch.object(registry, 'get_image_metadata') as \ with mock.patch.object(
mock_get_meta: registry, 'get_image_metadata') as mock_get_meta:
mock_get_meta.side_effect = mock_get_image_metadata mock_get_meta.side_effect = mock_get_image_metadata
with mock.patch.object(db_api, '_image_get') as mock_db_get: with mock.patch.object(db_api, '_image_get') as mock_db_get:
mock_db_get.side_effect = mock_image_get mock_db_get.side_effect = mock_image_get
with mock.patch.object(db_api, '_image_update') as \ with mock.patch.object(
mock_db_update: db_api, '_image_update') as mock_db_update:
mock_db_update.side_effect = mock_image_update mock_db_update.side_effect = mock_image_update
# Expect a 409 Conflict. # Expect a 409 Conflict.

View File

@ -32,7 +32,6 @@ from glance.db.sqlalchemy import api as db_api
from glance.db.sqlalchemy import models as db_models from glance.db.sqlalchemy import models as db_models
from glance.openstack.common import jsonutils from glance.openstack.common import jsonutils
from glance.openstack.common import timeutils from glance.openstack.common import timeutils
from glance.registry.api import v1 as rserver from glance.registry.api import v1 as rserver
from glance.tests.unit import base from glance.tests.unit import base
from glance.tests import utils as test_utils from glance.tests import utils as test_utils
@ -1287,8 +1286,8 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
self.log_image_id = False self.log_image_id = False
def fake_log_info(msg): def fake_log_info(msg):
if 'Successfully created image ' \ if ('Successfully created image '
'0564c64c-3545-4e34-abfb-9d18e5f2f2f9' in msg: '0564c64c-3545-4e34-abfb-9d18e5f2f2f9' in msg):
self.log_image_id = True self.log_image_id = True
self.stubs.Set(rserver.images.LOG, 'info', fake_log_info) self.stubs.Set(rserver.images.LOG, 'info', fake_log_info)
@ -1940,7 +1939,8 @@ class TestSharability(test_utils.BaseTestCase):
auth_tok='user:%s:admin' % TENANT2, auth_tok='user:%s:admin' % TENANT2,
owner_is_tenant=False) owner_is_tenant=False)
UUIDX = str(uuid.uuid4()) UUIDX = str(uuid.uuid4())
#we need private image and context.owner should not match image owner # We need private image and context.owner should not match image
# owner
image = db_api.image_create(ctxt1, {'id': UUIDX, image = db_api.image_create(ctxt1, {'id': UUIDX,
'status': 'queued', 'status': 'queued',
'is_public': False, 'is_public': False,
@ -1955,7 +1955,8 @@ class TestSharability(test_utils.BaseTestCase):
auth_tok='user:%s:user' % TENANT1, auth_tok='user:%s:user' % TENANT1,
owner_is_tenant=True) owner_is_tenant=True)
UUIDX = str(uuid.uuid4()) UUIDX = str(uuid.uuid4())
#we need private image and context.owner should not match image owner # We need private image and context.owner should not match image
# owner
image = db_api.image_create(ctxt1, {'id': UUIDX, image = db_api.image_create(ctxt1, {'id': UUIDX,
'status': 'queued', 'status': 'queued',
'is_public': False, 'is_public': False,
@ -1974,7 +1975,8 @@ class TestSharability(test_utils.BaseTestCase):
auth_tok='user:%s:user' % TENANT2, auth_tok='user:%s:user' % TENANT2,
owner_is_tenant=False) owner_is_tenant=False)
UUIDX = str(uuid.uuid4()) UUIDX = str(uuid.uuid4())
#we need private image and context.owner should not match image owner # We need private image and context.owner should not match image
# owner
image = db_api.image_create(ctxt1, {'id': UUIDX, image = db_api.image_create(ctxt1, {'id': UUIDX,
'status': 'queued', 'status': 'queued',
'is_public': False, 'is_public': False,
@ -1993,7 +1995,8 @@ class TestSharability(test_utils.BaseTestCase):
auth_tok='user:%s:user' % TENANT2, auth_tok='user:%s:user' % TENANT2,
owner_is_tenant=False) owner_is_tenant=False)
UUIDX = str(uuid.uuid4()) UUIDX = str(uuid.uuid4())
#we need private image and context.owner should not match image owner # We need private image and context.owner should not match image
# owner
image = db_api.image_create(ctxt1, {'id': UUIDX, image = db_api.image_create(ctxt1, {'id': UUIDX,
'status': 'queued', 'status': 'queued',
'is_public': False, 'is_public': False,
@ -2018,7 +2021,8 @@ class TestSharability(test_utils.BaseTestCase):
auth_tok='user:%s:user' % TENANT2, auth_tok='user:%s:user' % TENANT2,
owner_is_tenant=False) owner_is_tenant=False)
UUIDX = str(uuid.uuid4()) UUIDX = str(uuid.uuid4())
#we need private image and context.owner should not match image owner # We need private image and context.owner should not match image
# owner
image = db_api.image_create(ctxt1, {'id': UUIDX, image = db_api.image_create(ctxt1, {'id': UUIDX,
'status': 'queued', 'status': 'queued',
'is_public': False, 'is_public': False,
@ -2042,7 +2046,8 @@ class TestSharability(test_utils.BaseTestCase):
auth_tok='user:%s:user' % TENANT1, auth_tok='user:%s:user' % TENANT1,
owner_is_tenant=True) owner_is_tenant=True)
UUIDX = str(uuid.uuid4()) UUIDX = str(uuid.uuid4())
#we need private image and context.owner should not match image owner # We need private image and context.owner should not match image
# owner
image = db_api.image_create(ctxt1, {'id': UUIDX, image = db_api.image_create(ctxt1, {'id': UUIDX,
'status': 'queued', 'status': 'queued',
'is_public': False, 'is_public': False,

View File

@ -14,10 +14,10 @@
# under the License. # under the License.
from contextlib import contextmanager from contextlib import contextmanager
import mock
from mock import patch
import glance_store import glance_store
import mock
from mock import patch
import webob.exc import webob.exc
from glance.api.v1 import upload_utils from glance.api.v1 import upload_utils

View File

@ -12,18 +12,16 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock
import uuid import uuid
import glance_store import glance_store
import mock
import six import six
import webob import webob
import glance.api.v2.image_data import glance.api.v2.image_data
from glance.common import exception from glance.common import exception
from glance.common import wsgi from glance.common import wsgi
from glance.tests.unit import base from glance.tests.unit import base
import glance.tests.unit.utils as unit_test_utils import glance.tests.unit.utils as unit_test_utils
import glance.tests.utils as test_utils import glance.tests.utils as test_utils

View File

@ -24,7 +24,6 @@ from glance.openstack.common import jsonutils
import glance.tests.unit.utils as unit_test_utils import glance.tests.unit.utils as unit_test_utils
import glance.tests.utils as test_utils import glance.tests.utils as test_utils
DATETIME = datetime.datetime(2012, 5, 16, 15, 27, 36, 325355) DATETIME = datetime.datetime(2012, 5, 16, 15, 27, 36, 325355)
ISOTIME = '2012-05-16T15:27:36Z' ISOTIME = '2012-05-16T15:27:36Z'
@ -97,8 +96,8 @@ class TestImageMembersController(test_utils.BaseTestCase):
self.notifier = unit_test_utils.FakeNotifier() self.notifier = unit_test_utils.FakeNotifier()
self._create_images() self._create_images()
self._create_image_members() self._create_image_members()
self.controller = glance.api.v2.image_members\ self.controller = glance.api.v2.image_members.ImageMembersController(
.ImageMembersController(self.db, self.db,
self.policy, self.policy,
self.notifier, self.notifier,
self.store) self.store)

View File

@ -848,8 +848,7 @@ class TestImagesController(base.IsolatedUnitTest):
self.assertEqual(resp.container_format, 'bare') self.assertEqual(resp.container_format, 'bare')
def test_update_remove_property_while_over_limit(self): def test_update_remove_property_while_over_limit(self):
""" """Ensure that image properties can be removed.
Ensure that image properties can be removed.
Image properties should be able to be removed as long as the image has Image properties should be able to be removed as long as the image has
fewer than the limited number of image properties after the fewer than the limited number of image properties after the
@ -879,8 +878,7 @@ class TestImagesController(base.IsolatedUnitTest):
self.assertNotEqual(output.created_at, output.updated_at) self.assertNotEqual(output.created_at, output.updated_at)
def test_update_add_and_remove_property_under_limit(self): def test_update_add_and_remove_property_under_limit(self):
""" """Ensure that image properties can be removed.
Ensure that image properties can be removed.
Image properties should be able to be added and removed simultaneously Image properties should be able to be added and removed simultaneously
as long as the image has fewer than the limited number of image as long as the image has fewer than the limited number of image
@ -1132,10 +1130,7 @@ class TestImagesController(base.IsolatedUnitTest):
another_request, created_image.image_id, changes) another_request, created_image.image_id, changes)
def test_create_non_protected_prop(self): def test_create_non_protected_prop(self):
""" """Property marked with special char @ creatable by an unknown role"""
Verify property marked with special char '@' is creatable by an unknown
role
"""
self.set_property_protections() self.set_property_protections()
request = unit_test_utils.get_fake_request(roles=['admin']) request = unit_test_utils.get_fake_request(roles=['admin'])
image = {'name': 'image-1'} image = {'name': 'image-1'}
@ -1154,10 +1149,7 @@ class TestImagesController(base.IsolatedUnitTest):
'2') '2')
def test_read_non_protected_prop(self): def test_read_non_protected_prop(self):
""" """Property marked with special char @ readable by an unknown role"""
Verify property marked with special char '@' is readable by an unknown
role
"""
self.set_property_protections() self.set_property_protections()
request = unit_test_utils.get_fake_request(roles=['admin']) request = unit_test_utils.get_fake_request(roles=['admin'])
image = {'name': 'image-1'} image = {'name': 'image-1'}
@ -1170,10 +1162,7 @@ class TestImagesController(base.IsolatedUnitTest):
self.assertEqual(output.extra_properties['x_all_permitted'], '1') self.assertEqual(output.extra_properties['x_all_permitted'], '1')
def test_update_non_protected_prop(self): def test_update_non_protected_prop(self):
""" """Property marked with special char @ updatable by an unknown role"""
Verify property marked with special char '@' is updatable by an unknown
role
"""
self.set_property_protections() self.set_property_protections()
request = unit_test_utils.get_fake_request(roles=['admin']) request = unit_test_utils.get_fake_request(roles=['admin'])
image = {'name': 'image-1'} image = {'name': 'image-1'}
@ -1190,10 +1179,7 @@ class TestImagesController(base.IsolatedUnitTest):
self.assertEqual(output.extra_properties['x_all_permitted'], 'baz') self.assertEqual(output.extra_properties['x_all_permitted'], 'baz')
def test_delete_non_protected_prop(self): def test_delete_non_protected_prop(self):
""" """Property marked with special char @ deletable by an unknown role"""
Verify property marked with special char '@' is deletable by an unknown
role
"""
self.set_property_protections() self.set_property_protections()
request = unit_test_utils.get_fake_request(roles=['admin']) request = unit_test_utils.get_fake_request(roles=['admin'])
image = {'name': 'image-1'} image = {'name': 'image-1'}
@ -1211,9 +1197,7 @@ class TestImagesController(base.IsolatedUnitTest):
'x_all_permitted') 'x_all_permitted')
def test_create_locked_down_protected_prop(self): def test_create_locked_down_protected_prop(self):
""" """Property marked with special char ! creatable by no one"""
Verify a property protected by special char '!' is creatable by no one
"""
self.set_property_protections() self.set_property_protections()
request = unit_test_utils.get_fake_request(roles=['admin']) request = unit_test_utils.get_fake_request(roles=['admin'])
image = {'name': 'image-1'} image = {'name': 'image-1'}
@ -1230,9 +1214,7 @@ class TestImagesController(base.IsolatedUnitTest):
created_image.image_id, changes) created_image.image_id, changes)
def test_read_locked_down_protected_prop(self): def test_read_locked_down_protected_prop(self):
""" """Property marked with special char ! readable by no one"""
Verify a property protected by special char '!' is readable by no one
"""
self.set_property_protections() self.set_property_protections()
request = unit_test_utils.get_fake_request(roles=['member']) request = unit_test_utils.get_fake_request(roles=['member'])
image = {'name': 'image-1'} image = {'name': 'image-1'}
@ -1246,9 +1228,7 @@ class TestImagesController(base.IsolatedUnitTest):
'x_none_read') 'x_none_read')
def test_update_locked_down_protected_prop(self): def test_update_locked_down_protected_prop(self):
""" """Property marked with special char ! updatable by no one"""
Verify a property protected by special char '!' is updatable by no one
"""
self.set_property_protections() self.set_property_protections()
request = unit_test_utils.get_fake_request(roles=['admin']) request = unit_test_utils.get_fake_request(roles=['admin'])
image = {'name': 'image-1'} image = {'name': 'image-1'}
@ -1264,9 +1244,7 @@ class TestImagesController(base.IsolatedUnitTest):
another_request, created_image.image_id, changes) another_request, created_image.image_id, changes)
def test_delete_locked_down_protected_prop(self): def test_delete_locked_down_protected_prop(self):
""" """Property marked with special char ! deletable by no one"""
Verify a property protected by special char '!' is deletable by no one
"""
self.set_property_protections() self.set_property_protections()
request = unit_test_utils.get_fake_request(roles=['admin']) request = unit_test_utils.get_fake_request(roles=['admin'])
image = {'name': 'image-1'} image = {'name': 'image-1'}
@ -1559,8 +1537,7 @@ class TestImagesController(base.IsolatedUnitTest):
self.assertNotEqual(output.created_at, output.updated_at) self.assertNotEqual(output.created_at, output.updated_at)
def test_update_remove_location_while_over_limit(self): def test_update_remove_location_while_over_limit(self):
""" """Ensure that image locations can be removed.
Ensure that image locations can be removed.
Image locations should be able to be removed as long as the image has Image locations should be able to be removed as long as the image has
fewer than the limited number of image locations after the fewer than the limited number of image locations after the
@ -1592,8 +1569,7 @@ class TestImagesController(base.IsolatedUnitTest):
self.assertNotEqual(output.created_at, output.updated_at) self.assertNotEqual(output.created_at, output.updated_at)
def test_update_add_and_remove_location_under_limit(self): def test_update_add_and_remove_location_under_limit(self):
""" """Ensure that image locations can be removed.
Ensure that image locations can be removed.
Image locations should be able to be added and removed simultaneously Image locations should be able to be added and removed simultaneously
as long as the image has fewer than the limited number of image as long as the image has fewer than the limited number of image
@ -1787,9 +1763,9 @@ class TestImagesController(base.IsolatedUnitTest):
self.assertEqual(image['status'], 'deleted') self.assertEqual(image['status'], 'deleted')
def test_delete_queued_updates_status_delayed_delete(self): def test_delete_queued_updates_status_delayed_delete(self):
""" """Ensure status of queued image is updated (LP bug #1048851).
Ensure status of queued image is updated (LP bug #1048851)
to 'deleted' when delayed_delete isenabled Must be set to 'deleted' when delayed_delete isenabled.
""" """
scrubber_dir = os.path.join(self.test_dir, 'scrubber') scrubber_dir = os.path.join(self.test_dir, 'scrubber')
self.config(delayed_delete=True, scrubber_datadir=scrubber_dir) self.config(delayed_delete=True, scrubber_datadir=scrubber_dir)
@ -2054,13 +2030,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
def test_create_readonly_attributes_forbidden(self): def test_create_readonly_attributes_forbidden(self):
bodies = [ bodies = [
#{'created_at': ISOTIME},
#{'updated_at': ISOTIME},
#{'status': 'saving'},
{'direct_url': 'http://example.com'}, {'direct_url': 'http://example.com'},
#{'size': 10},
#{'virtual_size': 10},
#{'checksum': 'asdf'},
{'self': 'http://example.com'}, {'self': 'http://example.com'},
{'file': 'http://example.com'}, {'file': 'http://example.com'},
{'schema': 'http://example.com'}, {'schema': 'http://example.com'},
@ -2779,9 +2749,11 @@ class TestImagesSerializer(test_utils.BaseTestCase):
unit_test_utils.sort_url_by_qs_keys(output['next'])) unit_test_utils.sort_url_by_qs_keys(output['next']))
def test_index_forbidden_get_image_location(self): def test_index_forbidden_get_image_location(self):
"""Make sure the serializer works fine no mater if current user is """Make sure the serializer works fine.
authorized to get image location if the show_multiple_locations is
False. No mater if current user is authorized to get image location if the
show_multiple_locations is False.
""" """
class ImageLocations(object): class ImageLocations(object):
def __len__(self): def __len__(self):
@ -3173,8 +3145,10 @@ class TestImagesSerializerWithAdditionalProperties(test_utils.BaseTestCase):
self.assertEqual(expected, jsonutils.loads(response.body)) self.assertEqual(expected, jsonutils.loads(response.body))
def test_show_invalid_additional_property(self): def test_show_invalid_additional_property(self):
"""Ensure that the serializer passes through invalid additional """Ensure that the serializer passes
properties (i.e. non-string) without complaining. through invalid additional properties.
It must not complains with i.e. non-string.
""" """
serializer = glance.api.v2.images.ResponseSerializer() serializer = glance.api.v2.images.ResponseSerializer()
self.fixture.extra_properties['marx'] = 123 self.fixture.extra_properties['marx'] = 123

View File

@ -30,7 +30,6 @@ from glance.db.sqlalchemy import api as db_api
from glance.db.sqlalchemy import models as db_models from glance.db.sqlalchemy import models as db_models
from glance.openstack.common import jsonutils from glance.openstack.common import jsonutils
from glance.openstack.common import timeutils from glance.openstack.common import timeutils
from glance.registry.api import v2 as rserver from glance.registry.api import v2 as rserver
from glance.tests.unit import base from glance.tests.unit import base
from glance.tests import utils as test_utils from glance.tests import utils as test_utils
@ -114,10 +113,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
db_models.register_models(db_api.get_engine()) db_models.register_models(db_api.get_engine())
def test_show(self): def test_show(self):
""" """Tests that registry API endpoint returns the expected image."""
Tests that registry API endpoint
returns the expected image
"""
fixture = {'id': UUID2, fixture = {'id': UUID2,
'name': 'fake image #2', 'name': 'fake image #2',
'size': 19, 'size': 19,
@ -139,10 +135,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(v, image[k]) self.assertEqual(v, image[k])
def test_show_unknown(self): def test_show_unknown(self):
""" """Tests the registry API endpoint returns 404 for an unknown id."""
Tests that the registry API endpoint
returns a 404 for an unknown image id
"""
req = webob.Request.blank('/rpc') req = webob.Request.blank('/rpc')
req.method = "POST" req.method = "POST"
cmd = [{ cmd = [{
@ -156,10 +149,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
'glance.common.exception.NotFound') 'glance.common.exception.NotFound')
def test_get_index(self): def test_get_index(self):
""" """Tests that the image_get_all command returns list of images."""
Tests that the image_get_all command returns list of
images
"""
fixture = {'id': UUID2, fixture = {'id': UUID2,
'name': 'fake image #2', 'name': 'fake image #2',
'size': 19, 'size': 19,
@ -183,9 +173,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(v, images[0][k]) self.assertEqual(v, images[0][k])
def test_get_index_marker(self): def test_get_index_marker(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images that conforms to a marker query param Must conforms to a marker query param.
""" """
uuid5_time = timeutils.utcnow() + datetime.timedelta(seconds=10) uuid5_time = timeutils.utcnow() + datetime.timedelta(seconds=10)
uuid4_time = uuid5_time + datetime.timedelta(seconds=5) uuid4_time = uuid5_time + datetime.timedelta(seconds=5)
@ -450,10 +440,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(len(images), 0) self.assertEqual(len(images), 0)
def test_get_index_unknown_marker(self): def test_get_index_unknown_marker(self):
""" """Tests the registry API returns a NotFound with unknown marker."""
Tests that the registry API returns a NotFound
when an unknown marker is provided
"""
req = webob.Request.blank('/rpc') req = webob.Request.blank('/rpc')
req.method = "POST" req.method = "POST"
cmd = [{ cmd = [{
@ -468,9 +455,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertIn("NotFound", result["_error"]["cls"]) self.assertIn("NotFound", result["_error"]["cls"])
def test_get_index_limit(self): def test_get_index_limit(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images that conforms to a limit query param Must conforms to a limit query param.
""" """
uuid3_time = timeutils.utcnow() + datetime.timedelta(seconds=10) uuid3_time = timeutils.utcnow() + datetime.timedelta(seconds=10)
uuid4_time = uuid3_time + datetime.timedelta(seconds=5) uuid4_time = uuid3_time + datetime.timedelta(seconds=5)
@ -521,9 +508,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(images[0]['id'], UUID4) self.assertEqual(images[0]['id'], UUID4)
def test_get_index_limit_marker(self): def test_get_index_limit_marker(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images that conforms to limit and marker query params Must conforms to limit and marker query params.
""" """
uuid3_time = timeutils.utcnow() + datetime.timedelta(seconds=10) uuid3_time = timeutils.utcnow() + datetime.timedelta(seconds=10)
uuid4_time = uuid3_time + datetime.timedelta(seconds=5) uuid4_time = uuid3_time + datetime.timedelta(seconds=5)
@ -573,10 +560,11 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(images[0]['id'], UUID2) self.assertEqual(images[0]['id'], UUID2)
def test_get_index_filter_name(self): def test_get_index_filter_name(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images that have a specific name. This is really a sanity Use a specific name. This is really a sanity check, filtering is
check, filtering is tested more in-depth using /images/detail tested more in-depth using /images/detail
""" """
extra_fixture = {'id': _gen_uuid(), extra_fixture = {'id': _gen_uuid(),
'status': 'active', 'status': 'active',
@ -618,9 +606,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual('new name! #123', image['name']) self.assertEqual('new name! #123', image['name'])
def test_get_index_filter_on_user_defined_properties(self): def test_get_index_filter_on_user_defined_properties(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images that have a specific user-defined properties. Use a specific user-defined properties.
""" """
properties = {'distro': 'ubuntu', 'arch': 'i386', 'type': 'kernel'} properties = {'distro': 'ubuntu', 'arch': 'i386', 'type': 'kernel'}
extra_id = _gen_uuid() extra_id = _gen_uuid()
@ -728,9 +716,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(len(images), 0) self.assertEqual(len(images), 0)
def test_get_index_sort_default_created_at_desc(self): def test_get_index_sort_default_created_at_desc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images that conforms to a default sort key/dir Must conforms to a default sort key/dir.
""" """
uuid5_time = timeutils.utcnow() + datetime.timedelta(seconds=10) uuid5_time = timeutils.utcnow() + datetime.timedelta(seconds=10)
uuid4_time = uuid5_time + datetime.timedelta(seconds=5) uuid4_time = uuid5_time + datetime.timedelta(seconds=5)
@ -800,10 +788,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(images[4]['id'], UUID1) self.assertEqual(images[4]['id'], UUID1)
def test_get_index_sort_name_asc(self): def test_get_index_sort_name_asc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted alphabetically by name in Must be sorted alphabetically by name in ascending order.
ascending order.
""" """
UUID3 = _gen_uuid() UUID3 = _gen_uuid()
extra_fixture = {'id': UUID3, extra_fixture = {'id': UUID3,
@ -860,10 +847,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(images[4]['id'], UUID4) self.assertEqual(images[4]['id'], UUID4)
def test_get_index_sort_status_desc(self): def test_get_index_sort_status_desc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted alphabetically by status in Must be sorted alphabetically by status in descending order.
descending order.
""" """
uuid4_time = timeutils.utcnow() + datetime.timedelta(seconds=10) uuid4_time = timeutils.utcnow() + datetime.timedelta(seconds=10)
@ -912,10 +898,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(images[3]['id'], UUID3) self.assertEqual(images[3]['id'], UUID3)
def test_get_index_sort_disk_format_asc(self): def test_get_index_sort_disk_format_asc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted alphabetically by disk_format in Must be sorted alphabetically by disk_format in ascending order.
ascending order.
""" """
uuid3_time = timeutils.utcnow() + datetime.timedelta(seconds=5) uuid3_time = timeutils.utcnow() + datetime.timedelta(seconds=5)
@ -964,10 +949,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(images[3]['id'], UUID2) self.assertEqual(images[3]['id'], UUID2)
def test_get_index_sort_container_format_desc(self): def test_get_index_sort_container_format_desc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted alphabetically by container_format in Must be sorted alphabetically by container_format in descending order.
descending order.
""" """
uuid3_time = timeutils.utcnow() + datetime.timedelta(seconds=5) uuid3_time = timeutils.utcnow() + datetime.timedelta(seconds=5)
@ -1017,9 +1001,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(images[3]['id'], UUID1) self.assertEqual(images[3]['id'], UUID1)
def test_get_index_sort_size_asc(self): def test_get_index_sort_size_asc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted by size in ascending order. Must be sorted by size in ascending order.
""" """
UUID3 = _gen_uuid() UUID3 = _gen_uuid()
extra_fixture = {'id': UUID3, extra_fixture = {'id': UUID3,
@ -1065,9 +1049,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(images[3]['id'], UUID3) self.assertEqual(images[3]['id'], UUID3)
def test_get_index_sort_created_at_asc(self): def test_get_index_sort_created_at_asc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted by created_at in ascending order. Must be sorted by created_at in ascending order.
""" """
uuid4_time = timeutils.utcnow() + datetime.timedelta(seconds=10) uuid4_time = timeutils.utcnow() + datetime.timedelta(seconds=10)
uuid3_time = uuid4_time + datetime.timedelta(seconds=5) uuid3_time = uuid4_time + datetime.timedelta(seconds=5)
@ -1120,9 +1104,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertEqual(images[3]['id'], UUID3) self.assertEqual(images[3]['id'], UUID3)
def test_get_index_sort_updated_at_desc(self): def test_get_index_sort_updated_at_desc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted by updated_at in descending order. Must be sorted by updated_at in descending order.
""" """
uuid4_time = timeutils.utcnow() + datetime.timedelta(seconds=10) uuid4_time = timeutils.utcnow() + datetime.timedelta(seconds=10)
uuid3_time = uuid4_time + datetime.timedelta(seconds=5) uuid3_time = uuid4_time + datetime.timedelta(seconds=5)
@ -1383,9 +1367,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
self.assertTrue(deleted_image['deleted_at']) self.assertTrue(deleted_image['deleted_at'])
def test_get_image_members(self): def test_get_image_members(self):
""" """Tests members listing for existing images."""
Tests members listing for existing images
"""
req = webob.Request.blank('/rpc') req = webob.Request.blank('/rpc')
req.method = 'POST' req.method = 'POST'
cmd = [{ cmd = [{

View File

@ -31,7 +31,6 @@ from glance.common import exception
from glance import context from glance import context
from glance.db.sqlalchemy import api as db_api from glance.db.sqlalchemy import api as db_api
from glance.openstack.common import timeutils from glance.openstack.common import timeutils
from glance.registry.api import v2 as rserver from glance.registry.api import v2 as rserver
import glance.registry.client.v2.api as rapi import glance.registry.client.v2.api as rapi
from glance.registry.client.v2.api import client as rclient from glance.registry.client.v2.api import client as rclient
@ -50,9 +49,9 @@ config.parse_args(args=[])
class TestRegistryV2Client(base.IsolatedUnitTest, class TestRegistryV2Client(base.IsolatedUnitTest,
test_utils.RegistryAPIMixIn): test_utils.RegistryAPIMixIn):
""" """Test proper actions made against a registry service.
Test proper actions made for both valid and invalid requests
against a Registry service Test for both valid and invalid requests.
""" """
# Registry server to user # Registry server to user
@ -101,10 +100,9 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
self.assertEqual(0, image["min_disk"]) self.assertEqual(0, image["min_disk"])
def test_get_index_sort_name_asc(self): def test_get_index_sort_name_asc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted alphabetically by name in Must be sorted alphabetically by name in ascending order.
ascending order.
""" """
UUID3 = _gen_uuid() UUID3 = _gen_uuid()
extra_fixture = self.get_fixture(id=UUID3, name='asdf') extra_fixture = self.get_fixture(id=UUID3, name='asdf')
@ -122,10 +120,9 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
unjsonify=False) unjsonify=False)
def test_get_index_sort_status_desc(self): def test_get_index_sort_status_desc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted alphabetically by status in Must be sorted alphabetically by status in descending order.
descending order.
""" """
uuid4_time = timeutils.utcnow() + datetime.timedelta(seconds=10) uuid4_time = timeutils.utcnow() + datetime.timedelta(seconds=10)
@ -147,10 +144,9 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
unjsonify=False) unjsonify=False)
def test_get_index_sort_disk_format_asc(self): def test_get_index_sort_disk_format_asc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted alphabetically by disk_format in Must besorted alphabetically by disk_format in ascending order.
ascending order.
""" """
UUID3 = _gen_uuid() UUID3 = _gen_uuid()
extra_fixture = self.get_fixture(id=UUID3, name='asdf', extra_fixture = self.get_fixture(id=UUID3, name='asdf',
@ -172,10 +168,9 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
unjsonify=False) unjsonify=False)
def test_get_index_sort_container_format_desc(self): def test_get_index_sort_container_format_desc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted alphabetically by container_format in Must be sorted alphabetically by container_format in descending order.
descending order.
""" """
UUID3 = _gen_uuid() UUID3 = _gen_uuid()
extra_fixture = self.get_fixture(id=UUID3, name='asdf', extra_fixture = self.get_fixture(id=UUID3, name='asdf',
@ -198,9 +193,9 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
unjsonify=False) unjsonify=False)
def test_get_index_sort_size_asc(self): def test_get_index_sort_size_asc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted by size in ascending order. Must be sorted by size in ascending order.
""" """
UUID3 = _gen_uuid() UUID3 = _gen_uuid()
extra_fixture = self.get_fixture(id=UUID3, name='asdf', extra_fixture = self.get_fixture(id=UUID3, name='asdf',
@ -224,9 +219,9 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
unjsonify=False) unjsonify=False)
def test_get_index_sort_created_at_asc(self): def test_get_index_sort_created_at_asc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted by created_at in ascending order. Must be sorted by created_at in ascending order.
""" """
uuid4_time = timeutils.utcnow() + datetime.timedelta(seconds=10) uuid4_time = timeutils.utcnow() + datetime.timedelta(seconds=10)
uuid3_time = uuid4_time + datetime.timedelta(seconds=5) uuid3_time = uuid4_time + datetime.timedelta(seconds=5)
@ -248,9 +243,9 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
unjsonify=False) unjsonify=False)
def test_get_index_sort_updated_at_desc(self): def test_get_index_sort_updated_at_desc(self):
""" """Tests that the registry API returns list of public images.
Tests that the registry API returns list of
public images sorted by updated_at in descending order. Must be sorted by updated_at in descending order.
""" """
uuid4_time = timeutils.utcnow() + datetime.timedelta(seconds=10) uuid4_time = timeutils.utcnow() + datetime.timedelta(seconds=10)
uuid3_time = uuid4_time + datetime.timedelta(seconds=5) uuid3_time = uuid4_time + datetime.timedelta(seconds=5)
@ -354,9 +349,9 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
self.assertEqual(len(images), 4) self.assertEqual(len(images), 4)
def test_image_get_index_by_name(self): def test_image_get_index_by_name(self):
""" """Test correct set of public, name-filtered image returned.
Test correct set of public, name-filtered image returned. This
is just a sanity check, we test the details call more in-depth. This is just a sanity check, we test the details call more in-depth.
""" """
extra_fixture = self.get_fixture(id=_gen_uuid(), extra_fixture = self.get_fixture(id=_gen_uuid(),
name='new name! #123') name='new name! #123')
@ -577,10 +572,9 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
class TestRegistryV2ClientApi(base.IsolatedUnitTest): class TestRegistryV2ClientApi(base.IsolatedUnitTest):
"""Test proper actions made against a registry service.
""" Test for both valid and invalid requests.
Test proper actions made for both valid and invalid requests
against a Registry service
""" """
def setUp(self): def setUp(self):

View File

@ -294,9 +294,9 @@ def execute(cmd,
exitcode = 0 exitcode = 0
if exitcode != expected_exitcode and raise_error: if exitcode != expected_exitcode and raise_error:
msg = "Command %(cmd)s did not succeed. Returned an exit "\ msg = "Command %(cmd)s did not succeed. Returned an exit "
"code of %(exitcode)d."\ "code of %(exitcode)d."
"\n\nSTDOUT: %(out)s"\ "\n\nSTDOUT: %(out)s"
"\n\nSTDERR: %(err)s" % {'cmd': cmd, 'exitcode': exitcode, "\n\nSTDERR: %(err)s" % {'cmd': cmd, 'exitcode': exitcode,
'out': out, 'err': err} 'out': out, 'err': err}
if context: if context:

View File

@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8 # Hacking already pins down pep8, pyflakes and flake8
hacking>=0.8.0,<0.9 hacking>=0.9.2,<0.10
# For translations processing # For translations processing
Babel>=1.3 Babel>=1.3

View File

@ -42,18 +42,17 @@
"""Display a subunit stream through a colorized unittest test runner.""" """Display a subunit stream through a colorized unittest test runner."""
import heapq import heapq
import subunit
import sys import sys
import unittest import unittest
import subunit
import testtools import testtools
class _AnsiColorizer(object): class _AnsiColorizer(object):
""" """A colorizer is an object that loosely wraps around a stream.
A colorizer is an object that loosely wraps around a stream, allowing
callers to write text to the stream in a particular color.
That allows callers to write text to the stream in a particular color.
Colorizer classes must implement C{supported()} and C{write(text, color)}. Colorizer classes must implement C{supported()} and C{write(text, color)}.
""" """
_colors = dict(black=30, red=31, green=32, yellow=33, _colors = dict(black=30, red=31, green=32, yellow=33,
@ -64,9 +63,9 @@ class _AnsiColorizer(object):
@staticmethod @staticmethod
def supported(stream=sys.stdout): def supported(stream=sys.stdout):
""" """Method that checks if the current terminal supports coloring.
A method that returns True if the current platform supports
coloring terminal output using this method. Returns False otherwise. Returns True or False.
""" """
if not stream.isatty(): if not stream.isatty():
return False # auto color only on TTYs return False # auto color only on TTYs
@ -86,21 +85,19 @@ class _AnsiColorizer(object):
return False return False
def write(self, text, color): def write(self, text, color):
""" """Write the given text to the stream in the given color.
Write the given text to the stream in the given color.
@param text: Text to be written to the stream. @param text: Text to be written to the stream.
@param color: A string label for a color. e.g. 'red', 'white'. @param color: A string label for a color. e.g. 'red', 'white'.
""" """
color = self._colors[color] color = self._colors[color]
self.stream.write('\x1b[%s;1m%s\x1b[0m' % (color, text)) self.stream.write('\x1b[%s;1m%s\x1b[0m' % (color, text))
class _Win32Colorizer(object): class _Win32Colorizer(object):
""" """See _AnsiColorizer docstring."""
See _AnsiColorizer docstring.
"""
def __init__(self, stream): def __init__(self, stream):
import win32console import win32console
red, green, blue, bold = (win32console.FOREGROUND_RED, red, green, blue, bold = (win32console.FOREGROUND_RED,
@ -148,9 +145,7 @@ class _Win32Colorizer(object):
class _NullColorizer(object): class _NullColorizer(object):
""" """See _AnsiColorizer docstring."""
See _AnsiColorizer docstring.
"""
def __init__(self, stream): def __init__(self, stream):
self.stream = stream self.stream = stream

View File

@ -47,7 +47,9 @@ commands = python setup.py build_sphinx
# H302 import only modules # H302 import only modules
# H402 one line docstring needs punctuation. # H402 one line docstring needs punctuation.
# H404 multi line docstring should start with a summary # H404 multi line docstring should start with a summary
ignore = E711,E712,H302,H402,H404 # H405 multi line docstring summary not separated with an empty line
# H904 Wrap long lines in parentheses instead of a backslash
ignore = E711,E712,H302,H402,H404,H405,H904
builtins = _ builtins = _
exclude = .venv,.git,.tox,dist,doc,etc,*glance/locale*,*openstack/common*,*lib/python*,*egg,build exclude = .venv,.git,.tox,dist,doc,etc,*glance/locale*,*openstack/common*,*lib/python*,*egg,build