コード例 #1
0
def crash(request):
    """ Register crash data with the server
    """

    if request.method != 'POST':
        return HttpResponse('Invalid GET')

    node = vu._validate_node(request)
    if not node:
        return HttpResponse("Invalid node")

    #
    # checks out; with this we generate a new crash object,
    # tie it to the node ID, and write the crash data to
    # its respective file
    #

    try:
        data = json.loads(request.body)
        node.faults += + 1
        crash = Crash.objects.create(
            fault_index=data['crash_idx'],
            node_index=node,
            crash_time=utility.timestamp(),
            exception_type=vu.parse_key("EXCEPTION_TYPE", data['crash']),
            classification=vu.parse_key("CLASSIFICATION", data['crash'])
        )

        crash.save()
        node.save()
        vu._write_crash(data, node)
    except Exception, e:
        utility.msg("Failed to log crash: %s" % e, ERROR)
        return HttpResponse("Failed")
コード例 #2
0
def status(request):
    """ Register node status update
    """

    if request.method != "POST":
        return HttpResponse("Invalid GET")

    node = vu._validate_node(request)
    if not node:
        return HttpResponse("Invalid node")

    try:
        data = json.loads(request.body)
        node.state = data['state']
        node.save()
    except Exception:
        return HttpResponse("Bad node data")

    utility.msg("Node %d updated" % node.id)
    return HttpResponse("Node Updated")
コード例 #3
0
        crash = Crash.objects.create(
            fault_index=data['crash_idx'],
            node_index=node,
            crash_time=utility.timestamp(),
            exception_type=vu.parse_key("EXCEPTION_TYPE", data['crash']),
            classification=vu.parse_key("CLASSIFICATION", data['crash'])
        )

        crash.save()
        node.save()
        vu._write_crash(data, node)
    except Exception, e:
        utility.msg("Failed to log crash: %s" % e, ERROR)
        return HttpResponse("Failed")

    utility.msg("Node %d posted crash" % node.id)
    return HttpResponse("Node updated")


@csrf_exempt
def status(request):
    """ Register node status update
    """

    if request.method != "POST":
        return HttpResponse("Invalid GET")

    node = vu._validate_node(request)
    if not node:
        return HttpResponse("Invalid node")