/usr/lib/python2.7/dist-packages/maasserver/exceptions.py is in python-django-maas 1.5+bzr2252-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | # Copyright 2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Exceptions."""
from __future__ import (
absolute_import,
print_function,
unicode_literals,
)
str = None
__metaclass__ = type
__all__ = [
"ClusterUnavailable",
"ExternalComponentException",
"MAASException",
"MAASAPIBadRequest",
"MAASAPIException",
"MAASAPINotFound",
"NodeStateViolation",
"NodeGroupMisconfiguration",
"IteratorReusedError",
]
import httplib
from django.http import (
HttpResponse,
HttpResponseRedirect,
)
class MAASException(Exception):
"""Base class for MAAS' exceptions."""
class CannotDeleteUserException(Exception):
"""User can't be deleted."""
class NoRabbit(MAASException):
"""Could not reach RabbitMQ."""
class MAASAPIException(Exception):
"""Base class for MAAS' API exceptions.
:ivar api_error: The HTTP code that should be returned when this error
is raised in the API (defaults to 500: "Internal Server Error").
"""
api_error = httplib.INTERNAL_SERVER_ERROR
def make_http_response(self):
"""Create an :class:`HttpResponse` representing this exception."""
encoding = b'utf-8'
return HttpResponse(
status=self.api_error, content=unicode(self).encode(encoding),
mimetype=b"text/plain; charset=%s" % encoding)
class ExternalComponentException(MAASAPIException):
"""An external component failed."""
class MAASAPIBadRequest(MAASAPIException):
api_error = httplib.BAD_REQUEST
class MAASAPINotFound(MAASAPIException):
api_error = httplib.NOT_FOUND
class Unauthorized(MAASAPIException):
"""HTTP error 401: Unauthorized. Login required."""
api_error = httplib.UNAUTHORIZED
class NodeStateViolation(MAASAPIException):
"""Operation on node not possible given node's current state."""
api_error = httplib.CONFLICT
class NodesNotAvailable(NodeStateViolation):
"""Requested node(s) are not available to be acquired."""
api_error = httplib.CONFLICT
class Redirect(MAASAPIException):
"""Redirect. The exception message is the target URL."""
api_error = httplib.FOUND
def make_http_response(self):
return HttpResponseRedirect(unicode(self))
class NodeGroupMisconfiguration(MAASAPIException):
"""Node Groups (aka Cluster Controllers) are misconfigured.
This might mean that more than one controller is marked as managing the
same network
"""
api_error = httplib.CONFLICT
class ClusterUnavailable(MAASAPIException):
"""A Cluster Controller is not available for RPC queries."""
api_error = httplib.SERVICE_UNAVAILABLE
class IteratorReusedError(Exception):
"""Raise when a :class:`UseOnceIterator` gets reused."""
|