Exemplo n.º 1
0
def get_new_requests():
    query = "SELECT reqid, uid, reqname, reqstatus, num_containers FROM request WHERE reqstatus = 'NEW' ORDER BY reqid"
    req_list = []

    try:
        conn = get_connection()

        if conn:
            cursor = conn.cursor()
            cursor.execute(query)

            for item in cursor:
                request = Request()
                request.reqid = item[0]
                request.user = item[1]
                request.name = item[2]
                request.status = item[3]
                request.num_containers = item[4]
                print('Request: ', vars(request))
                req_list.append(request)

            cursor.close()
            conn.close()

    except mysql.connector.Error as err:
        logging.error('Getting New Requests on Database Error: %s', err)

    finally:
        if not req_list:
            logging.debug('Not find any New Request on Database')
        return req_list
Exemplo n.º 2
0
def requestMenu(session):
    print("""
    1. Create a New Request
    2. Exit
    """)
    menu = input("Enter the Selected Option: ")

    if menu == '1':
        request = Request()
        print('\n')
        request.name = input('Enter Request Name: ')
        request.user = session.uid
        request.num_containers = int(input('Enter the Number of Containers: '))

        print("""
        1. Executing equal jobs?
        2. Executing different jobs?
        3. Exit
        """)
        menu2 = input('Enter the Selected Option: ')

        if menu2 == '1':
            request.listcontainers = containerMenuType2(
                session, request.num_containers)

        elif menu2 == '2':
            request.listcontainers = containerMenuType1(
                session, request.num_containers)

        elif menu2 == '3':
            print('Get Out...')
            sys.exit()

        else:
            print('Invalid Option!')

        session.reqid = database.create_request(request)

        print('Request ID: ', session.reqid)
        i = 0

        for container in request.listcontainers:
            container.name = 'rqst' + str(session.reqid) + 'cntnr' + str(i)
            database.create_container(session.reqid, container.appid,
                                      container.name, container.command,
                                      container.estimated_time)
            i += 1

    elif menu == '2':
        print('Get Out...')
        sys.exit()

    else:
        print('Invalid Option!')
Exemplo n.º 3
0
estimated_time = 500
rqst_interval = 60
reps_interval = 500

if __name__ == '__main__':
    logging.basicConfig(filename='./log/auto-submit-script.log', filemode='a', format='%(asctime)s %(levelname)s:%(message)s',
						datefmt='%d/%m/%Y %H:%M:%S',level=logging.INFO)

    logging.info('Start Submission Test:')
    for i in range(num_reps):
        logging.info('Test %d', (i + 1))

        for j in range(num_requests):
            #Creating Request
            request = Request()
            request.name = req_name.replace('%', str(j + 1))
            request.user = uid
            request.num_containers = num_containers
            reqid = database.create_request(request)
            logging.info('Request Created: %d', reqid)

            #Creating Container
            for k in range(num_containers):
                container = Container()
                container.name = 'rqst' + str(reqid) + 'cntnr' + str(k)
                container.appid = appid
                container.command = command
                container.estimated_time = timedelta(seconds = estimated_time)
                request.listcontainers.append(container)
                database.create_container(reqid, container.appid, container.name, container.command, container.estimated_time)
                logging.info('Container Submitted: %s', container.name)