From 9de3be8f20ff7f8fa27e48c5d90d00cb7afb0232 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Fri, 26 Sep 2014 11:38:25 -0700
Subject: [PATCH] BGQ - Fix scontrol and sview to print reservations correctly
 for reservations less than a midplane.

---
 src/api/reservation_info.c |  8 ++++++--
 src/sview/common.c         |  9 ++++++---
 src/sview/resv_info.c      | 38 ++++++++++++++++++++++++++++++++------
 3 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/src/api/reservation_info.c b/src/api/reservation_info.c
index e953ba31530..076c6e74559 100644
--- a/src/api/reservation_info.c
+++ b/src/api/reservation_info.c
@@ -109,6 +109,8 @@ char *slurm_sprint_reservation_info ( reserve_info_t * resv_ptr,
 	char *out = NULL;
 	uint32_t duration;
 	time_t now = time(NULL);
+	uint32_t cluster_flags = slurmdb_setup_cluster_flags();
+	bool is_bluegene = cluster_flags & CLUSTER_FLAG_BG;
 
 	/****** Line 1 ******/
 	slurm_make_time_str(&resv_ptr->start_time, tmp1, sizeof(tmp1));
@@ -133,9 +135,11 @@ char *slurm_sprint_reservation_info ( reserve_info_t * resv_ptr,
 	flag_str = reservation_flags_string(resv_ptr->flags);
 
 	snprintf(tmp_line, sizeof(tmp_line),
-		 "Nodes=%s NodeCnt=%u CoreCnt=%u Features=%s "
+		 "%s=%s %sCnt=%u %sCnt=%u Features=%s "
 		 "PartitionName=%s Flags=%s",
-		 resv_ptr->node_list, resv_ptr->node_cnt, resv_ptr->core_cnt,
+		 is_bluegene ? "Midplanes" : "Nodes", resv_ptr->node_list,
+		 is_bluegene ? "Midplane" : "Node", resv_ptr->node_cnt,
+		 is_bluegene ? "Cnode" : "Core", resv_ptr->core_cnt,
 		 resv_ptr->features,  resv_ptr->partition, flag_str);
 	xfree(flag_str);
 	xstrcat(out, tmp_line);
diff --git a/src/sview/common.c b/src/sview/common.c
index 184c310f5d9..bc431722695 100644
--- a/src/sview/common.c
+++ b/src/sview/common.c
@@ -944,13 +944,16 @@ extern void set_page_opts(int page, display_data_t *display_data,
 	itr = list_iterator_create(page_opts->col_list);
 	while ((col_name = list_next(itr))) {
 		replus(col_name);
-		if (strstr(col_name, "list")) {
+		if (strstr(col_name, "list") || strstr(col_name, " count")) {
 			char *orig_ptr = col_name;
 			xstrsubstitute(col_name, "bp ", "midplane");
-			if (cluster_flags & CLUSTER_FLAG_BG)
+			if (cluster_flags & CLUSTER_FLAG_BG) {
 				xstrsubstitute(col_name, "node", "midplane");
-			else
+				xstrsubstitute(col_name, "core", "cnode");
+			} else {
 				xstrsubstitute(col_name, "midplane", "node");
+				xstrsubstitute(col_name, "cnode", "core");
+			}
 
 			/* Make sure we have the correct pointer here
 			   since xstrsubstitute() could of changed it
diff --git a/src/sview/resv_info.c b/src/sview/resv_info.c
index 80861924079..f15d1e6dea2 100644
--- a/src/sview/resv_info.c
+++ b/src/sview/resv_info.c
@@ -54,6 +54,7 @@ enum {
 	SORTID_ACTION,
 	SORTID_COLOR,
 	SORTID_COLOR_INX,
+	SORTID_CORE_CNT,
 	SORTID_DURATION,
 	SORTID_FEATURES,
 	SORTID_FLAGS,
@@ -78,7 +79,7 @@ enum {
 /*these are the settings to apply for the user
  * on the first startup after a fresh slurm install.
  * s/b a const probably*/
-static char *_initial_page_opts = "Name,Node_Count,NodeList,"
+static char *_initial_page_opts = "Name,Node_Count,Core_Count,NodeList,"
 	"Time_Start,Time_End";
 
 static display_data_t display_data_resv[] = {
@@ -90,8 +91,20 @@ static display_data_t display_data_resv[] = {
 	 refresh_resv, create_model_resv, admin_edit_resv},
 	{G_TYPE_STRING, SORTID_ACTION,     "Action", FALSE, EDIT_MODEL,
 	 refresh_resv, create_model_resv, admin_edit_resv},
-	{G_TYPE_STRING, SORTID_NODE_CNT,   "Node Count", FALSE, EDIT_TEXTBOX,
-	 refresh_resv, create_model_resv, admin_edit_resv},
+	{G_TYPE_STRING, SORTID_NODE_CNT,
+#ifdef HAVE_BG
+	 "Midplane Count",
+#else
+	 "Node Count",
+#endif
+	 FALSE, EDIT_TEXTBOX, refresh_resv, create_model_resv, admin_edit_resv},
+	{G_TYPE_STRING, SORTID_CORE_CNT,
+#ifdef HAVE_BG
+	 "Cnode Count",
+#else
+	 "Core Count",
+#endif
+	 FALSE, EDIT_TEXTBOX, refresh_resv, create_model_resv, admin_edit_resv},
 	{G_TYPE_STRING, SORTID_NODELIST,
 #ifdef HAVE_BG
 	 "MidplaneList",
@@ -131,8 +144,10 @@ static display_data_t create_data_resv[] = {
 	 refresh_resv, create_model_resv, admin_edit_resv},
 	{G_TYPE_STRING, SORTID_NAME,  "Name", FALSE, EDIT_TEXTBOX,
 	 refresh_resv, create_model_resv, admin_edit_resv},
-	{G_TYPE_STRING, SORTID_NODE_CNT,   "Node_Count", FALSE, EDIT_TEXTBOX,
-	 refresh_resv, create_model_resv, admin_edit_resv},
+	{G_TYPE_STRING, SORTID_NODE_CNT, "Node_Count",
+	 FALSE, EDIT_TEXTBOX, refresh_resv, create_model_resv, admin_edit_resv},
+	{G_TYPE_STRING, SORTID_NODE_CNT, "Core_Count",
+	 FALSE, EDIT_TEXTBOX, refresh_resv, create_model_resv, admin_edit_resv},
 	{G_TYPE_STRING, SORTID_NODELIST,
 #ifdef HAVE_BG
 	 "Midplane_List",
@@ -554,6 +569,12 @@ static void _layout_resv_record(GtkTreeView *treeview,
 						 SORTID_ACCOUNTS),
 				   resv_ptr->accounts);
 
+	convert_num_unit((float)resv_ptr->core_cnt,
+			 time_buf, sizeof(time_buf), UNIT_NONE);
+	add_display_treestore_line(update, treestore, &iter,
+				   find_col_name(display_data_resv,
+						 SORTID_CORE_CNT),
+				   time_buf);
 	secs2time_str((uint32_t)difftime(resv_ptr->end_time,
 					 resv_ptr->start_time),
 		      time_buf, sizeof(time_buf));
@@ -619,7 +640,8 @@ static void _layout_resv_record(GtkTreeView *treeview,
 static void _update_resv_record(sview_resv_info_t *sview_resv_info_ptr,
 				GtkTreeStore *treestore)
 {
-	char tmp_duration[40], tmp_end[40], tmp_nodes[40], tmp_start[40];
+	char tmp_duration[40], tmp_end[40], tmp_nodes[40], tmp_start[40],
+		tmp_cores[40];
 	char *tmp_flags;
 	reserve_info_t *resv_ptr = sview_resv_info_ptr->resv_ptr;
 
@@ -632,6 +654,9 @@ static void _update_resv_record(sview_resv_info_t *sview_resv_info_ptr,
 
 	tmp_flags = reservation_flags_string(resv_ptr->flags);
 
+	convert_num_unit((float)resv_ptr->core_cnt,
+			 tmp_cores, sizeof(tmp_cores), UNIT_NONE);
+
 	convert_num_unit((float)resv_ptr->node_cnt,
 			 tmp_nodes, sizeof(tmp_nodes), UNIT_NONE);
 
@@ -644,6 +669,7 @@ static void _update_resv_record(sview_resv_info_t *sview_resv_info_ptr,
 			   SORTID_COLOR,
 				sview_colors[sview_resv_info_ptr->color_inx],
 			   SORTID_COLOR_INX,  sview_resv_info_ptr->color_inx,
+			   SORTID_CORE_CNT,   tmp_cores,
 			   SORTID_DURATION,   tmp_duration,
 			   SORTID_FEATURES,   resv_ptr->features,
 			   SORTID_FLAGS,      tmp_flags,
-- 
GitLab