extern int sacctmgr_archive_load(int argc, char **argv) { int rc = SLURM_SUCCESS; slurmdb_archive_rec_t *arch_rec = xmalloc(sizeof(slurmdb_archive_rec_t)); int i, command_len = 0; struct stat st; for (i = 0; i < argc; i++) { int end = parse_option_end(argv[i]); if (!end) command_len=strlen(argv[i]); else { command_len=end-1; if (argv[i][end] == '=') { end++; } } if (!end || !strncasecmp (argv[i], "File", MAX(command_len, 1))) { arch_rec->archive_file = strip_quotes(argv[i]+end, NULL, 0); } else if (!strncasecmp (argv[i], "Insert", MAX(command_len, 2))) { arch_rec->insert = strip_quotes(argv[i]+end, NULL, 1); } else { exit_code = 1; fprintf(stderr, " Unknown option: %s\n", argv[i]); } } if (exit_code) { slurmdb_destroy_archive_rec(arch_rec); return SLURM_ERROR; } if (arch_rec->archive_file) { char *fullpath; char cwd[MAXPATHLEN + 1]; int mode = F_OK; if ((getcwd(cwd, MAXPATHLEN)) == NULL) fatal("getcwd failed: %m"); if ((fullpath = search_path(cwd, arch_rec->archive_file, true, mode, false))) { xfree(arch_rec->archive_file); arch_rec->archive_file = fullpath; } if (stat(arch_rec->archive_file, &st) < 0) { exit_code = errno; fprintf(stderr, " load: Failed to stat %s: %s\n " "Note: For archive load, the file must be on " "the calling host.\n", arch_rec->archive_file, slurm_strerror(errno)); slurmdb_destroy_archive_rec(arch_rec); return SLURM_ERROR; } } rc = jobacct_storage_g_archive_load(db_conn, arch_rec); 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 loading archive file: %s\n", slurm_strerror(rc)); rc = SLURM_ERROR; } slurmdb_destroy_archive_rec(arch_rec); return rc; }
extern int sacctmgr_archive_dump(int argc, char *argv[]) { int rc = SLURM_SUCCESS; slurmdb_archive_cond_t *arch_cond = xmalloc(sizeof(slurmdb_archive_cond_t)); int i=0; struct stat st; 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, arch_cond); } if (!arch_cond->purge_event) arch_cond->purge_event = NO_VAL; if (!arch_cond->purge_job) arch_cond->purge_job = NO_VAL; if (!arch_cond->purge_resv) arch_cond->purge_resv = NO_VAL; if (!arch_cond->purge_step) arch_cond->purge_step = NO_VAL; if (!arch_cond->purge_suspend) arch_cond->purge_suspend = NO_VAL; if (exit_code) { slurmdb_destroy_archive_cond(arch_cond); return SLURM_ERROR; } if (arch_cond->archive_dir) { if (stat(arch_cond->archive_dir, &st) < 0) { exit_code = errno; fprintf(stderr, " dump: Failed to stat %s: %s\n " "Note: For archive dump, " "the directory must be on " "the calling host.\n", arch_cond->archive_dir, slurm_strerror(errno)); return SLURM_ERROR; } if (!(st.st_mode & S_IFDIR)) { errno = EACCES; fprintf(stderr, " dump: " "archive dir %s isn't a directory\n", arch_cond->archive_dir); return SLURM_ERROR; } if (access(arch_cond->archive_dir, W_OK) < 0) { errno = EACCES; fprintf(stderr, " dump: " "archive dir %s is not writable\n", arch_cond->archive_dir); return SLURM_ERROR; } } if (arch_cond->archive_script) { if (stat(arch_cond->archive_script, &st) < 0) { exit_code = errno; fprintf(stderr, " dump: Failed to stat %s: %s\n " "Note: For archive dump, the script must be on " "the calling host.\n", arch_cond->archive_script, slurm_strerror(errno)); return SLURM_ERROR; } if (!(st.st_mode & S_IFREG)) { errno = EACCES; fprintf(stderr, " dump: " "archive script %s isn't a regular file\n", arch_cond->archive_script); return SLURM_ERROR; } if (access(arch_cond->archive_script, X_OK) < 0) { errno = EACCES; fprintf(stderr, " dump: " "archive script %s is not executable\n", arch_cond->archive_script); return SLURM_ERROR; } } rc = jobacct_storage_g_archive(db_conn, arch_cond); 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 dumping archive: %s\n", slurm_strerror(rc)); rc = SLURM_ERROR; } slurmdb_destroy_archive_cond(arch_cond); return rc; }
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_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_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(!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; }
extern int sacctmgr_modify_job(int argc, char **argv) { int rc = SLURM_SUCCESS; slurmdb_job_modify_cond_t *job_cond = xmalloc(sizeof( slurmdb_job_modify_cond_t)); slurmdb_job_rec_t *job = slurmdb_create_job_rec(); int i=0; int cond_set = 0, rec_set = 0, set = 0; List ret_list = NULL; for (i=0; i<argc; i++) { int command_len = strlen(argv[i]); if (!strncasecmp(argv[i], "Where", MAX(command_len, 5))) { i++; cond_set += _set_cond(&i, argc, argv, job_cond); } else if (!strncasecmp(argv[i], "Set", MAX(command_len, 3))) { i++; rec_set += _set_rec(&i, argc, argv, job); } else { cond_set += _set_cond(&i, argc, argv, job_cond); } } if (exit_code) { slurmdb_destroy_job_modify_cond(job_cond); slurmdb_destroy_job_rec(job); return SLURM_ERROR; } else if (!rec_set) { exit_code=1; fprintf(stderr, " You didn't give me anything to set\n"); slurmdb_destroy_job_modify_cond(job_cond); slurmdb_destroy_job_rec(job); return SLURM_ERROR; } else if (!cond_set) { if (!commit_check("You didn't set any conditions with 'WHERE'." "\nAre you sure you want to continue?")) { printf("Aborted\n"); slurmdb_destroy_job_modify_cond(job_cond); slurmdb_destroy_job_rec(job); return SLURM_SUCCESS; } } notice_thread_init(); ret_list = acct_storage_g_modify_job(db_conn, my_uid, job_cond, job); if (ret_list && list_count(ret_list)) { char *object = NULL; ListIterator itr = list_iterator_create(ret_list); printf(" Modified jobs...\n"); while((object = list_next(itr))) { printf(" %s\n", object); } list_iterator_destroy(itr); set = 1; } else if (ret_list) { printf(" Nothing modified\n"); rc = SLURM_ERROR; } else { exit_code=1; fprintf(stderr, " Error with request: %s\n", slurm_strerror(errno)); rc = SLURM_ERROR; } FREE_NULL_LIST(ret_list); notice_thread_fini(); if (set) { 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); } } slurmdb_destroy_job_modify_cond(job_cond); slurmdb_destroy_job_rec(job); return rc; }
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; }
extern int sacctmgr_delete_federation(int argc, char **argv) { int rc = SLURM_SUCCESS; slurmdb_federation_cond_t *fed_cond = xmalloc(sizeof(slurmdb_federation_cond_t)); int i=0; List ret_list = NULL; int cond_set = 0, prev_set; slurmdb_init_federation_cond(fed_cond, 0); fed_cond->federation_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++; prev_set = _set_cond(&i, argc, argv, fed_cond, NULL); cond_set |= prev_set; } if (exit_code) { slurmdb_destroy_federation_cond(fed_cond); return SLURM_ERROR; } else if (!cond_set) { exit_code=1; fprintf(stderr, " No conditions given to remove, not executing.\n"); slurmdb_destroy_federation_cond(fed_cond); return SLURM_ERROR; } if (!list_count(fed_cond->federation_list)) { exit_code=1; fprintf(stderr, "problem with delete request. " "Nothing given to delete.\n"); slurmdb_destroy_federation_cond(fed_cond); return SLURM_SUCCESS; } notice_thread_init(); ret_list = acct_storage_g_remove_federations(db_conn, my_uid, fed_cond); rc = errno; notice_thread_fini(); slurmdb_destroy_federation_cond(fed_cond); if (ret_list && list_count(ret_list)) { char *object = NULL; ListIterator itr = list_iterator_create(ret_list); printf(" Deleting federations...\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"); rc = SLURM_ERROR; } else { exit_code=1; fprintf(stderr, " Error with request: %s\n", slurm_strerror(errno)); rc = SLURM_ERROR; } FREE_NULL_LIST(ret_list); return rc; }
extern int sacctmgr_modify_federation(int argc, char **argv) { int rc = SLURM_SUCCESS; int i=0; int cond_set = 0, prev_set = 0, rec_set = 0, set = 0; List ret_list = NULL; slurmdb_federation_cond_t *federation_cond = xmalloc(sizeof(slurmdb_federation_cond_t)); slurmdb_federation_rec_t *federation = xmalloc(sizeof(slurmdb_federation_rec_t)); slurmdb_init_federation_cond(federation_cond, 0); slurmdb_init_federation_rec(federation, 0); for (i=0; i<argc; i++) { int command_len = strlen(argv[i]); if (!strncasecmp(argv[i], "Where", MAX(command_len, 5))) { i++; prev_set = _set_cond(&i, argc, argv, federation_cond, NULL); cond_set |= prev_set; } else if (!strncasecmp(argv[i], "Set", MAX(command_len, 3))) { i++; prev_set = _set_rec(&i, argc, argv, NULL, federation); rec_set |= prev_set; } else { prev_set = _set_cond(&i, argc, argv, federation_cond, NULL); cond_set |= prev_set; } } if (exit_code) { rc = SLURM_ERROR; goto end_it; } else if (!rec_set) { exit_code=1; fprintf(stderr, " You didn't give me anything to set\n"); rc = SLURM_ERROR; goto end_it; } else if (!cond_set) { if (!commit_check("You didn't set any conditions " "with 'WHERE'.\n" "Are you sure you want to continue?")) { printf("Aborted\n"); rc = SLURM_SUCCESS; goto end_it; } } else if (verify_federations_exist( federation_cond->federation_list)) { rc = SLURM_ERROR; goto end_it; } if (federation->cluster_list) { bool existing_feds = false; char *mod_fed = NULL; slurmdb_cluster_rec_t *tmp_c = NULL; List cluster_list = federation->cluster_list; if (federation_cond->federation_list && (list_count(federation_cond->federation_list) > 1)) { fprintf(stderr, " Can't assign clusters to " "multiple federations.\n"); rc = SLURM_ERROR; goto end_it; } /* Add all clusters that need to be removed if clearing all * clusters or add clusters that will be removed if setting * clusters to specific set. */ mod_fed = list_peek(federation_cond->federation_list); if ((!list_count(cluster_list) || ((tmp_c = list_peek(cluster_list)) && *tmp_c->name != '-' && *tmp_c->name != '+')) && ((rc = _add_clusters_to_remove(cluster_list, mod_fed)) || (rc = _change_assigns_to_adds(cluster_list)))) { goto end_it; } else if ((rc = verify_fed_clusters(cluster_list, mod_fed, &existing_feds))) { goto end_it; } else if (!list_count(cluster_list)) { printf("Nothing to change\n"); rc = SLURM_ERROR; goto end_it; } else if (existing_feds) { char *warning = "\nAre you sure you want to continue?"; if (!commit_check(warning)) { rc = SLURM_ERROR; goto end_it; } } } printf(" Setting\n"); sacctmgr_print_federation(federation); notice_thread_init(); ret_list = acct_storage_g_modify_federations(db_conn, my_uid, federation_cond, federation); if (ret_list && list_count(ret_list)) { char *object = NULL; ListIterator itr = list_iterator_create(ret_list); printf(" Modified federation...\n"); while((object = list_next(itr))) { printf(" %s\n", object); } list_iterator_destroy(itr); set = 1; } else if (ret_list) { printf(" Nothing modified\n"); rc = SLURM_ERROR; } else { exit_code=1; fprintf(stderr, " Error with request: %s\n", slurm_strerror(errno)); rc = SLURM_ERROR; } FREE_NULL_LIST(ret_list); notice_thread_fini(); if (set) { 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); } } end_it: slurmdb_destroy_federation_cond(federation_cond); slurmdb_destroy_federation_rec(federation); return rc; }
extern int sacctmgr_add_federation(int argc, char **argv) { int rc = SLURM_SUCCESS; int i = 0, limit_set = 0; slurmdb_federation_rec_t *start_fed = xmalloc(sizeof(slurmdb_federation_rec_t)); List name_list = list_create(slurm_destroy_char); List federation_list; ListIterator itr = NULL; char *name = NULL; slurmdb_init_federation_rec(start_fed, 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_fed); } if (exit_code) { FREE_NULL_LIST(name_list); slurmdb_destroy_federation_rec(start_fed); return SLURM_ERROR; } else if (!list_count(name_list)) { slurmdb_destroy_federation_rec(start_fed); FREE_NULL_LIST(name_list); fprintf(stderr, " Need name of federation to add.\n"); return SLURM_ERROR; } else if (_remove_existing_feds(name_list)) { FREE_NULL_LIST(name_list); slurmdb_destroy_federation_rec(start_fed); return SLURM_ERROR; } if ((list_count(name_list) > 1) && start_fed && start_fed->cluster_list && list_count(start_fed->cluster_list)) { slurmdb_destroy_federation_rec(start_fed); FREE_NULL_LIST(name_list); fprintf(stderr, " Can't assign clusters to multiple " "federations.\n"); return SLURM_ERROR; } if (start_fed && start_fed->cluster_list && list_count(start_fed->cluster_list)) { bool existing_feds = false; if (list_count(name_list) > 1){ slurmdb_destroy_federation_rec(start_fed); FREE_NULL_LIST(name_list); fprintf(stderr, " Can't assign clusters to " "multiple federations.\n"); return SLURM_ERROR; } /* ensure that clusters exist in db */ /* and if the clusters are already assigned to another fed. */ if (verify_fed_clusters(start_fed->cluster_list, NULL, &existing_feds)) { FREE_NULL_LIST(name_list); slurmdb_destroy_federation_rec(start_fed); return SLURM_ERROR; } else if (existing_feds) { char *warning = "\nAre you sure you want to continue?"; if (!commit_check(warning)) { FREE_NULL_LIST(name_list); slurmdb_destroy_federation_rec(start_fed); return SLURM_ERROR; } } } printf(" Adding Federation(s)\n"); federation_list = list_create(slurmdb_destroy_federation_rec); itr = list_iterator_create(name_list); while((name = list_next(itr))) { slurmdb_federation_rec_t *fed = NULL; if (!name[0]) { fprintf(stderr, " Skipping blank fed name.\n"); continue; } fed = xmalloc(sizeof(slurmdb_federation_rec_t)); slurmdb_init_federation_rec(fed, 0); list_append(federation_list, fed); slurmdb_copy_federation_rec(fed, start_fed); fed->name = xstrdup(name); printf(" %s\n", fed->name); } list_iterator_destroy(itr); FREE_NULL_LIST(name_list); if (limit_set) { printf(" Settings\n"); sacctmgr_print_federation(start_fed); } slurmdb_destroy_federation_rec(start_fed); if (!list_count(federation_list)) { printf(" Nothing new added.\n"); rc = SLURM_ERROR; goto end_it; } notice_thread_init(); rc = acct_storage_g_add_federations(db_conn, my_uid, federation_list); 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 federation(s): %s\n", slurm_strerror(rc)); rc = SLURM_ERROR; } end_it: FREE_NULL_LIST(federation_list); return rc; }
/* * _process_command - process the user's command * IN argc - count of arguments * IN argv - the arguments * RET 0 or errno (only for errors fatal to sacctmgr) */ static int _process_command (int argc, char *argv[]) { int command_len = 0; if (argc < 1) { exit_code = 1; if (quiet_flag == -1) fprintf(stderr, "no input"); return 0; } command_len = strlen(argv[0]); if (strncasecmp (argv[0], "associations", MAX(command_len, 3)) == 0) { with_assoc_flag = 1; } else if (strncasecmp (argv[0], "dump", MAX(command_len, 3)) == 0) { sacctmgr_dump_cluster((argc - 1), &argv[1]); } else if (strncasecmp (argv[0], "help", MAX(command_len, 2)) == 0) { if (argc > 1) { exit_code = 1; fprintf (stderr, "too many arguments for keyword:%s\n", argv[0]); } _usage (); } else if (strncasecmp (argv[0], "load", MAX(command_len, 2)) == 0) { load_sacctmgr_cfg_file((argc - 1), &argv[1]); } else if (strncasecmp (argv[0], "oneliner", MAX(command_len, 1)) == 0) { if (argc > 1) { exit_code = 1; fprintf (stderr, "too many arguments for keyword:%s\n", argv[0]); } one_liner = 1; } else if (strncasecmp (argv[0], "quiet", MAX(command_len, 4)) == 0) { if (argc > 1) { exit_code = 1; fprintf (stderr, "too many arguments for keyword:%s\n", argv[0]); } quiet_flag = 1; } else if ((strncasecmp (argv[0], "exit", MAX(command_len, 4)) == 0) || (strncasecmp (argv[0], "\\q", MAX(command_len, 2)) == 0) || (strncasecmp (argv[0], "quit", MAX(command_len, 4)) == 0)) { if (argc > 1) { exit_code = 1; fprintf (stderr, "too many arguments for keyword:%s\n", argv[0]); } exit_flag = 1; } else if ((strncasecmp (argv[0], "add", MAX(command_len, 3)) == 0) || (strncasecmp (argv[0], "create", MAX(command_len, 3)) == 0)) { _add_it((argc - 1), &argv[1]); } else if ((strncasecmp (argv[0], "archive", MAX(command_len, 3)) == 0)) { _archive_it((argc - 1), &argv[1]); } else if ((strncasecmp (argv[0], "show", MAX(command_len, 3)) == 0) || (strncasecmp (argv[0], "list", MAX(command_len, 3)) == 0)) { _show_it((argc - 1), &argv[1]); } else if (!strncasecmp (argv[0], "modify", MAX(command_len, 1)) || !strncasecmp (argv[0], "update", MAX(command_len, 1))) { _modify_it((argc - 1), &argv[1]); } else if ((strncasecmp (argv[0], "delete", MAX(command_len, 3)) == 0) || (strncasecmp (argv[0], "remove", MAX(command_len, 3)) == 0)) { _delete_it((argc - 1), &argv[1]); } else if (strncasecmp (argv[0], "verbose", MAX(command_len, 4)) == 0) { if (argc > 1) { exit_code = 1; fprintf (stderr, "too many arguments for %s keyword\n", argv[0]); } quiet_flag = -1; } else if (strncasecmp (argv[0], "readonly", MAX(command_len, 4)) == 0) { if (argc > 1) { exit_code = 1; fprintf (stderr, "too many arguments for %s keyword\n", argv[0]); } readonly_flag = 1; } else if (strncasecmp (argv[0], "reconfigure", MAX(command_len, 4)) == 0) { if (argc > 1) { exit_code = 1; fprintf (stderr, "too many arguments for %s keyword\n", argv[0]); } slurmdb_reconfig(db_conn); } else if (strncasecmp (argv[0], "rollup", MAX(command_len, 2)) == 0) { time_t my_start = 0; time_t my_end = 0; uint16_t archive_data = 0; if (argc > 4) { exit_code = 1; fprintf (stderr, "too many arguments for %s keyword\n", argv[0]); } if (argc > 1) my_start = parse_time(argv[1], 1); if (argc > 2) my_end = parse_time(argv[2], 1); if (argc > 3) archive_data = atoi(argv[3]); if (acct_storage_g_roll_usage(db_conn, my_start, my_end, archive_data) == SLURM_SUCCESS) { if (commit_check("Would you like to commit rollup?")) { acct_storage_g_commit(db_conn, 1); } else { printf(" Rollup Discarded\n"); acct_storage_g_commit(db_conn, 0); } } } else if (strncasecmp (argv[0], "version", MAX(command_len, 4)) == 0) { if (argc > 1) { exit_code = 1; fprintf (stderr, "too many arguments for %s keyword\n", argv[0]); } _print_version(); } else { exit_code = 1; fprintf (stderr, "invalid keyword: %s\n", argv[0]); } return 0; }