class PaymentRequired(HTTPClientError):
    """HTTP 402 - Payment Required.

    Reserved for future use.
    """
    status_code = 402
    message = _("Payment Required")
class RequestUriTooLong(HTTPClientError):
    """HTTP 414 - Request-URI Too Long.

    The URI provided was too long for the server to process.
    """
    status_code = 414
    message = _("Request-URI Too Long")
Пример #3
0
 def get_parser(self, prog_name):
     parser = super(ListInstanceCPUMappings, self).get_parser(prog_name)
     parser.add_argument('--long',
                         action='store_true',
                         default=False,
                         help=_("List additional fields in output"))
     return parser
Пример #4
0
    def take_action(self, parsed_args):
        kongmingclient = self.app.client_manager.resource_pin
        result = 0
        for one_mapping in parsed_args.instance_uuid:
            try:
                data = utils.find_resource(
                    kongmingclient.instance_cpu_mappings, one_mapping)
                kongmingclient.instance_cpu_mappings.delete(data.instance_uuid)
            except Exception as e:
                result += 1
                LOG.error(
                    "Failed to delete cpu mapping with instance UUID "
                    "'%(uuid)s': %(e)s", {
                        'uuid': one_mapping,
                        'e': e
                    })

        if result > 0:
            total = len(parsed_args.instance_uuid)
            msg = (_("%(result)s of %(total)s mapping failed "
                     "to delete.") % {
                         'result': result,
                         'total': total
                     })
            raise exceptions.CommandError(msg)
class HttpServerError(HttpError):
    """Server-side HTTP error.

    Exception for cases in which the server is aware that it has
    erred or is incapable of performing the request.
    """
    message = _("HTTP Server Error")
class RequestTimeout(HTTPClientError):
    """HTTP 408 - Request Timeout.

    The server timed out waiting for the request.
    """
    status_code = 408
    message = _("Request Timeout")
class ProxyAuthenticationRequired(HTTPClientError):
    """HTTP 407 - Proxy Authentication Required.

    The client must first authenticate itself with the proxy.
    """
    status_code = 407
    message = _("Proxy Authentication Required")
class HttpVersionNotSupported(HttpServerError):
    """HTTP 505 - HttpVersion Not Supported.

    The server does not support the HTTP protocol version used in the request.
    """
    status_code = 505
    message = _("HTTP Version Not Supported")
class BadRequest(HTTPClientError):
    """HTTP 400 - Bad Request.

    The request cannot be fulfilled due to bad syntax.
    """
    status_code = 400
    message = _("Bad Request")
class InternalServerError(HttpServerError):
    """HTTP 500 - Internal Server Error.

    A generic error message, given when no more specific message is suitable.
    """
    status_code = 500
    message = _("Internal Server Error")
class ServiceUnavailable(HttpServerError):
    """HTTP 503 - Service Unavailable.

    The server is currently unavailable.
    """
    status_code = 503
    message = _("Service Unavailable")
class ExpectationFailed(HTTPClientError):
    """HTTP 417 - Expectation Failed.

    The server cannot meet the requirements of the Expect request-header field.
    """
    status_code = 417
    message = _("Expectation Failed")
class NotFound(HTTPClientError):
    """HTTP 404 - Not Found.

    The requested resource could not be found but may be available again
    in the future.
    """
    status_code = 404
    message = _("Not Found")
class GatewayTimeout(HttpServerError):
    """HTTP 504 - Gateway Timeout.

    The server was acting as a gateway or proxy and did not receive a timely
    response from the upstream server.
    """
    status_code = 504
    message = _("Gateway Timeout")
class BadGateway(HttpServerError):
    """HTTP 502 - Bad Gateway.

    The server was acting as a gateway or proxy and received an invalid
    response from the upstream server.
    """
    status_code = 502
    message = _("Bad Gateway")
class HttpNotImplemented(HttpServerError):
    """HTTP 501 - Not Implemented.

    The server either does not recognize the request method, or it lacks
    the ability to fulfill the request.
    """
    status_code = 501
    message = _("Not Implemented")
class UnprocessableEntity(HTTPClientError):
    """HTTP 422 - Unprocessable Entity.

    The request was well-formed but was unable to be followed due to semantic
    errors.
    """
    status_code = 422
    message = _("Unprocessable Entity")
Пример #18
0
 def get_parser(self, prog_name):
     parser = super(ShowHost, self).get_parser(prog_name)
     parser.add_argument(
         'host_name',
         metavar='<host_name>',
         help=_("Host to display (Host_name)")
     )
     return parser
class NotAcceptable(HTTPClientError):
    """HTTP 406 - Not Acceptable.

    The requested resource is only capable of generating content not
    acceptable according to the Accept headers sent in the request.
    """
    status_code = 406
    message = _("Not Acceptable")
Пример #20
0
 def get_parser(self, prog_name):
     parser = super(CreateInstanceCPUMappings, self).get_parser(prog_name)
     parser.add_argument(
         "instance_uuid",
         metavar="<instance_uuid>",
         help=_("The instance uuid you want to create mapping for."))
     parser.add_argument(
         "cpu_mappings",
         metavar="<cpu_mappings>",
         help=_("The mappings you want to assign for the given instance."))
     parser.add_argument(
         "--wait-until-active",
         metavar='<wait_until_active|True>',
         default=False,
         help=_("Whether to perform this action now or do it "
                "automatically once the instance turn into ACTIVE status."))
     return parser
class PreconditionFailed(HTTPClientError):
    """HTTP 412 - Precondition Failed.

    The server does not meet one of the preconditions that the requester
    put on the request.
    """
    status_code = 412
    message = _("Precondition Failed")
class LengthRequired(HTTPClientError):
    """HTTP 411 - Length Required.

    The request did not specify the length of its content, which is
    required by the requested resource.
    """
    status_code = 411
    message = _("Length Required")
class Gone(HTTPClientError):
    """HTTP 410 - Gone.

    Indicates that the resource requested is no longer available and will
    not be available again.
    """
    status_code = 410
    message = _("Gone")
class Conflict(HTTPClientError):
    """HTTP 409 - Conflict.

    Indicates that the request could not be processed because of conflict
    in the request, such as an edit conflict.
    """
    status_code = 409
    message = _("Conflict")
class Forbidden(HTTPClientError):
    """HTTP 403 - Forbidden.

    The request was a valid request, but the server is refusing to respond
    to it.
    """
    status_code = 403
    message = _("Forbidden")
class MethodNotAllowed(HTTPClientError):
    """HTTP 405 - Method Not Allowed.

    A request was made of a resource using a request method not supported
    by that resource.
    """
    status_code = 405
    message = _("Method Not Allowed")
Пример #27
0
 def get_parser(self, prog_name):
     parser = super(DeleteInstanceCPUMappings, self).get_parser(prog_name)
     parser.add_argument(
         'instance_uuid',
         metavar='<instance_uuid>',
         nargs='+',
         help=_("instance_cpu_mapping(s) to delete (instance UUID)"))
     return parser
class UnsupportedMediaType(HTTPClientError):
    """HTTP 415 - Unsupported Media Type.

    The request entity has a media type which the server or resource does
    not support.
    """
    status_code = 415
    message = _("Unsupported Media Type")
Пример #29
0
 def strip_endpoint(self, location):
     if location is None:
         message = _("Location not returned with redirect")
         raise exc.EndpointException(message=message)
     if location.lower().startswith(self.endpoint):
         return location[len(self.endpoint):]
     else:
         return location
class RequestedRangeNotSatisfiable(HTTPClientError):
    """HTTP 416 - Requested Range Not Satisfiable.

    The client has asked for a portion of the file, but the server cannot
    supply that portion.
    """
    status_code = 416
    message = _("Requested Range Not Satisfiable")