From 12d2c1e5e1101d42a6dc9f490029cd56639e92c8 Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Tue, 25 May 2010 21:44:23 +0000 Subject: [PATCH] ok, start of sview conversion, doesn't do anything yet though --- src/sview/block_info.c | 198 ++++++++++++++++++++++++++--------------- src/sview/sview.c | 151 ++++++++++++++++++++----------- src/sview/sview.h | 7 ++ 3 files changed, 234 insertions(+), 122 deletions(-) diff --git a/src/sview/block_info.c b/src/sview/block_info.c index cec427f273d..d3718597da6 100644 --- a/src/sview/block_info.c +++ b/src/sview/block_info.c @@ -39,9 +39,7 @@ typedef struct { char *slurm_part_name; char *nodes; enum connection_type bg_conn_type; -#ifdef HAVE_BGL enum node_use_type bg_node_use; -#endif rm_partition_state_t state; int size; int node_cnt; @@ -52,9 +50,7 @@ typedef struct { int job_running; bool printed; bool small_block; -#ifdef HAVE_BGL char *imageblrts; /* ImageBlrts for this block */ -#endif char *imagelinux; /* ImageLinux for this block */ char *imagemloader; /* imagemloader for this block */ char *imageramdisk; /* ImageRamDisk for this block */ @@ -68,8 +64,8 @@ enum { SORTID_COLOR_INX, SORTID_CONN, SORTID_JOB, -#ifdef HAVE_BGL SORTID_IMAGEBLRTS, +#ifdef HAVE_BGL SORTID_IMAGELINUX, SORTID_IMAGEMLOADER, SORTID_IMAGERAMDISK, @@ -82,9 +78,7 @@ enum { SORTID_PARTITION, SORTID_STATE, SORTID_UPDATED, -#ifdef HAVE_BGL SORTID_USE, -#endif SORTID_NODE_INX, SORTID_SMALL_BLOCK, SORTID_USER, @@ -176,9 +170,7 @@ static void _block_list_del(void *object) xfree(block_ptr->bg_block_name); xfree(block_ptr->slurm_part_name); xfree(block_ptr->nodes); -#ifdef HAVE_BGL xfree(block_ptr->imageblrts); -#endif xfree(block_ptr->imagelinux); xfree(block_ptr->imagemloader); xfree(block_ptr->imageramdisk); @@ -233,37 +225,37 @@ static void _layout_block_record(GtkTreeView *treeview, SORTID_CONN), conn_type_string( block_ptr->bg_conn_type)); -#ifdef HAVE_BGL - add_display_treestore_line(update, treestore, &iter, - find_col_name(display_data_block, - SORTID_IMAGEBLRTS), - block_ptr->imageblrts); - add_display_treestore_line(update, treestore, &iter, - find_col_name(display_data_block, - SORTID_IMAGELINUX), - block_ptr->imagelinux); - add_display_treestore_line(update, treestore, &iter, - find_col_name(display_data_block, - SORTID_IMAGEMLOADER), - block_ptr->imagemloader); - add_display_treestore_line(update, treestore, &iter, - find_col_name(display_data_block, - SORTID_IMAGERAMDISK), - block_ptr->imageramdisk); -#else - add_display_treestore_line(update, treestore, &iter, - find_col_name(display_data_block, - SORTID_IMAGELINUX), - block_ptr->imagelinux); - add_display_treestore_line(update, treestore, &iter, - find_col_name(display_data_block, - SORTID_IMAGERAMDISK), - block_ptr->imageramdisk); - add_display_treestore_line(update, treestore, &iter, - find_col_name(display_data_block, - SORTID_IMAGEMLOADER), - block_ptr->imagemloader); -#endif + if(cluster_flags & CLUSTER_FLAG_BGL) { + add_display_treestore_line(update, treestore, &iter, + find_col_name(display_data_block, + SORTID_IMAGEBLRTS), + block_ptr->imageblrts); + add_display_treestore_line(update, treestore, &iter, + find_col_name(display_data_block, + SORTID_IMAGELINUX), + block_ptr->imagelinux); + add_display_treestore_line(update, treestore, &iter, + find_col_name(display_data_block, + SORTID_IMAGEMLOADER), + block_ptr->imagemloader); + add_display_treestore_line(update, treestore, &iter, + find_col_name(display_data_block, + SORTID_IMAGERAMDISK), + block_ptr->imageramdisk); + } else { + add_display_treestore_line(update, treestore, &iter, + find_col_name(display_data_block, + SORTID_IMAGELINUX), + block_ptr->imagelinux); + add_display_treestore_line(update, treestore, &iter, + find_col_name(display_data_block, + SORTID_IMAGERAMDISK), + block_ptr->imageramdisk); + add_display_treestore_line(update, treestore, &iter, + find_col_name(display_data_block, + SORTID_IMAGEMLOADER), + block_ptr->imagemloader); + } if(block_ptr->job_running > NO_JOB_RUNNING) snprintf(tmp_cnt, sizeof(tmp_cnt), @@ -275,12 +267,13 @@ static void _layout_block_record(GtkTreeView *treeview, find_col_name(display_data_block, SORTID_JOB), tmp_cnt); -#ifdef HAVE_BGL - add_display_treestore_line(update, treestore, &iter, - find_col_name(display_data_block, - SORTID_USE), - node_use_string(block_ptr->bg_node_use)); -#endif + if(cluster_flags & CLUSTER_FLAG_BGL) { + add_display_treestore_line(update, treestore, &iter, + find_col_name(display_data_block, + SORTID_USE), + node_use_string( + block_ptr->bg_node_use)); + } convert_num_unit((float)block_ptr->node_cnt, tmp_cnt, sizeof(tmp_cnt), UNIT_NONE); add_display_treestore_line(update, treestore, &iter, @@ -329,10 +322,10 @@ static void _update_block_record(sview_block_info_t *block_ptr, gtk_tree_store_set(treestore, iter, SORTID_CONN, conn_type_string(block_ptr->bg_conn_type), -1); -#ifdef HAVE_BGL - gtk_tree_store_set(treestore, iter, SORTID_USE, - node_use_string(block_ptr->bg_node_use), -1); -#endif + if(cluster_flags & CLUSTER_FLAG_BGL) + gtk_tree_store_set(treestore, iter, SORTID_USE, + node_use_string(block_ptr->bg_node_use), -1); + convert_num_unit((float)block_ptr->node_cnt, tmp_cnt, sizeof(tmp_cnt), UNIT_NONE); gtk_tree_store_set(treestore, iter, SORTID_NODES, tmp_cnt, -1); @@ -343,10 +336,10 @@ static void _update_block_record(sview_block_info_t *block_ptr, gtk_tree_store_set(treestore, iter, SORTID_NODE_INX, block_ptr->bp_inx, -1); -#ifdef HAVE_BGL - gtk_tree_store_set(treestore, iter, SORTID_IMAGEBLRTS, - block_ptr->imageblrts, -1); -#endif + if(cluster_flags & CLUSTER_FLAG_BGL) + gtk_tree_store_set(treestore, iter, SORTID_IMAGEBLRTS, + block_ptr->imageblrts, -1); + gtk_tree_store_set(treestore, iter, SORTID_IMAGELINUX, block_ptr->imagelinux, -1); gtk_tree_store_set(treestore, iter, SORTID_IMAGEMLOADER, @@ -532,7 +525,7 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr, */ if(block_ptr->color_inx < 0) block_ptr->color_inx = i; - + block_ptr->color_inx %= sview_colors_cnt; block_ptr->nodes @@ -550,10 +543,10 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr, block_ptr->bg_user_name = xstrdup(block_info_ptr-> block_array[i].owner_name); -#ifdef HAVE_BGL - block_ptr->imageblrts = xstrdup( - block_info_ptr->block_array[i].blrtsimage); -#endif + if(cluster_flags & CLUSTER_FLAG_BGL) + block_ptr->imageblrts = xstrdup( + block_info_ptr->block_array[i].blrtsimage); + block_ptr->imagelinux = xstrdup( block_info_ptr->block_array[i].linuximage); block_ptr->imagemloader = xstrdup( @@ -565,10 +558,11 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr, = block_info_ptr->block_array[i].state; block_ptr->bg_conn_type = block_info_ptr->block_array[i].conn_type; -#ifdef HAVE_BGL - block_ptr->bg_node_use - = block_info_ptr->block_array[i].node_use; -#endif + + if(cluster_flags & CLUSTER_FLAG_BGL) + block_ptr->bg_node_use + = block_info_ptr->block_array[i].node_use; + block_ptr->node_cnt = block_info_ptr->block_array[i].node_cnt; block_ptr->bp_inx @@ -697,17 +691,18 @@ extern void refresh_block(GtkAction *action, gpointer user_data) specific_info_block(popup_win); } -extern int get_new_info_block(block_info_msg_t **block_ptr, - int force) +extern int get_new_info_block(block_info_msg_t **block_ptr, int force) { int error_code = SLURM_NO_CHANGE_IN_DATA; -#ifdef HAVE_BG static block_info_msg_t *bg_info_ptr = NULL; static block_info_msg_t *new_bg_ptr = NULL; time_t now = time(NULL); static time_t last; static bool changed = 0; + if(!(cluster_flags & CLUSTER_FLAG_BG)) + return error_code; + if(!force && ((now - last) < working_sview_config.refresh_delay)) { if(*block_ptr != bg_info_ptr) error_code = SLURM_SUCCESS; @@ -735,12 +730,12 @@ extern int get_new_info_block(block_info_msg_t **block_ptr, } bg_info_ptr = new_bg_ptr; + if(block_ptr) { + if(*block_ptr != bg_info_ptr) + error_code = SLURM_SUCCESS; - if(*block_ptr != bg_info_ptr) - error_code = SLURM_SUCCESS; - - *block_ptr = new_bg_ptr; -#endif + *block_ptr = new_bg_ptr; + } return error_code; } @@ -898,12 +893,23 @@ extern void get_info_block(GtkTable *table, display_data_t *display_data) sview_block_info_t *sview_block_info_ptr = NULL; GtkTreePath *path = NULL; + /* reset */ + if(!table && !display_data) { + if(display_widget) + gtk_widget_destroy(display_widget); + display_widget = NULL; + get_new_info_part(&part_info_ptr, true); + get_new_info_block(&block_ptr, true); + return; + } + if(display_data) local_display_data = display_data; if(!table) { display_data_block->set_menu = local_display_data->set_menu; return; } + if(display_widget && toggled) { gtk_widget_destroy(display_widget); display_widget = NULL; @@ -1266,7 +1272,8 @@ extern void set_menus_block(void *arg, void *arg2, GtkTreePath *path, int type) make_options_menu(tree_view, path, menu, options_data_block); break; case ROW_LEFT_CLICKED: - highlight_grid(tree_view, path, SORTID_NODE_INX, 0, button_list); + highlight_grid(tree_view, path, SORTID_NODE_INX, + 0, button_list); break; case FULL_CLICKED: { @@ -1414,3 +1421,50 @@ extern void admin_block(GtkTreeModel *model, GtkTreeIter *iter, char *type) return; } +extern void cluster_change_block() +{ + display_data_t *display_data = display_data_block; + while(display_data++) { + if(display_data->id == -1) + break; + if(cluster_flags & CLUSTER_FLAG_BGL) { + switch(display_data->id) { + case SORTID_USE: + display_data->name = "Node Use"; + display_data->show = TRUE; + break; + case SORTID_IMAGEBLRTS: + display_data->name = "Image Blrt"; + break; + case SORTID_IMAGELINUX: + display_data->name = "Image Linux"; + break; + case SORTID_IMAGERAMDISK: + display_data->name = "Image Ramdisk"; + break; + default: + break; + } + } else { + switch(display_data->id) { + case SORTID_USE: + display_data->name = NULL; + display_data->show = FALSE; + break; + case SORTID_IMAGEBLRTS: + display_data->name = NULL; + display_data->show = FALSE; + break; + case SORTID_IMAGELINUX: + display_data->name = "Image Cnload"; + break; + case SORTID_IMAGERAMDISK: + display_data->name = "Image Ioload"; + break; + default: + break; + } + } + } + get_info_block(NULL, NULL); +} diff --git a/src/sview/sview.c b/src/sview/sview.c index 66af3c4b1f2..453142bf17f 100644 --- a/src/sview/sview.c +++ b/src/sview/sview.c @@ -71,6 +71,8 @@ GtkTable *main_grid_table = NULL; GStaticMutex sview_mutex = G_STATIC_MUTEX_INIT; GMutex *grid_mutex = NULL; GCond *grid_cond = NULL; +uint32_t cluster_flags; +int cluster_dims; static GtkActionGroup *admin_action_group = NULL; static GtkActionGroup *menu_action_group = NULL; @@ -444,20 +446,24 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook) GError *error = NULL; /* Our menu*/ - const char *ui_description = + char *ui_description = NULL; + + xstrcat(ui_description, "<ui>" " <menubar name='main'>" " <menu action='actions'>" " <menu action='search'>" " <menuitem action='jobid'/>" " <menuitem action='user_jobs'/>" - " <menuitem action='state_jobs'/>" -#ifdef HAVE_BG - " <separator/>" - " <menuitem action='bg_block_name'/>" - " <menuitem action='bg_block_size'/>" - " <menuitem action='bg_block_state'/>" -#endif + " <menuitem action='state_jobs'/>"); + if(cluster_flags & CLUSTER_FLAG_BG) + xstrcat(ui_description, + " <separator/>" + " <menuitem action='bg_block_name'/>" + " <menuitem action='bg_block_size'/>" + " <menuitem action='bg_block_state'/>"); + + xstrcat(ui_description, " <separator/>" " <menuitem action='partition_name'/>" " <menuitem action='partition_state'/>" @@ -486,10 +492,12 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook) " </menu>" " <menu action='options'>" " <menuitem action='grid'/>" - " <menuitem action='hidden'/>" -#ifndef HAVE_BG - " <menuitem action='grid_specs'/>" -#endif + " <menuitem action='hidden'/>"); + if(cluster_flags & CLUSTER_FLAG_BG) + xstrcat(ui_description, + " <menuitem action='grid_specs'/>"); + + xstrcat(ui_description, " <menuitem action='interval'/>" " <separator/>" " <menuitem action='admin'/>" @@ -512,7 +520,7 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook) /* " <menuitem action='manual'/>" */ " </menu>" " </menubar>" - "</ui>"; + "</ui>"); GtkActionEntry entries[] = { {"actions", NULL, "_Actions", "<alt>a"}, @@ -528,43 +536,12 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook) {"state_jobs", NULL, "Job(s) in a Specific State", "", "Search for job(s) in a specific state", G_CALLBACK(create_search_popup)}, -#ifdef HAVE_BG - {"bg_block_name", NULL, "BG Block Name", - "", "Search for a specific BG Block", - G_CALLBACK(create_search_popup)}, - {"bg_block_size", NULL, "BG Block Size", - "", - "Search for BG Blocks having given size in cnodes", - G_CALLBACK(create_search_popup)}, - {"bg_block_state", NULL, "BG Block State", - "", - "Search for BG Blocks having given state", - G_CALLBACK(create_search_popup)}, -#endif {"partition_name", NULL, "Slurm Partition Name", "", "Search for a specific SLURM partition", G_CALLBACK(create_search_popup)}, {"partition_state", NULL, "Slurm Partition State", "", "Search for SLURM partitions in a given state", G_CALLBACK(create_search_popup)}, - {"node_name", NULL, -#ifdef HAVE_BG - "Base Partition(s) Name", - "", "Search for a specific Base Partition(s)", -#else - "Node(s) Name", - "", "Search for a specific Node(s)", -#endif - G_CALLBACK(create_search_popup)}, - {"node_state", NULL, -#ifdef HAVE_BG - "Base Partition State", - "", "Search for a Base Partition in a given state", -#else - "Node State", - "", "Search for a Node in a given state", -#endif - G_CALLBACK(create_search_popup)}, {"reservation_name", NULL, "Reservation Name", "", "Search for reservation", G_CALLBACK(create_search_popup)}, @@ -596,6 +573,39 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook) G_CALLBACK(configure_defaults)}, }; + GtkActionEntry bg_entries[] = { + {"bg_block_name", NULL, "BG Block Name", + "", "Search for a specific BG Block", + G_CALLBACK(create_search_popup)}, + {"bg_block_size", NULL, "BG Block Size", + "", + "Search for BG Blocks having given size in cnodes", + G_CALLBACK(create_search_popup)}, + {"bg_block_state", NULL, "BG Block State", + "", + "Search for BG Blocks having given state", + G_CALLBACK(create_search_popup)}, + {"node_name", NULL, + "Base Partition(s) Name", + "", "Search for a specific Base Partition(s)", + G_CALLBACK(create_search_popup)}, + {"node_state", NULL, + "Base Partition State", + "", "Search for a Base Partition in a given state", + G_CALLBACK(create_search_popup)}, + }; + + GtkActionEntry nonbg_entries[] = { + {"node_name", NULL, + "Node(s) Name", + "", "Search for a specific Node(s)", + G_CALLBACK(create_search_popup)}, + {"node_state", NULL, + "Node State", + "", "Search for a Node in a given state", + G_CALLBACK(create_search_popup)}, + }; + GtkActionEntry admin_entries[] = { {"reconfig", GTK_STOCK_REDO, "SLUR_M Reconfigure", "<control>m", "Reconfigures System", @@ -649,6 +659,14 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook) gtk_action_group_add_actions(menu_action_group, entries, G_N_ELEMENTS(entries), window); + if(cluster_flags & CLUSTER_FLAG_BG) + gtk_action_group_add_actions(menu_action_group, bg_entries, + G_N_ELEMENTS(bg_entries), window); + else + gtk_action_group_add_actions(menu_action_group, nonbg_entries, + G_N_ELEMENTS(nonbg_entries), + window); + gtk_action_group_add_radio_actions(menu_action_group, radio_entries, G_N_ELEMENTS(radio_entries), working_sview_config.tab_pos, @@ -673,13 +691,14 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook) accel_group = gtk_ui_manager_get_accel_group(ui_manager); gtk_window_add_accel_group(GTK_WINDOW(window), accel_group); - if (!gtk_ui_manager_add_ui_from_string (ui_manager, ui_description, - -1, &error)) - { + if (!gtk_ui_manager_add_ui_from_string(ui_manager, ui_description, + -1, &error)) { + xfree(ui_description); g_error("building menus failed: %s", error->message); g_error_free (error); exit (0); } + xfree(ui_description); /* GList *action_list = gtk_action_group_list_actions(menu_action_group); */ /* GtkAction *action = NULL; */ /* int i=0; */ @@ -758,6 +777,39 @@ static void _get_info_tabs(GtkTable *table, display_data_t *display_data) } +extern void change_cluster_main() +{ + display_data_t *display_data = main_display_data; + while(display_data++) { + if(display_data->id == -1) + break; + if(cluster_flags & CLUSTER_FLAG_BG) { + switch(display_data->id) { + case BLOCK_PAGE: + display_data->show = TRUE; + break; + case NODE_PAGE: + display_data->name = "Base Partitions"; + break; + default: + break; + } + } else { + switch(display_data->id) { + case BLOCK_PAGE: + display_data->show = FALSE; + break; + case NODE_PAGE: + display_data->name = "Nodes"; + break; + default: + break; + } + } + } + cluster_change_block(); +} + extern void refresh_main(GtkAction *action, gpointer user_data) { int page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_notebook)); @@ -842,6 +894,8 @@ int main(int argc, char *argv[]) int i=0; load_defaults(); + cluster_flags = slurmdb_setup_cluster_flags(); + cluster_dims = slurmdb_setup_cluster_dims(); _init_pages(); g_thread_init(NULL); @@ -862,9 +916,6 @@ int main(int argc, char *argv[]) GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); -/* #ifdef HAVE_BG */ -/* gtk_widget_set_size_request(grid_window, 164, -1); */ -/* #endif */ /* fill in all static info for pages */ /* Make a window */ main_window = gtk_dialog_new(); diff --git a/src/sview/sview.h b/src/sview/sview.h index 7674b1794dc..b4edc9bb56a 100644 --- a/src/sview/sview.h +++ b/src/sview/sview.h @@ -291,6 +291,8 @@ extern int cpus_per_node; extern int g_node_scaling; extern char *sview_colors[]; extern int sview_colors_cnt; +extern uint32_t cluster_flags; +extern int cluster_dims; extern void init_grid(node_info_msg_t *node_info_ptr); extern int set_grid(int start, int end, int count); @@ -360,6 +362,7 @@ extern void specific_info_part(popup_info_t *popup_win); extern void set_menus_part(void *arg, void *arg2, GtkTreePath *path, int type); extern void popup_all_part(GtkTreeModel *model, GtkTreeIter *iter, int id); extern void admin_part(GtkTreeModel *model, GtkTreeIter *iter, char *type); +extern void cluster_change_part(); // block_info.c extern void refresh_block(GtkAction *action, gpointer user_data); @@ -376,6 +379,7 @@ extern void specific_info_block(popup_info_t *popup_win); extern void set_menus_block(void *arg, void *arg2, GtkTreePath *path, int type); extern void popup_all_block(GtkTreeModel *model, GtkTreeIter *iter, int id); extern void admin_block(GtkTreeModel *model, GtkTreeIter *iter, char *type); +extern void cluster_change_block(); // job_info.c extern void refresh_job(GtkAction *action, gpointer user_data); @@ -392,6 +396,7 @@ extern void specific_info_job(popup_info_t *popup_win); extern void set_menus_job(void *arg, void *arg2, GtkTreePath *path, int type); extern void popup_all_job(GtkTreeModel *model, GtkTreeIter *iter, int id); extern void admin_job(GtkTreeModel *model, GtkTreeIter *iter, char *type); +extern void cluster_change_job(); // node_info.c extern void refresh_node(GtkAction *action, gpointer user_data); @@ -415,6 +420,7 @@ extern void popup_all_node_name(char *name, int id); extern void admin_menu_node_name(char *name, GdkEventButton *event); extern void admin_node(GtkTreeModel *model, GtkTreeIter *iter, char *type); extern void admin_node_name(char *name, char *old_value, char *type); +extern void cluster_change_node(); // resv_info.c extern void refresh_resv(GtkAction *action, gpointer user_data); @@ -429,6 +435,7 @@ extern void specific_info_resv(popup_info_t *popup_win); extern void set_menus_resv(void *arg, void *arg2, GtkTreePath *path, int type); extern void popup_all_resv(GtkTreeModel *model, GtkTreeIter *iter, int id); extern void admin_resv(GtkTreeModel *model, GtkTreeIter *iter, char *type); +extern void cluster_change_resv(); // submit_info.c -- GitLab