示例#1
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;
}
示例#2
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;

}
示例#3
0
extern void scontrol_print_assoc_mgr_info(int argc, char *argv[])
{
	char *tag = NULL, *val = NULL;
	int cc, tag_len, i;
	assoc_mgr_info_request_msg_t req;
	assoc_mgr_info_msg_t *msg = NULL;

	memset(&req, 0, sizeof(assoc_mgr_info_request_msg_t));

	for (i = 0; i < argc; ++i) {
		tag = argv[i];
		tag_len = strlen(tag);
		val = strchr(argv[i], '=');
		if (val) {
			tag_len = val - argv[i];
			val++;
		}

		/* We free every list before creating it. This way we ensure
		 * we are just appending the last value if user repeats entity.
		 */
		if (!val || !val[0]) {
			fprintf(stderr, "No value given for option %s\n", tag);
			goto endit;
		} else if (!strncasecmp(tag, "accounts", MAX(tag_len, 1))) {
			if (!req.acct_list)
				req.acct_list = list_create(slurm_destroy_char);
			slurm_addto_char_list(req.acct_list, val);
		} else if (!strncasecmp(tag, "flags", MAX(tag_len, 1))) {
			if (slurm_strcasestr(val, "users"))
				req.flags |= ASSOC_MGR_INFO_FLAG_USERS;
			if (slurm_strcasestr(val, "assoc"))
				req.flags |= ASSOC_MGR_INFO_FLAG_ASSOC;
			if (slurm_strcasestr(val, "qos"))
				req.flags |= ASSOC_MGR_INFO_FLAG_QOS;

			if (!req.flags) {
				fprintf(stderr, "invalid flag '%s', "
					"valid options are "
					"'Assoc, QOS, and/or Users'\n",
					val);
				goto endit;
			}
		} else if (!strncasecmp(tag, "qos", MAX(tag_len, 1))) {
			if (!req.qos_list)
				req.qos_list = list_create(slurm_destroy_char);
			slurm_addto_char_list(req.qos_list, val);
		} else if (!strncasecmp(tag, "users", MAX(tag_len, 1))) {
			if (!req.user_list)
				req.user_list = list_create(slurm_destroy_char);
			slurm_addto_char_list(req.user_list, val);
		} else {
			exit_code = 1;
			if (quiet_flag != 1)
				fprintf(stderr, "invalid entity: %s for keyword"
					":show assoc_mgr\n", tag);
			goto endit;
		}
	}

	if (!req.flags)
		req.flags = ASSOC_MGR_INFO_FLAG_ASSOC |
			ASSOC_MGR_INFO_FLAG_USERS |
			ASSOC_MGR_INFO_FLAG_QOS;

	req_flags = req.flags;

	/* call the controller to get the meat */
	cc = slurm_load_assoc_mgr_info(&req, &msg);

	if (cc == SLURM_PROTOCOL_SUCCESS) {
		/* print the info
		 */
		_print_assoc_mgr_info(msg);
	} else {
		/* Hosed, crap out. */
		exit_code = 1;
		if (quiet_flag != 1)
			slurm_perror("slurm_load_assoc_mgr_info error");
	}

	slurm_free_assoc_mgr_info_msg(msg);
endit:
	slurm_free_assoc_mgr_info_request_members(&req);

	return;
}