예제 #1
0
def get_qos():
    if mocking:
        return mock('qos.json')

    try:
        qos = pyslurm.qos().get()
    except Exception as e:
        qos = {'error': str(e)}
    return qos
예제 #2
0
def get_qos():
    if mocking:
        return mock('qos.json')

    try:
        qos = pyslurm.qos().get()
    except Exception as e:
        qos = {'error': str(e)}
    return qos
예제 #3
0
def get_qos():

    try:
        qos = pyslurm.qos().get()
        # for all TRES limits of all QOS, replace TRES type IDs by their
        # textual form using tres_convert_ids()
        for qos_name in qos:
            xqos = qos[qos_name]
            qos[qos_name] = {key: convert_tres_ids(key, value)
                             for key, value in xqos.iteritems()}

    except Exception as e:
        qos = {'error': str(e)}
    return qos
예제 #4
0
def get_qos():

    try:
        qos = get_from_cache(pyslurm.qos().get, 'get_qos')
        # for all TRES limits of all QOS, replace TRES type IDs by their
        # textual form using tres_convert_ids()
        for qos_name in qos:
            xqos = qos[qos_name]
            for key, value in xqos.iteritems():
                if value is not None and key.find('_tres') > 0:
                    qos[qos_name][key] = convert_tres_ids(value)

    except Exception as e:
        qos = {'error': str(e)}
    return qos
예제 #5
0
def get_qos():

    try:
        qos = pyslurm.qos().get()
        # for all TRES limits of all QOS, replace TRES type IDs by their
        # textual form using tres_convert_ids()
        for qos_name in qos:
            xqos = qos[qos_name]
            for key, value in xqos.iteritems():
                if value is not None and key.find('_tres') > 0:
                    qos[qos_name][key] = convert_tres_ids(value)

    except Exception as e:
        qos = {'error': str(e)}
    return qos
예제 #6
0
def get_jobs_by_qos():

    jobs = pyslurm.job().get()
    qos = pyslurm.qos().get()

    returned_qos = {}

    for qos_id, q in qos.iteritems():
        returned_jobs = {}
        # filter jobs by node
        for jobid, job in jobs.iteritems():
            if qos_id == job['qos']:
                returned_jobs[jobid] = job

        returned_qos[qos_id] = returned_jobs

    return returned_qos
예제 #7
0
def get_jobs_by_qos():

    jobs = get_from_cache(pyslurm.job().get, 'get_jobs')
    qos = get_from_cache(pyslurm.qos().get, 'get_qos')

    returned_qos = {}

    for qos_id, q in qos.iteritems():
        returned_jobs = {}
        # filter jobs by node
        for jobid, job in jobs.iteritems():
            if qos_id == job['qos']:
                returned_jobs[jobid] = job

        returned_qos[qos_id] = filter_entities('jobs', returned_jobs)

    return returned_qos
예제 #8
0
def get_jobs_by_qos():

    jobs = pyslurm.job().get()
    qos = pyslurm.qos().get()

    returned_qos = {}

    for qos_id, q in qos.iteritems():
        returned_jobs = {}
        # filter jobs by node
        for jobid, job in jobs.iteritems():
            if qos_id == job['qos']:
                returned_jobs[jobid] = job

        returned_qos[qos_id] = returned_jobs

    return returned_qos
예제 #9
0
    def run(self):
        #pdb.set_trace()
        logger.info("Start running PyslurmReader ...")
        while True:
          # pyslurm query
          ts       = int(datetime.now().timestamp())
          job_dict = pyslurm.job().get()
          node_dict= pyslurm.node().get()
          part_dict= pyslurm.partition().get()
          qos_dict = pyslurm.qos().get()
          #res_dict = pyslurm.reservation().get()
          res_dict = {}  #TODO: pyslurm reservation coredump ERROR
          #js_dict  = pyslurm.jobstep().get()

          #convert to points
          points   = []
          for jid,job in job_dict.items():
              self.slurmJob2point(ts, job, points)
          finishJob = [jid for jid in self.sav_job_dict.keys() if jid not in job_dict.keys()]
          #logger.debug ("PyslurmReader::run: Finish jobs {}".format(finishJob))
          for jid in finishJob:
              del self.sav_job_dict[jid]

          for node in node_dict.values():
              self.slurmNode2point(ts, node, points)

          if json.dumps(part_dict) != json.dumps(self.sav_part_dict):
              for pname, part in part_dict.items():
                 self.slurmPartition2point(ts, pname, part, points)
              self.sav_part_dict = part_dict

          if json.dumps(qos_dict) != json.dumps(self.sav_qos_dict):
              for qname, qos in qos_dict.items():
                 self.slurmQOS2point(ts, qname, qos, points)
              self.sav_qos_dict = qos_dict

          if res_dict and (json.dumps(res_dict) != json.dumps(self.sav_res_dict)):
              for rname, res in res_dict.items():
                 self.slurmReservation2point(ts, rname, res, points)
              self.sav_res_dict = res_dict

          with self.lock:
              self.points.extend(points)

          time.sleep (PyslurmReader.INTERVAL)
예제 #10
0
def test_get_qos():
    """QoS: Test get_qos() return type"""
    test_qos = pyslurm.qos().get()
    assert_true(isinstance(test_qos, dict))
예제 #11
0
def get_qos():
    qos = pyslurm.qos().get()
    return jsonify(qos)
예제 #12
0
#!/usr/bin/env python
"""
List Slurm QOS
"""
import pyslurm

if __name__ == "__main__":
    try:
        qosDict = pyslurm.qos().get()
        if qosDict:
            for key, value in qosDict.items():
                print("{")
                if isinstance(value, dict):
                    print("\t{}=".format(key))
                    for k, v in value.items():
                        print("\t\t{}={}".format(k, v))
                else:
                    print("\t{}={}".format(key, value))
                print("}")
        else:
            print("No QOS found")
    except ValueError as qos_exception:
        print("Error:{}".format(qos_exception.args[0]))
예제 #13
0
#!/usr/bin/env python

import pyslurm

if __name__ == "__main__":
    try:
        qos_dict = pyslurm.qos().get()
        if len(qos_dict):
            for key, value in qos_dict.items():
                print("{")
                if type(value) is dict:
                    print("\t{}=".format(key))
                    for k, v in value.items():
                        print("\t\t{}={}".format(k, v))
                else:
                    print("\t{}={}".format(key, value))
                print("}")
        else:
            print("No QOS found")
    except ValueError as e:
        print("Error:{}".format(e.args[0]))