def controller_up(controller=1): rc = pyslurm.slurm_ping(controller) if rc != 0: rc = pyslurm.slurm_get_errno() print "\t\tFailed - %s" % pyslurm.slurm_strerror(rc) else: print "\t\tSuccess"
def update_nodes_from_tests (prefix, test_type, fail_nodes=None, error_nodes=None, down=False): fail_nodes_path = os.path.join(prefix, test_type, 'fail_nodes') try: fail_nodes_ = set(bench.util.read_node_list(fail_nodes_path)) except IOError as ex: logger.info('unable to read {0}'.format(fail_nodes_path)) logger.debug(ex, exc_info=True) fail_nodes_ = set() error_nodes_path = os.path.join(prefix, test_type, 'error_nodes') try: error_nodes_ = set(bench.util.read_node_list(error_nodes_path)) except IOError as ex: logger.info('unable to read {0}'.format(error_nodes_path)) logger.debug(ex, exc_info=True) error_nodes_ = set() # by default, reserve fail_nodes and error_nodes if not (fail_nodes or error_nodes): nodes_to_update = fail_nodes_ | error_nodes_ else: nodes_to_update = set() if fail_nodes: nodes_to_update |= fail_nodes_ if error_nodes: nodes_to_update |= error_nodes_ if down: node_state = pyslurm.NODE_STATE_DOWN node_state_s = 'DOWN' else: node_state = pyslurm.NODE_STATE_DRAIN node_state_s = 'DRAINED' pyslurm_node = pyslurm.node() for node in sorted(nodes_to_update): current_node_state = pyslurm_node.find_id(node)['node_state'] if current_node_state.startswith(node_state_s): continue node_update = { 'node_names': node, 'node_state': node_state, 'reason': 'bench:{0}'.format(test_type), } rc = pyslurm_node.update(node_update) if rc != 0: logger.error('unable to update node {0}: {1}'.format( node, pyslurm.slurm_strerror(pyslurm.slurm_get_errno()) )) else: logger.info('{0} set to {1}'.format( node, node_state_s))
def update_nodes_from_tests(prefix, test_type, fail_nodes=None, error_nodes=None, down=False): fail_nodes_path = os.path.join(prefix, test_type, 'fail_nodes') try: fail_nodes_ = set(bench.util.read_node_list(fail_nodes_path)) except IOError as ex: logger.info('unable to read {0}'.format(fail_nodes_path)) logger.debug(ex, exc_info=True) fail_nodes_ = set() error_nodes_path = os.path.join(prefix, test_type, 'error_nodes') try: error_nodes_ = set(bench.util.read_node_list(error_nodes_path)) except IOError as ex: logger.info('unable to read {0}'.format(error_nodes_path)) logger.debug(ex, exc_info=True) error_nodes_ = set() # by default, reserve fail_nodes and error_nodes if not (fail_nodes or error_nodes): nodes_to_update = fail_nodes_ | error_nodes_ else: nodes_to_update = set() if fail_nodes: nodes_to_update |= fail_nodes_ if error_nodes: nodes_to_update |= error_nodes_ if down: node_state = pyslurm.NODE_STATE_DOWN node_state_s = 'DOWN' else: node_state = pyslurm.NODE_STATE_DRAIN node_state_s = 'DRAINED' pyslurm_node = pyslurm.node() for node in sorted(nodes_to_update): current_node_state = pyslurm_node.find_id(node)['node_state'] if current_node_state.startswith(node_state_s): continue node_update = { 'node_names': node, 'node_state': node_state, 'reason': 'bench:{0}'.format(test_type), } rc = pyslurm_node.update(node_update) if rc != 0: logger.error('unable to update node {0}: {1}'.format( node, pyslurm.slurm_strerror(pyslurm.slurm_get_errno()))) else: logger.info('{0} set to {1}'.format(node, node_state_s))
dstring = "2013-12-31T18:00:00" dpattern = "%Y-%m-%dT%H:%M:%S" start_epoch = int(time.mktime(time.strptime(dstring, dpattern))) a = pyslurm.reservation() res_dict = pyslurm.create_reservation_dict() res_dict["node_cnt"] = 1 res_dict["users"] = "root" res_dict["start_time"] = start_epoch res_dict["duration"] = 600 resid = a.create(res_dict) rc = pyslurm.slurm_get_errno() if rc != 0: print "Failed - Error : %s" % pyslurm.slurm_strerror(pyslurm.slurm_get_errno()) #sys.exit(-1) else: print "Success - Created reservation %s\n" % resid res_dict = a.get() if res_dict.has_key(resid): date_fields = [ 'end_time', 'start_time' ] value = res_dict[resid] print "Res ID : %s" % (resid) for res_key in sorted(value.iterkeys()): if res_key in date_fields:
#!/usr/bin/env python import pyslurm SLURM_DEBUG=1 SCHED_DEBUG=0 rc = pyslurm.slurm_set_debug_level(SLURM_DEBUG) if rc == -1: print "Error : %s" % pyslurm.slurm_strerror(pyslurm.slurm_get_errno()) elif rc == 0: print "Slurmd debug level updated to %s" % SLURM_DEBUG rc = pyslurm.slurm_set_schedlog_level(SCHED_DEBUG) if rc == -1: print "Error : %s" % pyslurm.slurm_strerror(pyslurm.slurm_get_errno()) elif rc == 0: print "Schedlog log level updated to %s" % SCHED_DEBUG
#!/usr/bin/env python import pyslurm rc, Time = pyslurm.slurm_checkpoint_able(6,0,0) if rc != 0: print "Error : %s" % pyslurm.slurm_strerror(rc) else: print "Job can be checkpointed"
#!/usr/bin/env python import pyslurm SLURM_DEBUG = 1 SCHED_DEBUG = 0 rc = pyslurm.slurm_set_debug_level(SLURM_DEBUG) if rc == -1: print "Error : %s" % pyslurm.slurm_strerror(pyslurm.slurm_get_errno()) elif rc == 0: print "Slurmd debug level updated to %s" % SLURM_DEBUG rc = pyslurm.slurm_set_schedlog_level(SCHED_DEBUG) if rc == -1: print "Error : %s" % pyslurm.slurm_strerror(pyslurm.slurm_get_errno()) elif rc == 0: print "Schedlog log level updated to %s" % SCHED_DEBUG
#define TRIGGER_TYPE_PRI_DB_FAIL 0x00040000 #define TRIGGER_TYPE_PRI_DB_RES_OP 0x00080000 ctypedef struct trigger_info: uint32_t trig_id uint16_t res_type char * res_id uint16_t trig_type uint16_t offset uint32_t user_id char * program """ import pyslurm trigDict = { 'res_type': 'node' , 'res_id': 'makalu', 'offset': 0, 'event': 'down', 'program': '/tmp/test.sh' } a = pyslurm.trigger() rc = a.set(trigDict) if rc != 0: rc = pyslurm.slurm_get_errno() print "Unable to set trigger : %s" % pyslurm.slurm_strerror(rc) else: print "Trigger (%s) set !" % rc
#!/usr/bin/env python import pyslurm TrigID = 5 a = pyslurm.trigger() rc = a.clear(TrigID) if rc != 0: rc = pyslurm.slurm_get_errno() print "Unable to clear trigger : %s" % pyslurm.slurm_strerror(rc) else: print "TriggerID (%s) cleared" % TrigID
dstring = "2013-12-31T18:00:00" dpattern = "%Y-%m-%dT%H:%M:%S" start_epoch = int(time.mktime(time.strptime(dstring, dpattern))) a = pyslurm.reservation() res_dict = pyslurm.create_reservation_dict() res_dict["node_cnt"] = 1 res_dict["users"] = "root" res_dict["start_time"] = start_epoch res_dict["duration"] = 600 resid = a.create(res_dict) rc = pyslurm.slurm_get_errno() if rc != 0: print "Failed - Error : %s" % pyslurm.slurm_strerror( pyslurm.slurm_get_errno()) #sys.exit(-1) else: print "Success - Created reservation %s\n" % resid res_dict = a.get() if res_dict.has_key(resid): date_fields = ['end_time', 'start_time'] value = res_dict[resid] print "Res ID : %s" % (resid) for res_key in sorted(value.iterkeys()): if res_key in date_fields:
#define TRIGGER_TYPE_PRI_DB_FAIL 0x00040000 #define TRIGGER_TYPE_PRI_DB_RES_OP 0x00080000 ctypedef struct trigger_info: uint32_t trig_id uint16_t res_type char * res_id uint16_t trig_type uint16_t offset uint32_t user_id char * program """ import pyslurm trigDict = { 'res_type': 'node', 'res_id': 'makalu', 'offset': 0, 'event': 'down', 'program': '/tmp/test.sh' } a = pyslurm.trigger() rc = a.set(trigDict) if rc != 0: rc = pyslurm.slurm_get_errno() print "Unable to set trigger : %s" % pyslurm.slurm_strerror(rc) else: print "Trigger (%s) set !" % rc