Ejemplo n.º 1
0
/*
 * add qos's to accounting system
 * IN:  qos_list List of char *
 * RET: SLURM_SUCCESS on success SLURM_ERROR else
 */
extern int slurmdb_qos_add(void *db_conn, List qos_list)
{
	if (db_api_uid == -1)
		db_api_uid = getuid();

	return acct_storage_g_add_qos(db_conn, db_api_uid, qos_list);
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
0
/*
 * add qos's to accounting system
 * IN:  qos_list List of char *
 * RET: SLURM_SUCCESS on success SLURM_ERROR else
 */
extern int slurmdb_qos_add(void *db_conn, uint32_t uid, List qos_list)
{
	return acct_storage_g_add_qos(db_conn, getuid(), qos_list);
}