Exemplo n.º 1
0
def callback():
    payload = request.get_json()

    # Retreive original payload
    # ..

    # Call 'srm2local' service
    stage_endpoint = f'{proxy_host}/api/v1/function/srm2local/execute'
    response = post(stage_endpoint, json=payload)

    result = {}
    return json_respone(result, HTTPStatus.OK)
Exemplo n.º 2
0
def lta2hpc():
    payload = request.get_json()

    # Save original payload
    # ...

    # Overwrite webhook
    payload['webhook']['url'] = main_host + '/callback'

    # Call 'lofar-stage' service
    stage_endpoint = f'{proxy_host}/api/v1/function/lofar/stage'
    response = post(stage_endpoint, json=payload)

    # Save correlation id
    # ...

    result = {}
    return json_respone(result, HTTPStatus.ACCEPTED)
Exemplo n.º 3
0
def execute():
    payload = request.get_json()

    # Extract payload
    identifier = payload['id']
    command = payload['cmd']
    webhook = payload['webhook']

    # Determine appropriate container to run
    if command['type'] == 'stage' and command['subtype'] == 'lofar':
        container = LofarStage(identifier, command, webhook)
    if command['type'] == 'copy' and command['subtype'] == 'srm2hpc':
        container = Srm2Hpc(identifier, command, webhook)

    # Run container
    response = container.run()

    return json_respone({ 
        'identifier': identifier,
        'response': response 
    }, 202)
Exemplo n.º 4
0
def callback():
    payload = request.get_json()
    result, status = functions.get('callback')(payload, db)

    return json_respone(result, status)
Exemplo n.º 5
0
def status(identifier):
    payload = {'identifier': identifier}
    result, status = functions.get('status')(payload, db)

    return json_respone(result, status)
Exemplo n.º 6
0
def index():
    return json_respone({}, 200)
Exemplo n.º 7
0
def stage():
    payload = request.get_json()
    result, status = functions.get('stage')(payload)

    return json_respone(result, status)