Exemple #1
0
/*
 * get info from the storage
 * IN:  slurmdb_qos_cond_t *
 * RET: List of slurmdb_qos_rec_t *
 * note List needs to be freed with slurm_list_destroy() when called
 */
extern List slurmdb_qos_get(void *db_conn, slurmdb_qos_cond_t *qos_cond)
{
	if (db_api_uid == -1)
		db_api_uid = getuid();

	return acct_storage_g_get_qos(db_conn, db_api_uid, qos_cond);
}
extern int sacctmgr_list_cluster(int argc, char *argv[])
{
	int rc = SLURM_SUCCESS;
	slurmdb_cluster_cond_t *cluster_cond =
		xmalloc(sizeof(slurmdb_cluster_cond_t));
	List cluster_list;
	int i=0;
	ListIterator itr = NULL;
	ListIterator itr2 = NULL;
	slurmdb_cluster_rec_t *cluster = NULL;
	char *tmp_char = NULL;

	int field_count = 0;

	print_field_t *field = NULL;

	List format_list = list_create(slurm_destroy_char);
	List print_fields_list; /* types are of print_field_t */

	slurmdb_init_cluster_cond(cluster_cond, 0);
	cluster_cond->cluster_list = list_create(slurm_destroy_char);
	for (i=0; i<argc; i++) {
		int command_len = strlen(argv[i]);
		if (!strncasecmp(argv[i], "Where", MAX(command_len, 5))
		    || !strncasecmp(argv[i], "Set", MAX(command_len, 3)))
			i++;
		_set_cond(&i, argc, argv, cluster_cond, format_list);
	}

	if(exit_code) {
		slurmdb_destroy_cluster_cond(cluster_cond);
		list_destroy(format_list);
		return SLURM_ERROR;
	}

	if(!list_count(format_list)) {
		slurm_addto_char_list(format_list,
				      "Cl,Controlh,Controlp,RPC");
		if(!without_limits)
			slurm_addto_char_list(format_list,
					      "Fa,GrpJ,GrpN,GrpS,MaxJ,MaxN,"
					      "MaxS,MaxW,QOS,DefaultQOS");
	}

	cluster_cond->with_deleted = with_deleted;

	print_fields_list = sacctmgr_process_format_list(format_list);
	list_destroy(format_list);

	if(exit_code) {
		slurmdb_destroy_cluster_cond(cluster_cond);
		list_destroy(print_fields_list);
		return SLURM_ERROR;
	}

	cluster_list = acct_storage_g_get_clusters(db_conn, my_uid,
						   cluster_cond);
	slurmdb_destroy_cluster_cond(cluster_cond);

	if(!cluster_list) {
		exit_code=1;
		fprintf(stderr, " Problem with query.\n");
		list_destroy(print_fields_list);
		return SLURM_ERROR;
	}

	itr = list_iterator_create(cluster_list);
	itr2 = list_iterator_create(print_fields_list);
	print_fields_header(print_fields_list);

	field_count = list_count(print_fields_list);

	while((cluster = list_next(itr))) {
		int curr_inx = 1;
		slurmdb_association_rec_t *assoc = cluster->root_assoc;
		/* set up the working cluster rec so nodecnt's and node names
		 * are handled correctly */
		working_cluster_rec = cluster;
		while((field = list_next(itr2))) {
			switch(field->type) {
			case PRINT_CLUSTER:
				field->print_routine(field,
						     cluster->name,
						     (curr_inx == field_count));
				break;
			case PRINT_CHOST:
				field->print_routine(field,
						     cluster->control_host,
						     (curr_inx == field_count));
				break;
			case PRINT_CPORT:
				field->print_routine(field,
						     cluster->control_port,
						     (curr_inx == field_count));
				break;
			case PRINT_CLASS:
				field->print_routine(field,
						     get_classification_str(
							     cluster->
							     classification),
						     (curr_inx == field_count));
				break;
			case PRINT_CPUS:
			{
				char tmp_char[9];
				convert_num_unit((float)cluster->cpu_count,
						 tmp_char, sizeof(tmp_char),
						 UNIT_NONE);
				field->print_routine(field,
						     tmp_char,
						     (curr_inx == field_count));
				break;
			}
			case PRINT_DQOS:
				if(!g_qos_list) {
					g_qos_list = acct_storage_g_get_qos(
						db_conn,
						my_uid,
						NULL);
				}
				tmp_char = slurmdb_qos_str(g_qos_list,
							   assoc->def_qos_id);
				field->print_routine(
					field,
					tmp_char,
					(curr_inx == field_count));
				break;
			case PRINT_FAIRSHARE:
				field->print_routine(
					field,
					assoc->shares_raw,
					(curr_inx == field_count));
				break;
			case PRINT_FLAGS:
			{
				char *tmp_char = slurmdb_cluster_flags_2_str(
					cluster->flags);
				field->print_routine(
					field,
					tmp_char,
					(curr_inx == field_count));
				xfree(tmp_char);
				break;
			}
			case PRINT_GRPC:
				field->print_routine(field,
						     assoc->grp_cpus,
						     (curr_inx == field_count));
				break;
			case PRINT_GRPJ:
				field->print_routine(field,
						     assoc->grp_jobs,
						     (curr_inx == field_count));
				break;
			case PRINT_GRPN:
				field->print_routine(field,
						     assoc->grp_nodes,
						     (curr_inx == field_count));
				break;
			case PRINT_GRPS:
				field->print_routine(field,
						     assoc->grp_submit_jobs,
						     (curr_inx == field_count));
				break;
			case PRINT_MAXCM:
				field->print_routine(
					field,
					assoc->max_cpu_mins_pj,
					(curr_inx == field_count));
				break;
			case PRINT_MAXC:
				field->print_routine(field,
						     assoc->max_cpus_pj,
						     (curr_inx == field_count));
				break;
			case PRINT_MAXJ:
				field->print_routine(field,
						     assoc->max_jobs,
						     (curr_inx == field_count));
				break;
			case PRINT_MAXN:
				field->print_routine(field,
						     assoc->max_nodes_pj,
						     (curr_inx == field_count));
				break;
			case PRINT_MAXS:
				field->print_routine(field,
						     assoc->max_submit_jobs,
						     (curr_inx == field_count));
				break;
			case PRINT_MAXW:
				field->print_routine(
					field,
					assoc->max_wall_pj,
					(curr_inx == field_count));
				break;

			case PRINT_NODECNT:
			{
				hostlist_t hl = hostlist_create(cluster->nodes);
				int cnt = 0;
				if(hl) {
					cnt = hostlist_count(hl);
					hostlist_destroy(hl);
				}
				field->print_routine(
					field,
					cnt,
					(curr_inx == field_count));
				break;
			}
			case PRINT_CLUSTER_NODES:
				field->print_routine(
					field,
					cluster->nodes,
					(curr_inx == field_count));
				break;
			case PRINT_QOS:
				if(!g_qos_list)
					g_qos_list = acct_storage_g_get_qos(
						db_conn, my_uid, NULL);

				field->print_routine(field,
						     g_qos_list,
						     assoc->qos_list,
						     (curr_inx == field_count));
				break;
			case PRINT_QOS_RAW:
				field->print_routine(field,
						     assoc->qos_list,
						     (curr_inx == field_count));
				break;
			case PRINT_RPC_VERSION:
				field->print_routine(
					field,
					cluster->rpc_version,
					(curr_inx == field_count));
				break;
			case PRINT_SELECT:
				field->print_routine(
					field,
					cluster->plugin_id_select,
					(curr_inx == field_count));
				break;
			default:
				field->print_routine(
					field, NULL,
					(curr_inx == field_count));
				break;
			}
			curr_inx++;
		}
		list_iterator_reset(itr2);
		printf("\n");
	}
	/* clear the working cluster rec */
	working_cluster_rec = NULL;

	list_iterator_destroy(itr2);
	list_iterator_destroy(itr);
	list_destroy(cluster_list);
	list_destroy(print_fields_list);

	return rc;
}
Exemple #3
0
extern int sacctmgr_list_qos(int argc, char *argv[])
{
    int rc = SLURM_SUCCESS;
    slurmdb_qos_cond_t *qos_cond = xmalloc(sizeof(slurmdb_qos_cond_t));
    int i=0;
    ListIterator itr = NULL;
    ListIterator itr2 = NULL;
    slurmdb_qos_rec_t *qos = NULL;
    List qos_list = NULL;
    int field_count = 0;

    print_field_t *field = NULL;

    List format_list = list_create(slurm_destroy_char);
    List print_fields_list; /* types are of print_field_t */

    for (i=0; i<argc; i++) {
        int command_len = strlen(argv[i]);
        if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))
                || !strncasecmp (argv[i], "Set", MAX(command_len, 3)))
            i++;
        _set_cond(&i, argc, argv, qos_cond, format_list);
    }

    if(exit_code) {
        slurmdb_destroy_qos_cond(qos_cond);
        list_destroy(format_list);
        return SLURM_ERROR;
    } else if(!list_count(format_list)) {
        slurm_addto_char_list(format_list,
                              "Name,Prio,GraceT,Preempt,PreemptM,"
                              "Flags%40,UsageThres,UsageFactor,"
                              "GrpCPUs,GrpCPUMins,GrpCPURunMins,"
                              "GrpJ,GrpMEM,GrpN,GrpS,GrpW,"
                              "MaxCPUs,MaxCPUMins,MaxN,MaxW,"
                              "MaxCPUsPerUser,"
                              "MaxJobsPerUser,MaxNodesPerUser,"
                              "MaxSubmitJobsPerUser");
    }

    print_fields_list = sacctmgr_process_format_list(format_list);
    list_destroy(format_list);

    if(exit_code) {
        list_destroy(print_fields_list);
        return SLURM_ERROR;
    }
    qos_list = acct_storage_g_get_qos(db_conn, my_uid, qos_cond);
    slurmdb_destroy_qos_cond(qos_cond);

    if(!qos_list) {
        exit_code=1;
        fprintf(stderr, " Problem with query.\n");
        list_destroy(print_fields_list);
        return SLURM_ERROR;
    }
    itr = list_iterator_create(qos_list);
    itr2 = list_iterator_create(print_fields_list);
    print_fields_header(print_fields_list);

    field_count = list_count(print_fields_list);

    while((qos = list_next(itr))) {
        int curr_inx = 1;
        while((field = list_next(itr2))) {
            switch(field->type) {
            case PRINT_DESC:
                field->print_routine(
                    field, qos->description,
                    (curr_inx == field_count));
                break;
            case PRINT_FLAGS:
            {
                char *tmp_char = slurmdb_qos_flags_str(
                                     qos->flags);
                field->print_routine(
                    field,
                    tmp_char,
                    (curr_inx == field_count));
                xfree(tmp_char);
                break;
            }
            case PRINT_UT:
                field->print_routine(
                    field, qos->usage_thres,
                    (curr_inx == field_count));
                break;
            case PRINT_GRACE:
                field->print_routine(
                    field, (uint64_t)qos->grace_time,
                    (curr_inx == field_count));
                break;
            case PRINT_GRPCM:
                field->print_routine(
                    field,
                    qos->grp_cpu_mins,
                    (curr_inx == field_count));
                break;
            case PRINT_GRPCRM:
                field->print_routine(
                    field,
                    qos->grp_cpu_run_mins,
                    (curr_inx == field_count));
                break;
            case PRINT_GRPC:
                field->print_routine(field,
                                     qos->grp_cpus,
                                     (curr_inx == field_count));
                break;
            case PRINT_GRPJ:
                field->print_routine(field,
                                     qos->grp_jobs,
                                     (curr_inx == field_count));
                break;
            case PRINT_GRPMEM:
                field->print_routine(field,
                                     qos->grp_mem,
                                     (curr_inx == field_count));
                break;
            case PRINT_GRPN:
                field->print_routine(field,
                                     qos->grp_nodes,
                                     (curr_inx == field_count));
                break;
            case PRINT_GRPS:
                field->print_routine(field,
                                     qos->grp_submit_jobs,
                                     (curr_inx == field_count));
                break;
            case PRINT_GRPW:
                field->print_routine(
                    field,
                    qos->grp_wall,
                    (curr_inx == field_count));
                break;
            case PRINT_ID:
                field->print_routine(
                    field, qos->id,
                    (curr_inx == field_count));
                break;
            case PRINT_MAXCM:
                field->print_routine(
                    field,
                    qos->max_cpu_mins_pj,
                    (curr_inx == field_count));
                break;
            case PRINT_MAXCRM:
                field->print_routine(
                    field,
                    qos->max_cpu_run_mins_pu,
                    (curr_inx == field_count));
                break;
            case PRINT_MAXC:
                field->print_routine(field,
                                     qos->max_cpus_pj,
                                     (curr_inx == field_count));
                break;
            case PRINT_MAXCU:
                field->print_routine(field,
                                     qos->max_cpus_pu,
                                     (curr_inx == field_count));
                break;
            case PRINT_MAXJ:
                field->print_routine(field,
                                     qos->max_jobs_pu,
                                     (curr_inx == field_count));
                break;
            case PRINT_MAXN:
                field->print_routine(field,
                                     qos->max_nodes_pj,
                                     (curr_inx == field_count));
                break;
            case PRINT_MAXNU:
                field->print_routine(field,
                                     qos->max_nodes_pu,
                                     (curr_inx == field_count));
                break;
            case PRINT_MAXS:
                field->print_routine(field,
                                     qos->max_submit_jobs_pu,
                                     (curr_inx == field_count));
                break;
            case PRINT_MAXW:
                field->print_routine(
                    field,
                    qos->max_wall_pj,
                    (curr_inx == field_count));
                break;
            case PRINT_NAME:
                field->print_routine(
                    field, qos->name,
                    (curr_inx == field_count));
                break;
            case PRINT_PREE:
                if(!g_qos_list)
                    g_qos_list = acct_storage_g_get_qos(
                                     db_conn, my_uid, NULL);

                field->print_routine(
                    field, g_qos_list, qos->preempt_bitstr,
                    (curr_inx == field_count));
                break;
            case PRINT_PREEM:
            {
                char *tmp_char = "cluster";
                if(qos->preempt_mode)
                    tmp_char = xstrtolower(
                                   preempt_mode_string(
                                       qos->preempt_mode));
                field->print_routine(
                    field,
                    tmp_char,
                    (curr_inx == field_count));
                break;
            }
            case PRINT_PRIO:
                field->print_routine(
                    field, qos->priority,
                    (curr_inx == field_count));
                break;
            case PRINT_UF:
                field->print_routine(
                    field, qos->usage_factor,
                    (curr_inx == field_count));
                break;
            default:
                field->print_routine(
                    field, NULL,
                    (curr_inx == field_count));
                break;
            }
            curr_inx++;
        }
        list_iterator_reset(itr2);
        printf("\n");
    }
    list_iterator_destroy(itr2);
    list_iterator_destroy(itr);
    list_destroy(qos_list);
    list_destroy(print_fields_list);

    return rc;
}
Exemple #4
0
extern int sacctmgr_add_qos(int argc, char *argv[])
{
    int rc = SLURM_SUCCESS;
    int i=0, limit_set=0;
    ListIterator itr = NULL;
    slurmdb_qos_rec_t *qos = NULL;
    slurmdb_qos_rec_t *start_qos = xmalloc(sizeof(slurmdb_qos_rec_t));
    List name_list = list_create(slurm_destroy_char);
    char *description = NULL;
    char *name = NULL;
    List qos_list = NULL;
    char *qos_str = NULL;

    slurmdb_init_qos_rec(start_qos, 0);

    for (i=0; i<argc; i++) {
        int command_len = strlen(argv[i]);
        if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))
                || !strncasecmp (argv[i], "Set", MAX(command_len, 3)))
            i++;

        limit_set += _set_rec(&i, argc, argv, name_list, start_qos);
    }

    if(exit_code) {
        list_destroy(name_list);
        xfree(description);
        return SLURM_ERROR;
    } else if(!list_count(name_list)) {
        list_destroy(name_list);
        slurmdb_destroy_qos_rec(start_qos);
        exit_code=1;
        fprintf(stderr, " Need name of qos to add.\n");
        return SLURM_SUCCESS;
    }

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

        if(!g_qos_list) {
            exit_code=1;
            fprintf(stderr, " Problem getting qos's "
                    "from database.  "
                    "Contact your admin.\n");
            list_destroy(name_list);
            xfree(description);
            return SLURM_ERROR;
        }
    }

    qos_list = list_create(slurmdb_destroy_qos_rec);

    itr = list_iterator_create(name_list);
    while((name = list_next(itr))) {
        qos = NULL;
        if(!sacctmgr_find_qos_from_list(g_qos_list, name)) {
            qos = xmalloc(sizeof(slurmdb_qos_rec_t));
            slurmdb_init_qos_rec(qos, 0);
            qos->name = xstrdup(name);
            if(start_qos->description)
                qos->description =
                    xstrdup(start_qos->description);
            else
                qos->description = xstrdup(name);

            qos->grace_time = start_qos->grace_time;
            qos->grp_cpu_mins = start_qos->grp_cpu_mins;
            qos->grp_cpus = start_qos->grp_cpus;
            qos->grp_jobs = start_qos->grp_jobs;
            qos->grp_mem = start_qos->grp_mem;
            qos->grp_nodes = start_qos->grp_nodes;
            qos->grp_submit_jobs = start_qos->grp_submit_jobs;
            qos->grp_wall = start_qos->grp_wall;

            qos->max_cpu_mins_pj = start_qos->max_cpu_mins_pj;
            qos->max_cpu_run_mins_pu =
                start_qos->max_cpu_run_mins_pu;
            qos->max_cpus_pj = start_qos->max_cpus_pj;
            qos->max_cpus_pu = start_qos->max_cpus_pu;
            qos->max_jobs_pu = start_qos->max_jobs_pu;
            qos->max_nodes_pj = start_qos->max_nodes_pj;
            qos->max_nodes_pu = start_qos->max_nodes_pu;
            qos->max_submit_jobs_pu = start_qos->max_submit_jobs_pu;
            qos->max_wall_pj = start_qos->max_wall_pj;

            qos->preempt_list =
                copy_char_list(start_qos->preempt_list);
            qos->preempt_mode = start_qos->preempt_mode;

            qos->priority = start_qos->priority;

            qos->usage_factor = start_qos->usage_factor;
            qos->usage_thres = start_qos->usage_thres;

            xstrfmtcat(qos_str, "  %s\n", name);
            list_append(qos_list, qos);
        }
    }
    list_iterator_destroy(itr);
    list_destroy(name_list);

    if (g_qos_list) {
        list_destroy(g_qos_list);
        g_qos_list = NULL;
    }

    if(!list_count(qos_list)) {
        printf(" Nothing new added.\n");
        goto end_it;
    }

    if(qos_str) {
        printf(" Adding QOS(s)\n%s", qos_str);
        printf(" Settings\n");
        if(description)
            printf("  Description    = %s\n", description);
        else
            printf("  Description    = %s\n", "QOS Name");

        sacctmgr_print_qos_limits(start_qos);

        xfree(qos_str);
    }

    notice_thread_init();
    if(list_count(qos_list))
        rc = acct_storage_g_add_qos(db_conn, my_uid, qos_list);
    else
        goto end_it;

    notice_thread_fini();

    if(rc == SLURM_SUCCESS) {
        if(commit_check("Would you like to commit changes?")) {
            acct_storage_g_commit(db_conn, 1);
        } else {
            printf(" Changes Discarded\n");
            acct_storage_g_commit(db_conn, 0);
        }
    } else {
        exit_code=1;
        fprintf(stderr, " Problem adding QOS: %s\n",
                slurm_strerror(rc));
        rc = SLURM_ERROR;
    }

end_it:
    list_destroy(qos_list);
    xfree(description);

    return rc;
}
Exemple #5
0
static int _set_rec(int *start, int argc, char *argv[],
                    List name_list,
                    slurmdb_qos_rec_t *qos)
{
    int i, mins;
    int set = 0;
    int end = 0;
    int command_len = 0;
    int option = 0;

    for (i=(*start); i<argc; i++) {
        end = parse_option_end(argv[i]);
        if(!end)
            command_len=strlen(argv[i]);
        else {
            command_len=end-1;
            if(argv[i][end] == '=') {
                option = (int)argv[i][end-1];
                end++;
            }
        }

        if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))) {
            i--;
            break;
        } else if(!end && !strncasecmp(argv[i], "set",
                                       MAX(command_len, 3))) {
            continue;
        } else if(!end
                  || !strncasecmp (argv[i], "Name",
                                   MAX(command_len, 1))) {
            if(name_list)
                slurm_addto_char_list(name_list, argv[i]+end);
        } else if (!strncasecmp (argv[i], "Description",
                                 MAX(command_len, 1))) {
            if(!qos->description)
                qos->description =
                    strip_quotes(argv[i]+end, NULL, 1);
            set = 1;
        } else if (!strncasecmp (argv[i], "Flags",
                                 MAX(command_len, 2))) {
            if(!qos)
                continue;
            qos->flags = str_2_qos_flags(argv[i]+end, option);
            if (qos->flags == QOS_FLAG_NOTSET) {
                char *tmp_char = NULL;
                qos->flags = INFINITE;
                qos->flags &= (~QOS_FLAG_NOTSET &
                               ~QOS_FLAG_ADD &
                               ~QOS_FLAG_REMOVE);
                tmp_char = slurmdb_qos_flags_str(qos->flags);
                printf(" Unknown QOS flag used in:\n  '%s'\n"
                       " Valid QOS flags are\n  '%s'\n",
                       argv[i]+end, tmp_char);
                xfree(tmp_char);
                exit_code = 1;
            } else
                set = 1;
        } else if (!strncasecmp (argv[i], "GraceTime",
                                 MAX(command_len, 3))) {
            if (!qos)
                continue;
            if (get_uint(argv[i]+end, &qos->grace_time,
                         "GraceTime") == SLURM_SUCCESS) {
                set = 1;
            }
        } else if (!strncasecmp (argv[i], "GrpCPUMins",
                                 MAX(command_len, 7))) {
            if(!qos)
                continue;
            if (get_uint64(argv[i]+end,
                           &qos->grp_cpu_mins,
                           "GrpCPUMins") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "GrpCPURunMins",
                                 MAX(command_len, 7))) {
            if(!qos)
                continue;
            if (get_uint64(argv[i]+end, &qos->grp_cpu_run_mins,
                           "GrpCPURunMins") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "GrpCPUs",
                                 MAX(command_len, 7))) {
            if(!qos)
                continue;
            if (get_uint(argv[i]+end, &qos->grp_cpus,
                         "GrpCPUs") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "GrpJobs",
                                 MAX(command_len, 4))) {
            if(!qos)
                continue;
            if (get_uint(argv[i]+end, &qos->grp_jobs,
                         "GrpJobs") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "GrpMemory",
                                 MAX(command_len, 4))) {
            if(!qos)
                continue;
            if (get_uint(argv[i]+end, &qos->grp_mem,
                         "GrpMemory") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "GrpNodes",
                                 MAX(command_len, 4))) {
            if(!qos)
                continue;
            if (get_uint(argv[i]+end, &qos->grp_nodes,
                         "GrpNodes") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "GrpSubmitJobs",
                                 MAX(command_len, 4))) {
            if(!qos)
                continue;
            if (get_uint(argv[i]+end, &qos->grp_submit_jobs,
                         "GrpSubmitJobs") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "GrpWall",
                                 MAX(command_len, 4))) {
            if(!qos)
                continue;
            mins = time_str2mins(argv[i]+end);
            if (mins != NO_VAL) {
                qos->grp_wall	= (uint32_t) mins;
                set = 1;
            } else {
                exit_code=1;
                fprintf(stderr,
                        " Bad GrpWall time format: %s\n",
                        argv[i]);
            }
        } else if (!strncasecmp (argv[i], "MaxCPUMinsPerJob",
                                 MAX(command_len, 7))) {
            if(!qos)
                continue;
            if (get_uint64(argv[i]+end,
                           &qos->max_cpu_mins_pj,
                           "MaxCPUMins") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "MaxCPUsPerJob",
                                 MAX(command_len, 7))) {
            if(!qos)
                continue;
            if (get_uint(argv[i]+end, &qos->max_cpus_pj,
                         "MaxCPUs") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "MaxCPUsPerUser",
                                 MAX(command_len, 11))) {
            if(!qos)
                continue;
            if (get_uint(argv[i]+end, &qos->max_cpus_pu,
                         "MaxCPUsPerUser") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "MaxJobsPerUser",
                                 MAX(command_len, 4))) {
            if(!qos)
                continue;
            if (get_uint(argv[i]+end, &qos->max_jobs_pu,
                         "MaxJobs") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "MaxNodesPerJob",
                                 MAX(command_len, 4))) {
            if(!qos)
                continue;
            if (get_uint(argv[i]+end,
                         &qos->max_nodes_pj,
                         "MaxNodes") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "MaxNodesPerUser",
                                 MAX(command_len, 8))) {
            if(!qos)
                continue;
            if (get_uint(argv[i]+end,
                         &qos->max_nodes_pu,
                         "MaxNodesPerUser") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "MaxSubmitJobsPerUser",
                                 MAX(command_len, 4))) {
            if(!qos)
                continue;
            if (get_uint(argv[i]+end, &qos->max_submit_jobs_pu,
                         "MaxSubmitJobs") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "MaxWallDurationPerJob",
                                 MAX(command_len, 4))) {
            if(!qos)
                continue;
            mins = time_str2mins(argv[i]+end);
            if (mins != NO_VAL) {
                qos->max_wall_pj = (uint32_t) mins;
                set = 1;
            } else {
                exit_code=1;
                fprintf(stderr,
                        " Bad MaxWall time format: %s\n",
                        argv[i]);
            }
        } else if (!strncasecmp (argv[i], "PreemptMode",
                                 MAX(command_len, 8))) {
            if(!qos)
                continue;
            qos->preempt_mode = preempt_mode_num(argv[i]+end);
            if(qos->preempt_mode == (uint16_t)NO_VAL) {
                fprintf(stderr,
                        " Bad Preempt Mode given: %s\n",
                        argv[i]);
                exit_code = 1;
            } else if (qos->preempt_mode == PREEMPT_MODE_SUSPEND) {
                printf("PreemptType and PreemptMode "
                       "values incompatible\n");
                exit_code = 1;
            } else
                set = 1;
            /* Preempt needs to follow PreemptMode */
        } else if (!strncasecmp (argv[i], "Preempt",
                                 MAX(command_len, 7))) {
            if(!qos)
                continue;

            if(!qos->preempt_list)
                qos->preempt_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(qos->preempt_list,
                                           g_qos_list, argv[i]+end,
                                           option))
                set = 1;
            else
                exit_code = 1;
        } else if (!strncasecmp (argv[i], "Priority",
                                 MAX(command_len, 3))) {
            if(!qos)
                continue;

            if (get_uint(argv[i]+end, &qos->priority,
                         "Priority") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "UsageFactor",
                                 MAX(command_len, 6))) {
            if(!qos)
                continue;

            if (get_double(argv[i]+end, &qos->usage_factor,
                           "UsageFactor") == SLURM_SUCCESS)
                set = 1;
        } else if (!strncasecmp (argv[i], "UsageThreshold",
                                 MAX(command_len, 6))) {
            if(!qos)
                continue;
            if (get_double(argv[i]+end, &qos->usage_thres,
                           "UsageThreshold") == SLURM_SUCCESS)
                set = 1;
        } else {
            exit_code = 1;
            printf(" Unknown option: %s\n"
                   " Use keyword 'where' to modify condition\n",
                   argv[i]);
        }
    }

    (*start) = i;

    return set;
}
Exemple #6
0
extern int sacctmgr_delete_qos(int argc, char *argv[])
{
    int rc = SLURM_SUCCESS;
    slurmdb_qos_cond_t *qos_cond =
        xmalloc(sizeof(slurmdb_qos_cond_t));
    int i=0;
    List ret_list = NULL;
    int set = 0;

    for (i=0; i<argc; i++) {
        int command_len = strlen(argv[i]);
        if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))
                || !strncasecmp (argv[i], "Set", MAX(command_len, 3)))
            i++;
        set += _set_cond(&i, argc, argv, qos_cond, NULL);
    }

    if(!set) {
        exit_code=1;
        fprintf(stderr,
                " No conditions given to remove, not executing.\n");
        slurmdb_destroy_qos_cond(qos_cond);
        return SLURM_ERROR;
    } else if(set == -1) {
        slurmdb_destroy_qos_cond(qos_cond);
        return SLURM_ERROR;
    }

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

    notice_thread_init();
    ret_list = acct_storage_g_remove_qos(db_conn, my_uid, qos_cond);
    notice_thread_fini();
    slurmdb_destroy_qos_cond(qos_cond);

    if(ret_list && list_count(ret_list)) {
        char *object = NULL;
        ListIterator itr = NULL;

        /* Check to see if person is trying to remove a default
         * qos of an association.  _isdefault only works with the
         * output from acct_storage_g_remove_qos, and
         * with a previously got g_qos_list.
         */
        if (_isdefault(ret_list)) {
            exit_code=1;
            fprintf(stderr, " Please either remove the qos' listed "
                    "above from list and resubmit,\n"
                    " or change the default qos to "
                    "remove the qos.\n"
                    " Changes Discarded\n");
            acct_storage_g_commit(db_conn, 0);
            goto end_it;
        }

        itr = list_iterator_create(ret_list);
        printf(" Deleting QOS(s)...\n");

        while((object = list_next(itr))) {
            printf("  %s\n", object);
        }
        list_iterator_destroy(itr);
        if(commit_check("Would you like to commit changes?")) {
            acct_storage_g_commit(db_conn, 1);
        } else {
            printf(" Changes Discarded\n");
            acct_storage_g_commit(db_conn, 0);
        }
    } else if(ret_list) {
        printf(" Nothing deleted\n");
    } else {
        exit_code=1;
        fprintf(stderr, " Error with request: %s\n",
                slurm_strerror(errno));
        rc = SLURM_ERROR;
    }

end_it:
    if(ret_list)
        list_destroy(ret_list);

    return rc;
}
Exemple #7
0
/*
 * get info from the storage
 * IN:  slurmdb_qos_cond_t *
 * RET: List of slurmdb_qos_rec_t *
 * note List needs to be freed with slurm_list_destroy() when called
 */
extern List slurmdb_qos_get(void *db_conn, slurmdb_qos_cond_t *qos_cond)
{
	return acct_storage_g_get_qos(db_conn, getuid(), qos_cond);
}
extern void sacctmgr_print_association_rec(slurmdb_association_rec_t *assoc,
					   print_field_t *field, List tree_list,
					   bool last)
{
	char *print_acct = NULL;
	char *tmp_char = NULL;

	xassert(field);

	if(!assoc) {
		field->print_routine(field, NULL, last);
		return;
	}

	switch(field->type) {
	case PRINT_ACCT:
		if (tree_display) {
			char *local_acct = NULL;
			char *parent_acct = NULL;
			if (assoc->user) {
				local_acct = xstrdup_printf("|%s", assoc->acct);
				parent_acct = assoc->acct;
			} else {
				local_acct =
					xstrdup(assoc->acct);
				parent_acct =
					assoc->parent_acct;
			}
			print_acct = slurmdb_tree_name_get(
				local_acct, parent_acct, tree_list);
			xfree(local_acct);
		} else {
			print_acct = assoc->acct;
		}
		field->print_routine(field, print_acct, last);
		break;
	case PRINT_CLUSTER:
		field->print_routine(field, assoc->cluster, last);
		break;
	case PRINT_DQOS:
		if (!g_qos_list)
			g_qos_list = acct_storage_g_get_qos(
				db_conn, my_uid, NULL);
		tmp_char = slurmdb_qos_str(g_qos_list, assoc->def_qos_id);
		field->print_routine(field, tmp_char, last);
		break;
	case PRINT_FAIRSHARE:
		if (assoc->shares_raw == SLURMDB_FS_USE_PARENT)
			print_fields_str(field, "parent", last);
		else
			field->print_routine(field, assoc->shares_raw, last);
		break;
	case PRINT_GRPCM:
		field->print_routine(field, assoc->grp_cpu_mins, last);
		break;
	case PRINT_GRPCRM:
		field->print_routine(field, assoc->grp_cpu_run_mins, last);
		break;
	case PRINT_GRPC:
		field->print_routine(field, assoc->grp_cpus, last);
		break;
	case PRINT_GRPJ:
		field->print_routine(field, assoc->grp_jobs, last);
		break;
	case PRINT_GRPN:
		field->print_routine(field, assoc->grp_nodes, last);
		break;
	case PRINT_GRPS:
		field->print_routine(field, assoc->grp_submit_jobs, last);
		break;
	case PRINT_GRPW:
		field->print_routine(field, assoc->grp_wall, last);
		break;
	case PRINT_ID:
		field->print_routine(field, assoc->id, last);
		break;
	case PRINT_LFT:
		field->print_routine(field, assoc->lft, last);
		break;
	case PRINT_MAXCM:
		field->print_routine(field, assoc->max_cpu_mins_pj, last);
		break;
	case PRINT_MAXCRM:
		field->print_routine(field, assoc->max_cpu_run_mins, last);
		break;
	case PRINT_MAXC:
		field->print_routine(field, assoc->max_cpus_pj, last);
		break;
	case PRINT_MAXJ:
		field->print_routine(field, assoc->max_jobs, last);
		break;
	case PRINT_MAXN:
		field->print_routine(field, assoc->max_nodes_pj, last);
		break;
	case PRINT_MAXS:
		field->print_routine(field, assoc->max_submit_jobs, last);
		break;
	case PRINT_MAXW:
		field->print_routine(field, assoc->max_wall_pj,	last);
		break;
	case PRINT_PID:
		field->print_routine(field, assoc->parent_id, last);
		break;
	case PRINT_PNAME:
		field->print_routine(field, assoc->parent_acct, last);
		break;
	case PRINT_PART:
		field->print_routine(field, assoc->partition, last);
		break;
	case PRINT_QOS:
		if (!g_qos_list)
			g_qos_list = acct_storage_g_get_qos(
				db_conn, my_uid, NULL);

		field->print_routine(field, g_qos_list, assoc->qos_list, last);
		break;
	case PRINT_QOS_RAW:
		field->print_routine(field, assoc->qos_list, last);
		break;
	case PRINT_RGT:
		field->print_routine(field, assoc->rgt, last);
		break;
	case PRINT_USER:
		field->print_routine(field, assoc->user, last);
		break;
	default:
		field->print_routine(field, NULL, last);
		break;
	}
}
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;
}
extern int sacctmgr_set_association_cond(slurmdb_association_cond_t *assoc_cond,
					 char *type, char *value,
					 int command_len, int option)
{
	int set =0;

	xassert(assoc_cond);
	xassert(type);

	if (!strncasecmp (type, "Accounts", MAX(command_len, 2))
		   || !strncasecmp (type, "Acct", MAX(command_len, 4))) {
		if (!assoc_cond->acct_list)
			assoc_cond->acct_list = list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->acct_list, value))
			set = 1;
	} else if (!strncasecmp(type, "Ids", MAX(command_len, 1))
		   || !strncasecmp(type, "Associations", MAX(command_len, 2))) {
		ListIterator itr = NULL;
		char *temp = NULL;
		uint32_t id = 0;

		if (!assoc_cond->id_list)
			assoc_cond->id_list =list_create(slurm_destroy_char);
		slurm_addto_char_list(assoc_cond->id_list, value);
		/* check to make sure user gave ints here */
		itr = list_iterator_create(assoc_cond->id_list);
		while ((temp = list_next(itr))) {
			if (get_uint(temp, &id, "AssocId") != SLURM_SUCCESS) {
				exit_code = 1;
				list_delete_item(itr);
			}
		}
		list_iterator_destroy(itr);
		set = 1;
	} else if (!strncasecmp (type, "Clusters", MAX(command_len, 1))) {
		if (!assoc_cond->cluster_list)
			assoc_cond->cluster_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->cluster_list, value))
			set = 1;
	} else if (!strncasecmp (type, "DefaultQOS", MAX(command_len, 8))) {
		if (!assoc_cond->def_qos_id_list)
			assoc_cond->def_qos_id_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_cond->def_qos_id_list,
						g_qos_list, value, 0))
			set = 1;
		else
			exit_code = 1;
	} else if (!strncasecmp (type, "FairShare", MAX(command_len, 1))
		   || !strncasecmp (type, "Shares", MAX(command_len, 1))) {
		if (!assoc_cond->fairshare_list)
			assoc_cond->fairshare_list =
				list_create(slurm_destroy_char);

		if (slurm_addto_char_list(assoc_cond->fairshare_list, value))
			set = 1;
	} else if (!strncasecmp (type, "GrpCPUMins", MAX(command_len, 7))) {
		if (!assoc_cond->grp_cpu_mins_list)
			assoc_cond->grp_cpu_mins_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->grp_cpu_mins_list, value))
			set = 1;
	} else if (!strncasecmp (type, "GrpCPURunMins", MAX(command_len, 7))) {
		if (!assoc_cond->grp_cpu_run_mins_list)
			assoc_cond->grp_cpu_run_mins_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->grp_cpu_run_mins_list,
					 value))
			set = 1;
	} else if (!strncasecmp (type, "GrpCpus", MAX(command_len, 7))) {
		if (!assoc_cond->grp_cpus_list)
			assoc_cond->grp_cpus_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->grp_cpus_list,
					 value))
			set = 1;
	} else if (!strncasecmp (type, "GrpJobs", MAX(command_len, 4))) {
		if (!assoc_cond->grp_jobs_list)
			assoc_cond->grp_jobs_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->grp_jobs_list,
					 value))
			set = 1;
	} else if (!strncasecmp (type, "GrpNodes", MAX(command_len, 4))) {
		if (!assoc_cond->grp_nodes_list)
			assoc_cond->grp_nodes_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->grp_nodes_list,
					 value))
			set = 1;
	} else if (!strncasecmp (type, "GrpSubmitJobs", MAX(command_len, 4))) {
		if (!assoc_cond->grp_submit_jobs_list)
			assoc_cond->grp_submit_jobs_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->grp_submit_jobs_list,
					 value))
			set = 1;
	} else if (!strncasecmp (type, "GrpWall", MAX(command_len, 4))) {
		if (!assoc_cond->grp_wall_list)
			assoc_cond->grp_wall_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->grp_wall_list, value))
			set = 1;
	} else if (!strncasecmp (type, "MaxCPUMinsPerJob",
				 MAX(command_len, 7))) {
		if (!assoc_cond->max_cpu_mins_pj_list)
			assoc_cond->max_cpu_mins_pj_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->max_cpu_mins_pj_list,
					 value))
			set = 1;
	} else if (!strncasecmp (type, "MaxCPURunMins", MAX(command_len, 7))) {
		if (!assoc_cond->max_cpu_run_mins_list)
			assoc_cond->max_cpu_run_mins_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->max_cpu_run_mins_list,
					 value))
			set = 1;
	} else if (!strncasecmp (type, "MaxCpusPerJob", MAX(command_len, 7))) {
		if (!assoc_cond->max_cpus_pj_list)
			assoc_cond->max_cpus_pj_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->max_cpus_pj_list, value))
			set = 1;
	} else if (!strncasecmp (type, "MaxJobs", MAX(command_len, 4))) {
		if (!assoc_cond->max_jobs_list)
			assoc_cond->max_jobs_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->max_jobs_list, value))
			set = 1;
	} else if (!strncasecmp (type, "MaxNodesPerJob", MAX(command_len, 4))) {
		if (!assoc_cond->max_nodes_pj_list)
			assoc_cond->max_nodes_pj_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->max_nodes_pj_list, value))
			set = 1;
	} else if (!strncasecmp (type, "MaxSubmitJobs", MAX(command_len, 4))) {
		if (!assoc_cond->max_submit_jobs_list)
			assoc_cond->max_submit_jobs_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->max_submit_jobs_list,
					 value))
			set = 1;
	} else if (!strncasecmp (type, "MaxWallDurationPerJob",
				 MAX(command_len, 4))) {
		if (!assoc_cond->max_wall_pj_list)
			assoc_cond->max_wall_pj_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->max_wall_pj_list, value))
			set = 1;
	} else if (!strncasecmp (type, "Partitions", MAX(command_len, 3))) {
		if (!assoc_cond->partition_list)
			assoc_cond->partition_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->partition_list, value))
			set = 1;
	} else if (!strncasecmp(type, "Parents", MAX(command_len, 4))) {
		if (!assoc_cond->parent_acct_list)
			assoc_cond->parent_acct_list =
				list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->parent_acct_list, value))
			set = 1;
	} else if (!strncasecmp (type, "QosLevel", MAX(command_len, 1))) {
		if(!assoc_cond->qos_list)
			assoc_cond->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_cond->qos_list, g_qos_list,
					       value, option))
			set = 1;
	} else if (!strncasecmp (type, "Users", MAX(command_len, 1))) {
		if (!assoc_cond->user_list)
			assoc_cond->user_list = list_create(slurm_destroy_char);
		if (slurm_addto_char_list(assoc_cond->user_list, value))
			set = 1;
	}

	return set;
}
extern bool sacctmgr_check_default_qos(uint32_t qos_id,
				       slurmdb_association_cond_t *assoc_cond)
{
	char *object = NULL;
	ListIterator itr;
	slurmdb_association_rec_t *assoc;
	List no_access_list = NULL;
	List assoc_list = NULL;

	if (qos_id == NO_VAL)
		return true;

	assoc_list = acct_storage_g_get_associations(
		db_conn, my_uid, assoc_cond);
	if (!assoc_list) {
		fprintf(stderr, "Couldn't get a list back for checking qos.\n");
		return false;
	}

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

	itr = list_iterator_create(assoc_list);
	while ((assoc = list_next(itr))) {
		char *qos = NULL;

		if (assoc->qos_list) {
			int check_qos = qos_id;
			if (check_qos == -1)
				check_qos = assoc->def_qos_id;
			if ((int)check_qos > 0) {
				ListIterator qos_itr =
					list_iterator_create(assoc->qos_list);
				while ((qos = list_next(qos_itr))) {
					if (qos[0] == '-')
						continue;
					else if (qos[0] == '+')
						qos++;
					/* info("looking for %u ?= %u", */
					/*      check_qos, slurm_atoul(qos)); */
					if (check_qos == slurm_atoul(qos))
						break;
				}
				list_iterator_destroy(qos_itr);
			} else
				qos = "";
		}

		if (!qos) {
			char *name = slurmdb_qos_str(g_qos_list,
						     assoc->def_qos_id);
			if (!assoc->user) {
				// see if this isn't a user
				object = xstrdup_printf(
					"  DefQOS = %-10s C = %-10s A = %-20s ",
					name, assoc->cluster, assoc->acct);
			} else if (assoc->partition) {
				// see if there is a partition name
				object = xstrdup_printf(
					"  DefQOS = %-10s C = %-10s A = %-20s "
					"U = %-9s P = %s",
					name, assoc->cluster, assoc->acct,
					assoc->user, assoc->partition);
			} else {
				object = xstrdup_printf(
					"  DefQOS = %-10s C = %-10s A = %-20s "
					"U = %-9s",
					name, assoc->cluster,
					assoc->acct, assoc->user);
			}

			if (!no_access_list)
				no_access_list =
					list_create(slurm_destroy_char);
			list_append(no_access_list, object);
		}
	}
	list_iterator_destroy(itr);
	list_destroy(assoc_list);

	if (!no_access_list)
		return true;
	fprintf(stderr,
		" These associations don't have access to their "
		"default qos.\n");
	fprintf(stderr,
		" Please give them access before they the default "
		"can be set to this.\n");
	itr = list_iterator_create(no_access_list);
	while ((object = list_next(itr)))
		fprintf(stderr, "%s\n", object);
	list_iterator_destroy(itr);
	list_destroy(no_access_list);

	return 0;
}