print flt.faultString raise SystemExit, 1 jobs_existed = [j.get('jobid') for j in check_response] all_jobs = all_jobs.union(set(jobs_existed)) update_specs = [{ 'tag': 'job', 'user': user, 'jobid': jobid, 'user_hold': "*", 'is_active': "*" } for jobid in jobs_existed] updates = {'user_hold': True} try: update_response = cqm.set_jobs(update_specs, updates, user) except xmlrpclib.Fault, flt: print flt.faultString raise SystemExit, 1 jobs_found = [j.get('jobid') for j in update_response] jobs_not_found = list(all_jobs.difference(set(jobs_existed))) jobs_completed = [j.get('jobid') for j in update_response if j.get('has_completed')] + \ list(set(jobs_existed).difference(set(jobs_found))) jobs_had_hold = [ j.get('jobid') for j in check_response if j.get('user_hold') and j.get('jobid') in jobs_found ] jobs_active = [ j.get('jobid') for j in update_response if j.get('is_active') ]
except ConfigParser.NoOptionError: filters = [] try: jobdata = cqm.get_jobs(spec) except xmlrpclib.Fault, flt: print flt.faultString raise SystemExit, 1 if not jobdata: print "Failed to match any jobs" sys.exit(1) response = [] for jobinfo in jobdata: original_spec = jobinfo.copy() jobinfo.update({'queue': queue}) for filt in filters: Cobalt.Util.processfilter(filt, jobinfo) try: [job] = cqm.set_jobs([original_spec], jobinfo, user) response.append("moved job %d to queue '%s'" % (job.get('jobid'), job.get('queue'))) except xmlrpclib.Fault, flt: response.append(flt.faultString) if not response: logger.error("Failed to match any jobs or queues") else: logger.debug(response) for line in response: print line
# for c in copy: # c['state'] = 'user hold' # spec += copy if opts['queue']: updates['queue'] = opts['queue'] if opts['index']: updates['index'] = opts['index'] if opts['time']: try: minutes = Cobalt.Util.get_time(opts['time']) except Cobalt.Exceptions.TimeFormatError, e: print "invalid time specification: %s" % e.args[0] sys.exit(1) updates['walltime'] = str(minutes) try: response = [] if updates: response = cqm.set_jobs(spec, updates, whoami) except xmlrpclib.Fault, flt: response = [] if flt.faultCode == 30 or flt.faultCode == 42: print flt.faultString raise SystemExit, 1 else: print flt.faultString raise SystemExit, 1 if not response: Cobalt.Logging.logging.error("Failed to match any jobs or queues") else: Cobalt.Logging.logging.debug(response)
print >> sys.stderr, "cannot change mode of a running job" if updates.has_key('errorpath'): print >> sys.stderr, "cannot change the error path of a running job" if updates.has_key('outputpath'): print >> sys.stderr, "cannot change the output path of a running job" sys.exit(1) response = False for jobinfo in jobdata: del jobinfo['is_active'] original_spec = jobinfo.copy() jobinfo.update(updates) for filt in filters: Cobalt.Util.processfilter(filt, jobinfo) try: cqm.set_jobs([original_spec], jobinfo, user) response = True for key in jobinfo: if not original_spec.has_key(key): if key == "all_dependencies": print "dependencies set to %s" % ":".join(jobinfo[key]) else: print "%s set to %s" % (key, jobinfo[key]) elif jobinfo[key] != original_spec[key]: print "%s changed from %s to %s" % ( key, original_spec[key], jobinfo[key]) except xmlrpclib.Fault, flt: print >> sys.stderr, flt.faultString response = True if not response:
check_response = cqm.get_jobs(check_specs) except xmlrpclib.Fault, flt: print flt.faultString raise SystemExit, 1 jobs_existed = [j.get('jobid') for j in check_response] all_jobs = all_jobs.union(set(jobs_existed)) update_specs = [{'tag':'job', 'user':user, 'jobid':jobid, 'user_hold':"*", 'is_active':"*"} for jobid in jobs_existed] if opt.deps: updates = {'all_dependencies': []} else: updates = {'user_hold':False} try: update_response = cqm.set_jobs(update_specs, updates, user) except xmlrpclib.Fault, flt: print flt.faultString raise SystemExit, 1 if opt.deps: print " Removed dependencies from jobs: " for j in update_response: print " %s" % j.get("jobid") sys.exit(0) jobs_found = [j.get('jobid') for j in update_response] jobs_not_found = list(all_jobs.difference(set(jobs_existed))) jobs_completed = [j.get('jobid') for j in update_response if j.get('has_completed')] + \ list(set(jobs_existed).difference(set(jobs_found))) jobs_had_hold = [j.get('jobid') for j in check_response if j.get('user_hold') and j.get('jobid') in jobs_found]