def alter(self, jobs): resources = {} for job in jobs: resource_arg = ":".join(["%s=%s" % (x, y) for x, y in job.iteritems()]) if resource_arg not in resources: resources[resource_arg] = [] resources[resource_arg].append(job["job_id"]) for resource_arg, job_ids in resources.iteritems(): tandem_utils.check_call(". /etc/cluster-setup.sh && qalter %s -l %s" % (",".join([str(j) for j in job_ids]), resource_arg))
def _version(self): try: version_line = tandem_utils.check_call(["qmgr", "--version" ]).split("\n")[0] return version_line.split("=")[1].strip() except: return "-1"
def submit(self, scheduler_name, format, submit_data): if format == "tandem": parsed_submit_data = submit_data elif format == "tandem": buf = cStringIO.StringIO() jobs_data = json.loads(submit_data) for job in jobs_data: transform_tandem_job(job, buf) submit_data = buf.getvalue() jobid = tandem_utils.check_call([self._bin("qsub"), "-"], parsed_submit_data) return [job[tandem_utils.LOCAL_JOB_ID_KEY] for job in self.jobstatus(scheduler_name, 0, jobid.strip())]
def queues(self): lines = tandem_utils.check_call([self._bin("qstat"), "-Q"]).split("\n") return [x.split()[0] for x in lines[2:] if x.strip()]
def delete_host(self, hostname): tandem_utils.check_call([self._bin("qmgr"), "-c", "delete node %s" % hostname])
def set_offline(self, hostname): tandem_utils.check_call([self._bin("pbsnodes"), "-o", hostname])