def dcv_create_session():
    try:
        username = session['username']
        walltime = request.args.get('walltime')
        instance_type = request.args.get('instance_type')
        session_number = int(request.args.get('session_number'))
        if walltime is None or instance_type is None or session_number is None:
            return redirect('/remotedesktop')

        user_sessions = dcv.check_user_session(username)
        if user_sessions.__len__() >= parameters.authorized_dcv_session_count(
        ):
            print(
                username +
                ' is not authorized to launch more sessions. Delete existing DCV file or make sure user is not querying endpoint directly'
            )
            return redirect('/remotedesktop')
        else:
            launch_job = dcv.build_qsub(username, session_number, walltime,
                                        instance_type)
            if launch_job is True:
                return redirect('/remotedesktop')
            else:
                flash(
                    'Error while trying to launch your session: Please verify you can submit job to the desktop queue. Error:<hr> '
                    + str(launch_job))
                return redirect('/remotedesktop')

    except Exception as e:
        flash(
            'Error while trying to launch your session: Please verify you can submit job to the desktop queue (eg: verify budget restrictions for this queue, queue syntax). Trace: '
            + str(e))
        return redirect('/remotedesktop')
def dcv_close_session():
    username = session['username']
    session_number = int(request.args.get('session_number'))
    if session_number not in range(parameters.authorized_dcv_session_count() +
                                   1):
        return redirect('/remotedesktop')

    dcv.clean_session(username, session_number)
    return redirect('/remotedesktop')
Пример #3
0
def remotedesktop():
    username = session_info()['username']
    sudoers = session_info()['sudoers']
    user_sessions = dcv.check_user_session(username)
    max_number_of_sessions = parameters.authorized_dcv_session_count()
    # List of instances not available for DCV. Adjust as needed
    blacklist = ['t1', 't2', 'm1','m4', 'm5.large', 'c3', 'p2', 'p3', 'r3', 'r4', 'metal', 'nano', 'micro']
    all_instances_available = client._service_model.shape_for('InstanceType').enum
    all_instances = [p for p in all_instances_available if not any(substr in p for substr in blacklist)]
    return render_template('remotedesktop.html', user_sessions=user_sessions, username=username, view='remotedesktop',
                           all_instances=all_instances, max_number_of_sessions=max_number_of_sessions, sudoers=sudoers)
def dcv_create_client_file():
    username = session['username']
    session_number = int(request.args.get('session_number'))
    if session_number not in range(parameters.authorized_dcv_session_count() +
                                   1):
        return redirect('/remotedesktop')
    dcv_file = dcv.build_dcv_connect_client(username, session_number)
    return Response(dcv_file,
                    mimetype='text/txt',
                    headers={
                        'Content-disposition':
                        'attachment; filename=' + username + '_soca_' +
                        str(session_number) + '.dcv'
                    })