void get_command(void) { char com[255]; int text_width, text_startx; allocated_block_t *allocated_block = NULL; int i = 0; int count = 0; WINDOW *command_win = NULL; List allocated_blocks = NULL; ListIterator results_i; if (params.commandline && !params.command) { printf("Configure won't work with commandline mode.\n"); printf("Please remove the -c from the commandline.\n"); bg_configure_ba_fini(); exit(0); } if (working_cluster_rec) { char *cluster_name = slurm_get_cluster_name(); if (strcmp(working_cluster_rec->name, cluster_name)) { xfree(cluster_name); endwin(); printf("To use the configure option you must be on the " "cluster the configure is for.\nCross cluster " "support doesn't exist today.\nSorry for the " "inconvenince.\n"); bg_configure_ba_fini(); exit(0); } xfree(cluster_name); } /* make sure we don't get any noisy debug */ ba_configure_set_ba_debug_flags(0); bg_configure_ba_setup_wires(); color_count = 0; allocated_blocks = list_create(_destroy_allocated_block); if (params.commandline) { snprintf(com, sizeof(com), "%s", params.command); goto run_command; } else { text_width = text_win->_maxx; text_startx = text_win->_begx; command_win = newwin(3, text_width - 1, LINES - 4, text_startx + 1); curs_set(1); echo(); } while (strcmp(com, "quit")) { clear_window(grid_win); print_grid(); clear_window(text_win); box(text_win, 0, 0); box(grid_win, 0, 0); if (!params.no_header) _print_header_command(); if (error_string != NULL) { i = 0; while (error_string[i] != '\0') { if (error_string[i] == '\n') { main_ycord++; main_xcord=1; i++; } mvwprintw(text_win, main_ycord, main_xcord, "%c", error_string[i++]); main_xcord++; } main_ycord++; main_xcord = 1; memset(error_string, 0, 255); } results_i = list_iterator_create(allocated_blocks); count = list_count(allocated_blocks) - (LINES-(main_ycord+5)); if (count<0) count=0; i=0; while ((allocated_block = list_next(results_i)) != NULL) { if (i >= count) _print_text_command(allocated_block); i++; } list_iterator_destroy(results_i); wnoutrefresh(text_win); wnoutrefresh(grid_win); doupdate(); clear_window(command_win); box(command_win, 0, 0); mvwprintw(command_win, 0, 3, "Input Command: (type quit to change view, " "exit to exit)"); wmove(command_win, 1, 1); wgetstr(command_win, com); if (!strcmp(com, "exit")) { endwin(); if (allocated_blocks) list_destroy(allocated_blocks); bg_configure_ba_fini(); exit(0); } run_command: if (!strcmp(com, "quit") || !strcmp(com, "\\q")) { break; } else if (!strncasecmp(com, "layout", 6)) { _set_layout(com); } else if (!strncasecmp(com, "basepartition", 13)) { _set_base_part_cnt(com); } else if (!strncasecmp(com, "nodecard", 8)) { _set_nodecard_cnt(com); } else if (!strncasecmp(com, "resolve", 7) || !strncasecmp(com, "r ", 2)) { _resolve(com); } else if (!strncasecmp(com, "resume", 6)) { mvwprintw(text_win, main_ycord, main_xcord, "%s", com); } else if (!strncasecmp(com, "drain", 5)) { mvwprintw(text_win, main_ycord, main_xcord, "%s", com); } else if (!strncasecmp(com, "alldown", 7)) { _change_state_all_bps(com, NODE_STATE_DOWN); } else if (!strncasecmp(com, "down", 4)) { _change_state_bps(com, NODE_STATE_DOWN); } else if (!strncasecmp(com, "allup", 5)) { _change_state_all_bps(com, NODE_STATE_IDLE); } else if (!strncasecmp(com, "up", 2)) { _change_state_bps(com, NODE_STATE_IDLE); } else if (!strncasecmp(com, "remove", 6) || !strncasecmp(com, "delete", 6) || !strncasecmp(com, "drop", 4)) { _remove_allocation(com, allocated_blocks); } else if (!strncasecmp(com, "create", 6)) { _create_allocation(com, allocated_blocks); } else if (!strncasecmp(com, "copy", 4) || !strncasecmp(com, "c ", 2) || !strncasecmp(com, "c\0", 2)) { _copy_allocation(com, allocated_blocks); } else if (!strncasecmp(com, "save", 4)) { _save_allocation(com, allocated_blocks); } else if (!strncasecmp(com, "load", 4)) { _load_configuration(com, allocated_blocks); } else if (!strncasecmp(com, "clear all", 9) || !strncasecmp(com, "clear", 5)) { list_flush(allocated_blocks); } else { memset(error_string, 0, 255); sprintf(error_string, "Unknown command '%s'",com); } if (params.commandline) { bg_configure_ba_fini(); exit(1); } } if (allocated_blocks) list_destroy(allocated_blocks); params.display = 0; noecho(); clear_window(text_win); main_xcord = 1; main_ycord = 1; curs_set(0); print_date(); get_job(); return; }
extern char *resolve_mp(char *desc, node_info_msg_t *node_info_ptr) { char *ret_str = NULL; #if defined HAVE_BG_FILES ba_mp_t *ba_mp = NULL; int i, start_pos; char *name; if (!desc) { ret_str = xstrdup("No Description given.\n"); goto fini; } start_pos = strlen(desc) - params.cluster_dims; if (start_pos < 0) { ret_str = xstrdup_printf("Must enter %d coords to resolve.\n", params.cluster_dims); goto fini; } if (desc[0] != 'R') name = desc+start_pos; else name = desc; if (node_info_ptr) { for (i=0; i<node_info_ptr->record_count; i++) { char *rack_mid, *node_geo; node_info_t *node_ptr = &(node_info_ptr->node_array[i]); if (!node_ptr->name || (node_ptr->name[0] == '\0')) continue; start_pos = strlen(node_ptr->name) - params.cluster_dims; node_geo = node_ptr->name+start_pos; slurm_get_select_nodeinfo(node_ptr->select_nodeinfo, SELECT_NODEDATA_RACK_MP, 0, &rack_mid); if (!rack_mid) break; if (desc[0] != 'R') { if (!xstrcasecmp(name, node_geo)) ret_str = xstrdup_printf( "%s resolves to %s\n", node_geo, rack_mid); } else if (!xstrcasecmp(name, rack_mid)) ret_str = xstrdup_printf( "%s resolves to %s\n", rack_mid, node_geo); xfree(rack_mid); if (ret_str) return ret_str; } if (desc[0] != 'R') ret_str = xstrdup_printf("%s has no resolve\n", name); else ret_str = xstrdup_printf("%s has no resolve.\n", desc); return ret_str; } /* Quite any errors that could come our way here. */ ba_configure_set_ba_debug_flags(0); bg_configure_ba_setup_wires(); if (desc[0] != 'R') { ba_mp = bg_configure_str2ba_mp(name); if (ba_mp) ret_str = xstrdup_printf("%s resolves to %s\n", ba_mp->coord_str, ba_mp->loc); else ret_str = xstrdup_printf("%s has no resolve\n", name); } else { ba_mp = bg_configure_loc2ba_mp(desc); if (ba_mp) ret_str = xstrdup_printf("%s resolves to %s\n", desc, ba_mp->coord_str); else ret_str = xstrdup_printf("%s has no resolve.\n", desc); } fini: #else ret_str = xstrdup("Must be physically on a BlueGene system for support " "of resolve option.\n"); #endif return ret_str; }