示例#1
0
文件: sdiag.c 项目: rathamahata/slurm
int main(int argc, char *argv[])
{
    int rc = 0;

    slurm_conf_init(NULL);
    parse_command_line(argc, argv);

    if (sdiag_param == STAT_COMMAND_RESET) {
        req.command_id = STAT_COMMAND_RESET;
        rc = slurm_reset_statistics((stats_info_request_msg_t *)&req);
        if (rc == SLURM_SUCCESS)
            printf("Reset scheduling statistics\n");
        else
            slurm_perror("slurm_reset_statistics");
    } else {
        req.command_id = STAT_COMMAND_GET;
        rc = slurm_get_statistics(&buf,
                                  (stats_info_request_msg_t *)&req);
        if (rc == SLURM_SUCCESS) {
            _sort_rpc();
            rc = _print_stats();
#ifdef MEMORY_LEAK_DEBUG
            uid_cache_clear();
            slurm_free_stats_response_msg(buf);
            xfree(rpc_type_ave_time);
            xfree(rpc_user_ave_time);
#endif
        } else
            slurm_perror("slurm_get_statistics");
    }

    exit(rc);
}
示例#2
0
/*
 * scontrol_pid_info - given a local process id, print the corresponding
 *	slurm job id and its expected end time
 * IN job_pid - the local process id of interest
 */
extern void
scontrol_pid_info(pid_t job_pid)
{
	int error_code;
	uint32_t job_id;
	time_t end_time;
	long rem_time;

	error_code = slurm_pid2jobid (job_pid, &job_id);
	if (error_code) {
		exit_code = 1;
		if (quiet_flag != 1)
			slurm_perror ("slurm_pid2jobid error");
		return;
	}

	error_code = slurm_get_end_time(job_id, &end_time);
	if (error_code) {
		exit_code = 1;
		if (quiet_flag != 1)
			slurm_perror ("slurm_get_end_time error");
		return;
	}
	printf("Slurm job id %u ends at %s\n", job_id, slurm_ctime(&end_time));

	rem_time = slurm_get_rem_time(job_id);
	printf("slurm_get_rem_time is %ld\n", rem_time);
	return;
}
示例#3
0
static int _get_job_size(uint32_t job_id)
{
	job_info_msg_t *job_buffer_ptr;
	job_info_t * job_ptr;
	int i, size = 1;
	hostlist_t hl;

	if (slurm_load_jobs((time_t) 0, &job_buffer_ptr, SHOW_ALL)) {
		slurm_perror("slurm_load_jobs");
		return 1;
	}

	for (i = 0; i < job_buffer_ptr->record_count; i++) {
		job_ptr = &job_buffer_ptr->job_array[i];
		if (job_ptr->job_id != job_id)
			continue;
		hl = hostlist_create(job_ptr->nodes);
		if (hl) {
			size = hostlist_count(hl);
			hostlist_destroy(hl);
		}
		break;
	}
	slurm_free_job_info_msg (job_buffer_ptr);

#if _DEBUG
	printf("Size is %d\n", size);
#endif
	return size;
}
示例#4
0
/* scontrol_print_licenses()
 *
 * Retrieve and display the license information
 * from the controller
 *
 */
void
scontrol_print_licenses(const char *name)
{
	int cc;
	license_info_msg_t *msg;
	uint16_t show_flags;
	static time_t last_update;

	show_flags = 0;
	/* call the controller to get the meat
	 */
	cc = slurm_load_licenses(last_update, &msg, show_flags);
	if (cc != SLURM_PROTOCOL_SUCCESS) {
		/* Hosed, crap out.
		 */
		exit_code = 1;
		if (quiet_flag != 1)
			slurm_perror ("slurm_load_license error");
		return;
	}

	last_update = time(NULL);
	/* print the info
	 */
	_print_license_info(name, msg);

	/* free at last
	 */
	slurm_free_license_info_msg(msg);

	return;
}
示例#5
0
/*
 * _bg_report - download and print current bgblock state information
 */
static int _bg_report(block_info_msg_t *block_ptr)
{
	int i;

	if (!block_ptr) {
		slurm_perror("No block_ptr given");
		return SLURM_ERROR;
	}

	if (!params.no_header)
		printf("BG_BLOCK         MIDPLANES       STATE    CONNECTION USE\n");
/*                      1234567890123456 123456789012 12345678 1234567890 12345+ */
/*                      RMP_22Apr1544018 bg[123x456]  READY    TORUS      COPROCESSOR */

	for (i=0; i<block_ptr->record_count; i++) {
		char *conn_str = conn_type_string_full(
			block_ptr->block_array[i].conn_type);
		printf("%-16.16s %-15.15s %-8.8s %-10.10s %s\n",
		       block_ptr->block_array[i].bg_block_id,
		       block_ptr->block_array[i].mp_str,
		       bg_block_state_string(
			       block_ptr->block_array[i].state),
		       conn_str,
		       node_use_string(
			       block_ptr->block_array[i].node_use));
		xfree(conn_str);
	}

	return SLURM_SUCCESS;
}
示例#6
0
static int _clear_trigger(void)
{
	trigger_info_t ti;
	char tmp_c[128];

	slurm_init_trigger_msg(&ti);
	ti.trig_id	= params.trigger_id;
	ti.user_id	= params.user_id;
	if (params.job_id) {
		ti.res_type = TRIGGER_RES_TYPE_JOB;
		snprintf(tmp_c, sizeof(tmp_c), "%u", params.job_id);
		ti.res_id   = tmp_c;
	}
	if (slurm_clear_trigger(&ti)) {
		if (!params.quiet) {
			slurm_perror("slurm_clear_trigger");
			return 1;
		}
		return 0;
	}

	if (params.job_id)
		verbose("triggers for job %s cleared", ti.res_id);
	else if (params.user_id != NO_VAL)
		verbose("triggers for user %u cleared", ti.user_id);
	else
		verbose("trigger %u cleared", ti.trig_id);
	return 0;
}
示例#7
0
void
scontrol_print_cache(const char *name)
{
	int cc;
	cache_info_msg_t *msg;
	uint16_t show_flags;

	show_flags = 0;
	/* call the controller to get the meat
	 */
	cc = slurm_load_cache(&msg, show_flags);
	if (cc != SLURM_PROTOCOL_SUCCESS) {
		/* Hosed, crap out.
		 */
		exit_code = 1;
		if (quiet_flag != 1)
			slurm_perror ("slurm_load_cache error");
		return;
	}

	/* print the info
	 */
	_print_cache_info(name, msg);

	/* free at last
	 */
	slurm_free_cache_info_msg(msg);

	return;
}
示例#8
0
extern int state_control_configured_tres(char *type)
{
	int i, cc;
	int rc = SLURM_ERROR;
	assoc_mgr_info_request_msg_t req;
	assoc_mgr_info_msg_t *msg = NULL;

	memset(&req, 0, sizeof(assoc_mgr_info_request_msg_t));
	cc = slurm_load_assoc_mgr_info(&req, &msg);
	if (cc != SLURM_PROTOCOL_SUCCESS) {
		slurm_perror("slurm_load_assoc_mgr_info error");
		goto cleanup;
	}

	for (i = 0; i < msg->tres_cnt; ++i) {
		if (!xstrcasecmp(msg->tres_names[i], type)) {
			rc = SLURM_SUCCESS;
			goto cleanup;
		}
	}

cleanup:
	slurm_free_assoc_mgr_info_msg(msg);
	return rc;
}
示例#9
0
/* -1 = error, 0 = is configured, 1 = isn't configured */
static int _is_configured_tres(char *type)
{

    int i, cc;
    assoc_mgr_info_request_msg_t req;
    assoc_mgr_info_msg_t *msg = NULL;

    memset(&req, 0, sizeof(assoc_mgr_info_request_msg_t));
    cc = slurm_load_assoc_mgr_info(&req, &msg);
    if (cc != SLURM_PROTOCOL_SUCCESS) {
        slurm_perror("slurm_load_assoc_mgr_info error");
        slurm_free_assoc_mgr_info_msg(msg);
        return SLURM_ERROR;
    }

    for (i = 0; i < msg->tres_cnt; ++i) {
        if (!strcasecmp(msg->tres_names[i], type)) {
            slurm_free_assoc_mgr_info_msg(msg);
            return SLURM_SUCCESS;
        }
    }

    error("'%s' is not a configured TRES", type);
    slurm_free_assoc_mgr_info_msg(msg);
    return SLURM_ERROR;

}
示例#10
0
文件: update_part.c 项目: HDOD/slurm
/*
 * scontrol_create_part - create a slurm partition configuration per the
 *	supplied arguments
 * IN argc - count of arguments
 * IN argv - list of arguments
 * RET 0 if no slurm error, errno otherwise. parsing error prints
 *			error message and returns 0
 */
extern int
scontrol_create_part (int argc, char *argv[])
{
	int update_cnt = 0;
	update_part_msg_t part_msg;

	slurm_init_part_desc_msg ( &part_msg );
	scontrol_parse_part_options (argc, argv, &update_cnt, &part_msg);

	if (part_msg.name == NULL) {
		exit_code = 1;
		error("PartitionName must be given.");
		return 0;
	} else if (xstrcasecmp(part_msg.name, "default") == 0) {
		exit_code = 1;
		error("PartitionName cannot be \"DEFAULT\".");
		return 0;
	}

	if (update_cnt == 0) {
		exit_code = 1;
		error("No parameters specified");
		return 0;
	}

	if (slurm_create_partition(&part_msg)) {
		exit_code = 1;
		slurm_perror("Error creating the partition");
		return slurm_get_errno ();
	} else
		return 0;
}
示例#11
0
extern uint16_t
scontrol_get_job_state(uint32_t job_id)
{
	job_info_msg_t * job_buffer_ptr = NULL;
	int error_code = SLURM_SUCCESS, i;
	job_info_t *job_ptr = NULL;

	error_code = scontrol_load_job(&job_buffer_ptr, job_id);
	if (error_code) {
		exit_code = 1;
		if (quiet_flag == -1)
			slurm_perror ("slurm_load_job error");
		return (uint16_t) NO_VAL;
	}
	if (quiet_flag == -1) {
		char time_str[32];
		slurm_make_time_str((time_t *)&job_buffer_ptr->last_update,
				    time_str, sizeof(time_str));
		printf("last_update_time=%s, records=%d\n",
		       time_str, job_buffer_ptr->record_count);
	}

	job_ptr = job_buffer_ptr->job_array ;
	for (i = 0; i < job_buffer_ptr->record_count; i++) {
		if (job_ptr->job_id == job_id)
			return job_ptr->job_state;
	}
	if (quiet_flag == -1)
		printf("Could not find job %u", job_id);
	return (uint16_t) NO_VAL;
}
示例#12
0
文件: info_node.c 项目: BYUHPC/slurm
/*
 * scontrol_print_node_list - print information about the supplied node list
 *	(or regular expression)
 * IN node_list - print information about the supplied node list
 *	(or regular expression)
 */
extern void
scontrol_print_node_list (char *node_list)
{
	node_info_msg_t *node_info_ptr = NULL;
	hostlist_t host_list;
	int error_code;
	uint16_t show_flags = 0;
	char *this_node_name;

	if (all_flag)
		show_flags |= SHOW_ALL;
	if (detail_flag)
		show_flags |= SHOW_DETAIL;

	error_code = scontrol_load_nodes(&node_info_ptr, show_flags);
	if (error_code) {
		exit_code = 1;
		if (quiet_flag != 1)
			slurm_perror ("slurm_load_node error");
		return;
	}

	if (quiet_flag == -1) {
		char time_str[32];
		slurm_make_time_str ((time_t *)&node_info_ptr->last_update,
			             time_str, sizeof(time_str));
		printf ("last_update_time=%s, records=%d\n",
			time_str, node_info_ptr->record_count);
	}

	if (node_list == NULL) {
		scontrol_print_node (NULL, node_info_ptr);
	} else {
		if ((host_list = hostlist_create (node_list))) {
			while ((this_node_name = hostlist_shift (host_list))) {
				scontrol_print_node(this_node_name,
						    node_info_ptr);
				free(this_node_name);
			}

			hostlist_destroy(host_list);
		} else {
			exit_code = 1;
			if (quiet_flag != 1) {
				if (errno == EINVAL) {
					fprintf(stderr,
					        "unable to parse node list %s\n",
					        node_list);
				 } else if (errno == ERANGE) {
					fprintf(stderr,
					        "too many nodes in supplied range %s\n",
					        node_list);
				} else
					perror("error parsing node list");
			}
		}
	}
	return;
}
示例#13
0
/*
 * scontrol_print_job - print the specified job's information
 * IN job_id - job's id or NULL to print information about all jobs
 */
extern void
scontrol_print_job (char * job_id_str)
{
	int error_code = SLURM_SUCCESS, i, print_cnt = 0;
	uint32_t job_id = 0;
	uint16_t array_id = (uint16_t) NO_VAL;
	job_info_msg_t * job_buffer_ptr = NULL;
	job_info_t *job_ptr = NULL;
	char *end_ptr = NULL;

	if (job_id_str) {
		job_id = (uint32_t) strtol (job_id_str, &end_ptr, 10);
		if (end_ptr[0] == '_')
			array_id = strtol( end_ptr + 1, &end_ptr, 10 );
	}

	error_code = scontrol_load_job(&job_buffer_ptr, job_id);
	if (error_code) {
		exit_code = 1;
		if (quiet_flag != 1)
			slurm_perror ("slurm_load_jobs error");
		return;
	}
	if (quiet_flag == -1) {
		char time_str[32];
		slurm_make_time_str ((time_t *)&job_buffer_ptr->last_update,
				     time_str, sizeof(time_str));
		printf ("last_update_time=%s, records=%d\n",
			time_str, job_buffer_ptr->record_count);
	}

	job_ptr = job_buffer_ptr->job_array ;
	for (i = 0, job_ptr = job_buffer_ptr->job_array;
	     i < job_buffer_ptr->record_count; i++, job_ptr++) {
		if ((array_id != (uint16_t) NO_VAL) &&
		    (array_id != job_ptr->array_task_id))
			continue;
		slurm_print_job_info(stdout, job_ptr, one_liner);
		print_cnt++;
	}

	if (print_cnt == 0) {
		if (job_id_str) {
			exit_code = 1;
			if (quiet_flag != 1) {
				if (array_id == (uint16_t) NO_VAL) {
					printf("Job %u not found\n", job_id);
				} else {
					printf("Job %u_%u not found\n",
					       job_id, array_id);
				}
			}
		} else if (quiet_flag != 1)
			printf ("No jobs in the system\n");
	}
}
示例#14
0
文件: squeue.c 项目: bingzhang/slurm
/* _print_job_step - print the specified job step's information */
static int
_print_job_steps( bool clear_old )
{
	int error_code;
	static job_step_info_response_msg_t * old_step_ptr = NULL;
	static job_step_info_response_msg_t  * new_step_ptr;
	uint16_t show_flags = 0;

	if (params.all_flag)
		show_flags |= SHOW_ALL;

	if (old_step_ptr) {
		if (clear_old)
			old_step_ptr->last_update = 0;
		/* Use a last_update time of 0 so that we can get an updated
		 * run_time for jobs rather than just its start_time */
		error_code = slurm_get_job_steps((time_t) 0, NO_VAL, NO_VAL,
						 &new_step_ptr, show_flags);
		if (error_code ==  SLURM_SUCCESS)
			slurm_free_job_step_info_response_msg( old_step_ptr );
		else if (slurm_get_errno () == SLURM_NO_CHANGE_IN_DATA) {
			error_code = SLURM_SUCCESS;
			new_step_ptr = old_step_ptr;
		}
	} else {
		error_code = slurm_get_job_steps((time_t) 0, NO_VAL, NO_VAL,
						 &new_step_ptr, show_flags);
	}
	if (error_code) {
		slurm_perror ("slurm_get_job_steps error");
		return SLURM_ERROR;
	}
	old_step_ptr = new_step_ptr;

	if (params.verbose) {
		printf ("last_update_time=%ld records=%u\n",
			(long) new_step_ptr->last_update,
			new_step_ptr->job_step_count);
	}

	if (!params.format && !params.format_long)
		params.format = "%.15i %.8j %.9P %.8u %.9M %N";

	if (!params.format_list) {
		if (params.format)
			parse_format(params.format);
		else if (params.format_long)
			parse_long_format(params.format_long);
	}

	print_steps_array( new_step_ptr->job_steps,
			   new_step_ptr->job_step_count,
			   params.format_list );
	return SLURM_SUCCESS;
}
示例#15
0
文件: sdiag.c 项目: IFCA/slurm
static int _get_info(void)
{
	int rc;

	req.command_id = STAT_COMMAND_GET;
	rc = slurm_get_statistics(&buf, (stats_info_request_msg_t *)&req);
	if (rc != SLURM_SUCCESS)
		slurm_perror("slurm_get_statistics");

	return rc;
}
示例#16
0
文件: info_job.c 项目: cread/slurm
/*
 * scontrol_print_completing - print jobs in completing state and
 *	associated nodes in COMPLETING or DOWN state
 */
extern void
scontrol_print_completing (void)
{
	int error_code, i;
	job_info_msg_t  *job_info_msg;
	job_info_t      *job_info;
	node_info_msg_t *node_info_msg;
	uint16_t         show_flags = 0;

	error_code = scontrol_load_job (&job_info_msg, 0);
	if (error_code) {
		exit_code = 1;
		if (quiet_flag != 1)
			slurm_perror ("slurm_load_jobs error");
		return;
	}
	/* Must load all nodes including hidden for cross-index
	 * from job's node_inx to node table to work */
	/*if (all_flag)		Always set this flag */
	show_flags |= SHOW_ALL;
	if (federation_flag)
		show_flags |= SHOW_FEDERATION;
	if (local_flag)
		show_flags |= SHOW_LOCAL;
	error_code = scontrol_load_nodes(&node_info_msg, show_flags);
	if (error_code) {
		exit_code = 1;
		if (quiet_flag != 1)
			slurm_perror ("slurm_load_nodes error");
		return;
	}

	/* Scan the jobs for completing state */
	job_info = job_info_msg->job_array;
	for (i = 0; i < job_info_msg->record_count; i++) {
		if (job_info[i].job_state & JOB_COMPLETING)
			scontrol_print_completing_job(&job_info[i],
						      node_info_msg);
	}
	slurm_free_node_info_msg(node_info_msg);
}
示例#17
0
/*
 * _reservation_report - print current reservation information
 */
static int _reservation_report(reserve_info_msg_t *resv_ptr)
{
	if (!resv_ptr) {
		slurm_perror("No resv_ptr given\n");
		return SLURM_ERROR;
	}
	if (resv_ptr->record_count != 0) {
		print_sinfo_reservation(resv_ptr);
	} else
		printf ("No reservations in the system\n");
	return SLURM_SUCCESS;
}
示例#18
0
/* DO NOT RUN AGAINST PRODUCTION NODES, IT CAN MESS UP STATE */
int
main (int argc, char *argv[]) {
	int error_code;
	update_part_msg_t	part_update1 ;
	update_part_msg_t	part_update2 ;
	update_node_msg_t	node_update1 ;
	update_node_msg_t	node_update2 ;
	char node_name[NAME_LEN];

	slurm_init_part_desc_msg ( &part_update1 );
	slurm_init_part_desc_msg ( &part_update2 );
	part_update1 . name = "batch" ;
	part_update2 . name = "batch" ;
	part_update1 . state_up = false ;
	part_update2 . state_up = true ; 

	_getnodename(node_name, NAME_LEN);
	node_update1 . node_names = node_name ;
	node_update2 . node_names = node_name ;
	node_update1 . node_state = NODE_STATE_DRAIN ;
	node_update2 . node_state = NODE_RESUME ; 

	error_code = slurm_update_partition ( &part_update1);
	if (error_code)
		slurm_perror ("slurm_update_partition #1");

	error_code = slurm_update_partition ( &part_update2);
	if (error_code)
		slurm_perror ("slurm_update_partition #2");

	error_code = slurm_update_node ( &node_update1);
	if (error_code)
		slurm_perror ("slurm_update_node #1");

	error_code = slurm_update_node ( &node_update2);
	if (error_code)
		slurm_perror ("slurm_update_node #2");

	return (errno);
}
示例#19
0
/*
 * scontrol_print_bbstat - Print burst buffer status information to stdout
 */
extern void scontrol_print_bbstat(int argc, char **argv)
{
	char *stat_resp = NULL;
	int error_code;

	error_code = slurm_load_burst_buffer_stat(argc, argv, &stat_resp);
	if (error_code) {
		exit_code = 1;
		if (quiet_flag != 1)
			slurm_perror("slurm_load_burst_buffer_stat error");
		return;
	}
	fprintf(stdout, "%s", stat_resp);
	xfree(stat_resp);
}
示例#20
0
文件: scancel.c 项目: adammoody/slurm
/* _load_job_records - load all job information for filtering
 * and verification
 */
static void
_load_job_records (void)
{
	int error_code;

	/* We need the fill job array string representation for identifying
	 * and killing job arrays */
	setenv("SLURM_BITSTR_LEN", "0", 1);
	error_code = slurm_load_jobs ((time_t) NULL, &job_buffer_ptr, 1);

	if (error_code) {
		slurm_perror ("slurm_load_jobs error");
		exit (1);
	}
}
示例#21
0
文件: info_node.c 项目: VURM/slurm
/*
 * scontrol_print_topo - print the switch topology above the specified node
 * IN node_name - NULL to print all topology information
 */
extern void	scontrol_print_topo (char *node_list)
{
	static topo_info_response_msg_t *topo_info_msg = NULL;
	int i, match, match_cnt = 0;
	hostset_t hs;

	if ((topo_info_msg == NULL) &&
	    slurm_load_topo(&topo_info_msg)) {
		slurm_perror ("slurm_load_topo error");
		return;
	}

	if ((node_list == NULL) || (node_list[0] == '\0')) {
		slurm_print_topo_info_msg(stdout, topo_info_msg, one_liner);
		return;
	}

	/* Search for matching switch name */
	for (i=0; i<topo_info_msg->record_count; i++) {
		if (strcmp(topo_info_msg->topo_array[i].name, node_list))
			continue;
		slurm_print_topo_record(stdout, &topo_info_msg->topo_array[i],
					one_liner);
		return;
	}

	/* Search for matching node name */
	for (i=0; i<topo_info_msg->record_count; i++) {
		if ((topo_info_msg->topo_array[i].nodes == NULL) ||
		    (topo_info_msg->topo_array[i].nodes[0] == '\0'))
			continue;
		hs = hostset_create(topo_info_msg->topo_array[i].nodes);
		if (hs == NULL)
			fatal("hostset_create: memory allocation failure");
		match = hostset_within(hs, node_list);
		hostset_destroy(hs);
		if (!match)
			continue;
		match_cnt++;
		slurm_print_topo_record(stdout, &topo_info_msg->topo_array[i],
					one_liner);
	}

	if (match_cnt == 0) {
		error("Topology information contains no switch or "
		      "node named %s", node_list);
	}
}
示例#22
0
文件: sshare.c 项目: jtfrey/slurm
static int _single_cluster(shares_request_msg_t *req_msg)
{
	int rc = SLURM_SUCCESS;
	shares_response_msg_t *resp_msg = NULL;

	rc = _get_info(req_msg, &resp_msg);
	if (rc) {
		slurm_perror("Couldn't get shares from controller");
		return rc;
	}

	process(resp_msg, options);
	slurm_free_shares_response_msg(resp_msg);

	return rc;
}
示例#23
0
/*
 * scontrol_update_res - update the slurm reservation configuration per the
 *     supplied arguments
 * IN argc - count of arguments
 * IN argv - list of arguments
 * RET 0 if no slurm error, errno otherwise. parsing error prints
 *     error message and returns 0.
 */
extern int
scontrol_update_res(int argc, char *argv[])
{
    resv_desc_msg_t   resv_msg;
    int err, ret = 0;
    int free_user_str = 0, free_acct_str = 0, free_tres_license = 0,
        free_tres_bb = 0, free_tres_corecnt = 0, free_tres_nodecnt = 0;

    slurm_init_resv_desc_msg (&resv_msg);
    err = scontrol_parse_res_options(argc, argv, "No reservation update.",
                                     &resv_msg, &free_user_str,
                                     &free_acct_str, &free_tres_license,
                                     &free_tres_bb, &free_tres_corecnt,
                                     &free_tres_nodecnt);
    if (err)
        goto SCONTROL_UPDATE_RES_CLEANUP;

    if (resv_msg.name == NULL) {
        exit_code = 1;
        error("Reservation must be given.  No reservation update.");
        goto SCONTROL_UPDATE_RES_CLEANUP;
    }

    err = slurm_update_reservation(&resv_msg);
    if (err) {
        exit_code = 1;
        slurm_perror("Error updating the reservation");
        ret = slurm_get_errno();
    } else {
        printf("Reservation updated.\n");
    }

SCONTROL_UPDATE_RES_CLEANUP:
    if (free_user_str)
        xfree(resv_msg.users);
    if (free_acct_str)
        xfree(resv_msg.accounts);
    if (free_tres_license)
        xfree(resv_msg.licenses);
    if (free_tres_bb)
        xfree(resv_msg.burst_buffer);
    if (free_tres_corecnt)
        xfree(resv_msg.core_cnt);
    if (free_tres_nodecnt)
        xfree(resv_msg.node_cnt);
    return ret;
}
示例#24
0
文件: info_block.c 项目: A1ve5/slurm
/*
 * scontrol_print_block - print the specified block's information
 * IN block_name - NULL to print information about all block
 */
extern void
scontrol_print_block (char *block_name)
{
	int error_code, i, print_cnt = 0;
	block_info_msg_t *block_info_ptr = NULL;
	block_info_t *block_ptr = NULL;

	error_code = scontrol_load_block(&block_info_ptr);
	if (error_code) {
		exit_code = 1;
		if (quiet_flag != 1)
			slurm_perror ("slurm_load_block error");
		return;
	}

	if (quiet_flag == -1) {
		char time_str[32];
		slurm_make_time_str(
			(time_t *)&block_info_ptr->last_update,
			time_str, sizeof(time_str));
		printf ("last_update_time=%s, records=%d\n",
			time_str, block_info_ptr->record_count);
	}

	block_ptr = block_info_ptr->block_array;
	for (i = 0; i < block_info_ptr->record_count; i++) {
		if (block_name
		    && xstrcmp(block_name, block_ptr[i].bg_block_id))
			continue;
		print_cnt++;
		slurm_print_block_info(
			stdout, &block_ptr[i], one_liner);
		if (block_name)
			break;
	}

	if (print_cnt == 0) {
		if (block_name) {
			exit_code = 1;
			if (quiet_flag != 1)
				printf ("Block %s not found\n",
				        block_name);
		} else if (quiet_flag != 1)
			printf ("No blocks in the system\n");
	}
}
示例#25
0
文件: info_part.c 项目: BYUHPC/slurm
/*
 * scontrol_print_part - print the specified partition's information
 * IN partition_name - NULL to print information about all partition
 */
extern void
scontrol_print_part (char *partition_name)
{
	int error_code, i, print_cnt = 0;
	partition_info_msg_t *part_info_ptr = NULL;
	partition_info_t *part_ptr = NULL;

	error_code = scontrol_load_partitions(&part_info_ptr);
	if (error_code) {
		exit_code = 1;
		if (quiet_flag != 1)
			slurm_perror ("slurm_load_partitions error");
		return;
	}

	if (quiet_flag == -1) {
		char time_str[32];
		slurm_make_time_str ((time_t *)&part_info_ptr->last_update,
			       time_str, sizeof(time_str));
		printf ("last_update_time=%s, records=%d\n",
			time_str, part_info_ptr->record_count);
	}

	part_ptr = part_info_ptr->partition_array;
	for (i = 0; i < part_info_ptr->record_count; i++) {
		if (partition_name &&
		    strcmp (partition_name, part_ptr[i].name) != 0)
			continue;
		print_cnt++;
		slurm_print_partition_info (stdout, & part_ptr[i],
		                            one_liner ) ;
		if (partition_name)
			break;
	}

	if (print_cnt == 0) {
		if (partition_name) {
			exit_code = 1;
			if (quiet_flag != 1)
				printf ("Partition %s not found\n",
				        partition_name);
		} else if (quiet_flag != 1)
			printf ("No partitions in the system\n");
	}
}
示例#26
0
/* main is used here for testing purposes only */
int 
main (int argc, char *argv[]) 
{
	static time_t last_update_time = (time_t) NULL;
	int error_code;
	job_info_msg_t * job_info_msg_ptr = NULL;

	error_code = slurm_load_jobs (last_update_time, &job_info_msg_ptr, 1);
	if (error_code) {
		slurm_perror ("slurm_load_jobs");
		return (error_code);
	}

	slurm_print_job_info_msg ( stdout, job_info_msg_ptr, 1 ) ;

	slurm_free_job_info_msg ( job_info_msg_ptr ) ;
	return (0);
}
示例#27
0
/* main is used here for module testing purposes only */
int 
main (int argc, char *argv[]) {
	int i, count, error_code;

	if (argc < 2)
		count = 1;
	else
		count = atoi (argv[1]);

	for (i = 0; i < count; i++) {
		error_code = slurm_reconfigure ();
		if (error_code != 0) {
			slurm_perror ("slurm_reconfigure");
			return (1);
		}
	}
	return (0);
}
示例#28
0
文件: update_job.c 项目: Cray/slurm
/* _get_job_info()
 */
static job_info_msg_t *
_get_job_info(const char *jobid, uint32_t *task_id)
{
	char buf[64];
	char *taskid;
	char *next_str;
	uint32_t job_id;
	int cc;
	job_info_msg_t *job_info;

	if (strlen(jobid) > 63)
		return NULL;

	strcpy(buf, jobid);

	taskid = strchr(buf, '_');
	if (taskid) {

		*taskid = 0;
		++taskid;

		*task_id = (uint32_t)strtol(taskid, &next_str, 10);
		if (next_str[0] != '\0') {
			fprintf(stderr, "Invalid task_id specified\n");
			return NULL;
		}
	}

	job_id = (uint32_t)strtol(buf, &next_str, 10);
	if (next_str[0] != '\0') {
		fprintf(stderr, "Invalid job_id specified\n");
		return NULL;
	}

	cc = slurm_load_job(&job_info, job_id, SHOW_ALL);
	if (cc < 0) {
		slurm_perror("slurm_load_job");
		return NULL;
	}

	return job_info;
}
示例#29
0
bitstr_t *get_requested_node_bitmap(void)
{
	static bitstr_t *bitmap = NULL;
	static node_info_msg_t *old_node_ptr = NULL, *new_node_ptr;
	int error_code;
	int i = 0;
	node_info_t *node_ptr = NULL;

	if (!params.hl)
		return NULL;

	if (old_node_ptr) {
		error_code = slurm_load_node(old_node_ptr->last_update,
					     &new_node_ptr, SHOW_ALL);
		if (error_code == SLURM_SUCCESS)
			slurm_free_node_info_msg(old_node_ptr);
		else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA)
			return bitmap;
	} else {
		error_code = slurm_load_node((time_t) NULL, &new_node_ptr,
					     SHOW_ALL);
	}

	if (bitmap)
		FREE_NULL_BITMAP(bitmap);

	if (error_code) {
		slurm_perror("slurm_load_node");
		return NULL;
	}

	old_node_ptr = new_node_ptr;

	bitmap = bit_alloc(old_node_ptr->record_count);
	for (i = 0; i < old_node_ptr->record_count; i++) {
		node_ptr = &(old_node_ptr->node_array[i]);
		if (hostlist_find(params.hl, node_ptr->name) != -1)
			bit_set(bitmap, i);
	}
	return bitmap;
}
示例#30
0
/* main is used here for module testing purposes only */
int
main (int argc, char *argv[]) 
{
	static time_t last_update_time = (time_t) NULL;
	int error_code ;
	partition_info_msg_t * part_info_ptr = NULL;

	error_code = slurm_load_partitions (last_update_time, &part_info_ptr, 1);
	if (error_code) {
		slurm_perror ("slurm_load_partitions");
		return (error_code);
	}

	note("Updated at %ld, record count %d\n",
		(time_t) part_info_ptr->last_update, 
		part_info_ptr->record_count);

	slurm_print_partition_info_msg (stdout, part_info_ptr, 0);
	slurm_free_partition_info_msg (part_info_ptr);
	return (0);
}