def get_all_available_tests(filterstring=""): """ Get all available (enabled) tests in VRL. Optionally limit with a filter string. Parameters: filterstring? - a substring that is searched for in the test string. Returns: JSON[] of objects. - "id": VRL id of test - "testname": Name of test - "program": which VRL program to use to run the test - "triad": argumnets passed to the program - "contact": who to contact for issues related to the test. """ with vrl_conn() as cursor: try: sql = ''' SELECT id, testname, program, triad, contact FROM vrl.tests WHERE enabled = True AND ''' + sql_filter_clause('testname', filterstring) + ';' cursor.execute(sql, []) rows = list(cursor) return jsonify(rows) except Exception as e: return jsonify({"status": "error", "error": str(e)}), 400
def machine_pooling(): """ API function to get a list of all machines along with its GPU information which belong to any Compiler-Graphics machine pool :return: list of dict of machine and machine pool details :rtype: list """ try: conn = vrl_conn() with conn.cursor() as cursor: sql = """ SELECT m.name as machine_name, m.gpu as gpu,mp.name as pool_name FROM machine m, machinePools mp, machinePools_machine mpm WHERE m.id = mpm.machineId AND mp.id = mpm.machinePoolId AND mp.name like 'Compiler-Graphics%' ORDER BY 3""" cursor.execute(sql) rows = cursor.fetchall() conn.close() return jsonify(rows) except Exception as err: print(err) logger.error(err) return jsonify("ERROR", str(err)), 400
def get_vrl_machines(filterstring=""): # Pymysql seems to convert a connection in a with statement to a cursor with vrl_conn() as cursor: try: sql = 'SELECT id, name, location, description, cpu, gpu FROM vrl.machine WHERE enabled AND ' + sql_filter_clause( 'name', filterstring) + ';' cursor.execute(sql) rows = list(cursor) return jsonify(rows) except Exception as e: return jsonify({"status": "error", "error": str(e)}), 400
def get_vrl_oses(filterstring=""): # Pymysql seems to convert a connection in a with statement to a cursor with vrl_conn() as cursor: try: sql = 'SELECT id, name FROM vrl.oses WHERE ' + sql_filter_clause( 'name', filterstring) + ';' cursor.execute(sql) rows = list(cursor) return jsonify(rows) except Exception as e: return jsonify({"status": "error", "error": str(e)}), 400
def __init__(self, test_system, test_name, params, conn): super().__init__(test_system, test_name, params, conn) self.gg2_groupTypeId = params[ 'gg2groupid'] if 'gg2groupid' in params else None self.gg2_testpatt = params[ 'gg2pattern'] if 'gg2pattern' in params else ( params['gg2group'] if 'gg2group' in params else self.test_name) self.wantsSubtests = params[ 'wantsSubtests'] if 'wantsSubtests' in params else True self.readJSON = bool(params.get('readJSON')) self._listings = {} # file listings for each serial. self._listing_dicts = {} # file listings for each serial. self.vrlconn = vrl_conn()
def get_vrl_machines_by_pool(pool): with vrl_conn() as cursor: try: sql = ''' SELECT vrl.machine.id, vrl.machine.name, vrl.machine.location, vrl.machine.description, vrl.machine.cpu, vrl.machine.gpu FROM vrl.machine JOIN vrl.machinePools_machine ON vrl.machinePools_machine.machineId = vrl.machine.id JOIN vrl.machinePools ON vrl.machinePools.id = vrl.machinePools_machine.machinePoolId WHERE vrl.machinePools.name = %s ''' cursor.execute(sql, [pool]) rows = list(cursor) return jsonify(rows) except Exception as e: return jsonify({"status": "error", "error": str(e)}), 400
def orchestrate(): """Orchestration for scraping machine data from VRL and inserting into compiler HUB """ try: days = 2 conn = vrl_conn() with conn.cursor() as cursor: for i in range(days, 1, -1): get_machine_monitoring_data_from_vrl(cursor, i) conn.close() return jsonify("Scrapping completed"), 200 except Exception as err: return (str(err)), 400
def get_all_running_jobs_on_vrl(): """get all the running job on VRL for user DVS :return: a list of rows :rtype: list """ try: rows = () conn = vrl_conn() with conn.cursor() as cursor: sql = ''' SELECT vrl.job.gpu, vrl.job.status, vrl.job.submitted, vrl.job.jobstarted, vrl.job.notes, vrl.machine.name as MachineName, vrl.tests.testname as TestName FROM vrl.job JOIN vrl.tests on vrl.job.testId = vrl.tests.id JOIN vrl.machine on vrl.job.machineId = vrl.machine.id WHERE username='******' AND status='RUNNING' LiMIT 1000 ''' cursor.execute(sql) rows = cursor.fetchall() conn.close() json_res = jsonify(rows) return json_res, 200 except Exception as e: logger.error(e) return jsonify("ERROR"), 400