diff --git a/src/sacctmgr/account_functions.c b/src/sacctmgr/account_functions.c index befec66362f5a31729da98a10dc1b7baa4e9b574..0e6bf02773e3b4a9437837b1be9ec159c7b60573 100644 --- a/src/sacctmgr/account_functions.c +++ b/src/sacctmgr/account_functions.c @@ -223,40 +223,6 @@ static int _set_rec(int *start, int argc, char *argv[], /* } */ -static void _remove_existing_accounts(List ret_list) -{ - ListIterator itr = NULL; - ListIterator itr2 = NULL; - char *tmp_char = NULL; - acct_account_rec_t *acct = NULL; - acct_association_rec_t *assoc = NULL; - acct_cluster_rec_t *cluster = NULL; - - if(!ret_list) { - error("no return list given"); - return; - } - - itr = list_iterator_create(ret_list); - itr2 = list_iterator_create(sacctmgr_cluster_list); - - while((tmp_char = list_next(itr))) { - if((acct = sacctmgr_find_account(tmp_char))) - sacctmgr_remove_from_list(sacctmgr_account_list, acct); - - list_iterator_reset(itr2); - while((cluster = list_next(itr2))) { - if((assoc = sacctmgr_find_account_base_assoc( - tmp_char, cluster->name))) - sacctmgr_remove_from_list( - sacctmgr_association_list, assoc); - } - } - list_iterator_destroy(itr); - list_iterator_destroy(itr2); -} - - extern int sacctmgr_add_account(int argc, char *argv[]) { int rc = SLURM_SUCCESS; @@ -574,6 +540,7 @@ extern int sacctmgr_list_account(int argc, char *argv[]) acct_cond->acct_list = list_create(slurm_destroy_char); acct_cond->description_list = list_create(slurm_destroy_char); acct_cond->organization_list = list_create(slurm_destroy_char); + acct_cond->with_assocs = with_assoc_flag; acct_cond->assoc_cond = xmalloc(sizeof(acct_association_cond_t)); acct_cond->assoc_cond->user_list = list_create(slurm_destroy_char); @@ -853,7 +820,6 @@ extern int sacctmgr_delete_account(int argc, char *argv[]) list_iterator_destroy(itr); if(commit_check("Would you like to commit changes?")) { acct_storage_g_commit(db_conn, 1); - _remove_existing_accounts(ret_list); } else { printf(" Changes Discarded\n"); acct_storage_g_commit(db_conn, 0); diff --git a/src/sacctmgr/cluster_functions.c b/src/sacctmgr/cluster_functions.c index fb898d6d6c2d70852accad76cfa8b700c0a3b604..44c7d3cef0a0fe61b84b7fbd36aba9f0503f0b8d 100644 --- a/src/sacctmgr/cluster_functions.c +++ b/src/sacctmgr/cluster_functions.c @@ -113,32 +113,6 @@ static int _set_rec(int *start, int argc, char *argv[], } -static void _remove_existing_clusters(List ret_list) -{ - ListIterator itr = NULL; - char *tmp_char = NULL; - acct_cluster_rec_t *cluster = NULL; - acct_association_rec_t *assoc = NULL; - - if(!ret_list) { - error("no return list given"); - return; - } - - - itr = list_iterator_create(ret_list); - while((tmp_char = list_next(itr))) { - if((cluster = sacctmgr_find_cluster(tmp_char))) - sacctmgr_remove_from_list(sacctmgr_cluster_list, - cluster); - - if((assoc = sacctmgr_find_root_assoc(cluster->name))) - sacctmgr_remove_from_list(sacctmgr_association_list, - assoc); - } - list_iterator_destroy(itr); -} - extern int sacctmgr_add_cluster(int argc, char *argv[]) { int rc = SLURM_SUCCESS; @@ -460,7 +434,6 @@ extern int sacctmgr_delete_cluster(int argc, char *argv[]) list_iterator_destroy(itr); if(commit_check("Would you like to commit changes?")) { acct_storage_g_commit(db_conn, 1); - _remove_existing_clusters(ret_list); } else { printf(" Changes Discarded\n"); acct_storage_g_commit(db_conn, 0); diff --git a/src/sacctmgr/common.c b/src/sacctmgr/common.c index fd32c3c72e51c83f6d2a978d7a05c1108be8d3af..3049ab4737dc305f411dc2d00f059631a95db132 100644 --- a/src/sacctmgr/common.c +++ b/src/sacctmgr/common.c @@ -315,38 +315,6 @@ extern int sacctmgr_remove_from_list(List list, void *object) return SLURM_ERROR; } -extern int do_rollback() -{ - if(user_changes) { - list_destroy(sacctmgr_user_list); - sacctmgr_user_list = acct_storage_g_get_users(db_conn, - NULL); - user_changes = 0; - } - - if(account_changes) { - list_destroy(sacctmgr_user_list); - sacctmgr_account_list = acct_storage_g_get_accounts(db_conn, - NULL); - account_changes = 0; - } - - if(cluster_changes) { - list_destroy(sacctmgr_cluster_list); - sacctmgr_cluster_list = acct_storage_g_get_clusters(db_conn, - NULL); - cluster_changes = 0; - } - - if(association_changes) { - list_destroy(sacctmgr_association_list); - sacctmgr_association_list = acct_storage_g_get_associations( - db_conn, NULL); - association_changes = 0; - } - return SLURM_SUCCESS; -} - extern acct_association_rec_t *sacctmgr_find_association(char *user, char *account, char *cluster, diff --git a/src/sacctmgr/sacctmgr.c b/src/sacctmgr/sacctmgr.c index 31fba2239c2b5d415429d0bcad31c2e8b63e40f5..550b295252d0104e9553106fef9ca0e74527e94a 100644 --- a/src/sacctmgr/sacctmgr.c +++ b/src/sacctmgr/sacctmgr.c @@ -57,11 +57,7 @@ int input_words; /* number of words of input permitted */ int one_liner; /* one record per line if =1 */ int quiet_flag; /* quiet=1, verbose=-1, normal=0 */ int rollback_flag; /* immediate execute=1, else = 0 */ -int association_changes = 0; -int account_changes = 0; -int cluster_changes = 0; -int user_changes = 0; -int changes_made = 0; +int with_assoc_flag = 0; List sacctmgr_action_list = NULL; List sacctmgr_user_list = NULL; List sacctmgr_association_list = NULL; @@ -112,7 +108,7 @@ main (int argc, char *argv[]) if (getenv ("SACCTMGR_ALL")) all_flag= 1; - while((opt_char = getopt_long(argc, argv, "ahioqvV", + while((opt_char = getopt_long(argc, argv, "ahioqsvV", long_options, &option_index)) != -1) { switch (opt_char) { case (int)'?': @@ -138,6 +134,9 @@ main (int argc, char *argv[]) case (int)'q': quiet_flag = 1; break; + case (int)'s': + with_assoc_flag = 1; + break; case (int)'v': quiet_flag = -1; break; @@ -308,6 +307,8 @@ _process_command (int argc, char *argv[]) fprintf(stderr, "no input"); } else if (strncasecmp (argv[0], "all", 3) == 0) { all_flag = 1; + } else if (strncasecmp (argv[0], "associations", 3) == 0) { + with_assoc_flag = 1; } else if (strncasecmp (argv[0], "exit", 1) == 0) { exit_flag = 1; } else if (strncasecmp (argv[0], "help", 2) == 0) { diff --git a/src/sacctmgr/sacctmgr.h b/src/sacctmgr/sacctmgr.h index a173098bff636f4dd16e95c9ac98ff9b9f3a9816..bd2505a610261d149426e9295ca8474770e71c58 100644 --- a/src/sacctmgr/sacctmgr.h +++ b/src/sacctmgr/sacctmgr.h @@ -118,6 +118,7 @@ extern int input_words; /* number of words of input permitted */ extern int one_liner; /* one record per line if =1 */ extern int quiet_flag; /* quiet=1, verbose=-1, normal=0 */ extern int rollback_flag;/* immediate execute=0, else = 1 */ +extern int with_assoc_flag;/* show acct/user associations flag */ extern int association_changes; extern int account_changes; extern int cluster_changes; @@ -160,7 +161,6 @@ extern int notice_thread_fini(); extern int commit_check(char *warning); extern int sacctmgr_init(); extern int sacctmgr_remove_from_list(List list, void *object); -extern int do_rollback(); /* do not free the objects returned from these functions */ extern acct_association_rec_t *sacctmgr_find_association(char *user, diff --git a/src/sacctmgr/user_functions.c b/src/sacctmgr/user_functions.c index 6e139d1fcd19aa19086a73b8edf622e1f743926b..a7cb315cac408872ba35a4213136c85d00553484 100644 --- a/src/sacctmgr/user_functions.c +++ b/src/sacctmgr/user_functions.c @@ -221,25 +221,6 @@ static int _set_rec(int *start, int argc, char *argv[], /* acct_admin_level_str(user->admin_level)); */ /* } */ -static void _remove_existing_users(List ret_list) -{ - ListIterator itr = NULL; - char *tmp_char = NULL; - acct_user_rec_t *user = NULL; - - if(!ret_list) { - error("no return list given"); - return; - } - - itr = list_iterator_create(ret_list); - while((tmp_char = list_next(itr))) { - if((user = sacctmgr_find_user(tmp_char))) - sacctmgr_remove_from_list(sacctmgr_cluster_list, user); - } - list_iterator_destroy(itr); -} - extern int sacctmgr_add_user(int argc, char *argv[]) { int rc = SLURM_SUCCESS; @@ -608,6 +589,7 @@ extern int sacctmgr_list_user(int argc, char *argv[]) user_cond->user_list = list_create(slurm_destroy_char); user_cond->def_acct_list = list_create(slurm_destroy_char); + user_cond->with_assocs = with_assoc_flag; user_cond->assoc_cond = xmalloc(sizeof(acct_association_cond_t)); user_cond->assoc_cond->user_list = list_create(slurm_destroy_char); @@ -886,7 +868,6 @@ extern int sacctmgr_delete_user(int argc, char *argv[]) list_iterator_destroy(itr); if(commit_check("Would you like to commit changes?")) { acct_storage_g_commit(db_conn, 1); - _remove_existing_users(ret_list); } else { printf(" Changes Discarded\n"); acct_storage_g_commit(db_conn, 0);