Пример #1
0
def transitionsfbv_machines_pk_snapshot(request, pk):
    data = request.GET
    mc = get_machine_catalog()
    m = mc.get(pk)
    verbose = bool(ast.literal_eval(data.get('verbose', 'False')))
    data = m.snapshot(verbose=verbose)
    return Response(data)
Пример #2
0
def transitionsfbv_machines_pk_graph(request, pk, ext=None):
    if request.method == 'GET':
        mc = get_machine_catalog()
        m = mc.get(pk)
        image_format = str(ext or '').lower()
        return create_graphviz_graph_response(m, title=pk, image_format=image_format)
    elif request.method == 'POST':
        pass

    return Response('Not yet implemented')
Пример #3
0
def transitionsfbv_machines_pk(request, pk):
    if request.method == 'GET':
        mc = get_machine_catalog()
        m = mc.get(pk)
        # LogUtils.log_object_state(m.blueprints, level=logging.WARN, name='m.blueprints', context='original')
        # LogUtils.log_object_state(m.snapshot(), level=logging.WARN, name='m.snapshot()', context='original')
        data = get_machine_detail_dom(m, machine_name=pk, request=request, view_prefix='transitionsfbv_')
        return Response(data)
    elif request.method == 'POST':
        pass

    return Response('Not yet implemented')
Пример #4
0
def transitionsfbv_machines_pk_blueprint(request, pk):
    if request.method == 'GET':
        mc = get_machine_catalog()
        m = mc.get(pk)
        # data = get_machine_detail_dom(m, machine_name=pk, request=request, view_prefix='transitionsfbv_').get('blueprints')
        try:
            bp_ = m.blueprints
        except AttributeError:
            raise RequestedOperationFailedException(detail='The specified Machine does not support blueprints functionality.')
        else:
            data = bp_
        return Response(data)
    elif request.method == 'POST':
        pass

    # return Response('Not yet implemented')
    raise MethodNotAllowed()
Пример #5
0
def transitionsfbv_machines_pk_transition(request, pk):
    # {"trigger": "evaporate", "dest": "gas"}
    if request.method == 'GET':
        data = request.GET
    elif request.method == 'POST':
        data = request.POST

    mc = get_machine_catalog()
    m = mc.get(pk)
    trigger = data.get('trigger')
    dest = data.get('destination')

    if not trigger:
        raise serializers.ValidationError("Invalid value: '{}'".format('trigger'))
    if not dest:
        raise serializers.ValidationError("Invalid value: '{}'".format('destination'))

    t = m.trigger_transition(trigger=trigger, dest_state=dest)
    if not t:
        raise RequestedOperationFailedException()
    # data = get_machine_detail_dom(m, machine_name=pk, request=request)
    data = m.snapshot()
    return Response(data)