From 6a67d20e39306d9740794fbc045506c3bb2adca0 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Mon, 23 Oct 2006 19:15:54 +0000
Subject: [PATCH] fix for displaying job and other info for bluegene blocks

---
 src/sview/block_info.c | 55 ++++++++++++++++++------------------------
 src/sview/grid.c       |  4 ++-
 src/sview/job_info.c   | 12 +++++++++
 src/sview/sview.h      |  1 +
 4 files changed, 40 insertions(+), 32 deletions(-)

diff --git a/src/sview/block_info.c b/src/sview/block_info.c
index 8b63559ebe4..1b957256c0e 100644
--- a/src/sview/block_info.c
+++ b/src/sview/block_info.c
@@ -186,9 +186,7 @@ static void _layout_block_record(GtkTreeView *treeview,
 				 sview_block_info_t *block_ptr, 
 				 int update)
 {
-	char *nodes = NULL;
 	char tmp_cnt[7];
-	char tmp_nodes[30];
 	GtkTreeIter iter;
 	GtkTreeStore *treestore = 
 		GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
@@ -217,31 +215,17 @@ static void _layout_block_record(GtkTreeView *treeview,
 	add_display_treestore_line(update, treestore, &iter, 
 				   display_data_block[SORTID_NODES].name,
 				   tmp_cnt);
-	
-	nodes = block_ptr->nodes;		
-	
-	if(block_ptr->quarter != (uint16_t) NO_VAL) {
-		if(block_ptr->nodecard != (uint16_t) NO_VAL)
-			sprintf(tmp_nodes, "%s.%d.%d", nodes,
-				block_ptr->quarter,
-				block_ptr->nodecard);
-		else
-			sprintf(tmp_nodes, "%s.%d", nodes,
-				block_ptr->quarter);
-		nodes = tmp_nodes;
-	} 
+		
 	add_display_treestore_line(update, treestore, &iter, 
 				   display_data_block[SORTID_NODELIST].name,
-				   nodes);
+				   block_ptr->nodes);
 
 }
 
 static void _update_block_record(sview_block_info_t *block_ptr, 
 				 GtkTreeStore *treestore, GtkTreeIter *iter)
 {
-	char *nodes = NULL;
 	char tmp_cnt[7];
-	char tmp_nodes[30];
 	
 	gtk_tree_store_set(treestore, iter, SORTID_POINTER, block_ptr, -1);
 	gtk_tree_store_set(treestore, iter, SORTID_BLOCK, 
@@ -260,18 +244,8 @@ static void _update_block_record(sview_block_info_t *block_ptr,
 	convert_num_unit((float)block_ptr->node_cnt, tmp_cnt, UNIT_NONE);
 	gtk_tree_store_set(treestore, iter, SORTID_NODES, tmp_cnt, -1);
 
-	nodes = block_ptr->nodes;			
-	if(block_ptr && (block_ptr->quarter != (uint16_t) NO_VAL)) {
-		if(block_ptr->nodecard != (uint16_t) NO_VAL)
-			sprintf(tmp_nodes, "%s.%d.%d", nodes,
-				block_ptr->quarter,
-				block_ptr->nodecard);
-		else
-			sprintf(tmp_nodes, "%s.%d", nodes,
-				block_ptr->quarter);
-		nodes = tmp_nodes;
-	} 
-	gtk_tree_store_set(treestore, iter, SORTID_NODELIST, nodes, -1);
+	gtk_tree_store_set(treestore, iter, SORTID_NODELIST,
+			   block_ptr->nodes, -1);
 
 	gtk_tree_store_set(treestore, iter, SORTID_UPDATED, 1, -1);
 	
@@ -378,6 +352,8 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr,
 	static List block_list = NULL;
 	partition_info_t part;
 	sview_block_info_t *block_ptr = NULL;
+	char *nodes = NULL;
+	char tmp_nodes[50];
 	
 	if(!changed && block_list) {
 		return block_list;
@@ -413,6 +389,22 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr,
 			= node_select_ptr->bg_info_array[i].quarter;
 		block_ptr->nodecard 
 			= node_select_ptr->bg_info_array[i].nodecard;
+
+		if(block_ptr->quarter != (uint16_t) NO_VAL) {
+			nodes = block_ptr->nodes;		
+			if(block_ptr->nodecard != (uint16_t) NO_VAL)
+				snprintf(tmp_nodes,  sizeof(tmp_nodes),
+					 "%s.%d.%d", nodes,
+					 block_ptr->quarter,
+					 block_ptr->nodecard);
+			else
+				snprintf(tmp_nodes, sizeof(tmp_nodes),
+					 "%s.%d", nodes,
+					 block_ptr->quarter);
+			xfree(block_ptr->nodes);
+			block_ptr->nodes = xstrdup(tmp_nodes);
+		}
+
 		block_ptr->node_cnt 
 			= node_select_ptr->bg_info_array[i].node_cnt;
 		block_ptr->bp_inx 
@@ -467,7 +459,8 @@ need_refresh:
 	itr = list_iterator_create(block_list);
 	while ((block_ptr = (sview_block_info_t*) list_next(itr))) {
 		i++;
-		if(!strcmp(block_ptr->bg_block_name, name)) {
+		if(!strcmp(block_ptr->bg_block_name, name)
+		   || !strcmp(block_ptr->nodes, name)) {
 			j = 0;
 			while(block_ptr->bp_inx[j] >= 0) {
 				change_grid_color(
diff --git a/src/sview/grid.c b/src/sview/grid.c
index 02fe2ba5403..6711f60cbcd 100644
--- a/src/sview/grid.c
+++ b/src/sview/grid.c
@@ -99,7 +99,7 @@ static void _open_block(GtkWidget *widget, GdkEventButton *event,
 	popup_info_t *popup_win = NULL;
 
 	snprintf(title, 100, 
-		 "Info about block %s", grid_button->node_name);
+		 "Info about block containing %s", grid_button->node_name);
 
 	itr = list_iterator_create(popup_list);
 	while((popup_win = list_next(itr))) {
@@ -112,6 +112,8 @@ static void _open_block(GtkWidget *widget, GdkEventButton *event,
 
 	if(!popup_win) {
 		popup_win = create_popup_info(INFO_PAGE, BLOCK_PAGE, title);
+		popup_win->spec_info->search_info->search_type =
+			SEARCH_BLOCK_NODENAME;
 		popup_win->spec_info->search_info->gchar_data =
 			g_strdup(grid_button->node_name);
 		if (!g_thread_create((gpointer)popup_thr, popup_win,
diff --git a/src/sview/job_info.c b/src/sview/job_info.c
index 5ed7cef79d1..f8acf7be521 100644
--- a/src/sview/job_info.c
+++ b/src/sview/job_info.c
@@ -313,6 +313,12 @@ static void _layout_job_record(GtkTreeView *treeview,
 				   job_state_string(job_ptr->job_state));
 	
 #ifdef HAVE_BG
+	select_g_get_jobinfo(job_ptr->select_jobinfo, 
+			     SELECT_DATA_QUARTER, 
+			     &quarter);
+	select_g_get_jobinfo(job_ptr->select_jobinfo, 
+			     SELECT_DATA_NODECARD, 
+			     &nodecard);
 	select_g_get_jobinfo(job_ptr->select_jobinfo, 
 			     SELECT_DATA_NODE_CNT, 
 			     &node_cnt);
@@ -410,6 +416,12 @@ static void _update_job_record(sview_job_info_t *sview_job_info_ptr,
 			   job_state_string(job_ptr->job_state), -1);
 	
 #ifdef HAVE_BG
+	select_g_get_jobinfo(job_ptr->select_jobinfo, 
+			     SELECT_DATA_QUARTER, 
+			     &quarter);
+	select_g_get_jobinfo(job_ptr->select_jobinfo, 
+			     SELECT_DATA_NODECARD, 
+			     &nodecard);
 	select_g_get_jobinfo(job_ptr->select_jobinfo, 
 			     SELECT_DATA_NODE_CNT, 
 			     &node_cnt);
diff --git a/src/sview/sview.h b/src/sview/sview.h
index e5149955fc9..eb5761ed83c 100644
--- a/src/sview/sview.h
+++ b/src/sview/sview.h
@@ -104,6 +104,7 @@ typedef enum { SEARCH_JOB_ID = 1,
 	       SEARCH_JOB_USER,
 	       SEARCH_JOB_STATE,
 	       SEARCH_BLOCK_NAME,
+	       SEARCH_BLOCK_NODENAME,
 	       SEARCH_BLOCK_SIZE,
 	       SEARCH_BLOCK_STATE,
 	       SEARCH_PARTITION_NAME,
-- 
GitLab