Exemple #1
0
def view_jobflow_with_ajax(context, request):
    req_type = request.params.get('type')
    resource = get_resource(context)
    emr_conn = get_emr_connection(resource)

    if req_type == 'runjobflow' and is_runnable_jobflow(context):
        run_jobflow(emr_conn, resource, context)

    jobflow_ids = get_jobflow_ids(context)

    if req_type == 'terminate' and jobflow_ids:
        emr_conn.terminate_jobflows(jobflow_ids)
        # FIXME: enforce a termination against protection

    if req_type == 'getlog':
        s3_conn = get_s3_connection(resource)
        keys_list = get_s3_log_keys(s3_conn, resource.log_uri, jobflow_ids)
        bucket_name = keys_list[0].bucket.name if keys_list else u''
        keys = [dict(get_object_attributes(key, ['name', 'size']))
                        for key in chain.from_iterable(keys_list)]
        return {'keys': keys, 'bucket_name': bucket_name}
    else:  # refresh
        res_jobflows = get_jobflows_for_json(emr_conn, jobflow_ids)
        set_jobflow_state(context, res_jobflows)
        return res_jobflows
Exemple #2
0
def view_jobflow(context, request):
    return {
        'api': template_api(context, request),
        'bootstraps': get_bootstraps(context),
        'is_runnable': is_runnable_jobflow(context),
        'resource': get_resource(context),
        'resource_models': [JobFlow],
    }