diff --git a/NEWS b/NEWS index cab08de5103f036baa5bf29c886ec5baea87e2eb..f0f92b1ca2a6ad10f48adb30922ee1ceb149d2fe 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ documents those changes that are of interest to users and admins. -- BLUEGENE - Fix it so 1 midplane clusters will run small block jobs. -- Add Command and WorkDir to the output of "scontrol show job" for job allocations created using srun (not just sbatch). + -- Fixed sacctmgr to not add blank defaultqos' when doing a cluster dump. * Changes in SLURM 2.2.0.rc3 ============================ diff --git a/src/sacctmgr/file_functions.c b/src/sacctmgr/file_functions.c index 229178f3d8f85205e5af831e6ac7c7f2bc0c4712..40de864adf546f6fa892876c49f67aaf2de38521 100644 --- a/src/sacctmgr/file_functions.c +++ b/src/sacctmgr/file_functions.c @@ -80,7 +80,7 @@ typedef enum { static int _init_sacctmgr_file_opts(sacctmgr_file_opts_t *file_opts) { - if(!file_opts) + if (!file_opts) return SLURM_ERROR; memset(file_opts, 0, sizeof(sacctmgr_file_opts_t)); @@ -208,8 +208,8 @@ static void _destroy_sacctmgr_file_opts(void *object) { sacctmgr_file_opts_t *file_opts = (sacctmgr_file_opts_t *)object; - if(file_opts) { - if(file_opts->coord_list) + if (file_opts) { + if (file_opts->coord_list) list_destroy(file_opts->coord_list); xfree(file_opts->def_acct); xfree(file_opts->def_wckey); @@ -217,7 +217,9 @@ static void _destroy_sacctmgr_file_opts(void *object) xfree(file_opts->name); xfree(file_opts->org); xfree(file_opts->part); - if(file_opts->wckey_list) + if (file_opts->qos_list) + list_destroy(file_opts->qos_list); + if (file_opts->wckey_list) list_destroy(file_opts->wckey_list); xfree(file_opts); } @@ -235,14 +237,14 @@ static sacctmgr_file_opts_t *_parse_options(char *options) _init_sacctmgr_file_opts(file_opts); - while(options[i]) { + while (options[i]) { quote = 0; start=i; - while(options[i] && options[i] != ':' && options[i] != '\n') { - if(options[i] == '"' || options[i] == '\'') { - if(quote) { - if(options[i] == quote_c) + while (options[i] && options[i] != ':' && options[i] != '\n') { + if (options[i] == '"' || options[i] == '\'') { + if (quote) { + if (options[i] == quote_c) quote = 0; } else { quote = 1; @@ -251,44 +253,46 @@ static sacctmgr_file_opts_t *_parse_options(char *options) } i++; } - if(quote) { - while(options[i] && options[i] != quote_c) + if (quote) { + while (options[i] && options[i] != quote_c) i++; - if(!options[i]) + if (!options[i]) fatal("There is a problem with option " "%s with quotes.", option); i++; } - if(i-start <= 0) + if (i-start <= 0) goto next_col; sub = xstrndup(options+start, i-start); end = parse_option_end(sub); command_len = end - 1; - if(sub[end] == '=') { + if (sub[end] == '=') { option2 = (int)sub[end-1]; end++; } option = strip_quotes(sub+end, NULL, 1); - if(!end) { - if(file_opts->name) { + if (!end) { + if (file_opts->name) { exit_code=1; fprintf(stderr, " Bad format on %s: " - "End your option with " - "an '=' sign\n", sub); + "End your option with " + "an '=' sign\n", sub); _destroy_sacctmgr_file_opts(file_opts); break; } file_opts->name = xstrdup(option); + } else if (end && !strlen(option)) { + debug("blank field given for %s discarding", sub); } else if (!strncasecmp (sub, "AdminLevel", MAX(command_len, 2))) { file_opts->admin = str_2_slurmdb_admin_level(option); } else if (!strncasecmp (sub, "Coordinator", MAX(command_len, 2))) { - if(!file_opts->coord_list) + if (!file_opts->coord_list) file_opts->coord_list = list_create(slurm_destroy_char); slurm_addto_char_list(file_opts->coord_list, option); @@ -301,7 +305,7 @@ static sacctmgr_file_opts_t *_parse_options(char *options) file_opts->def_acct = xstrdup(option); } else if (!strncasecmp (sub, "DefaultQOS", MAX(command_len, 8))) { - if(!g_qos_list) { + if (!g_qos_list) { g_qos_list = acct_storage_g_get_qos( db_conn, my_uid, NULL); } @@ -309,7 +313,7 @@ static sacctmgr_file_opts_t *_parse_options(char *options) file_opts->def_qos_id = str_2_slurmdb_qos( g_qos_list, option); - if(file_opts->def_qos_id == NO_VAL) { + if (file_opts->def_qos_id == NO_VAL) { fprintf(stderr, "You gave a bad qos '%s'. " "Use 'list qos' to get " @@ -321,7 +325,7 @@ static sacctmgr_file_opts_t *_parse_options(char *options) } else if (!strncasecmp (sub, "DefaultWCKey", MAX(command_len, 8))) { file_opts->def_wckey = xstrdup(option); - if(!file_opts->wckey_list) + if (!file_opts->wckey_list) file_opts->wckey_list = list_create(slurm_destroy_char); slurm_addto_char_list(file_opts->wckey_list, option); @@ -331,9 +335,9 @@ static sacctmgr_file_opts_t *_parse_options(char *options) } else if (!strncasecmp (sub, "FairShare", MAX(command_len, 1)) || !strncasecmp (sub, "Shares", - MAX(command_len, 1))) { + MAX(command_len, 1))) { if (get_uint(option, &file_opts->fairshare, - "FairShare") != SLURM_SUCCESS) { + "FairShare") != SLURM_SUCCESS) { exit_code=1; fprintf(stderr, " Bad FairShare value: %s\n", option); @@ -473,15 +477,18 @@ static sacctmgr_file_opts_t *_parse_options(char *options) } else if (!strncasecmp (sub, "Organization", MAX(command_len, 1))) { file_opts->org = xstrdup(option); + } else if (!strncasecmp (sub, "Partition", + MAX(command_len, 1))) { + file_opts->part = xstrdup(option); } else if (!strncasecmp (sub, "QosLevel", MAX(command_len, 1)) || !strncasecmp (sub, "Expedite", MAX(command_len, 1))) { - if(!file_opts->qos_list) { + if (!file_opts->qos_list) { file_opts->qos_list = list_create(slurm_destroy_char); } - if(!g_qos_list) { + if (!g_qos_list) { g_qos_list = acct_storage_g_get_qos( db_conn, my_uid, NULL); } @@ -491,7 +498,7 @@ static sacctmgr_file_opts_t *_parse_options(char *options) option, option2); } else if (!strncasecmp (sub, "WCKeys", MAX(command_len, 2))) { - if(!file_opts->wckey_list) + if (!file_opts->wckey_list) file_opts->wckey_list = list_create(slurm_destroy_char); slurm_addto_char_list(file_opts->wckey_list, option); @@ -504,7 +511,7 @@ static sacctmgr_file_opts_t *_parse_options(char *options) xfree(option); next_col: - if(options[i] == ':') + if (options[i] == ':') i++; else break; @@ -513,12 +520,12 @@ static sacctmgr_file_opts_t *_parse_options(char *options) xfree(sub); xfree(option); - if(!file_opts->name) { + if (!file_opts->name) { exit_code=1; fprintf(stderr, " No name given\n"); _destroy_sacctmgr_file_opts(file_opts); file_opts = NULL; - } else if(exit_code) { + } else if (exit_code) { _destroy_sacctmgr_file_opts(file_opts); file_opts = NULL; } @@ -536,11 +543,11 @@ static int _print_out_assoc(List assoc_list, bool user, bool add) int rc = SLURM_SUCCESS; char *tmp_char = NULL; - if(!assoc_list || !list_count(assoc_list)) + if (!assoc_list || !list_count(assoc_list)) return rc; format_list = list_create(slurm_destroy_char); - if(user) + if (user) slurm_addto_char_list(format_list, "User,Account"); else @@ -558,15 +565,15 @@ static int _print_out_assoc(List assoc_list, bool user, bool add) itr = list_iterator_create(assoc_list); itr2 = list_iterator_create(print_fields_list); - while((assoc = list_next(itr))) { - while((field = list_next(itr2))) { + while ((assoc = list_next(itr))) { + while ((field = list_next(itr2))) { switch(field->type) { case PRINT_ACCT: field->print_routine(field, assoc->acct); break; case PRINT_DQOS: - if(!g_qos_list) + if (!g_qos_list) g_qos_list = acct_storage_g_get_qos( db_conn, my_uid, @@ -644,7 +651,7 @@ static int _print_out_assoc(List assoc_list, bool user, bool add) assoc->partition); break; case PRINT_QOS: - if(!g_qos_list) + if (!g_qos_list) g_qos_list = acct_storage_g_get_qos( db_conn, my_uid, NULL); @@ -669,7 +676,7 @@ static int _print_out_assoc(List assoc_list, bool user, bool add) list_iterator_destroy(itr); list_iterator_destroy(itr2); list_destroy(print_fields_list); - if(add) + if (add) rc = acct_storage_g_add_associations(db_conn, my_uid, assoc_list); printf("--------------------------------------------------------------\n\n"); @@ -709,8 +716,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, slurmdb_init_association_rec(&mod_assoc, 0); memset(&assoc_cond, 0, sizeof(slurmdb_association_cond_t)); - if((file_opts->fairshare != NO_VAL) - && (assoc->shares_raw != file_opts->fairshare)) { + if ((file_opts->fairshare != NO_VAL) + && (assoc->shares_raw != file_opts->fairshare)) { mod_assoc.shares_raw = file_opts->fairshare; changed = 1; xstrfmtcat(my_info, @@ -721,8 +728,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, file_opts->fairshare); } - if((file_opts->grp_cpu_mins != NO_VAL) - && (assoc->grp_cpu_mins != file_opts->grp_cpu_mins)) { + if ((file_opts->grp_cpu_mins != NO_VAL) + && (assoc->grp_cpu_mins != file_opts->grp_cpu_mins)) { mod_assoc.grp_cpu_mins = file_opts->grp_cpu_mins; changed = 1; xstrfmtcat(my_info, @@ -734,8 +741,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, file_opts->grp_cpu_mins); } - if((file_opts->grp_cpus != NO_VAL) - && (assoc->grp_cpus != file_opts->grp_cpus)) { + if ((file_opts->grp_cpus != NO_VAL) + && (assoc->grp_cpus != file_opts->grp_cpus)) { mod_assoc.grp_cpus = file_opts->grp_cpus; changed = 1; xstrfmtcat(my_info, @@ -746,8 +753,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, file_opts->grp_cpus); } - if((file_opts->grp_jobs != NO_VAL) - && (assoc->grp_jobs != file_opts->grp_jobs)) { + if ((file_opts->grp_jobs != NO_VAL) + && (assoc->grp_jobs != file_opts->grp_jobs)) { mod_assoc.grp_jobs = file_opts->grp_jobs; changed = 1; xstrfmtcat(my_info, @@ -758,8 +765,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, file_opts->grp_jobs); } - if((file_opts->grp_nodes != NO_VAL) - && (assoc->grp_nodes != file_opts->grp_nodes)) { + if ((file_opts->grp_nodes != NO_VAL) + && (assoc->grp_nodes != file_opts->grp_nodes)) { mod_assoc.grp_nodes = file_opts->grp_nodes; changed = 1; xstrfmtcat(my_info, @@ -770,8 +777,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, file_opts->grp_nodes); } - if((file_opts->grp_submit_jobs != NO_VAL) - && (assoc->grp_submit_jobs != file_opts->grp_submit_jobs)) { + if ((file_opts->grp_submit_jobs != NO_VAL) + && (assoc->grp_submit_jobs != file_opts->grp_submit_jobs)) { mod_assoc.grp_submit_jobs = file_opts->grp_submit_jobs; changed = 1; xstrfmtcat(my_info, @@ -782,8 +789,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, file_opts->grp_submit_jobs); } - if((file_opts->grp_wall != NO_VAL) - && (assoc->grp_wall != file_opts->grp_wall)) { + if ((file_opts->grp_wall != NO_VAL) + && (assoc->grp_wall != file_opts->grp_wall)) { mod_assoc.grp_wall = file_opts->grp_wall; changed = 1; xstrfmtcat(my_info, @@ -794,8 +801,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, file_opts->grp_wall); } - if((file_opts->max_cpu_mins_pj != (uint64_t)NO_VAL) - && (assoc->max_cpu_mins_pj != file_opts->max_cpu_mins_pj)) { + if ((file_opts->max_cpu_mins_pj != (uint64_t)NO_VAL) + && (assoc->max_cpu_mins_pj != file_opts->max_cpu_mins_pj)) { mod_assoc.max_cpu_mins_pj = file_opts->max_cpu_mins_pj; changed = 1; @@ -808,8 +815,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, file_opts->max_cpu_mins_pj); } - if((file_opts->max_cpus_pj != NO_VAL) - && (assoc->max_cpus_pj != file_opts->max_cpus_pj)) { + if ((file_opts->max_cpus_pj != NO_VAL) + && (assoc->max_cpus_pj != file_opts->max_cpus_pj)) { mod_assoc.max_cpus_pj = file_opts->max_cpus_pj; changed = 1; xstrfmtcat(my_info, @@ -820,8 +827,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, file_opts->max_cpus_pj); } - if((file_opts->max_jobs != NO_VAL) - && (assoc->max_jobs != file_opts->max_jobs)) { + if ((file_opts->max_jobs != NO_VAL) + && (assoc->max_jobs != file_opts->max_jobs)) { mod_assoc.max_jobs = file_opts->max_jobs; changed = 1; xstrfmtcat(my_info, @@ -832,8 +839,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, file_opts->max_jobs); } - if((file_opts->max_nodes_pj != NO_VAL) - && (assoc->max_nodes_pj != file_opts->max_nodes_pj)) { + if ((file_opts->max_nodes_pj != NO_VAL) + && (assoc->max_nodes_pj != file_opts->max_nodes_pj)) { mod_assoc.max_nodes_pj = file_opts->max_nodes_pj; changed = 1; xstrfmtcat(my_info, @@ -844,8 +851,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, file_opts->max_nodes_pj); } - if((file_opts->max_submit_jobs != NO_VAL) - && (assoc->max_submit_jobs != file_opts->max_submit_jobs)) { + if ((file_opts->max_submit_jobs != NO_VAL) + && (assoc->max_submit_jobs != file_opts->max_submit_jobs)) { mod_assoc.max_submit_jobs = file_opts->max_submit_jobs; changed = 1; xstrfmtcat(my_info, @@ -856,8 +863,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, file_opts->max_submit_jobs); } - if((file_opts->max_wall_pj != NO_VAL) - && (assoc->max_wall_pj != file_opts->max_wall_pj)) { + if ((file_opts->max_wall_pj != NO_VAL) + && (assoc->max_wall_pj != file_opts->max_wall_pj)) { mod_assoc.max_wall_pj = file_opts->max_wall_pj; changed = 1; xstrfmtcat(my_info, @@ -867,7 +874,8 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, assoc->max_wall_pj, file_opts->max_wall_pj); } - if(assoc->parent_acct && parent && strcmp(assoc->parent_acct, parent)) { + if (assoc->parent_acct && parent + && strcmp(assoc->parent_acct, parent)) { mod_assoc.parent_acct = parent; changed = 1; xstrfmtcat(my_info, @@ -878,31 +886,31 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, parent); } - if(assoc->qos_list && list_count(assoc->qos_list) - && file_opts->qos_list && list_count(file_opts->qos_list)) { + if (assoc->qos_list && list_count(assoc->qos_list) + && file_opts->qos_list && list_count(file_opts->qos_list)) { ListIterator now_qos_itr = list_iterator_create(assoc->qos_list), new_qos_itr = list_iterator_create(file_opts->qos_list); char *now_qos = NULL, *new_qos = NULL; - if(!mod_assoc.qos_list) + if (!mod_assoc.qos_list) mod_assoc.qos_list = list_create(slurm_destroy_char); - while((new_qos = list_next(new_qos_itr))) { - while((now_qos = list_next(now_qos_itr))) { - if(!strcmp(new_qos, now_qos)) + while ((new_qos = list_next(new_qos_itr))) { + while ((now_qos = list_next(now_qos_itr))) { + if (!strcmp(new_qos, now_qos)) break; } list_iterator_reset(now_qos_itr); - if(!now_qos) + if (!now_qos) list_append(mod_assoc.qos_list, xstrdup(new_qos)); } list_iterator_destroy(new_qos_itr); list_iterator_destroy(now_qos_itr); - if(mod_assoc.qos_list && list_count(mod_assoc.qos_list)) + if (mod_assoc.qos_list && list_count(mod_assoc.qos_list)) new_qos = get_qos_complete_str(g_qos_list, mod_assoc.qos_list); - if(new_qos) { + if (new_qos) { xstrfmtcat(my_info, "%-30.30s for %-7.7s %-10.10s %8s\n", " Added QOS", @@ -914,11 +922,11 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, list_destroy(mod_assoc.qos_list); mod_assoc.qos_list = NULL; } - } else if(file_opts->qos_list && list_count(file_opts->qos_list)) { + } else if (file_opts->qos_list && list_count(file_opts->qos_list)) { char *new_qos = get_qos_complete_str(g_qos_list, file_opts->qos_list); - if(new_qos) { + if (new_qos) { xstrfmtcat(my_info, "%-30.30s for %-7.7s %-10.10s %8s\n", " Added QOS", @@ -931,7 +939,7 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, } } - if(changed) { + if (changed) { List ret_list = NULL; assoc_cond.cluster_list = list_create(NULL); @@ -940,10 +948,10 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, assoc_cond.acct_list = list_create(NULL); list_push(assoc_cond.acct_list, assoc->acct); - if(mod_type == MOD_USER) { + if (mod_type == MOD_USER) { assoc_cond.user_list = list_create(NULL); list_push(assoc_cond.user_list, assoc->user); - if(assoc->partition) { + if (assoc->partition) { assoc_cond.partition_list = list_create(NULL); list_push(assoc_cond.partition_list, assoc->partition); @@ -957,27 +965,27 @@ static int _mod_assoc(sacctmgr_file_opts_t *file_opts, &mod_assoc); notice_thread_fini(); - if(mod_assoc.qos_list) + if (mod_assoc.qos_list) list_destroy(mod_assoc.qos_list); list_destroy(assoc_cond.cluster_list); list_destroy(assoc_cond.acct_list); - if(assoc_cond.user_list) + if (assoc_cond.user_list) list_destroy(assoc_cond.user_list); - if(assoc_cond.partition_list) + if (assoc_cond.partition_list) list_destroy(assoc_cond.partition_list); -/* if(ret_list && list_count(ret_list)) { */ +/* if (ret_list && list_count(ret_list)) { */ /* char *object = NULL; */ /* ListIterator itr = list_iterator_create(ret_list); */ /* printf(" Modified account defaults for " */ /* "associations...\n"); */ -/* while((object = list_next(itr))) */ +/* while ((object = list_next(itr))) */ /* printf(" %s\n", object); */ /* list_iterator_destroy(itr); */ /* } */ - if(ret_list) { + if (ret_list) { printf("%s", my_info); list_destroy(ret_list); } else @@ -999,8 +1007,8 @@ static int _mod_cluster(sacctmgr_file_opts_t *file_opts, slurmdb_init_cluster_rec(&mod_cluster, 0); slurmdb_init_cluster_cond(&cluster_cond, 0); - if(file_opts->classification - && (file_opts->classification != cluster->classification)) { + if (file_opts->classification + && (file_opts->classification != cluster->classification)) { xstrfmtcat(my_info, "%-30.30s for %-7.7s %-10.10s %8s -> %s\n", " Changed Classification", "Cluster", @@ -1011,7 +1019,7 @@ static int _mod_cluster(sacctmgr_file_opts_t *file_opts, changed = 1; } - if(changed) { + if (changed) { List ret_list = NULL; cluster_cond.cluster_list = list_create(NULL); @@ -1026,24 +1034,24 @@ static int _mod_cluster(sacctmgr_file_opts_t *file_opts, list_destroy(cluster_cond.cluster_list); -/* if(ret_list && list_count(ret_list)) { */ +/* if (ret_list && list_count(ret_list)) { */ /* char *object = NULL; */ /* ListIterator itr = list_iterator_create(ret_list); */ /* printf(" Modified account defaults for " */ /* "associations...\n"); */ -/* while((object = list_next(itr))) */ +/* while ((object = list_next(itr))) */ /* printf(" %s\n", object); */ /* list_iterator_destroy(itr); */ /* } */ - if(ret_list) { + if (ret_list) { printf("%s", my_info); list_destroy(ret_list); } else changed = 0; xfree(my_info); } - if(!cluster->root_assoc || !cluster->root_assoc->cluster) { + if (!cluster->root_assoc || !cluster->root_assoc->cluster) { error("Cluster %s doesn't appear to have a root association. " "Try removing this cluster and then re-run load.", cluster->name); @@ -1069,10 +1077,10 @@ static int _mod_acct(sacctmgr_file_opts_t *file_opts, memset(&acct_cond, 0, sizeof(slurmdb_account_cond_t)); memset(&assoc_cond, 0, sizeof(slurmdb_association_cond_t)); - if(file_opts->desc) + if (file_opts->desc) desc = xstrdup(file_opts->desc); - if(desc && strcmp(desc, acct->description)) { + if (desc && strcmp(desc, acct->description)) { xstrfmtcat(my_info, "%-30.30s for %-7.7s %-10.10s %8s -> %s\n", " Changed description", "Account", @@ -1084,10 +1092,10 @@ static int _mod_acct(sacctmgr_file_opts_t *file_opts, } else xfree(desc); - if(file_opts->org) + if (file_opts->org) org = xstrdup(file_opts->org); - if(org && strcmp(org, acct->organization)) { + if (org && strcmp(org, acct->organization)) { xstrfmtcat(my_info, "%-30.30s for %-7.7s %-10.10s %8s -> %s\n", " Changed organization", "Account", @@ -1099,7 +1107,7 @@ static int _mod_acct(sacctmgr_file_opts_t *file_opts, } else xfree(org); - if(changed) { + if (changed) { List ret_list = NULL; assoc_cond.acct_list = list_create(NULL); @@ -1114,17 +1122,17 @@ static int _mod_acct(sacctmgr_file_opts_t *file_opts, list_destroy(assoc_cond.acct_list); -/* if(ret_list && list_count(ret_list)) { */ +/* if (ret_list && list_count(ret_list)) { */ /* char *object = NULL; */ /* ListIterator itr = list_iterator_create(ret_list); */ /* printf(" Modified account defaults for " */ /* "associations...\n"); */ -/* while((object = list_next(itr))) */ +/* while ((object = list_next(itr))) */ /* printf(" %s\n", object); */ /* list_iterator_destroy(itr); */ /* } */ - if(ret_list) { + if (ret_list) { printf("%s", my_info); list_destroy(ret_list); } else @@ -1148,7 +1156,7 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, List ret_list = NULL; slurmdb_association_cond_t assoc_cond; - if(!user || !user->name) { + if (!user || !user->name) { fatal(" We need a user name in _mod_user"); } @@ -1160,11 +1168,11 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, list_append(assoc_cond.user_list, user->name); user_cond.assoc_cond = &assoc_cond; - if(file_opts->def_acct) + if (file_opts->def_acct) def_acct = xstrdup(file_opts->def_acct); - if(def_acct && - (!user->default_acct || strcmp(def_acct, user->default_acct))) { + if (def_acct && + (!user->default_acct || strcmp(def_acct, user->default_acct))) { xstrfmtcat(my_info, "%-30.30s for %-7.7s %-10.10s %8s -> %s\n", " Changed Default Account", "User", @@ -1175,11 +1183,11 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, changed = 1; } - if(file_opts->def_wckey) + if (file_opts->def_wckey) def_wckey = xstrdup(file_opts->def_wckey); - if(def_wckey && - (!user->default_wckey || strcmp(def_wckey, user->default_wckey))) { + if (def_wckey && + (!user->default_wckey || strcmp(def_wckey, user->default_wckey))) { xstrfmtcat(my_info, "%-30.30s for %-7.7s %-10.10s %8s -> %s\n", " Changed Default WCKey", "User", @@ -1190,9 +1198,9 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, changed = 1; } - if(user->admin_level != SLURMDB_ADMIN_NOTSET - && file_opts->admin != SLURMDB_ADMIN_NOTSET - && user->admin_level != file_opts->admin) { + if (user->admin_level != SLURMDB_ADMIN_NOTSET + && file_opts->admin != SLURMDB_ADMIN_NOTSET + && user->admin_level != file_opts->admin) { xstrfmtcat(my_info, "%-30.30s for %-7.7s %-10.10s %8s -> %s\n", " Changed Admin Level", "User", @@ -1205,7 +1213,7 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, changed = 1; } - if(changed) { + if (changed) { notice_thread_init(); ret_list = acct_storage_g_modify_users( db_conn, my_uid, @@ -1213,17 +1221,17 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, &mod_user); notice_thread_fini(); -/* if(ret_list && list_count(ret_list)) { */ +/* if (ret_list && list_count(ret_list)) { */ /* char *object = NULL; */ /* ListIterator itr = list_iterator_create(ret_list); */ /* printf(" Modified user defaults for " */ /* "associations...\n"); */ -/* while((object = list_next(itr))) */ +/* while ((object = list_next(itr))) */ /* printf(" %s\n", object); */ /* list_iterator_destroy(itr); */ /* } */ - if(ret_list) { + if (ret_list) { printf("%s", my_info); list_destroy(ret_list); set = 1; @@ -1233,9 +1241,9 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, xfree(def_acct); xfree(def_wckey); - if((!user->coord_accts || !list_count(user->coord_accts)) - && (file_opts->coord_list - && list_count(file_opts->coord_list))) { + if ((!user->coord_accts || !list_count(user->coord_accts)) + && (file_opts->coord_list + && list_count(file_opts->coord_list))) { ListIterator coord_itr = NULL; char *temp_char = NULL; slurmdb_coord_rec_t *coord = NULL; @@ -1250,13 +1258,13 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, coord_itr = list_iterator_create(file_opts->coord_list); printf(" Making User '%s' coordinator for account(s)", user->name); - while((temp_char = list_next(coord_itr))) { + while ((temp_char = list_next(coord_itr))) { coord = xmalloc(sizeof(slurmdb_coord_rec_t)); coord->name = xstrdup(temp_char); coord->direct = 1; list_push(user->coord_accts, coord); - if(first) { + if (first) { printf(" %s", temp_char); first = 0; } else @@ -1265,9 +1273,9 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, list_iterator_destroy(coord_itr); printf("\n"); set = 1; - } else if((user->coord_accts && list_count(user->coord_accts)) - && (file_opts->coord_list - && list_count(file_opts->coord_list))) { + } else if ((user->coord_accts && list_count(user->coord_accts)) + && (file_opts->coord_list + && list_count(file_opts->coord_list))) { ListIterator coord_itr = NULL; ListIterator char_itr = NULL; char *temp_char = NULL; @@ -1277,15 +1285,15 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, coord_itr = list_iterator_create(user->coord_accts); char_itr = list_iterator_create(file_opts->coord_list); - while((temp_char = list_next(char_itr))) { - while((coord = list_next(coord_itr))) { - if(!coord->direct) + while ((temp_char = list_next(char_itr))) { + while ((coord = list_next(coord_itr))) { + if (!coord->direct) continue; - if(!strcmp(coord->name, temp_char)) { + if (!strcmp(coord->name, temp_char)) { break; } } - if(!coord) { + if (!coord) { printf(" Making User '%s' coordinator of " "account '%s'\n", user->name, @@ -1299,7 +1307,7 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, list_iterator_destroy(char_itr); list_iterator_destroy(coord_itr); - if(list_count(add_list)) { + if (list_count(add_list)) { notice_thread_init(); rc = acct_storage_g_add_coord(db_conn, my_uid, add_list, @@ -1310,9 +1318,9 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, list_destroy(add_list); } - if((!user->wckey_list || !list_count(user->wckey_list)) - && (file_opts->wckey_list - && list_count(file_opts->wckey_list))) { + if ((!user->wckey_list || !list_count(user->wckey_list)) + && (file_opts->wckey_list + && list_count(file_opts->wckey_list))) { ListIterator wckey_itr = NULL; char *temp_char = NULL; slurmdb_wckey_rec_t *wckey = NULL; @@ -1321,7 +1329,7 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, user->wckey_list = list_create(slurmdb_destroy_wckey_rec); wckey_itr = list_iterator_create(file_opts->wckey_list); printf(" Adding WCKey(s) "); - while((temp_char = list_next(wckey_itr))) { + while ((temp_char = list_next(wckey_itr))) { wckey = xmalloc(sizeof(slurmdb_wckey_rec_t)); wckey->name = xstrdup(temp_char); wckey->cluster = xstrdup(cluster); @@ -1330,7 +1338,7 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, wckey->is_def = 1; list_push(user->wckey_list, wckey); - if(first) { + if (first) { printf("'%s'", temp_char); first = 0; } else @@ -1343,9 +1351,9 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, rc = acct_storage_g_add_wckeys(db_conn, my_uid, user->wckey_list); notice_thread_fini(); - } else if((user->wckey_list && list_count(user->wckey_list)) - && (file_opts->wckey_list - && list_count(file_opts->wckey_list))) { + } else if ((user->wckey_list && list_count(user->wckey_list)) + && (file_opts->wckey_list + && list_count(file_opts->wckey_list))) { ListIterator wckey_itr = NULL; ListIterator char_itr = NULL; char *temp_char = NULL; @@ -1355,12 +1363,12 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, wckey_itr = list_iterator_create(user->wckey_list); char_itr = list_iterator_create(file_opts->wckey_list); - while((temp_char = list_next(char_itr))) { - while((wckey = list_next(wckey_itr))) { - if(!strcmp(wckey->name, temp_char)) + while ((temp_char = list_next(char_itr))) { + while ((wckey = list_next(wckey_itr))) { + if (!strcmp(wckey->name, temp_char)) break; } - if(!wckey) { + if (!wckey) { printf(" Adding WCKey '%s' to User '%s'\n", temp_char, user->name); wckey = xmalloc(sizeof(slurmdb_wckey_rec_t)); @@ -1378,7 +1386,7 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, list_iterator_destroy(char_itr); list_iterator_destroy(wckey_itr); - if(list_count(add_list)) { + if (list_count(add_list)) { notice_thread_init(); rc = acct_storage_g_add_wckeys(db_conn, my_uid, add_list); @@ -1395,26 +1403,26 @@ static int _mod_user(sacctmgr_file_opts_t *file_opts, } static slurmdb_user_rec_t *_set_user_up(sacctmgr_file_opts_t *file_opts, - char *cluster, char *parent) + char *cluster, char *parent) { slurmdb_user_rec_t *user = xmalloc(sizeof(slurmdb_user_rec_t)); user->assoc_list = NULL; user->name = xstrdup(file_opts->name); - if(file_opts->def_acct) + if (file_opts->def_acct) user->default_acct = xstrdup(file_opts->def_acct); else user->default_acct = xstrdup(parent); - if(file_opts->def_wckey) + if (file_opts->def_wckey) user->default_wckey = xstrdup(file_opts->def_wckey); else user->default_wckey = xstrdup(""); user->admin_level = file_opts->admin; - if(file_opts->coord_list) { + if (file_opts->coord_list) { slurmdb_user_cond_t user_cond; slurmdb_association_cond_t assoc_cond; ListIterator coord_itr = NULL; @@ -1435,7 +1443,7 @@ static slurmdb_user_rec_t *_set_user_up(sacctmgr_file_opts_t *file_opts, list_destroy(assoc_cond.user_list); user->coord_accts = list_create(slurmdb_destroy_coord_rec); coord_itr = list_iterator_create(file_opts->coord_list); - while((temp_char = list_next(coord_itr))) { + while ((temp_char = list_next(coord_itr))) { coord = xmalloc(sizeof(slurmdb_coord_rec_t)); coord->name = xstrdup(temp_char); coord->direct = 1; @@ -1444,14 +1452,14 @@ static slurmdb_user_rec_t *_set_user_up(sacctmgr_file_opts_t *file_opts, list_iterator_destroy(coord_itr); } - if(file_opts->wckey_list) { + if (file_opts->wckey_list) { ListIterator wckey_itr = NULL; char *temp_char = NULL; slurmdb_wckey_rec_t *wckey = NULL; user->wckey_list = list_create(slurmdb_destroy_wckey_rec); wckey_itr = list_iterator_create(file_opts->wckey_list); - while((temp_char = list_next(wckey_itr))) { + while ((temp_char = list_next(wckey_itr))) { wckey = xmalloc(sizeof(slurmdb_wckey_rec_t)); wckey->name = xstrdup(temp_char); wckey->user = xstrdup(user->name); @@ -1470,18 +1478,18 @@ static slurmdb_user_rec_t *_set_user_up(sacctmgr_file_opts_t *file_opts, static slurmdb_account_rec_t *_set_acct_up(sacctmgr_file_opts_t *file_opts, - char *parent) + char *parent) { slurmdb_account_rec_t *acct = xmalloc(sizeof(slurmdb_account_rec_t)); acct->assoc_list = NULL; acct->name = xstrdup(file_opts->name); - if(file_opts->desc) + if (file_opts->desc) acct->description = xstrdup(file_opts->desc); else acct->description = xstrdup(file_opts->name); - if(file_opts->org) + if (file_opts->org) acct->organization = xstrdup(file_opts->org); - else if(strcmp(parent, "root")) + else if (strcmp(parent, "root")) acct->organization = xstrdup(parent); else acct->organization = xstrdup(file_opts->name); @@ -1498,12 +1506,12 @@ static slurmdb_association_rec_t *_set_assoc_up(sacctmgr_file_opts_t *file_opts, { slurmdb_association_rec_t *assoc = NULL; - if(!cluster) { + if (!cluster) { error("No cluster name was given for _set_assoc_up"); return NULL; } - if(!parent && (mod_type != MOD_CLUSTER)) { + if (!parent && (mod_type != MOD_CLUSTER)) { error("No parent was given for _set_assoc_up"); return NULL; } @@ -1554,7 +1562,7 @@ static slurmdb_association_rec_t *_set_assoc_up(sacctmgr_file_opts_t *file_opts, assoc->max_submit_jobs = file_opts->max_submit_jobs; assoc->max_wall_pj = file_opts->max_wall_pj; - if(file_opts->qos_list && list_count(file_opts->qos_list)) + if (file_opts->qos_list && list_count(file_opts->qos_list)) assoc->qos_list = copy_char_list(file_opts->qos_list); @@ -1572,33 +1580,33 @@ static int _print_file_slurmdb_hierarchical_rec_childern( slurmdb_account_rec_t *acct_rec = NULL; itr = list_iterator_create(slurmdb_hierarchical_rec_list); - while((slurmdb_hierarchical_rec = list_next(itr))) { - if(slurmdb_hierarchical_rec->assoc->user) { + while ((slurmdb_hierarchical_rec = list_next(itr))) { + if (slurmdb_hierarchical_rec->assoc->user) { user_rec = sacctmgr_find_user_from_list( user_list, slurmdb_hierarchical_rec->assoc->user); line = xstrdup_printf( "User - %s", slurmdb_hierarchical_rec->sort_name); - if(slurmdb_hierarchical_rec->assoc->partition) + if (slurmdb_hierarchical_rec->assoc->partition) xstrfmtcat(line, ":Partition='%s'", slurmdb_hierarchical_rec-> assoc->partition); - if(user_rec) { + if (user_rec) { xstrfmtcat(line, ":DefaultAccount='%s'", user_rec->default_acct); - if(user_rec->default_wckey - && user_rec->default_wckey[0]) + if (user_rec->default_wckey + && user_rec->default_wckey[0]) xstrfmtcat(line, ":DefaultWCKey='%s'", user_rec->default_wckey); - if(user_rec->admin_level > SLURMDB_ADMIN_NONE) + if (user_rec->admin_level > SLURMDB_ADMIN_NONE) xstrfmtcat(line, ":AdminLevel='%s'", slurmdb_admin_level_str( user_rec-> admin_level)); - if(user_rec->coord_accts - && list_count(user_rec->coord_accts)) { + if (user_rec->coord_accts + && list_count(user_rec->coord_accts)) { ListIterator itr2 = NULL; slurmdb_coord_rec_t *coord = NULL; int first_coord = 1; @@ -1606,13 +1614,13 @@ static int _print_file_slurmdb_hierarchical_rec_childern( (ListCmpF)sort_coord_list); itr2 = list_iterator_create( user_rec->coord_accts); - while((coord = list_next(itr2))) { + while ((coord = list_next(itr2))) { /* We only care about * the direct accounts here */ - if(!coord->direct) + if (!coord->direct) continue; - if(first_coord) { + if (first_coord) { xstrfmtcat( line, ":Coordinator" @@ -1624,20 +1632,27 @@ static int _print_file_slurmdb_hierarchical_rec_childern( coord->name); } } - if(!first_coord) + if (!first_coord) xstrcat(line, "'"); list_iterator_destroy(itr2); } - if(user_rec->wckey_list - && list_count(user_rec->wckey_list)) { + if (user_rec->wckey_list + && list_count(user_rec->wckey_list)) { ListIterator itr2 = NULL; slurmdb_wckey_rec_t *wckey = NULL; int first_wckey = 1; itr2 = list_iterator_create( user_rec->wckey_list); - while((wckey = list_next(itr2))) { - if(first_wckey) { + while ((wckey = list_next(itr2))) { + /* Avoid sending + non-legitimate wckeys. + */ + if (!wckey->name || + !wckey->name[0] || + wckey->name[0] == '*') + continue; + if (first_wckey) { xstrfmtcat( line, ":WCKeys='%s", @@ -1648,7 +1663,7 @@ static int _print_file_slurmdb_hierarchical_rec_childern( wckey->name); } } - if(!first_wckey) + if (!first_wckey) xstrcat(line, "'"); list_iterator_destroy(itr2); } @@ -1660,7 +1675,7 @@ static int _print_file_slurmdb_hierarchical_rec_childern( line = xstrdup_printf( "Account - %s", slurmdb_hierarchical_rec->sort_name); - if(acct_rec) { + if (acct_rec) { xstrfmtcat(line, ":Description='%s'", acct_rec->description); xstrfmtcat(line, ":Organization='%s'", @@ -1671,7 +1686,7 @@ static int _print_file_slurmdb_hierarchical_rec_childern( print_file_add_limits_to_line(&line, slurmdb_hierarchical_rec->assoc); - if(fprintf(fd, "%s\n", line) < 0) { + if (fprintf(fd, "%s\n", line) < 0) { exit_code=1; fprintf(stderr, " Can't write to file"); xfree(line); @@ -1691,61 +1706,61 @@ static int _print_file_slurmdb_hierarchical_rec_childern( extern int print_file_add_limits_to_line(char **line, slurmdb_association_rec_t *assoc) { - if(!assoc) + if (!assoc) return SLURM_ERROR; - if(assoc->def_qos_id != NO_VAL) { + if (assoc->def_qos_id && (assoc->def_qos_id != NO_VAL)) { char *tmp_char; - if(!g_qos_list) + 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); - xstrfmtcat(*line, ":DefaultQOS='%s'", tmp_char); + if ((tmp_char = slurmdb_qos_str(g_qos_list, assoc->def_qos_id))) + xstrfmtcat(*line, ":DefaultQOS='%s'", tmp_char); } - if(assoc->shares_raw != INFINITE) + if (assoc->shares_raw != INFINITE) xstrfmtcat(*line, ":Fairshare=%u", assoc->shares_raw); - if(assoc->grp_cpu_mins != (uint64_t)INFINITE) + if (assoc->grp_cpu_mins != (uint64_t)INFINITE) xstrfmtcat(*line, ":GrpCPUMins=%"PRIu64, assoc->grp_cpu_mins); - if(assoc->grp_cpus != INFINITE) + if (assoc->grp_cpus != INFINITE) xstrfmtcat(*line, ":GrpCPUs=%u", assoc->grp_cpus); - if(assoc->grp_jobs != INFINITE) + if (assoc->grp_jobs != INFINITE) xstrfmtcat(*line, ":GrpJobs=%u", assoc->grp_jobs); - if(assoc->grp_nodes != INFINITE) + if (assoc->grp_nodes != INFINITE) xstrfmtcat(*line, ":GrpNodes=%u", assoc->grp_nodes); - if(assoc->grp_submit_jobs != INFINITE) + if (assoc->grp_submit_jobs != INFINITE) xstrfmtcat(*line, ":GrpSubmitJobs=%u", assoc->grp_submit_jobs); - if(assoc->grp_wall != INFINITE) + if (assoc->grp_wall != INFINITE) xstrfmtcat(*line, ":GrpWall=%u", assoc->grp_wall); - if(assoc->max_cpu_mins_pj != (uint64_t)INFINITE) + if (assoc->max_cpu_mins_pj != (uint64_t)INFINITE) xstrfmtcat(*line, ":MaxCPUMinsPerJob=%"PRIu64, assoc->max_cpu_mins_pj); - if(assoc->max_cpus_pj != INFINITE) + if (assoc->max_cpus_pj != INFINITE) xstrfmtcat(*line, ":MaxCPUsPerJob=%u", assoc->max_cpus_pj); - if(assoc->max_jobs != INFINITE) + if (assoc->max_jobs != INFINITE) xstrfmtcat(*line, ":MaxJobs=%u", assoc->max_jobs); - if(assoc->max_nodes_pj != INFINITE) + if (assoc->max_nodes_pj != INFINITE) xstrfmtcat(*line, ":MaxNodesPerJob=%u", assoc->max_nodes_pj); - if(assoc->max_submit_jobs != INFINITE) + if (assoc->max_submit_jobs != INFINITE) xstrfmtcat(*line, ":MaxSubmitJobs=%u", assoc->max_submit_jobs); - if(assoc->max_wall_pj != INFINITE) + if (assoc->max_wall_pj != INFINITE) xstrfmtcat(*line, ":MaxWallDurationPerJob=%u", assoc->max_wall_pj); - if(assoc->qos_list && list_count(assoc->qos_list)) { + if (assoc->qos_list && list_count(assoc->qos_list)) { char *temp_char = NULL; - if(!g_qos_list) + if (!g_qos_list) g_qos_list = acct_storage_g_get_qos( db_conn, my_uid, NULL); @@ -1768,20 +1783,20 @@ extern int print_file_slurmdb_hierarchical_rec_list( slurmdb_hierarchical_rec_t *slurmdb_hierarchical_rec = NULL; itr = list_iterator_create(slurmdb_hierarchical_rec_list); - while((slurmdb_hierarchical_rec = list_next(itr))) { + while ((slurmdb_hierarchical_rec = list_next(itr))) { /* info("got here %d with %d from %s %s", */ /* depth, list_count(slurmdb_hierarchical_rec->childern), */ /* slurmdb_hierarchical_rec->assoc->acct, slurmdb_hierarchical_rec->assoc->user); */ - if(!list_count(slurmdb_hierarchical_rec->childern)) + if (!list_count(slurmdb_hierarchical_rec->childern)) continue; - if(fprintf(fd, "Parent - %s\n", - slurmdb_hierarchical_rec->assoc->acct) < 0) { + if (fprintf(fd, "Parent - %s\n", + slurmdb_hierarchical_rec->assoc->acct) < 0) { error("Can't write to file"); return SLURM_ERROR; } info("%s - %s", "Parent", - slurmdb_hierarchical_rec->assoc->acct); + slurmdb_hierarchical_rec->assoc->acct); /* info("sending %d from %s", */ /* list_count(slurmdb_hierarchical_rec->childern), */ /* slurmdb_hierarchical_rec->assoc->acct); */ @@ -1840,7 +1855,7 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) int set = 0, command_len = 0; - if(readonly_flag) { + if (readonly_flag) { exit_code = 1; fprintf(stderr, "Can't run this command in readonly mode.\n"); return; @@ -1852,21 +1867,21 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) for (i=0; i<argc; i++) { int option = 0; int end = parse_option_end(argv[i]); - if(!end) + if (!end) command_len=strlen(argv[i]); else { command_len=end-1; - if(argv[i][end] == '=') { + if (argv[i][end] == '=') { option = (int)argv[i][end-1]; end++; } } - if(!end && !strncasecmp(argv[i], "clean", - MAX(command_len, 3))) { + if (!end && !strncasecmp(argv[i], "clean", + MAX(command_len, 3))) { start_clean = 1; - } else if(!end || !strncasecmp (argv[i], "File", - MAX(command_len, 1))) { - if(file_name) { + } else if (!end || !strncasecmp (argv[i], "File", + MAX(command_len, 1))) { + if (file_name) { exit_code=1; fprintf(stderr, " File name already set to %s\n", @@ -1876,7 +1891,7 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) file_name = xstrdup(argv[i]+end); } else if (!strncasecmp (argv[i], "Cluster", MAX(command_len, 3))) { - if(cluster_name) { + if (cluster_name) { exit_code=1; fprintf(stderr, " Can only do one cluster at a time. " @@ -1891,7 +1906,7 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) } } - if(!file_name) { + if (!file_name) { exit_code=1; xfree(cluster_name); fprintf(stderr, @@ -1923,7 +1938,7 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) format_list = list_create(slurm_destroy_char); - while((num_lines = _get_next_line(line, BUFFER_SIZE, fd)) > 0) { + while ((num_lines = _get_next_line(line, BUFFER_SIZE, fd)) > 0) { lc += num_lines; /* skip empty lines */ if (line[0] == '\0') { @@ -1936,21 +1951,21 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) /* first find the object */ start=0; for(i=0; i<len; i++) { - if(line[i] == '-') { + if (line[i] == '-') { start = i; - if(line[i-1] == ' ') + if (line[i-1] == ' ') i--; - if(i<sizeof(object)) + if (i<sizeof(object)) strncpy(object, line, i); break; } } - if(!object[0]) + if (!object[0]) continue; - while(line[start] != ' ' && start<len) + while (line[start] != ' ' && start<len) start++; - if(start>=len) { + if (start>=len) { exit_code=1; fprintf(stderr, " Nothing after object " "name '%s'. line(%d)\n", @@ -1960,21 +1975,21 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) } start++; - if(!strcasecmp("Machine", object) - || !strcasecmp("Cluster", object)) { + if (!strcasecmp("Machine", object) + || !strcasecmp("Cluster", object)) { slurmdb_association_cond_t assoc_cond; - if(cluster_name && !cluster_name_set) { + if (cluster_name && !cluster_name_set) { exit_code=1; fprintf(stderr, " You can only add one cluster " - "at a time.\n"); + "at a time.\n"); rc = SLURM_ERROR; break; } file_opts = _parse_options(line+start); - if(!file_opts) { + if (!file_opts) { exit_code=1; fprintf(stderr, " error: Problem with line(%d)\n", lc); @@ -1982,7 +1997,7 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) break; } - if(!cluster_name_set) + if (!cluster_name_set) cluster_name = xstrdup(file_opts->name); /* we have to do this here since this is the @@ -2008,28 +2023,28 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) /* make sure this person running is an admin */ user_name = uid_to_string(my_uid); - if(!(user = sacctmgr_find_user_from_list( - curr_user_list, user_name))) { + if (!(user = sacctmgr_find_user_from_list( + curr_user_list, user_name))) { exit_code=1; fprintf(stderr, " Your uid (%u) is not in the " "accounting system, can't load file.\n", my_uid); - if(curr_user_list) + if (curr_user_list) list_destroy(curr_user_list); xfree(user_name); return; } else { - if(my_uid != slurm_get_slurm_user_id() - && my_uid != 0 - && (user->admin_level - < SLURMDB_ADMIN_SUPER_USER)) { + if (my_uid != slurm_get_slurm_user_id() + && my_uid != 0 + && (user->admin_level + < SLURMDB_ADMIN_SUPER_USER)) { exit_code=1; fprintf(stderr, " Your user does not have " "sufficient " "privileges to load files.\n"); - if(curr_user_list) + if (curr_user_list) list_destroy(curr_user_list); xfree(user_name); return; @@ -2037,15 +2052,15 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) } xfree(user_name); - if(start_clean) { + if (start_clean) { slurmdb_cluster_cond_t cluster_cond; List ret_list = NULL; - if(!commit_check("You requested to flush " - "the cluster before " - "adding it again.\n" - "Are you sure you want " - "to continue?")) { + if (!commit_check("You requested to flush " + "the cluster before " + "adding it again.\n" + "Are you sure you want " + "to continue?")) { printf("Aborted\n"); break; } @@ -2061,7 +2076,7 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) notice_thread_fini(); list_destroy(cluster_cond.cluster_list); - if(!ret_list) { + if (!ret_list) { exit_code=1; fprintf(stderr, " There was a problem " "removing the cluster.\n"); @@ -2075,11 +2090,11 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) curr_cluster_list = acct_storage_g_get_clusters( db_conn, my_uid, NULL); - if(cluster_name) + if (cluster_name) printf("For cluster %s\n", cluster_name); - if(!(cluster = sacctmgr_find_cluster_from_list( - curr_cluster_list, cluster_name))) { + if (!(cluster = sacctmgr_find_cluster_from_list( + curr_cluster_list, cluster_name))) { List temp_assoc_list = list_create(NULL); List cluster_list = list_create( slurmdb_destroy_cluster_rec); @@ -2089,7 +2104,7 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) slurmdb_init_cluster_rec(cluster, 0); list_append(cluster_list, cluster); cluster->name = xstrdup(cluster_name); - if(file_opts->classification) { + if (file_opts->classification) { cluster->classification = file_opts->classification; printf("Classification: %s\n", @@ -2113,7 +2128,7 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) notice_thread_fini(); list_destroy(cluster_list); - if(rc != SLURM_SUCCESS) { + if (rc != SLURM_SUCCESS) { exit_code=1; fprintf(stderr, " Problem adding cluster: %s\n", @@ -2138,7 +2153,7 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) db_conn, my_uid, &assoc_cond); list_destroy(assoc_cond.cluster_list); - if(!curr_assoc_list) { + if (!curr_assoc_list) { exit_code=1; fprintf(stderr, " Problem getting associations " "for this cluster\n"); @@ -2147,54 +2162,54 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) } //info("got %d assocs", list_count(curr_assoc_list)); continue; - } else if(!cluster_name) { + } else if (!cluster_name) { exit_code=1; fprintf(stderr, " You need to specify a cluster name " "first with 'Cluster - $NAME' in your file\n"); break; } - if(!strcasecmp("Parent", object)) { + if (!strcasecmp("Parent", object)) { xfree(parent); i = start; - while(line[i] != '\n' && i<len) + while (line[i] != '\n' && i<len) i++; - if(i >= len) { + if (i >= len) { exit_code=1; fprintf(stderr, " No parent name " "given line(%d)\n", - lc); + lc); rc = SLURM_ERROR; break; } parent = xstrndup(line+start, i-start); //info("got parent %s", parent); - if(!sacctmgr_find_account_base_assoc_from_list( - curr_assoc_list, parent, cluster_name) - && !sacctmgr_find_account_base_assoc_from_list( - slurmdb_assoc_list, parent, cluster_name)) { + if (!sacctmgr_find_account_base_assoc_from_list( + curr_assoc_list, parent, cluster_name) + && !sacctmgr_find_account_base_assoc_from_list( + slurmdb_assoc_list, parent, cluster_name)) { exit_code=1; fprintf(stderr, " line(%d) You need to add " - "this parent (%s) as a child before " - "you can add childern to it.\n", - lc, parent); + "this parent (%s) as a child before " + "you can add childern to it.\n", + lc, parent); break; } continue; - } else if(!parent) { + } else if (!parent) { parent = xstrdup("root"); printf(" No parent given creating off root, " "If incorrect specify 'Parent - name' " "before any childern in your file\n"); } - if(!strcasecmp("Project", object) - || !strcasecmp("Account", object)) { + if (!strcasecmp("Project", object) + || !strcasecmp("Account", object)) { file_opts = _parse_options(line+start); - if(!file_opts) { + if (!file_opts) { exit_code=1; fprintf(stderr, " Problem with line(%d)\n", lc); rc = SLURM_ERROR; @@ -2202,10 +2217,10 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) } //info("got a project %s of %s", file_opts->name, parent); - if(!(acct = sacctmgr_find_account_from_list( - curr_acct_list, file_opts->name)) - && !sacctmgr_find_account_from_list( - acct_list, file_opts->name)) { + if (!(acct = sacctmgr_find_account_from_list( + curr_acct_list, file_opts->name)) + && !sacctmgr_find_account_from_list( + acct_list, file_opts->name)) { acct = _set_acct_up(file_opts, parent); list_append(acct_list, acct); /* don't add anything to the @@ -2217,22 +2232,22 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) list_append(slurmdb_assoc_list, assoc); /* don't add anything to the curr_assoc_list */ - } else if(!(assoc = - sacctmgr_find_account_base_assoc_from_list( - curr_assoc_list, file_opts->name, - cluster_name)) && - !sacctmgr_find_account_base_assoc_from_list( - slurmdb_assoc_list, file_opts->name, - cluster_name)) { + } else if (!(assoc = + sacctmgr_find_account_base_assoc_from_list( + curr_assoc_list, file_opts->name, + cluster_name)) && + !sacctmgr_find_account_base_assoc_from_list( + slurmdb_assoc_list, file_opts->name, + cluster_name)) { acct2 = sacctmgr_find_account_from_list( mod_acct_list, file_opts->name); - if(!acct2) { + if (!acct2) { acct2 = xmalloc( sizeof(slurmdb_account_rec_t)); list_append(mod_acct_list, acct2); acct2->name = xstrdup(file_opts->name); - if(_mod_acct(file_opts, acct, parent)) + if (_mod_acct(file_opts, acct, parent)) set = 1; } else { debug2("already modified this account"); @@ -2244,16 +2259,16 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) list_append(slurmdb_assoc_list, assoc); /* don't add anything to the curr_assoc_list */ - } else if(assoc) { + } else if (assoc) { acct2 = sacctmgr_find_account_from_list( mod_acct_list, file_opts->name); - if(!acct2) { + if (!acct2) { acct2 = xmalloc( sizeof(slurmdb_account_rec_t)); list_append(mod_acct_list, acct2); acct2->name = xstrdup(file_opts->name); - if(_mod_acct(file_opts, acct, parent)) + if (_mod_acct(file_opts, acct, parent)) set = 1; } else { debug2("already modified this account"); @@ -2265,7 +2280,7 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) cluster_name, NULL); - if(!assoc2) { + if (!assoc2) { assoc2 = xmalloc( sizeof(slurmdb_association_rec_t)); slurmdb_init_association_rec(assoc2, 0); @@ -2274,8 +2289,8 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) assoc2->acct = xstrdup(file_opts->name); assoc2->parent_acct = xstrdup(assoc->parent_acct); - if(_mod_assoc(file_opts, - assoc, MOD_ACCT, parent)) + if (_mod_assoc(file_opts, + assoc, MOD_ACCT, parent)) set = 1; } else { debug2("already modified this assoc"); @@ -2283,20 +2298,20 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) } _destroy_sacctmgr_file_opts(file_opts); continue; - } else if(!strcasecmp("User", object)) { + } else if (!strcasecmp("User", object)) { file_opts = _parse_options(line+start); - if(!file_opts) { + if (!file_opts) { exit_code=1; fprintf(stderr, " Problem with line(%d)\n", lc); rc = SLURM_ERROR; break; } - if(!(user = sacctmgr_find_user_from_list( - curr_user_list, file_opts->name)) - && !sacctmgr_find_user_from_list( - user_list, file_opts->name)) { + if (!(user = sacctmgr_find_user_from_list( + curr_user_list, file_opts->name)) + && !sacctmgr_find_user_from_list( + user_list, file_opts->name)) { user = _set_user_up(file_opts, cluster_name, parent); @@ -2310,21 +2325,22 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) list_append(user_assoc_list, assoc); /* don't add anything to the curr_assoc_list */ - } else if(!(assoc = sacctmgr_find_association_from_list( - curr_assoc_list, - file_opts->name, parent, - cluster_name, file_opts->part)) - && !sacctmgr_find_association_from_list( - user_assoc_list, - file_opts->name, parent, - cluster_name, - file_opts->part)) { + } else if (!(assoc = + sacctmgr_find_association_from_list( + curr_assoc_list, + file_opts->name, parent, + cluster_name, file_opts->part)) + && !sacctmgr_find_association_from_list( + user_assoc_list, + file_opts->name, parent, + cluster_name, + file_opts->part)) { /* This means the user was added * during this round but this is a new * association we are adding */ - if(!user) + if (!user) goto new_association; /* This means there could be a change @@ -2332,13 +2348,13 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) */ user2 = sacctmgr_find_user_from_list( mod_user_list, file_opts->name); - if(!user2) { + if (!user2) { user2 = xmalloc( sizeof(slurmdb_user_rec_t)); list_append(mod_user_list, user2); user2->name = xstrdup(file_opts->name); - if(_mod_user(file_opts, user, - cluster_name, parent)) + if (_mod_user(file_opts, user, + cluster_name, parent)) set = 1; } else { debug2("already modified this user"); @@ -2350,16 +2366,16 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) list_append(user_assoc_list, assoc); /* don't add anything to the curr_assoc_list */ - } else if(assoc) { + } else if (assoc) { user2 = sacctmgr_find_user_from_list( mod_user_list, file_opts->name); - if(!user2) { + if (!user2) { user2 = xmalloc( sizeof(slurmdb_user_rec_t)); list_append(mod_user_list, user2); user2->name = xstrdup(file_opts->name); - if(_mod_user(file_opts, user, - cluster_name, parent)) + if (_mod_user(file_opts, user, + cluster_name, parent)) set = 1; } else { debug2("already modified this user"); @@ -2371,7 +2387,7 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) cluster_name, file_opts->part); - if(!assoc2) { + if (!assoc2) { assoc2 = xmalloc( sizeof(slurmdb_association_rec_t)); slurmdb_init_association_rec(assoc2, 0); @@ -2381,8 +2397,8 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) assoc2->user = xstrdup(file_opts->name); assoc2->partition = xstrdup(file_opts->part); - if(_mod_assoc(file_opts, - assoc, MOD_USER, parent)) + if (_mod_assoc(file_opts, + assoc, MOD_USER, parent)) set = 1; } else { debug2("already modified this assoc"); @@ -2404,10 +2420,10 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) xfree(parent); START_TIMER; - if(rc == SLURM_SUCCESS && list_count(acct_list)) { + if (rc == SLURM_SUCCESS && list_count(acct_list)) { printf("Accounts\n"); slurm_addto_char_list(format_list, - "Name,Description,Organization,QOS"); + "Name,Description,Organization,QOS"); print_fields_list = sacctmgr_process_format_list(format_list); list_flush(format_list); @@ -2416,8 +2432,8 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) itr = list_iterator_create(acct_list); itr2 = list_iterator_create(print_fields_list); - while((acct = list_next(itr))) { - while((field = list_next(itr2))) { + while ((acct = list_next(itr))) { + while ((field = list_next(itr2))) { switch(field->type) { case PRINT_DESC: field->print_routine( @@ -2449,12 +2465,12 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) set = 1; } - if(rc == SLURM_SUCCESS && list_count(slurmdb_assoc_list)) { + if (rc == SLURM_SUCCESS && list_count(slurmdb_assoc_list)) { printf("Account Associations\n"); rc = _print_out_assoc(slurmdb_assoc_list, 0, 1); set = 1; } - if(rc == SLURM_SUCCESS && list_count(user_list)) { + if (rc == SLURM_SUCCESS && list_count(user_list)) { printf("Users\n"); slurm_addto_char_list(format_list, @@ -2466,8 +2482,8 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) itr = list_iterator_create(user_list); itr2 = list_iterator_create(print_fields_list); - while((user = list_next(itr))) { - while((field = list_next(itr2))) { + while ((user = list_next(itr))) { + while ((field = list_next(itr2))) { switch(field->type) { case PRINT_ADMIN: field->print_routine( @@ -2517,19 +2533,19 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) set = 1; } - if(rc == SLURM_SUCCESS && list_count(user_assoc_list)) { + if (rc == SLURM_SUCCESS && list_count(user_assoc_list)) { printf("User Associations\n"); rc = _print_out_assoc(user_assoc_list, 1, 1); set = 1; } END_TIMER2("add cluster"); - if(set) + if (set) info("Done adding cluster in %s", TIME_STR); - if(rc == SLURM_SUCCESS) { - if(set) { - if(commit_check("Would you like to commit changes?")) { + if (rc == SLURM_SUCCESS) { + if (set) { + if (commit_check("Would you like to commit changes?")) { acct_storage_g_commit(db_conn, 1); } else { printf(" Changes Discarded\n"); @@ -2552,12 +2568,12 @@ extern void load_sacctmgr_cfg_file (int argc, char *argv[]) list_destroy(user_list); list_destroy(user_assoc_list); list_destroy(mod_assoc_list); - if(curr_acct_list) + if (curr_acct_list) list_destroy(curr_acct_list); - if(curr_assoc_list) + if (curr_assoc_list) list_destroy(curr_assoc_list); - if(curr_cluster_list) + if (curr_cluster_list) list_destroy(curr_cluster_list); - if(curr_user_list) + if (curr_user_list) list_destroy(curr_user_list); }