**** CubicPower OpenStack Study ****
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Glance exception subclasses"""
import six
import six.moves.urllib.parse as urlparse
_FATAL_EXCEPTION_FORMAT_ERRORS = False
**** CubicPower OpenStack Study ****
class RedirectException(Exception):
**** CubicPower OpenStack Study ****
def __init__(self, url):
self.url = urlparse.urlparse(url)
**** CubicPower OpenStack Study ****
class GlanceException(Exception):
"""
Base Glance Exception
To correctly use this class, inherit from it and
**** CubicPower OpenStack Study ****
def __init__(self, message=None, *args, **kwargs):
if not message:
message = self.message
try:
if kwargs:
message = message % kwargs
except Exception:
if _FATAL_EXCEPTION_FORMAT_ERRORS:
raise
else:
# at least get the core message out if something happened
pass
self.msg = message
super(GlanceException, self).__init__(message)
**** CubicPower OpenStack Study ****
def __unicode__(self):
# NOTE(flwang): By default, self.msg is an instance of Message, which
# can't be converted by str(). Based on the definition of
# __unicode__, it should return unicode always.
return six.text_type(self.msg)
**** CubicPower OpenStack Study ****
class MissingCredentialError(GlanceException):
message = _("Missing required credential: %(required)s")
**** CubicPower OpenStack Study ****
class BadAuthStrategy(GlanceException):
message = _("Incorrect auth strategy, expected \"%(expected)s\" but "
"received \"%(received)s\"")
**** CubicPower OpenStack Study ****
class NotFound(GlanceException):
message = _("An object with the specified identifier was not found.")
**** CubicPower OpenStack Study ****
class UnknownScheme(GlanceException):
message = _("Unknown scheme '%(scheme)s' found in URI")
**** CubicPower OpenStack Study ****
class BadStoreUri(GlanceException):
message = _("The Store URI was malformed.")
**** CubicPower OpenStack Study ****
class Duplicate(GlanceException):
message = _("An object with the same identifier already exists.")
**** CubicPower OpenStack Study ****
class Conflict(GlanceException):
message = _("An object with the same identifier is currently being "
"operated on.")
**** CubicPower OpenStack Study ****
class StorageFull(GlanceException):
message = _("There is not enough disk space on the image storage media.")
**** CubicPower OpenStack Study ****
class StorageQuotaFull(GlanceException):
message = _("The size of the data %(image_size)s will exceed the limit. "
"%(remaining)s bytes remaining.")
**** CubicPower OpenStack Study ****
class StorageWriteDenied(GlanceException):
message = _("Permission to write image storage media denied.")
**** CubicPower OpenStack Study ****
class AuthBadRequest(GlanceException):
message = _("Connect error/bad request to Auth service at URL %(url)s.")
**** CubicPower OpenStack Study ****
class AuthUrlNotFound(GlanceException):
message = _("Auth service at URL %(url)s not found.")
**** CubicPower OpenStack Study ****
class AuthorizationFailure(GlanceException):
message = _("Authorization failed.")
**** CubicPower OpenStack Study ****
class NotAuthenticated(GlanceException):
message = _("You are not authenticated.")
**** CubicPower OpenStack Study ****
class Forbidden(GlanceException):
message = _("You are not authorized to complete this action.")
**** CubicPower OpenStack Study ****
class ForbiddenPublicImage(Forbidden):
message = _("You are not authorized to complete this action.")
**** CubicPower OpenStack Study ****
class ProtectedImageDelete(Forbidden):
message = _("Image %(image_id)s is protected and cannot be deleted.")
**** CubicPower OpenStack Study ****
class Invalid(GlanceException):
message = _("Data supplied was not valid.")
**** CubicPower OpenStack Study ****
class InvalidSortKey(Invalid):
message = _("Sort key supplied was not valid.")
**** CubicPower OpenStack Study ****
class InvalidPropertyProtectionConfiguration(Invalid):
message = _("Invalid configuration in property protection file.")
**** CubicPower OpenStack Study ****
class InvalidFilterRangeValue(Invalid):
message = _("Unable to filter using the specified range.")
**** CubicPower OpenStack Study ****
class ReadonlyProperty(Forbidden):
message = _("Attribute '%(property)s' is read-only.")
**** CubicPower OpenStack Study ****
class ReservedProperty(Forbidden):
message = _("Attribute '%(property)s' is reserved.")
**** CubicPower OpenStack Study ****
class AuthorizationRedirect(GlanceException):
message = _("Redirecting to %(uri)s for authorization.")
**** CubicPower OpenStack Study ****
class ClientConnectionError(GlanceException):
message = _("There was an error connecting to a server")
**** CubicPower OpenStack Study ****
class ClientConfigurationError(GlanceException):
message = _("There was an error configuring the client.")
**** CubicPower OpenStack Study ****
class MultipleChoices(GlanceException):
message = _("The request returned a 302 Multiple Choices. This generally "
"means that you have not included a version indicator in a "
"request URI.\n\nThe body of response returned:\n%(body)s")
**** CubicPower OpenStack Study ****
class LimitExceeded(GlanceException):
message = _("The request returned a 413 Request Entity Too Large. This "
"generally means that rate limiting or a quota threshold was "
"breached.\n\nThe response body:\n%(body)s")
**** CubicPower OpenStack Study ****
def __init__(self, *args, **kwargs):
self.retry_after = (int(kwargs['retry']) if kwargs.get('retry')
else None)
super(LimitExceeded, self).__init__(*args, **kwargs)
**** CubicPower OpenStack Study ****
class ServiceUnavailable(GlanceException):
message = _("The request returned 503 Service Unavilable. This "
"generally occurs on service overload or other transient "
"outage.")
**** CubicPower OpenStack Study ****
def __init__(self, *args, **kwargs):
self.retry_after = (int(kwargs['retry']) if kwargs.get('retry')
else None)
super(ServiceUnavailable, self).__init__(*args, **kwargs)
**** CubicPower OpenStack Study ****
class ServerError(GlanceException):
message = _("The request returned 500 Internal Server Error.")
**** CubicPower OpenStack Study ****
class UnexpectedStatus(GlanceException):
message = _("The request returned an unexpected status: %(status)s."
"\n\nThe response body:\n%(body)s")
**** CubicPower OpenStack Study ****
class InvalidContentType(GlanceException):
message = _("Invalid content type %(content_type)s")
**** CubicPower OpenStack Study ****
class BadRegistryConnectionConfiguration(GlanceException):
message = _("Registry was not configured correctly on API server. "
"Reason: %(reason)s")
**** CubicPower OpenStack Study ****
class BadStoreConfiguration(GlanceException):
message = _("Store %(store_name)s could not be configured correctly. "
"Reason: %(reason)s")
**** CubicPower OpenStack Study ****
class BadDriverConfiguration(GlanceException):
message = _("Driver %(driver_name)s could not be configured correctly. "
"Reason: %(reason)s")
**** CubicPower OpenStack Study ****
class StoreDeleteNotSupported(GlanceException):
message = _("Deleting images from this store is not supported.")
**** CubicPower OpenStack Study ****
class StoreGetNotSupported(GlanceException):
message = _("Getting images from this store is not supported.")
**** CubicPower OpenStack Study ****
class StoreAddNotSupported(GlanceException):
message = _("Adding images to this store is not supported.")
**** CubicPower OpenStack Study ****
class StoreAddDisabled(GlanceException):
message = _("Configuration for store failed. Adding images to this "
"store is disabled.")
**** CubicPower OpenStack Study ****
class MaxRedirectsExceeded(GlanceException):
message = _("Maximum redirects (%(redirects)s) was exceeded.")
**** CubicPower OpenStack Study ****
class InvalidRedirect(GlanceException):
message = _("Received invalid HTTP redirect.")
**** CubicPower OpenStack Study ****
class NoServiceEndpoint(GlanceException):
message = _("Response from Keystone does not contain a Glance endpoint.")
**** CubicPower OpenStack Study ****
class RegionAmbiguity(GlanceException):
message = _("Multiple 'image' service matches for region %(region)s. This "
"generally means that a region is required and you have not "
"supplied one.")
**** CubicPower OpenStack Study ****
class WorkerCreationFailure(GlanceException):
message = _("Server worker creation failed: %(reason)s.")
**** CubicPower OpenStack Study ****
class SchemaLoadError(GlanceException):
message = _("Unable to load schema: %(reason)s")
**** CubicPower OpenStack Study ****
class InvalidObject(GlanceException):
message = _("Provided object does not match schema "
"'%(schema)s': %(reason)s")
**** CubicPower OpenStack Study ****
class UnsupportedHeaderFeature(GlanceException):
message = _("Provided header feature is unsupported: %(feature)s")
**** CubicPower OpenStack Study ****
class InUseByStore(GlanceException):
message = _("The image cannot be deleted because it is in use through "
"the backend store outside of Glance.")
**** CubicPower OpenStack Study ****
class ImageSizeLimitExceeded(GlanceException):
message = _("The provided image is too large.")
**** CubicPower OpenStack Study ****
class ImageMemberLimitExceeded(LimitExceeded):
message = _("The limit has been exceeded on the number of allowed image "
"members for this image. Attempted: %(attempted)s, "
"Maximum: %(maximum)s")
**** CubicPower OpenStack Study ****
class ImagePropertyLimitExceeded(LimitExceeded):
message = _("The limit has been exceeded on the number of allowed image "
"properties. Attempted: %(attempted)s, Maximum: %(maximum)s")
**** CubicPower OpenStack Study ****
class ImageTagLimitExceeded(LimitExceeded):
message = _("The limit has been exceeded on the number of allowed image "
"tags. Attempted: %(attempted)s, Maximum: %(maximum)s")
**** CubicPower OpenStack Study ****
class ImageLocationLimitExceeded(LimitExceeded):
message = _("The limit has been exceeded on the number of allowed image "
"locations. Attempted: %(attempted)s, Maximum: %(maximum)s")
**** CubicPower OpenStack Study ****
class RPCError(GlanceException):
message = _("%(cls)s exception was raised in the last rpc call: %(val)s")
**** CubicPower OpenStack Study ****
class TaskException(GlanceException):
message = _("An unknown task exception occurred")
**** CubicPower OpenStack Study ****
class TaskNotFound(TaskException, NotFound):
message = _("Task with the given id %(task_id)s was not found")
**** CubicPower OpenStack Study ****
class InvalidTaskStatus(TaskException, Invalid):
message = _("Provided status of task is unsupported: %(status)s")
**** CubicPower OpenStack Study ****
class InvalidTaskType(TaskException, Invalid):
message = _("Provided type of task is unsupported: %(type)s")
**** CubicPower OpenStack Study ****
class InvalidTaskStatusTransition(TaskException, Invalid):
message = _("Status transition from %(cur_status)s to"
" %(new_status)s is not allowed")
**** CubicPower OpenStack Study ****
class DuplicateLocation(Duplicate):
message = _("The location %(location)s already exists")
**** CubicPower OpenStack Study ****
class ImageDataNotFound(NotFound):
message = _("No image data could be found")
**** CubicPower OpenStack Study ****
class InvalidParameterValue(Invalid):
message = _("Invalid value '%(value)s' for parameter '%(param)s': "
"%(extra_msg)s")
**** CubicPower OpenStack Study ****
class InvalidImageStatusTransition(Invalid):
message = _("Image status transition from %(cur_status)s to"
" %(new_status)s is not allowed")