Exemple #1
0
        def handler(*args, **kwargs):
            request_data = u.request_data()
            try:
                if schema:
                    validator = api_validator.ApiValidator(schema)
                    validator.validate(request_data)
                if validators:
                    for validator in validators:
                        validator(**kwargs)
            except jsonschema.ValidationError as e:
                e.code = "VALIDATION_ERROR"
                return u.bad_request(e)
            except ex.SavannaException as e:
                return u.bad_request(e)
            except os_ex.MalformedRequestBody as e:
                e.code = "MALFORMED_REQUEST_BODY"
                return u.bad_request(e)
            except Exception as e:
                return u.internal_error(500,
                                        "Error occurred during validation", e)

            return func(*args, **kwargs)
Exemple #2
0
        def handler(*args, **kwargs):
            request_data = u.request_data()
            try:
                if schema:
                    validator = api_validator.ApiValidator(schema)
                    validator.validate(request_data)
                if validators:
                    for validator in validators:
                        validator(**kwargs)
            except jsonschema.ValidationError as e:
                e.code = "VALIDATION_ERROR"
                return u.bad_request(e)
            except ex.SavannaException as e:
                return u.bad_request(e)
            except os_ex.MalformedRequestBody as e:
                e.code = "MALFORMED_REQUEST_BODY"
                return u.bad_request(e)
            except Exception as e:
                return u.internal_error(
                    500, "Error occurred during validation", e)

            return func(*args, **kwargs)
Exemple #3
0
 def handler(*args, **kwargs):
     try:
         validate_func(api_u.request_data(), **kwargs)
     except jsonschema.ValidationError, e:
         e.code = "VALIDATION_ERROR"
         return api_u.bad_request(e)
Exemple #4
0
def clusters_create():
    data = request_data()
    try:
        return render(api.create_cluster(data).wrapped_dict)
    except Exception, e:
        abort_and_log(500, "Exception while adding new Cluster", e)
Exemple #5
0
def templates_create():
    data = request_data()
    try:
        return render(api.create_node_template(data).wrapped_dict)
    except Exception, e:
        abort_and_log(500, "Exception while adding NodeTemplate", e)
Exemple #6
0
def clusters_create():
    data = api_u.request_data()
    headers = request.headers

    return api_u.render(api.create_cluster(data, headers).wrapped_dict)
Exemple #7
0
def templates_create():
    data = api_u.request_data()
    headers = request.headers

    return api_u.render(api.create_node_template(data, headers).wrapped_dict)