Ejemplo n.º 1
0
static bool _isdefault(List qos_list)
{
    int rc = 0;
    slurmdb_association_cond_t assoc_cond;
    slurmdb_association_rec_t *assoc = NULL;
    ListIterator itr;
    List ret_list = NULL;
    char *name = NULL;

    if(!qos_list || !list_count(qos_list))
        return rc;

    /* this needs to happen before any removing takes place so we
       can figure out things correctly */
    xassert(g_qos_list);

    memset(&assoc_cond, 0, sizeof(slurmdb_association_cond_t));
    assoc_cond.without_parent_info = 1;
    assoc_cond.def_qos_id_list = list_create(slurm_destroy_char);

    itr = list_iterator_create(qos_list);
    while ((name = list_next(itr))) {
        uint32_t id = str_2_slurmdb_qos(g_qos_list, name);
        if(id == NO_VAL)
            continue;
        list_append(assoc_cond.def_qos_id_list,
                    xstrdup_printf("%u", id));
    }
    list_iterator_destroy(itr);

    ret_list = acct_storage_g_get_associations(
                   db_conn, my_uid, &assoc_cond);
    list_destroy(assoc_cond.def_qos_id_list);

    if(!ret_list || !list_count(ret_list))
        goto end_it;

    fprintf(stderr," Associations listed below have these "
            "as their Default QOS.\n");
    itr = list_iterator_create(ret_list);
    while((assoc = list_next(itr))) {
        name = slurmdb_qos_str(g_qos_list, assoc->def_qos_id);
        if (!assoc->user) {
            // see if this isn't a user
            fprintf(stderr,
                    "  DefQOS = %-10s C = %-10s A = %-20s\n",
                    name, assoc->cluster, assoc->acct);
        } else if (assoc->partition) {
            // see if there is a partition name
            fprintf(stderr,
                    "  DefQOS = %-10s C = %-10s A = %-20s "
                    "U = %-9s P = %s\n",
                    name, assoc->cluster, assoc->acct,
                    assoc->user, assoc->partition);
        } else {
            fprintf(stderr,
                    "  DefQOS = %-10s C = %-10s A = %-20s "
                    "U = %-9s\n",
                    name, assoc->cluster, assoc->acct, assoc->user);
        }
    }
    list_iterator_destroy(itr);
    rc = 1;
end_it:
    if(ret_list)
        list_destroy(ret_list);

    return rc;
}
Ejemplo n.º 2
0
extern int sacctmgr_set_association_rec(slurmdb_association_rec_t *assoc,
					char *type, char *value,
					int command_len, int option)
{
	int set = 0;
	uint32_t mins = NO_VAL;

	if (!assoc)
		return set;

	if (!strncasecmp (type, "DefaultQOS", MAX(command_len, 8))) {
		if(!g_qos_list)
			g_qos_list = acct_storage_g_get_qos(
				db_conn, my_uid, NULL);

		if(atoi(value) == -1)
			assoc->def_qos_id = -1;
		else
			assoc->def_qos_id = str_2_slurmdb_qos(
				g_qos_list, value);

		if(assoc->def_qos_id == NO_VAL) {
			fprintf(stderr,
				"You gave a bad default qos '%s'.  "
				"Use 'list qos' to get "
				"complete list.\n",
				value);
			exit_code = 1;
		}
		set = 1;
	} else if (!strncasecmp(type, "FairShare", MAX(command_len, 1))
		   || !strncasecmp(type, "Shares", MAX(command_len, 1))) {
		if (!strncasecmp(value, "parent", 6)) {
			assoc->shares_raw = SLURMDB_FS_USE_PARENT;
			set = 1;
		} else if (get_uint(value, &assoc->shares_raw,
				    "FairShare") == SLURM_SUCCESS) {
			set = 1;
		}
	} else if (!strncasecmp(type, "GrpCPUMins", MAX(command_len, 7))) {
		if (get_uint64(value, &assoc->grp_cpu_mins,
			       "GrpCPUMins") == SLURM_SUCCESS)
			set = 1;
	} else if (!strncasecmp(type, "GrpCPURunMins", MAX(command_len, 7))) {
		if (get_uint64(value, &assoc->grp_cpu_run_mins,
			       "GrpCPURunMins") == SLURM_SUCCESS)
			set = 1;
	} else if (!strncasecmp(type, "GrpCpus", MAX(command_len, 7))) {
		if (get_uint(value, &assoc->grp_cpus,
			     "GrpCpus") == SLURM_SUCCESS)
			set = 1;
	} else if (!strncasecmp(type, "GrpJobs", MAX(command_len, 4))) {
		if (get_uint(value, &assoc->grp_jobs,
			     "GrpJobs") == SLURM_SUCCESS)
			set = 1;
	} else if (!strncasecmp(type, "GrpNodes", MAX(command_len, 4))) {
		if (get_uint(value, &assoc->grp_nodes,
			     "GrpNodes") == SLURM_SUCCESS)
			set = 1;
	} else if (!strncasecmp(type, "GrpSubmitJobs",
				MAX(command_len, 4))) {
		if (get_uint(value, &assoc->grp_submit_jobs,
			     "GrpSubmitJobs") == SLURM_SUCCESS)
			set = 1;
	} else if (!strncasecmp(type, "GrpWall", MAX(command_len, 4))) {
		mins = time_str2mins(value);
		if (mins != NO_VAL) {
			assoc->grp_wall	= mins;
			set = 1;
		} else {
			exit_code=1;
			fprintf(stderr, " Bad GrpWall time format: %s\n", type);
		}
	} else if (!strncasecmp(type, "MaxCPUMinsPerJob",
				MAX(command_len, 7))) {
		if (get_uint64(value, &assoc->max_cpu_mins_pj,
			       "MaxCPUMins") == SLURM_SUCCESS)
			set = 1;
	} else if (!strncasecmp(type, "MaxCPURunMins", MAX(command_len, 7))) {
		if (get_uint64(value, &assoc->max_cpu_run_mins,
			       "MaxCPURunMins") == SLURM_SUCCESS)
			set = 1;
	} else if (!strncasecmp(type, "MaxCpusPerJob", MAX(command_len, 7))) {
		if (get_uint(value, &assoc->max_cpus_pj,
			     "MaxCpus") == SLURM_SUCCESS)
			set = 1;
	} else if (!strncasecmp(type, "MaxJobs", MAX(command_len, 4))) {
		if (get_uint(value, &assoc->max_jobs,
			     "MaxJobs") == SLURM_SUCCESS)
			set = 1;
	} else if (!strncasecmp(type, "MaxNodesPerJob", MAX(command_len, 4))) {
		if (get_uint(value, &assoc->max_nodes_pj,
			     "MaxNodes") == SLURM_SUCCESS)
			set = 1;
	} else if (!strncasecmp(type, "MaxSubmitJobs", MAX(command_len, 4))) {
		if (get_uint(value, &assoc->max_submit_jobs,
			     "MaxSubmitJobs") == SLURM_SUCCESS)
			set = 1;
	} else if (!strncasecmp(type, "MaxWallDurationPerJob",
				MAX(command_len, 4))) {
		mins = time_str2mins(value);
		if (mins != NO_VAL) {
			assoc->max_wall_pj = mins;
			set = 1;
		} else {
			exit_code=1;
			fprintf(stderr,
				" Bad MaxWall time format: %s\n",
				type);
		}
	} else if (!strncasecmp(type, "Parent", MAX(command_len, 1))) {
		assoc->parent_acct = strip_quotes(value, NULL, 1);
		set = 1;
	} else if (!strncasecmp(type, "QosLevel", MAX(command_len, 1))) {
		if (!assoc->qos_list)
			assoc->qos_list = list_create(slurm_destroy_char);

		if (!g_qos_list)
			g_qos_list = acct_storage_g_get_qos(
				db_conn, my_uid, NULL);

		if (slurmdb_addto_qos_char_list(assoc->qos_list,
						g_qos_list, value,
						option))
			set = 1;
	}

	return set;
}