Exemple #1
0
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;

	if (!desc) {
		ret_str = xstrdup("No Description given.\n");
		goto fini;
	}

#ifdef HAVE_BG
	bg_configure_ba_setup_wires();
#endif
	i = strlen(desc) - params.cluster_dims;
	if (i < 0) {
		ret_str = xstrdup_printf("Must enter %d coords to resolve.\n",
					 params.cluster_dims);
		goto fini;
	}

	if (desc[0] != 'R') {
		ba_mp = bg_configure_str2ba_mp(desc+i);
		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", desc+i);
	} 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;
}
Exemple #2
0
/* Build the smap_system_ptr structure from the node records */
extern void init_grid(node_info_msg_t *node_info_ptr, int cols)
{
	int i, j, len;
	int default_y_offset = 0;
	smap_node_t *smap_node;

	smap_system_ptr = xmalloc(sizeof(smap_system_t));

	if (!node_info_ptr) {
		if (params.display != COMMANDS)
			return;
#ifdef HAVE_BG
		uint16_t coords[params.cluster_dims];

		smap_system_ptr->node_cnt = 1;
		for (i=0; i<params.cluster_dims; i++)
			smap_system_ptr->node_cnt *= dim_size[i];
		smap_system_ptr->grid = xmalloc(sizeof(smap_node_t *) *
						smap_system_ptr->node_cnt);
		/* We need to make sure we set up the wires if we
		   don't have a node_info_ptr.
		*/
		bg_configure_ba_setup_wires();

		_internal_setup_grid(0, coords);
#endif
	} else {
		smap_system_ptr->grid = xmalloc(sizeof(smap_node_t *) *
						node_info_ptr->record_count);
		for (i = 0; i < node_info_ptr->record_count; i++) {
			node_info_t *node_ptr = &node_info_ptr->node_array[i];

			if ((node_ptr->name == NULL) ||
			    (node_ptr->name[0] == '\0'))
				continue;

			smap_node = xmalloc(sizeof(smap_node_t));

			len = strlen(node_ptr->name);
			if (params.cluster_dims == 1) {
				smap_node->coord = xmalloc(sizeof(uint16_t));
				j = len - 1;
				while ((node_ptr->name[j] >= '0') &&
				       (node_ptr->name[j] <= '9')) {
					smap_node->coord[0] *= 10;
					smap_node->coord[0] +=
						node_ptr->name[j] - '0';
					j++;
				}
			} else if (params.cluster_flags & CLUSTER_FLAG_CRAY) {
				int len_a, len_h;
				len_a = strlen(node_ptr->node_addr);
				len_h = strlen(node_ptr->node_hostname);
				if (len_a < params.cluster_dims) {
					printf("Invalid node addr %s\n",
					       node_ptr->node_addr);
					xfree(smap_node);
					continue;
				}
				if (len_h < 1) {
					printf("Invalid node hostname %s\n",
					       node_ptr->node_hostname);
					xfree(smap_node);
					continue;
				}
				smap_node->coord = xmalloc(sizeof(uint16_t) *
							   params.cluster_dims);
				len_a -= params.cluster_dims;
				for (j = 0; j < params.cluster_dims; j++) {
					smap_node->coord[j] = select_char2coord(
						node_ptr->node_addr[len_a+j]);
				}
			} else {
				len -= params.cluster_dims;
				if (len < 0) {
					printf("Invalid node name: %s.\n",
					       node_ptr->name);
					xfree(smap_node);
					continue;
				}
				smap_node->coord = xmalloc(sizeof(uint16_t) *
							   params.cluster_dims);
				for (j = 0; j < params.cluster_dims; j++) {
					smap_node->coord[j] = select_char2coord(
						node_ptr->name[len+j]);
				}
			}
			smap_node->index = i;
			smap_node->state = node_ptr->node_state;
			smap_system_ptr->grid[i] = smap_node;
			smap_system_ptr->node_cnt++;
		}
	}

	if (params.cluster_dims == 3) {
		default_y_offset = (dim_size[2] * dim_size[1]) +
				   (dim_size[1] - dim_size[2]);
	} else if (params.cluster_dims == 4) {
		default_y_offset = (dim_size[3] * dim_size[2]) +
				   (dim_size[2] - dim_size[3]);
	}
	if (cols == 0)
		cols = 80;
	for (i = 0; i < smap_system_ptr->node_cnt; i++) {
		smap_node = smap_system_ptr->grid[i];
		if (!smap_node)		/* Null node name */
			continue;
		if (params.cluster_dims == 1) {
			smap_node->grid_xcord = (i % cols) + 1;
			smap_node->grid_ycord = (i / cols) + 1;
		} else if (params.cluster_dims == 2) {
			smap_node->grid_xcord = smap_node->coord[0] + 1;
			smap_node->grid_ycord =
				dim_size[1] - smap_node->coord[1];
		} else if (params.cluster_dims == 3) {
			_calc_coord_3d(smap_node->coord[0], smap_node->coord[1],
				       smap_node->coord[2],
				       default_y_offset,
				       &smap_node->grid_xcord,
				       &smap_node->grid_ycord, dim_size);
		} else if (params.cluster_dims == 4) {
			_calc_coord_4d(smap_node->coord[0], smap_node->coord[1],
				       smap_node->coord[2], smap_node->coord[3],
				       default_y_offset,
				       &smap_node->grid_xcord,
				       &smap_node->grid_ycord, dim_size);
		}
	}
}
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;
}
Exemple #4
0
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;
}