extern int sacctmgr_list_problem(int argc, char *argv[]) { int rc = SLURM_SUCCESS; slurmdb_association_cond_t *assoc_cond = xmalloc(sizeof(slurmdb_association_cond_t)); List assoc_list = NULL; slurmdb_association_rec_t *assoc = NULL; int i=0; ListIterator itr = NULL; ListIterator itr2 = NULL; List tree_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, assoc_cond, format_list); } if (exit_code) { slurmdb_destroy_association_cond(assoc_cond); list_destroy(format_list); return SLURM_ERROR; } else if (!list_count(format_list)) slurm_addto_char_list(format_list, "Cl,Acct,User,Problem"); print_fields_list = sacctmgr_process_format_list(format_list); list_destroy(format_list); if (exit_code) { slurmdb_destroy_association_cond(assoc_cond); list_destroy(print_fields_list); return SLURM_ERROR; } assoc_list = acct_storage_g_get_problems(db_conn, my_uid, assoc_cond); slurmdb_destroy_association_cond(assoc_cond); if (!assoc_list) { exit_code=1; fprintf(stderr, " Error with request: %s\n", slurm_strerror(errno)); list_destroy(print_fields_list); return SLURM_ERROR; } itr = list_iterator_create(assoc_list); itr2 = list_iterator_create(print_fields_list); print_fields_header(print_fields_list); field_count = list_count(print_fields_list); while((assoc = list_next(itr))) { int curr_inx = 1; while((field = list_next(itr2))) { switch(field->type) { case PRINT_ACCT: field->print_routine( field, assoc->acct, (curr_inx == field_count)); break; case PRINT_CLUSTER: field->print_routine( field, assoc->cluster, (curr_inx == field_count)); break; case PRINT_PROBLEM: /* make some sort of string here to print out the problem reported. Maybe make an array or something and just print out a standard error. */ field->print_routine( field, slurmdb_problem_str_get(assoc->id), (curr_inx == field_count)); break; case PRINT_USER: field->print_routine(field, assoc->user, (curr_inx == field_count)); break; default: field->print_routine( field, NULL, (curr_inx == field_count)); break; } curr_inx++; } list_iterator_reset(itr2); printf("\n"); } if (tree_list) list_destroy(tree_list); list_iterator_destroy(itr2); list_iterator_destroy(itr); list_destroy(assoc_list); list_destroy(print_fields_list); tree_display = 0; return rc; }
/* * get info from the storage * IN: slurmdb_association_cond_t * * RET: List of slurmdb_association_rec_t * * note List needs to be freed when called */ extern List slurmdb_problems_get(void *db_conn, slurmdb_association_cond_t *assoc_cond) { return acct_storage_g_get_problems(db_conn, getuid(), assoc_cond); }