Esempio n. 1
0
File: job.py Progetto: oar-team/oar3
def frag_job(jid):

    if 'OARDO_USER' in os.environ:
        luser = os.environ['OARDO_USER']
    else:
        luser = os.environ['USER']

    job = get_job(jid)

    if (job is not None) and ((luser == job.user)
                              or (luser == 'oar')
                              or (luser == 'root')):
        res = db.query(FragJob).filter(FragJob.job_id == jid).all()

        if len(res) == 0:

            date = tools.get_date()
            frajob = FragJob(job_id=jid, date=date)
            db.add(frajob)
            db.commit()
            add_new_event("FRAG_JOB_REQUEST",
                          jid, "User %s requested to frag the job %s"
                          % (luser, str(jid)))
            return 0
        else:
            # Job already killed
            return -2
    else:
        return -1
Esempio n. 2
0
def db_initialization(nb_res, node_size=None):

    print("Set default queue")
    db.add(Queue(name="default", priority=3, scheduler_policy="kamelot", state="Active"))

    print("add resources")
    # add some resources
    for i in range(nb_res):
        db.add(Resource(network_address="localhost"))

    db.commit()
Esempio n. 3
0
def add_new_event(type, job_id, description):
    event_data = EventLog(type=type, job_id=job_id, date=get_date(),
                          description=description[:255])
    db.add(event_data)