(parameters, create=False)
return _fail
Helper function to produce a failure to create function.  Either creating
    the server or not.

    Takes three parameters:

    ``"code"``, an integer describing the HTTP response code, and
    ``"message"``, a string describing a textual message.
    ``"type"``, a string representing what type of error message it is

    If ``type`` is "string", the message is just returned as the string body.
    Otherwise, the following JSON body will be synthesized (as per the
    canonical Nova error format):

    ```
    {
        <type>: {
            "message": <message>,
            "code": <code>
        }
    }

    The default type is computeFault, the default code is 500, and the default
    message is "The server has either erred or is incapable of performing the
    requested operation".
Helper function to produce a failure to create function.  Either creating
    the server or not.
Helper function to produce a failure to create function . Either creating the server or not .
def _get_failure_behavior(parameters, create=False):
    """
    Helper function to produce a failure to create function.  Either creating
    the server or not.

    Takes three parameters:

    ``"code"``, an integer describing the HTTP response code, and
    ``"message"``, a string describing a textual message.
    ``"type"``, a string representing what type of error message it is

    If ``type`` is "string", the message is just returned as the string body.
    Otherwise, the following JSON body will be synthesized (as per the
    canonical Nova error format):

    ```
    {
        <type>: {
            "message": <message>,
            "code": <code>
        }
    }

    The default type is computeFault, the default code is 500, and the default
    message is "The server has either erred or is incapable of performing the
    requested operation".
    """
    status_code = parameters.get("code", 500)
    failure_type = parameters.get("type", "computeFault")
    failure_message = parameters.get(
        "message",
        ("The server has either erred or is incapable of performing the "
         "requested operation"))

    if failure_type == "string":
        fail_body = failure_message
    else:
        fail_body = dumps({
            failure_type: {
                "message": failure_message,
                "code": status_code
            }
        })

    def _fail(collection, http, json, absolutize_url):
        if create:
            Server.from_creation_request_json(
                collection, json, lambda: randrange(255))

        http.setResponseCode(status_code)
        return fail_body
    return _fail
def _get_failure_behavior ( parameters , create = False ) : status_code = parameters . get ( "code" , 500 ) failure_type = parameters . get ( "type" , "computeFault" ) failure_message = parameters . get ( "message" , ( "The server has either erred or is incapable of performing the " "requested operation" ) ) if failure_type == "string" : fail_body = failure_message else : fail_body = dumps ( { failure_type : { "message" : failure_message , "code" : status_code } } ) def _fail ( collection , http , json , absolutize_url ) : if create : Server . from_creation_request_json ( collection , json , lambda : randrange ( 255 ) ) http . setResponseCode ( status_code ) return fail_body return _fail