diff --git a/src/sview/Makefile.am b/src/sview/Makefile.am index ed216cbb742b5eb0511006e426bbfddced75db29..1a5047c84b297a6bf1a21a7a56e19ebd5439c9e4 100644 --- a/src/sview/Makefile.am +++ b/src/sview/Makefile.am @@ -15,7 +15,7 @@ sview_LDADD = \ noinst_HEADERS = sview.h sview_SOURCES = sview.c popups.c grid.c part_info.c job_info.c \ - block_info.c node_info.c \ + block_info.c node_info.c resv_info.c \ submit_info.c admin_info.c common.c force: @@ -28,7 +28,7 @@ sview_CFLAGS = $(GTK2_CFLAGS) else EXTRA_sview_SOURCES = sview.h sview.c popups.c grid.c part_info.c job_info.c \ - block_info.c node_info.c \ + block_info.c node_info.c resv_info.c \ submit_info.c admin_info.c common.c endif diff --git a/src/sview/Makefile.in b/src/sview/Makefile.in index afd9b17298761890ade7e29db4e235b155e75dff..f8ae8de486c077cf273f90770f8aa36e77629f7a 100644 --- a/src/sview/Makefile.in +++ b/src/sview/Makefile.in @@ -80,20 +80,21 @@ am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am__sview_SOURCES_DIST = sview.c popups.c grid.c part_info.c \ - job_info.c block_info.c node_info.c submit_info.c admin_info.c \ - common.c + job_info.c block_info.c node_info.c resv_info.c submit_info.c \ + admin_info.c common.c @HAVE_GTK_TRUE@am_sview_OBJECTS = sview-sview.$(OBJEXT) \ @HAVE_GTK_TRUE@ sview-popups.$(OBJEXT) sview-grid.$(OBJEXT) \ @HAVE_GTK_TRUE@ sview-part_info.$(OBJEXT) \ @HAVE_GTK_TRUE@ sview-job_info.$(OBJEXT) \ @HAVE_GTK_TRUE@ sview-block_info.$(OBJEXT) \ @HAVE_GTK_TRUE@ sview-node_info.$(OBJEXT) \ +@HAVE_GTK_TRUE@ sview-resv_info.$(OBJEXT) \ @HAVE_GTK_TRUE@ sview-submit_info.$(OBJEXT) \ @HAVE_GTK_TRUE@ sview-admin_info.$(OBJEXT) \ @HAVE_GTK_TRUE@ sview-common.$(OBJEXT) am__EXTRA_sview_SOURCES_DIST = sview.h sview.c popups.c grid.c \ - part_info.c job_info.c block_info.c node_info.c submit_info.c \ - admin_info.c common.c + part_info.c job_info.c block_info.c node_info.c resv_info.c \ + submit_info.c admin_info.c common.c sview_OBJECTS = $(am_sview_OBJECTS) @HAVE_GTK_TRUE@sview_DEPENDENCIES = $(top_builddir)/src/plugins/select/bluegene/block_allocator/libbluegene_block_allocator.la \ @HAVE_GTK_TRUE@ $(top_builddir)/src/api/libslurm.o @@ -301,13 +302,13 @@ INCLUDES = -I$(top_srcdir) $(BG_INCLUDES) @HAVE_GTK_TRUE@noinst_HEADERS = sview.h @HAVE_GTK_TRUE@sview_SOURCES = sview.c popups.c grid.c part_info.c job_info.c \ -@HAVE_GTK_TRUE@ block_info.c node_info.c \ +@HAVE_GTK_TRUE@ block_info.c node_info.c resv_info.c \ @HAVE_GTK_TRUE@ submit_info.c admin_info.c common.c @HAVE_GTK_TRUE@sview_LDFLAGS = -export-dynamic $(CMD_LDFLAGS) $(BG_LDFLAGS) $(GTK2_LIBS) @HAVE_GTK_TRUE@sview_CFLAGS = $(GTK2_CFLAGS) @HAVE_GTK_FALSE@EXTRA_sview_SOURCES = sview.h sview.c popups.c grid.c part_info.c job_info.c \ -@HAVE_GTK_FALSE@ block_info.c node_info.c \ +@HAVE_GTK_FALSE@ block_info.c node_info.c resv_info.c \ @HAVE_GTK_FALSE@ submit_info.c admin_info.c common.c all: all-am @@ -389,6 +390,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sview-node_info.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sview-part_info.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sview-popups.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sview-resv_info.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sview-submit_info.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sview-sview.Po@am__quote@ @@ -511,6 +513,20 @@ sview-node_info.obj: node_info.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sview_CFLAGS) $(CFLAGS) -c -o sview-node_info.obj `if test -f 'node_info.c'; then $(CYGPATH_W) 'node_info.c'; else $(CYGPATH_W) '$(srcdir)/node_info.c'; fi` +sview-resv_info.o: resv_info.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sview_CFLAGS) $(CFLAGS) -MT sview-resv_info.o -MD -MP -MF $(DEPDIR)/sview-resv_info.Tpo -c -o sview-resv_info.o `test -f 'resv_info.c' || echo '$(srcdir)/'`resv_info.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sview-resv_info.Tpo $(DEPDIR)/sview-resv_info.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='resv_info.c' object='sview-resv_info.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sview_CFLAGS) $(CFLAGS) -c -o sview-resv_info.o `test -f 'resv_info.c' || echo '$(srcdir)/'`resv_info.c + +sview-resv_info.obj: resv_info.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sview_CFLAGS) $(CFLAGS) -MT sview-resv_info.obj -MD -MP -MF $(DEPDIR)/sview-resv_info.Tpo -c -o sview-resv_info.obj `if test -f 'resv_info.c'; then $(CYGPATH_W) 'resv_info.c'; else $(CYGPATH_W) '$(srcdir)/resv_info.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sview-resv_info.Tpo $(DEPDIR)/sview-resv_info.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='resv_info.c' object='sview-resv_info.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sview_CFLAGS) $(CFLAGS) -c -o sview-resv_info.obj `if test -f 'resv_info.c'; then $(CYGPATH_W) 'resv_info.c'; else $(CYGPATH_W) '$(srcdir)/resv_info.c'; fi` + sview-submit_info.o: submit_info.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sview_CFLAGS) $(CFLAGS) -MT sview-submit_info.o -MD -MP -MF $(DEPDIR)/sview-submit_info.Tpo -c -o sview-submit_info.o `test -f 'submit_info.c' || echo '$(srcdir)/'`submit_info.c @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sview-submit_info.Tpo $(DEPDIR)/sview-submit_info.Po diff --git a/src/sview/common.c b/src/sview/common.c index 88547542bb3bb678b529331cf1130617b6d15a97..524b9b99fdae401ce0faa358aafef992088507a2 100644 --- a/src/sview/common.c +++ b/src/sview/common.c @@ -592,7 +592,7 @@ extern GtkTreeStore *create_treestore(GtkTreeView *tree_view, treestore = gtk_tree_store_newv(count, types); if(!treestore) { - g_error("Can't create treestore.\n"); + g_print("Can't create treestore.\n"); return NULL; } diff --git a/src/sview/resv_info.c b/src/sview/resv_info.c new file mode 100644 index 0000000000000000000000000000000000000000..fa435167bb2cb276d996d7ed54e30741714ccbb9 --- /dev/null +++ b/src/sview/resv_info.c @@ -0,0 +1,270 @@ +/*****************************************************************************\ + * resv_info.c - Functions related to advanced reservation display + * mode of sview. + ***************************************************************************** + * Copyright (C) 2009 Lawrence Livermore National Security. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Morris Jette <jette@llnl.gov> + * CODE-OCEC-09-009. All rights reserved. + * + * This file is part of SLURM, a resource management program. + * For details, see <https://computing.llnl.gov/linux/slurm/>. + * Please also read the included file: DISCLAIMER. + * + * SLURM is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * SLURM is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along + * with SLURM; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +\*****************************************************************************/ + +#include "src/common/uid.h" +#include "src/sview/sview.h" +#include "src/common/parse_time.h" + +#define _DEBUG 0 + +/* These need to be in alpha order (except POS and CNT) */ +enum { + SORTID_POS = POS_LOC, + SORTID_ACCOUNTS, + SORTID_END_TIME, + SORTID_FEATURES, + SORTID_FLAGS, + SORTID_NAME, + SORTID_NODE_CNT, + SORTID_NODE_LIST, + SORTID_PARTITION, + SORTID_START_TIME, + SORTID_USERS, + SORTID_CNT +}; + +/* extra field here is for choosing the type of edit you that will + * take place. If you choose EDIT_MODEL (means only display a set of + * known options) create it in function create_model_*. + */ + +static display_data_t display_data_resv[] = { + {G_TYPE_INT, SORTID_POS, NULL, FALSE, EDIT_NONE, + refresh_resv, create_model_resv, admin_edit_resv}, + {G_TYPE_STRING, SORTID_ACCOUNTS, "Accounts", FALSE, EDIT_TEXTBOX, + refresh_resv, create_model_resv, admin_edit_resv}, + {G_TYPE_STRING, SORTID_END_TIME, "EndTime", FALSE, EDIT_TEXTBOX, + refresh_resv, create_model_resv, admin_edit_resv}, + {G_TYPE_STRING, SORTID_FEATURES, "Features", FALSE, EDIT_TEXTBOX, + refresh_resv, create_model_resv, admin_edit_resv}, + {G_TYPE_STRING, SORTID_FLAGS, "Flags", FALSE, EDIT_NONE, + refresh_resv, create_model_resv, admin_edit_resv}, + {G_TYPE_STRING, SORTID_NAME, "Name", TRUE, EDIT_NONE, + refresh_resv, create_model_resv, admin_edit_resv}, + {G_TYPE_INT, SORTID_NODE_CNT, "Nodes", TRUE, EDIT_TEXTBOX, + refresh_resv, create_model_resv, admin_edit_resv}, + {G_TYPE_STRING, SORTID_NODE_LIST, "NodeList", TRUE, EDIT_TEXTBOX, + refresh_resv, create_model_resv, admin_edit_resv}, + {G_TYPE_STRING, SORTID_PARTITION, "Partition", FALSE, EDIT_TEXTBOX, + refresh_resv, create_model_resv, admin_edit_resv}, + {G_TYPE_STRING, SORTID_START_TIME, "StartTime", FALSE, EDIT_TEXTBOX, + refresh_resv, create_model_resv, admin_edit_resv}, + {G_TYPE_STRING, SORTID_USERS, "Users", FALSE, EDIT_TEXTBOX, + refresh_resv, create_model_resv, admin_edit_resv}, + {G_TYPE_NONE, -1, NULL, FALSE, EDIT_NONE} +}; + +static display_data_t *local_display_data = NULL; + +extern void refresh_resv(GtkAction *action, gpointer user_data) +{ + popup_info_t *popup_win = (popup_info_t *)user_data; + xassert(popup_win != NULL); + xassert(popup_win->spec_info != NULL); + xassert(popup_win->spec_info->title != NULL); + popup_win->force_refresh = 1; + specific_info_resv(popup_win); +} + +extern GtkListStore *create_model_resv(int type) +{ + return (GtkListStore *) NULL; +} + +extern void admin_edit_resv(GtkCellRendererText *cell, + const char *path_string, + const char *new_text, + gpointer data) +{ +} + +extern void get_info_resv(GtkTable *table, display_data_t *display_data) +{ + int error_code = SLURM_SUCCESS; + static int view = -1; + static reserve_info_msg_t *resv_info_ptr = NULL; + reserve_info_t *resv; + char error_char[100]; + GtkWidget *label = NULL; + GtkTreeView *tree_view = NULL; + static GtkWidget *display_widget = NULL; + List info_list = NULL; + int i = 0, j = 0; + + if(display_data) + local_display_data = display_data; + if(!table) { + display_data_resv->set_menu = local_display_data->set_menu; + return; + } + if(display_widget && toggled) { + gtk_widget_destroy(display_widget); + display_widget = NULL; + goto display_it; + } + + error_code = get_new_info_resv(&resv_info_ptr, force_refresh); + if ((error_code != SLURM_SUCCESS) && + (error_code != SLURM_NO_CHANGE_IN_DATA)) { + if(view == ERROR_VIEW) + goto end_it; + if(display_widget) + gtk_widget_destroy(display_widget); + view = ERROR_VIEW; + sprintf(error_char, "slurm_load_reservations: %s", + slurm_strerror(slurm_get_errno())); + label = gtk_label_new(error_char); + gtk_table_attach_defaults(table, label, 0, 1, 0, 1); + gtk_widget_show(label); + display_widget = gtk_widget_ref(GTK_WIDGET(label)); + goto end_it; + } + +display_it: + for (i=0; i<resv_info_ptr->record_count; i++) { + resv = &resv_info_ptr->reservation_array[i]; + j = 0; + while (resv->node_inx[j] >= 0) { +//FIXME: Need to capure the color here? + (void) change_grid_color(grid_button_list, + resv->node_inx[j], + resv->node_inx[j+1], + i); + j += 2; + } + } + + if(view == ERROR_VIEW && display_widget) { + gtk_widget_destroy(display_widget); + display_widget = NULL; + } + + if(!display_widget) { + tree_view = create_treeview(local_display_data); + + display_widget = gtk_widget_ref(GTK_WIDGET(tree_view)); + gtk_table_attach_defaults(GTK_TABLE(table), + GTK_WIDGET(tree_view), + 0, 1, 0, 1); + /* since this function sets the model of the tree_view + * to the treestore we don't really care about + * the return value */ + create_treestore(tree_view, display_data_resv, SORTID_CNT); + } + + view = INFO_VIEW; +// _update_info_job(info_list, GTK_TREE_VIEW(display_widget)); + +end_it: + toggled = FALSE; + force_refresh = FALSE; + + return; +} + +extern int get_new_info_resv(reserve_info_msg_t **info_ptr, + int force) +{ + static reserve_info_msg_t *resv_info_ptr = NULL, *new_resv_ptr = NULL; + int error_code = SLURM_NO_CHANGE_IN_DATA; + time_t now = time(NULL); + static time_t last; + static bool changed = 0; + + if(!force && ((now - last) < global_sleep_time)) { + error_code = SLURM_NO_CHANGE_IN_DATA; + *info_ptr = resv_info_ptr; + if(changed) + return SLURM_SUCCESS; + return error_code; + } + last = now; + if (resv_info_ptr) { + error_code = slurm_load_reservations(resv_info_ptr->last_update, + &new_resv_ptr); + if (error_code == SLURM_SUCCESS) { + slurm_free_reservation_info_msg(resv_info_ptr); + changed = 1; + } else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) { + error_code = SLURM_NO_CHANGE_IN_DATA; + new_resv_ptr = resv_info_ptr; + changed = 0; + } + } else { + error_code = slurm_load_reservations((time_t) NULL, + &new_resv_ptr); + changed = 1; + } + resv_info_ptr = new_resv_ptr; + *info_ptr = new_resv_ptr; + return error_code; +} + +extern void specific_info_resv(popup_info_t *popup_win) +{ +} + +extern void set_menus_resv(void *arg, GtkTreePath *path, + GtkMenu *menu, int type) +{ +} + +#if 0 +static void _layout_job_record(GtkTreeView *treeview, + sview_job_info_t *sview_job_info_ptr, + int update) +{ + char *nodes = NULL, *reason = NULL, *uname = NULL; + char tmp_char[50]; + time_t now_time = time(NULL); + job_info_t *job_ptr = sview_job_info_ptr->job_ptr; + struct group *group_info = NULL; + uint16_t term_sig = 0; + + GtkTreeIter iter; + GtkTreeStore *treestore = + GTK_TREE_STORE(gtk_tree_view_get_model(treeview)); + + if(!treestore) + return; + + add_display_treestore_line(update, treestore, &iter, + find_col_name(display_data_job, + SORTID_NAME), + job_ptr->name); +} + +static void _update_job_record(sview_job_info_t *sview_job_info_ptr, + GtkTreeStore *treestore, + GtkTreeIter *iter) +{ + + gtk_tree_store_set(treestore, iter, SORTID_NAME, job_ptr->name, -1); +} + +#endif diff --git a/src/sview/sview.c b/src/sview/sview.c index 0fc221f104ac0cfc9f615d34024daf359d41d7bc..c44669ca14903e761ea324a164520acbb1e9822d 100644 --- a/src/sview/sview.c +++ b/src/sview/sview.c @@ -2,7 +2,7 @@ * sview.c - main for sview ***************************************************************************** * Copyright (C) 2002-2007 The Regents of the University of California. - * Copyright (C) 2008 Lawrence Livermore National Security. + * Copyright (C) 2008-2009 Lawrence Livermore National Security. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Danny Auble <da@llnl.gov>, et. al. * CODE-OCEC-09-009. All rights reserved. @@ -79,6 +79,12 @@ display_data_t main_display_data[] = { refresh_main, create_model_part, admin_edit_part, get_info_part, specific_info_part, set_menus_part, NULL}, + {G_TYPE_NONE, RESV_PAGE, "Reservations", TRUE, -1, + refresh_main, create_model_resv, admin_edit_resv, + get_info_resv, specific_info_resv, + set_menus_resv, NULL}, + + #ifdef HAVE_BG {G_TYPE_NONE, BLOCK_PAGE, "BG Blocks", TRUE, -1, refresh_main, NULL, NULL, diff --git a/src/sview/sview.h b/src/sview/sview.h index 320c34240bda464264f7cc7f1c0856d6f3f908b2..e275d7dbcfb83adb1c582d359db385598e2e6a74 100644 --- a/src/sview/sview.h +++ b/src/sview/sview.h @@ -85,7 +85,8 @@ enum { JOB_PAGE, STEP_PAGE, - PART_PAGE, + PART_PAGE, + RESV_PAGE, NODE_PAGE, BLOCK_PAGE, SUBMIT_PAGE, @@ -354,6 +355,20 @@ extern void set_menus_node(void *arg, GtkTreePath *path, extern void popup_all_node(GtkTreeModel *model, GtkTreeIter *iter, int id); extern void admin_node(GtkTreeModel *model, GtkTreeIter *iter, char *type); +// resv_info.c +extern void admin_edit_resv(GtkCellRendererText *cell, + const char *path_string, + const char *new_text, + gpointer data); +extern GtkListStore *create_model_resv(int type); +extern void get_info_resv(GtkTable *table, display_data_t *display_data); +extern int get_new_info_resv(reserve_info_msg_t **info_ptr, + int force); +extern void set_menus_resv(void *arg, GtkTreePath *path, + GtkMenu *menu, int type); +extern void specific_info_resv(popup_info_t *popup_win); +extern void refresh_resv(GtkAction *action, gpointer user_data); + // submit_info.c extern void get_info_submit(GtkTable *table, display_data_t *display_data); extern void set_menus_submit(void *arg, GtkTreePath *path,