예제 #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)
예제 #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)
예제 #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)
예제 #4
0
def callback():
    payload = request.get_json()
    result, status = functions.get('callback')(payload, db)

    return json_respone(result, status)
예제 #5
0
def status(identifier):
    payload = {'identifier': identifier}
    result, status = functions.get('status')(payload, db)

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

    return json_respone(result, status)