octavia.common.exceptions

Source code for octavia.common.exceptions

# Copyright 2011 VMware, Inc, 2014 A10 Networks
# 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.

"""
Octavia base exception handling.
"""

import six

from oslo_utils import excutils
from webob import exc


[docs]class OctaviaException(Exception): """Base Octavia Exception. To correctly use this class, inherit from it and define a 'message' property. That message will get printf'd with the keyword arguments provided to the constructor. """ message = _("An unknown exception occurred.") orig_msg = None orig_code = None def __init__(self, *args, **kwargs): try: if len(args) > 0: self.message = args[0] self.orig_msg = kwargs.get('orig_msg') self.orig_code = kwargs.get('orig_code') super(OctaviaException, self).__init__(self.message % kwargs) self.msg = self.message % kwargs except Exception: with excutils.save_and_reraise_exception() as ctxt: if not self.use_fatal_exceptions(): ctxt.reraise = False # at least get the core message out if something happened super(OctaviaException, self).__init__(self.message) def __unicode__(self): return six.text_type(self.msg)
[docs] @staticmethod def use_fatal_exceptions(): return False
# NOTE(blogan) Using webob exceptions here because WSME exceptions a very # limited at this point and they do not work well in _lookup methods in the # controllers
[docs]class APIException(exc.HTTPClientError): msg = "Something unknown went wrong" code = 500 def __init__(self, **kwargs): self.msg = self.msg % kwargs super(APIException, self).__init__(detail=self.msg)
[docs]class NotFound(APIException): msg = _('%(resource)s %(id)s not found.') code = 404
[docs]class PolicyForbidden(APIException): msg = _("Policy does not allow this request to be performed.") code = 403
[docs]class InvalidOption(APIException): msg = _("%(value)s is not a valid option for %(option)s") code = 400
[docs]class DisabledOption(APIException): msg = _("The selected %(option)s is not allowed in this deployment: " "%(value)s") code = 400
[docs]class L7RuleValidation(APIException): msg = _("Error parsing L7Rule: %(error)s") code = 400
[docs]class SingleCreateDetailsMissing(APIException): msg = _("Missing details for %(type)s object: %(name)") code = 400
[docs]class InvalidHMACException(OctaviaException): message = _("HMAC hashes didn't match")
[docs]class MissingArguments(OctaviaException): message = _("Missing arguments.")
[docs]class NetworkConfig(OctaviaException): message = _("Unable to allocate network resource from config")
[docs]class NeedsPassphrase(OctaviaException): message = _("Passphrase needed to decrypt key but client " "did not provide one.")
[docs]class UnreadableCert(OctaviaException): message = _("Could not read X509 from PEM")
[docs]class MisMatchedKey(OctaviaException): message = _("Key and x509 certificate do not match")
[docs]class CertificateStorageException(OctaviaException): message = _('Could not store certificate: %(msg)s')
[docs]class CertificateGenerationException(OctaviaException): message = _('Could not sign the certificate request: %(msg)s')
[docs]class DuplicateListenerEntry(APIException): msg = _("Another Listener on this Load Balancer " "is already using protocol_port %(port)d") code = 409
[docs]class DuplicateMemberEntry(APIException): msg = _("Another member on this pool is already using ip %(ip_address)s " "on protocol_port %(port)d") code = 409
[docs]class DuplicateHealthMonitor(APIException): msg = _("This pool already has a health monitor") code = 409
[docs]class DuplicatePoolEntry(APIException): msg = _("This listener already has a default pool") code = 409
[docs]class PoolInUseByL7Policy(APIException): msg = _("Pool %(id)s is in use by L7 policy %(l7policy_id)s") code = 409
[docs]class ImmutableObject(APIException): msg = _("%(resource)s %(id)s is immutable and cannot be updated.") code = 409
[docs]class LBPendingStateError(APIException): msg = _("Invalid state %(state)s of loadbalancer resource %(id)s") code = 409
[docs]class TooManyL7RulesOnL7Policy(APIException): msg = _("Too many rules on L7 policy %(id)s") code = 409
[docs]class ComputeBuildException(OctaviaException): message = _("Failed to build compute instance due to: %(fault)s")
[docs]class ComputeBuildQueueTimeoutException(OctaviaException): message = _('Failed to get an amphora build slot.')
[docs]class ComputeDeleteException(OctaviaException): message = _('Failed to delete compute instance.')
[docs]class ComputeGetException(OctaviaException): message = _('Failed to retrieve compute instance.')
[docs]class ComputeStatusException(OctaviaException): message = _('Failed to retrieve compute instance status.')
[docs]class ComputeGetInterfaceException(OctaviaException): message = _('Failed to retrieve compute virtual interfaces.')
[docs]class IDAlreadyExists(APIException): msg = _('Already an entity with that specified id.') code = 409
[docs]class NoReadyAmphoraeException(OctaviaException): message = _('There are not any READY amphora available.')
[docs]class GlanceNoTaggedImages(OctaviaException): message = _("No Glance images are tagged with %(tag)s tag.")
[docs]class NoSuitableAmphoraException(OctaviaException): message = _('Unable to allocate an amphora due to: %(msg)s')
# This is an internal use exception for the taskflow work flow # and will not be exposed to the customer. This means it is a # normal part of operation while waiting for compute to go active # on the instance
[docs]class ComputeWaitTimeoutException(OctaviaException): message = _('Waiting for compute to go active timeout.')
[docs]class InvalidTopology(OctaviaException): message = _('Invalid topology specified: %(topology)s')
# L7 policy and rule exceptions
[docs]class InvalidL7PolicyAction(APIException): msg = _('Invalid L7 Policy action specified: %(action)s') code = 400
[docs]class InvalidL7PolicyArgs(APIException): msg = _('Invalid L7 Policy arguments: %(msg)s') code = 400
[docs]class InvalidURL(OctaviaException): message = _('Not a valid URL: %(url)s')
[docs]class InvalidURLPath(APIException): msg = _('Not a valid URLPath: %(url_path)s') code = 400
[docs]class InvalidString(OctaviaException): message = _('Invalid characters in %(what)s')
[docs]class InvalidRegex(OctaviaException): message = _('Unable to parse regular expression: %(e)s')
[docs]class InvalidL7Rule(OctaviaException): message = _('Invalid L7 Rule: %(msg)s')
[docs]class ServerGroupObjectCreateException(OctaviaException): message = _('Failed to create server group object.')
[docs]class ServerGroupObjectDeleteException(OctaviaException): message = _('Failed to delete server group object.')
[docs]class InvalidAmphoraOperatingSystem(OctaviaException): message = _('Invalid amphora operating system: %(os_name)s')
[docs]class QuotaException(APIException): msg = _('Quota has been met.') code = 403
[docs]class ProjectBusyException(APIException): msg = _('Project busy. Unable to lock the project. Please try again.') code = 503
[docs]class MissingProjectID(OctaviaException): message = _('Missing project ID in request where one is required.')
[docs]class MissingAPIProjectID(APIException): message = _('Missing project ID in request where one is required.') code = 400
[docs]class InvalidSubresource(APIException): msg = _('%(resource)s %(id)s not found.') code = 400
[docs]class ValidationException(APIException): msg = _('Validation failure: %(detail)s') code = 400
[docs]class VIPValidationException(APIException): msg = _('Validation failure: VIP must contain one of: %(objects)s.') code = 400
[docs]class InvalidSortKey(APIException): msg = _("Supplied sort key '%(key)s' is not valid.") code = 400
[docs]class InvalidSortDirection(APIException): msg = _("Supplied sort direction '%(key)s' is not valid.") code = 400
[docs]class InvalidMarker(APIException): msg = _("Supplied pagination marker '%(key)s' is not valid.") code = 400
[docs]class InvalidLimit(APIException): msg = _("Supplied pagination limit '%(key)s' is not valid.") code = 400
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.