def set_hold(self, hold_type=None): """Set hold on job of specified type.""" # we can't set this default for hold_type in function signature, # because we need to be able to load this module even when the pbs module is not available if hold_type is None: hold_type = pbs.USER_HOLD # only set hold if it wasn't set before if hold_type not in self.holds: if hold_type not in KNOWN_HOLD_TYPES: self.log.error( "set_hold: unknown hold type: %s (supported: %s)" % (hold_type, KNOWN_HOLD_TYPES)) # set hold, check for errors, and keep track of this hold ec = pbs.pbs_holdjob(self.pbsconn, self.jobid, hold_type, NULL) is_error, errormsg = pbs.error() if is_error or ec: tup = (hold_type, self.jobid, is_error, ec, errormsg) self.log.error( "Failed to set hold of type %s on job %s (is_error: %s, exit code: %s, msg: %s)" % tup) else: self.holds.append(hold_type) else: self.log.warning("Hold type %s was already set for %s" % (hold_type, self.jobid))
def hold_rls_job(self, job_id, server, mode, permission): ''' Example: job_id: 183 server: jim-desktop mode: hold | rls permission: u | o | s ''' c = pbs.pbs_connect(str( pbs.pbs_default())) # Create new connection for the child process if server is None: server = pbs.pbs_default() job_full_id = job_id + '.' + server if mode == 'hold': result = pbs.pbs_holdjob(c, job_full_id, permission, 'NULL') elif mode == 'rls': result = pbs.pbs_rlsjob(c, job_full_id, permission, 'NULL') return result # If operation is successfull, result == 0
def set_hold(self, hold_type=None): """Set hold on job of specified type.""" # we can't set this default for hold_type in function signature, # because we need to be able to load this module even when the pbs module is not available if hold_type is None: hold_type = pbs.USER_HOLD # only set hold if it wasn't set before if hold_type not in self.holds: if hold_type not in KNOWN_HOLD_TYPES: self.log.error("set_hold: unknown hold type: %s (supported: %s)" % (hold_type, KNOWN_HOLD_TYPES)) # set hold, check for errors, and keep track of this hold ec = pbs.pbs_holdjob(self.pbsconn, self.jobid, hold_type, NULL) is_error, errormsg = pbs.error() if is_error or ec: tup = (hold_type, self.jobid, is_error, ec, errormsg) self.log.error("Failed to set hold of type %s on job %s (is_error: %s, exit code: %s, msg: %s)" % tup) else: self.holds.append(hold_type) else: self.log.warning("Hold type %s was already set for %s" % (hold_type, self.jobid))