From fde43539cdae94d7f1be7d1dd460f65af7e5e095 Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Thu, 11 Jun 2009 23:12:29 +0000 Subject: [PATCH] BLUEGENE - add support for scontrol show blocks --- NEWS | 1 + src/api/node_select_info.c | 141 ++++++++++- src/api/node_select_info.h | 32 +++ src/common/slurm_protocol_defs.c | 221 ++++++++++++------ src/common/slurm_protocol_defs.h | 7 + .../block_allocator/block_allocator.c | 33 --- .../block_allocator/block_allocator.h | 3 - .../select/bluegene/plugin/bg_job_place.c | 4 +- .../bluegene/plugin/bg_record_functions.c | 12 +- src/plugins/select/bluegene/plugin/bluegene.c | 50 +--- src/plugins/select/bluegene/plugin/bluegene.h | 5 - src/scontrol/Makefile.am | 1 + src/scontrol/Makefile.in | 10 +- src/scontrol/info_block.c | 121 ++++++++++ src/scontrol/scontrol.c | 37 ++- src/scontrol/scontrol.h | 7 +- src/slurmctld/partition_mgr.c | 2 +- src/smap/partition_functions.c | 62 +---- src/sview/block_info.c | 63 +---- 19 files changed, 497 insertions(+), 315 deletions(-) create mode 100644 src/scontrol/info_block.c diff --git a/NEWS b/NEWS index e15bac8dbc9..7a502ddd0d3 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,7 @@ documents those changes that are of interest to users and admins. Put into new RPM: sjstat. -- Add sched/wiki2 (Moab) JOBMODIFY command support for VARIABLELIST option to set supplemental environment variables for pending batch jobs. + -- BLUEGENE - add support for scontrol show blocks * Changes in SLURM 2.0.2 ======================== diff --git a/src/api/node_select_info.c b/src/api/node_select_info.c index 354b368d7d1..51237d2f662 100644 --- a/src/api/node_select_info.c +++ b/src/api/node_select_info.c @@ -61,6 +61,143 @@ #include "src/common/node_select.h" #include "src/common/slurm_protocol_api.h" #include "src/common/xmalloc.h" +#include "src/plugins/select/bluegene/plugin/bluegene.h" + + +/* + * slurm_print_node_select_info_msg - output information about all Bluegene + * blocks based upon message as loaded using slurm_load_node_select + * IN out - file to write to + * IN info_ptr - node_select information message pointer + * IN one_liner - print as a single line if true + */ +void slurm_print_node_select_info_msg( + FILE *out, node_select_info_msg_t *info_ptr, int one_liner) +{ + int i ; + bg_info_record_t * bg_info_ptr = info_ptr->bg_info_array; + char time_str[32]; + + slurm_make_time_str ((time_t *)&info_ptr->last_update, time_str, + sizeof(time_str)); + fprintf( out, "Bluegene Block data as of %s, record count %d\n", + time_str, info_ptr->record_count); + + for (i = 0; i < info_ptr->record_count; i++) + slurm_print_node_select_info(out, & bg_info_ptr[i], one_liner); +} + +/* + * slurm_print_node_select_info - output information about a specific Bluegene + * block based upon message as loaded using slurm_load_node_select + * IN out - file to write to + * IN bg_info_ptr - an individual block information record pointer + * IN one_liner - print as a single line if true + */ +void slurm_print_node_select_info( + FILE *out, bg_info_record_t *bg_info_ptr, int one_liner) +{ + char *print_this = slurm_sprint_node_select_info( + bg_info_ptr, one_liner); + fprintf(out, "%s", print_this); + xfree(print_this); +} + + +/* + * slurm_sprint_node_select_info - output information about a specific Bluegene + * block based upon message as loaded using slurm_load_node_select + * IN bg_info_ptr - an individual partition information record pointer + * IN one_liner - print as a single line if true + * RET out - char * containing formatted output (must be freed after call) + * NULL is returned on failure. + */ +char *slurm_sprint_node_select_info( + bg_info_record_t * bg_info_ptr, int one_liner) +{ + int j; + char tmp1[16]; + char *out = NULL; + char *line_end = "\n "; + + if (one_liner) + line_end = " "; + + /****** Line 1 ******/ + convert_num_unit((float)bg_info_ptr->node_cnt, tmp1, sizeof(tmp1), + UNIT_NONE); + + out = xstrdup_printf("BlockName=%s TotalCNodes=%s State=%s%s", + bg_info_ptr->bg_block_id, tmp1, + bg_block_state_string(bg_info_ptr->state), + line_end); + + /****** Line 2 ******/ + if (bg_info_ptr->job_running > NO_JOB_RUNNING) + xstrfmtcat(out, "JobRunning=%u ", bg_info_ptr->job_running); + else + xstrcat(out, "JobRunning=NONE "); + + xstrfmtcat(out, "User=%s ConnType=%s", + bg_info_ptr->owner_name, + conn_type_string(bg_info_ptr->conn_type)); +#ifdef HAVE_BGL + xstrfmtcat(out, " NodeUse=%s", + node_use_string(bg_info_ptr->node_use)); +#endif + xstrcat(out, line_end); + + /****** Line 3 ******/ + xstrfmtcat(out, "BasePartitions=%s BPIndices=", bg_info_ptr->nodes); + for (j = 0; + (bg_info_ptr->bp_inx && (bg_info_ptr->bp_inx[j] != -1)); + j+=2) { + if (j > 0) + xstrcat(out, ","); + xstrfmtcat(out, "%d-%d", bg_info_ptr->bp_inx[j], + bg_info_ptr->bp_inx[j+1]); + } + xstrcat(out, line_end); + + /****** Line 4 ******/ + if(bg_info_ptr->ionodes) { + xstrfmtcat(out, "IONodes=%s IONIndices=", bg_info_ptr->ionodes); + for (j = 0; + (bg_info_ptr->ionode_inx + && (bg_info_ptr->ionode_inx[j] != -1)); + j+=2) { + if (j > 0) + xstrcat(out, ","); + xstrfmtcat(out, "%d-%d", bg_info_ptr->ionode_inx[j], + bg_info_ptr->ionode_inx[j+1]); + } + xstrcat(out, line_end); + } + + /****** Line 5 ******/ + xstrfmtcat(out, "MloaderImage=%s%s", + bg_info_ptr->mloaderimage, line_end); + +#ifdef HAVE_BGL + /****** Line 6 ******/ + xstrfmtcat(out, "BlrtsImage=%s%s", bg_info_ptr->blrtsimage, line_end); + /****** Line 7 ******/ + xstrfmtcat(out, "LinuxImage=%s%s", bg_info_ptr->linuximage, line_end); + /****** Line 8 ******/ + xstrfmtcat(out, "RamdiskImage=%s", bg_info_ptr->ramdiskimage); +#else + /****** Line 6 ******/ + xstrfmtcat(out, "CnloadImage=%s%s", bg_info_ptr->linuximage, line_end); + /****** Line 7 ******/ + xstrfmtcat(out, "IoloadImage=%s", bg_info_ptr->ramdiskimage); +#endif + if (one_liner) + xstrcat(out, "\n"); + else + xstrcat(out, "\n\n"); + + return out; +} /* * slurm_load_node_select - issue RPC to get slurm all node select plugin @@ -71,8 +208,8 @@ * RET 0 or a slurm error code * NOTE: free the response using slurm_free_node_select_info_msg */ -extern int slurm_load_node_select (time_t update_time, - node_select_info_msg_t **node_select_info_msg_pptr) +extern int slurm_load_node_select ( + time_t update_time, node_select_info_msg_t **node_select_info_msg_pptr) { int rc; slurm_msg_t req_msg; diff --git a/src/api/node_select_info.h b/src/api/node_select_info.h index 1b1beb3e6a0..a37011863fb 100644 --- a/src/api/node_select_info.h +++ b/src/api/node_select_info.h @@ -45,6 +45,7 @@ #ifndef _NODE_SELECT_INFO_H #define _NODE_SELECT_INFO_H +#include <stdio.h> #include <stdint.h> #include <time.h> #include "src/common/pack.h" @@ -78,6 +79,37 @@ typedef struct { uint32_t record_count; } node_select_info_msg_t; +/* + * slurm_print_node_select_info_msg - output information about all Bluegene + * blocks based upon message as loaded using slurm_load_node_select + * IN out - file to write to + * IN info_ptr - node_select information message pointer + * IN one_liner - print as a single line if true + */ +void slurm_print_node_select_info_msg( + FILE *out, node_select_info_msg_t *info_ptr, int one_liner); + +/* + * slurm_print_node_select_info - output information about a specific Bluegene + * block based upon message as loaded using slurm_load_node_select + * IN out - file to write to + * IN bg_info_ptr - an individual block information record pointer + * IN one_liner - print as a single line if true + */ +void slurm_print_node_select_info( + FILE *out, bg_info_record_t *bg_info_ptr, int one_liner); + +/* + * slurm_sprint_node_select_info - output information about a specific Bluegene + * block based upon message as loaded using slurm_load_node_select + * IN bg_info_ptr - an individual partition information record pointer + * IN one_liner - print as a single line if true + * RET out - char * containing formatted output (must be freed after call) + * NULL is returned on failure. + */ +char *slurm_sprint_node_select_info( + bg_info_record_t * bg_info_ptr, int one_liner); + /* * slurm_load_node_select - issue RPC to get slurm all node select plugin * information if changed since update_time diff --git a/src/common/slurm_protocol_defs.c b/src/common/slurm_protocol_defs.c index 70e51fd0b2d..e87c9ced79b 100644 --- a/src/common/slurm_protocol_defs.c +++ b/src/common/slurm_protocol_defs.c @@ -59,6 +59,9 @@ #include "src/common/job_options.h" #include "src/common/forward.h" #include "src/common/slurm_jobacct_gather.h" +#ifdef HAVE_BG +#include "src/plugins/select/bluegene/wrap_rm_api.h" +#endif static void _free_all_job_info (job_info_msg_t *msg); @@ -818,78 +821,6 @@ void inline slurm_free_will_run_response_msg(will_run_response_msg_t *msg) xfree(msg); } } - -extern void -private_data_string(uint16_t private_data, char *str, int str_len) -{ - if (str_len > 0) - str[0] = '\0'; - if (str_len < 42) { - error("private_data_string: output buffer too small"); - return; - } - - if (private_data & PRIVATE_DATA_JOBS) - strcat(str, "jobs"); //4 len - if (private_data & PRIVATE_DATA_NODES) { - if (str[0]) - strcat(str, ","); - strcat(str, "nodes"); //6 len - } - if (private_data & PRIVATE_DATA_PARTITIONS) { - if (str[0]) - strcat(str, ","); - strcat(str, "partitions"); //11 len - } - if (private_data & PRIVATE_DATA_USAGE) { - if (str[0]) - strcat(str, ","); - strcat(str, "usage"); //6 len - } - if (private_data & PRIVATE_DATA_USERS) { - if (str[0]) - strcat(str, ","); - strcat(str, "users"); //6 len - } - if (private_data & PRIVATE_DATA_ACCOUNTS) { - if (str[0]) - strcat(str, ","); - strcat(str, "accounts"); //9 len - } - // total len 42 - - if (str[0] == '\0') - strcat(str, "none"); -} - -extern void -accounting_enforce_string(uint16_t enforce, char *str, int str_len) -{ - if (str_len > 0) - str[0] = '\0'; - if (str_len < 26) { - error("enforce: output buffer too small"); - return; - } - - if (enforce & ACCOUNTING_ENFORCE_ASSOCS) - strcat(str, "associations"); //12 len - if (enforce & ACCOUNTING_ENFORCE_LIMITS) { - if (str[0]) - strcat(str, ","); - strcat(str, "limits"); //7 len - } - if (enforce & ACCOUNTING_ENFORCE_WCKEYS) { - if (str[0]) - strcat(str, ","); - strcat(str, "wckeys"); //7 len - } - // total len 26 - - if (str[0] == '\0') - strcat(str, "none"); -} - char *job_state_string(uint16_t inx) { /* Process JOB_STATE_FLAGS */ @@ -1176,6 +1107,152 @@ char *node_state_string_compact(uint16_t inx) return "?"; } + +extern void +private_data_string(uint16_t private_data, char *str, int str_len) +{ + if (str_len > 0) + str[0] = '\0'; + if (str_len < 42) { + error("private_data_string: output buffer too small"); + return; + } + + if (private_data & PRIVATE_DATA_JOBS) + strcat(str, "jobs"); //4 len + if (private_data & PRIVATE_DATA_NODES) { + if (str[0]) + strcat(str, ","); + strcat(str, "nodes"); //6 len + } + if (private_data & PRIVATE_DATA_PARTITIONS) { + if (str[0]) + strcat(str, ","); + strcat(str, "partitions"); //11 len + } + if (private_data & PRIVATE_DATA_USAGE) { + if (str[0]) + strcat(str, ","); + strcat(str, "usage"); //6 len + } + if (private_data & PRIVATE_DATA_USERS) { + if (str[0]) + strcat(str, ","); + strcat(str, "users"); //6 len + } + if (private_data & PRIVATE_DATA_ACCOUNTS) { + if (str[0]) + strcat(str, ","); + strcat(str, "accounts"); //9 len + } + // total len 42 + + if (str[0] == '\0') + strcat(str, "none"); +} + +extern void +accounting_enforce_string(uint16_t enforce, char *str, int str_len) +{ + if (str_len > 0) + str[0] = '\0'; + if (str_len < 26) { + error("enforce: output buffer too small"); + return; + } + + if (enforce & ACCOUNTING_ENFORCE_ASSOCS) + strcat(str, "associations"); //12 len + if (enforce & ACCOUNTING_ENFORCE_LIMITS) { + if (str[0]) + strcat(str, ","); + strcat(str, "limits"); //7 len + } + if (enforce & ACCOUNTING_ENFORCE_WCKEYS) { + if (str[0]) + strcat(str, ","); + strcat(str, "wckeys"); //7 len + } + // total len 26 + + if (str[0] == '\0') + strcat(str, "none"); +} + +extern char *conn_type_string(enum connection_type conn_type) +{ + switch (conn_type) { + case (SELECT_MESH): + return "MESH"; + case (SELECT_TORUS): + return "TORUS"; + case (SELECT_SMALL): + return "SMALL"; + case (SELECT_NAV): + return "NAV"; +#ifndef HAVE_BGL + case SELECT_HTC_S: + return "HTC_S"; + case SELECT_HTC_D: + return "HTC_D"; + case SELECT_HTC_V: + return "HTC_V"; + case SELECT_HTC_L: + return "HTC_L"; +#endif + default: + return ""; + } + return ""; +} + +#ifdef HAVE_BGL +extern char* node_use_string(enum node_use_type node_use) +{ + switch (node_use) { + case (SELECT_COPROCESSOR_MODE): + return "COPROCESSOR"; + case (SELECT_VIRTUAL_NODE_MODE): + return "VIRTUAL"; + default: + break; + } + return ""; +} +#endif + +extern char *bg_block_state_string(uint16_t state) +{ + static char tmp[16]; + +#ifdef HAVE_BG + switch ((rm_partition_state_t)state) { +#ifdef HAVE_BGL + case RM_PARTITION_BUSY: + return "BUSY"; +#else + case RM_PARTITION_REBOOTING: + return "REBOOTING"; +#endif + case RM_PARTITION_CONFIGURING: + return "CONFIG"; + case RM_PARTITION_DEALLOCATING: + return "DEALLOC"; + case RM_PARTITION_ERROR: + return "ERROR"; + case RM_PARTITION_FREE: + return "FREE"; + case RM_PARTITION_NAV: + return "NAV"; + case RM_PARTITION_READY: + return "READY"; + } +#endif + + snprintf(tmp, sizeof(tmp), "%d", state); + return tmp; +} + /* * slurm_free_resource_allocation_response_msg - free slurm resource * allocation response message diff --git a/src/common/slurm_protocol_defs.h b/src/common/slurm_protocol_defs.h index 542b3401b4d..fb5ddd2c81d 100644 --- a/src/common/slurm_protocol_defs.h +++ b/src/common/slurm_protocol_defs.h @@ -1032,6 +1032,13 @@ extern char *node_state_string_compact(uint16_t inx); extern void private_data_string(uint16_t private_data, char *str, int str_len); extern void accounting_enforce_string(uint16_t enforce, char *str, int str_len); +extern char *conn_type_string(enum connection_type conn_type); +#ifdef HAVE_BGL +extern char *node_use_string(enum node_use_type node_use); +#endif +/* Translate a state enum to a readable string */ +extern char *bg_block_state_string(uint16_t state); + /* Validate SPANK specified job environment does not contain any invalid * names. Log failures using info() */ diff --git a/src/plugins/select/bluegene/block_allocator/block_allocator.c b/src/plugins/select/bluegene/block_allocator/block_allocator.c index 7f4b3ff33dd..ffaa57bfe4c 100644 --- a/src/plugins/select/bluegene/block_allocator/block_allocator.c +++ b/src/plugins/select/bluegene/block_allocator/block_allocator.c @@ -214,39 +214,6 @@ static int _set_one_dim(int *start, int *end, int *coord); /* */ static void _destroy_geo(void *object); - -extern char *bg_block_state_string(rm_partition_state_t state) -{ - static char tmp[16]; - -#ifdef HAVE_BG - switch (state) { -#ifdef HAVE_BGL - case RM_PARTITION_BUSY: - return "BUSY"; -#else - case RM_PARTITION_REBOOTING: - return "REBOOTING"; -#endif - case RM_PARTITION_CONFIGURING: - return "CONFIG"; - case RM_PARTITION_DEALLOCATING: - return "DEALLOC"; - case RM_PARTITION_ERROR: - return "ERROR"; - case RM_PARTITION_FREE: - return "FREE"; - case RM_PARTITION_NAV: - return "NAV"; - case RM_PARTITION_READY: - return "READY"; - } -#endif - - snprintf(tmp, sizeof(tmp), "%d", state); - return tmp; -} - extern char *ba_passthroughs_string(uint16_t passthrough) { char *pass = NULL; diff --git a/src/plugins/select/bluegene/block_allocator/block_allocator.h b/src/plugins/select/bluegene/block_allocator/block_allocator.h index 61e62e059fb..41fd629c69d 100644 --- a/src/plugins/select/bluegene/block_allocator/block_allocator.h +++ b/src/plugins/select/bluegene/block_allocator/block_allocator.h @@ -275,9 +275,6 @@ extern s_p_options_t bg_conf_file_options[]; /* used to parse the extern uint16_t ba_deny_pass; extern ba_system_t *ba_system_ptr; -/* Translate a state enum to a readable string */ -extern char *bg_block_state_string(rm_partition_state_t state); - /* must xfree return of this */ extern char *ba_passthroughs_string(uint16_t passthrough); diff --git a/src/plugins/select/bluegene/plugin/bg_job_place.c b/src/plugins/select/bluegene/plugin/bg_job_place.c index d66ce2dc7cb..b576da5418e 100644 --- a/src/plugins/select/bluegene/plugin/bg_job_place.c +++ b/src/plugins/select/bluegene/plugin/bg_job_place.c @@ -483,8 +483,8 @@ static bg_record_t *_find_matching_block(List block_list, debug("bg block %s conn-type not usable asking for %s " "bg_record is %s", bg_record->bg_block_id, - convert_conn_type(request->conn_type), - convert_conn_type(bg_record->conn_type)); + conn_type_string(request->conn_type), + conn_type_string(bg_record->conn_type)); continue; } #ifndef HAVE_BGL diff --git a/src/plugins/select/bluegene/plugin/bg_record_functions.c b/src/plugins/select/bluegene/plugin/bg_record_functions.c index 5000b8b3165..f8eae1c9fe1 100644 --- a/src/plugins/select/bluegene/plugin/bg_record_functions.c +++ b/src/plugins/select/bluegene/plugin/bg_record_functions.c @@ -65,8 +65,10 @@ extern void print_bg_record(bg_record_t* bg_record) bg_record->cpu_cnt); info("\tgeo: %ux%ux%u", bg_record->geo[X], bg_record->geo[Y], bg_record->geo[Z]); - info("\tconn_type: %s", convert_conn_type(bg_record->conn_type)); - info("\tnode_use: %s", convert_node_use(bg_record->node_use)); + info("\tconn_type: %s", conn_type_string(bg_record->conn_type)); +#ifdef HAVE_BGL + info("\tnode_use: %s", node_use_string(bg_record->node_use)); +#endif if (bg_record->bitmap) { char bitstring[BITSIZE]; bit_fmt(bitstring, BITSIZE, bg_record->bitmap); @@ -78,7 +80,7 @@ extern void print_bg_record(bg_record_t* bg_record) format_node_name(bg_record, tmp_char, sizeof(tmp_char)); info("Record: BlockID:%s Nodes:%s Conn:%s", bg_record->bg_block_id, tmp_char, - convert_conn_type(bg_record->conn_type)); + conn_type_string(bg_record->conn_type)); } #endif } @@ -707,13 +709,13 @@ extern int add_bg_record(List records, List used_nodes, blockreq_t *blockreq, #ifdef HAVE_BGL debug2("add_bg_record: asking for %s %d %d %s", blockreq->block, blockreq->small32, blockreq->small128, - convert_conn_type(blockreq->conn_type)); + conn_type_string(blockreq->conn_type)); #else debug2("add_bg_record: asking for %s %d %d %d %d %d %s", blockreq->block, blockreq->small256, blockreq->small128, blockreq->small64, blockreq->small32, blockreq->small16, - convert_conn_type(blockreq->conn_type)); + conn_type_string(blockreq->conn_type)); #endif /* Set the bitmap blank here if it is a full node we don't want anything set we also don't want the bg_record->ionodes set. diff --git a/src/plugins/select/bluegene/plugin/bluegene.c b/src/plugins/select/bluegene/plugin/bluegene.c index 907616de07e..074805a2111 100644 --- a/src/plugins/select/bluegene/plugin/bluegene.c +++ b/src/plugins/select/bluegene/plugin/bluegene.c @@ -290,52 +290,6 @@ extern int set_block_user(bg_record_t *bg_record) return rc; } -extern char* convert_conn_type(rm_connection_type_t conn_type) -{ - switch (conn_type) { - case (SELECT_MESH): - return "MESH"; - case (SELECT_TORUS): - return "TORUS"; - case (SELECT_SMALL): - return "SMALL"; - case (SELECT_NAV): - return "NAV"; -#ifndef HAVE_BGL - case SELECT_HTC_S: - return "HTC_S"; - break; - case SELECT_HTC_D: - return "HTC_D"; - break; - case SELECT_HTC_V: - return "HTC_V"; - break; - case SELECT_HTC_L: - return "HTC_L"; - break; -#endif - default: - break; - } - return ""; -} - -#ifdef HAVE_BGL -extern char* convert_node_use(rm_partition_mode_t pt) -{ - switch (pt) { - case (SELECT_COPROCESSOR_MODE): - return "COPROCESSOR"; - case (SELECT_VIRTUAL_NODE_MODE): - return "VIRTUAL"; - default: - break; - } - return ""; -} -#endif - /** * sort the partitions by increasing size */ @@ -1518,7 +1472,7 @@ static int _validate_config_nodes(List curr_block_list, info("Existing: BlockID:%s Nodes:%s Conn:%s", bg_record->bg_block_id, tmp_char, - convert_conn_type(bg_record->conn_type)); + conn_type_string(bg_record->conn_type)); if(((bg_record->state == RM_PARTITION_READY) || (bg_record->state == RM_PARTITION_CONFIGURING)) && !block_ptr_exist_in_list(bg_lists->booted, @@ -1542,7 +1496,7 @@ static int _validate_config_nodes(List curr_block_list, info("Existing: BlockID:%s Nodes:%s Conn:%s", bg_record->bg_block_id, tmp_char, - convert_conn_type(bg_record->conn_type)); + conn_type_string(bg_record->conn_type)); if(((bg_record->state == RM_PARTITION_READY) || (bg_record->state == RM_PARTITION_CONFIGURING)) diff --git a/src/plugins/select/bluegene/plugin/bluegene.h b/src/plugins/select/bluegene/plugin/bluegene.h index 8654108fe5f..0b9c5b40f6f 100644 --- a/src/plugins/select/bluegene/plugin/bluegene.h +++ b/src/plugins/select/bluegene/plugin/bluegene.h @@ -143,11 +143,6 @@ extern bool blocks_overlap(bg_record_t *rec_a, bg_record_t *rec_b); extern int remove_all_users(char *bg_block_id, char *user_name); extern int set_block_user(bg_record_t *bg_record); -/* Return strings representing blue gene data types */ -extern char *convert_conn_type(rm_connection_type_t conn_type); -#ifdef HAVE_BGL -extern char *convert_node_use(rm_partition_mode_t pt); -#endif /* sort a list of bg_records by size (node count) */ extern void sort_bg_record_inc_size(List records); diff --git a/src/scontrol/Makefile.am b/src/scontrol/Makefile.am index 7e5907dbb0e..fe0f224e81b 100644 --- a/src/scontrol/Makefile.am +++ b/src/scontrol/Makefile.am @@ -8,6 +8,7 @@ bin_PROGRAMS = scontrol scontrol_SOURCES = \ create_res.c \ + info_block.c \ info_job.c \ info_node.c \ info_part.c \ diff --git a/src/scontrol/Makefile.in b/src/scontrol/Makefile.in index e958dece92f..e1b94e786d5 100644 --- a/src/scontrol/Makefile.in +++ b/src/scontrol/Makefile.in @@ -75,10 +75,10 @@ CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) -am_scontrol_OBJECTS = create_res.$(OBJEXT) info_job.$(OBJEXT) \ - info_node.$(OBJEXT) info_part.$(OBJEXT) info_res.$(OBJEXT) \ - scontrol.$(OBJEXT) update_job.$(OBJEXT) update_node.$(OBJEXT) \ - update_part.$(OBJEXT) +am_scontrol_OBJECTS = create_res.$(OBJEXT) info_block.$(OBJEXT) \ + info_job.$(OBJEXT) info_node.$(OBJEXT) info_part.$(OBJEXT) \ + info_res.$(OBJEXT) scontrol.$(OBJEXT) update_job.$(OBJEXT) \ + update_node.$(OBJEXT) update_part.$(OBJEXT) scontrol_OBJECTS = $(am_scontrol_OBJECTS) am__DEPENDENCIES_1 = $(top_builddir)/src/api/libslurm.o am__DEPENDENCIES_2 = @@ -280,6 +280,7 @@ AUTOMAKE_OPTIONS = foreign INCLUDES = -I$(top_srcdir) scontrol_SOURCES = \ create_res.c \ + info_block.c \ info_job.c \ info_node.c \ info_part.c \ @@ -368,6 +369,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/create_res.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info_block.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info_job.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info_node.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info_part.Po@am__quote@ diff --git a/src/scontrol/info_block.c b/src/scontrol/info_block.c new file mode 100644 index 00000000000..ebd610c3141 --- /dev/null +++ b/src/scontrol/info_block.c @@ -0,0 +1,121 @@ +/*****************************************************************************\ + * info_block.c - BlueGene block information functions for scontrol. + ***************************************************************************** + * Copyright (C) 2009 Lawrence Livermore National Security. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Danny Auble <da@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. + * + * In addition, as a special exception, the copyright holders give permission + * to link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. You must obey the GNU + * General Public License in all respects for all of the code used other than + * OpenSSL. If you modify file(s) with this exception, you may extend this + * exception to your version of the file(s), but you are not obligated to do + * so. If you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files in + * the program, then also delete it here. + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +\*****************************************************************************/ + +#include "scontrol.h" + +/* Load current partiton table information into *part_buffer_pptr */ +extern int +scontrol_load_node_select (node_select_info_msg_t **node_select_info_pptr) +{ + int error_code; + static node_select_info_msg_t *last_info_ptr = NULL; + node_select_info_msg_t *info_ptr = NULL; + + if (last_info_ptr) { + error_code = slurm_load_node_select( + last_info_ptr->last_update, &info_ptr); + if (error_code == SLURM_SUCCESS) + slurm_free_node_select(&last_info_ptr); + else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) { + info_ptr = last_info_ptr; + error_code = SLURM_SUCCESS; + if (quiet_flag == -1) + printf ("slurm_load_node_select no " + "change in data\n"); + } + } else + error_code = slurm_load_node_select((time_t)NULL, &info_ptr); + + if (error_code == SLURM_SUCCESS) { + last_info_ptr = info_ptr; + *node_select_info_pptr = info_ptr; + } + + return error_code; +} + +/* + * scontrol_print_node_select - print the specified block's information + * IN block_name - NULL to print information about all block + */ +extern void +scontrol_print_node_select (char *block_name) +{ + int error_code, i, print_cnt = 0; + node_select_info_msg_t *node_select_info_ptr = NULL; + bg_info_record_t *node_select_ptr = NULL; + + error_code = scontrol_load_node_select(&node_select_info_ptr); + if (error_code) { + exit_code = 1; + if (quiet_flag != 1) + slurm_perror ("slurm_load_node_select error"); + return; + } + + if (quiet_flag == -1) { + char time_str[32]; + slurm_make_time_str( + (time_t *)&node_select_info_ptr->last_update, + time_str, sizeof(time_str)); + printf ("last_update_time=%s, records=%d\n", + time_str, node_select_info_ptr->record_count); + } + + node_select_ptr = node_select_info_ptr->bg_info_array; + for (i = 0; i < node_select_info_ptr->record_count; i++) { + if (block_name + && strcmp(block_name, node_select_ptr[i].bg_block_id)) + continue; + print_cnt++; + slurm_print_node_select_info( + stdout, &node_select_ptr[i], one_liner); + if (block_name) + break; + } + + if (print_cnt == 0) { + if (block_name) { + exit_code = 1; + if (quiet_flag != 1) + printf ("Block %s not found\n", + block_name); + } else if (quiet_flag != 1) + printf ("No blocks in the system\n"); + } +} diff --git a/src/scontrol/scontrol.c b/src/scontrol/scontrol.c index 2b22d628443..139f29c1cc4 100644 --- a/src/scontrol/scontrol.c +++ b/src/scontrol/scontrol.c @@ -961,10 +961,11 @@ _show_it (int argc, char *argv[]) val = NULL; } - if (strncasecmp (tag, "config", MAX(taglen, 1)) == 0) { + if (strncasecmp (tag, "blocks", MAX(taglen, 1)) == 0) { + scontrol_print_node_select (val); + } else if (strncasecmp (tag, "config", MAX(taglen, 1)) == 0) { _print_config (val); - } - else if (strncasecmp (tag, "daemons", MAX(taglen, 1)) == 0) { + } else if (strncasecmp (tag, "daemons", MAX(taglen, 1)) == 0) { if (val) { exit_code = 1; if (quiet_flag != 1) @@ -973,46 +974,36 @@ _show_it (int argc, char *argv[]) argv[0]); } _print_daemons (); - } - else if (strncasecmp (tag, "jobs", MAX(taglen, 1)) == 0 || + } else if (strncasecmp (tag, "jobs", MAX(taglen, 1)) == 0 || strncasecmp (tag, "jobid", MAX(taglen, 1)) == 0 ) { scontrol_print_job (val); - } - else if (strncasecmp (tag, "hostnames", MAX(taglen, 5)) == 0) { + } else if (strncasecmp (tag, "hostnames", MAX(taglen, 5)) == 0) { if (val) scontrol_print_hosts(val); else scontrol_print_hosts(getenv("SLURM_NODELIST")); - } - else if (strncasecmp (tag, "hostlist", MAX(taglen, 5)) == 0) { + } else if (strncasecmp (tag, "hostlist", MAX(taglen, 5)) == 0) { if (!val) { exit_code = 1; fprintf(stderr, "invalid encode argument\n"); _usage(); } else if (scontrol_encode_hostlist(val)) exit_code = 1; - } - else if (strncasecmp (tag, "nodes", MAX(taglen, 1)) == 0) { + } else if (strncasecmp (tag, "nodes", MAX(taglen, 1)) == 0) { scontrol_print_node_list (val); - } - else if (strncasecmp (tag, "partitions", MAX(taglen, 1)) == 0 || + } else if (strncasecmp (tag, "partitions", MAX(taglen, 1)) == 0 || strncasecmp (tag, "partitionname", MAX(taglen, 1)) == 0) { scontrol_print_part (val); - } - else if (strncasecmp (tag, "reservations", MAX(taglen, 1)) == 0 || + } else if (strncasecmp (tag, "reservations", MAX(taglen, 1)) == 0 || strncasecmp (tag, "reservationname", MAX(taglen, 1)) == 0) { scontrol_print_res (val); - } - else if (strncasecmp (tag, "slurmd", MAX(taglen, 2)) == 0) { + } else if (strncasecmp (tag, "slurmd", MAX(taglen, 2)) == 0) { _print_slurmd (val); - } - else if (strncasecmp (tag, "steps", MAX(taglen, 2)) == 0) { + } else if (strncasecmp (tag, "steps", MAX(taglen, 2)) == 0) { scontrol_print_step (val); - } - else if (strncasecmp (tag, "topology", MAX(taglen, 1)) == 0) { + } else if (strncasecmp (tag, "topology", MAX(taglen, 1)) == 0) { scontrol_print_topo (val); - } - else { + } else { exit_code = 1; if (quiet_flag != 1) fprintf (stderr, diff --git a/src/scontrol/scontrol.h b/src/scontrol/scontrol.h index d6b4251e4e2..dd6344cb6e8 100644 --- a/src/scontrol/scontrol.h +++ b/src/scontrol/scontrol.h @@ -106,8 +106,10 @@ extern int scontrol_job_notify(int argc, char *argv[]); extern int scontrol_load_jobs (job_info_msg_t ** job_buffer_pptr); extern int scontrol_load_nodes (node_info_msg_t ** node_buffer_pptr, uint16_t show_flags); -extern int scontrol_load_partitions (partition_info_msg_t - **part_info_pptr); +extern int scontrol_load_partitions ( + partition_info_msg_t **part_info_pptr); +extern int scontrol_load_node_select( + node_select_info_msg_t **node_select_info_pptr); extern void scontrol_pid_info(pid_t job_pid); extern void scontrol_print_completing (void); extern void scontrol_print_completing_job(job_info_t *job_ptr, @@ -118,6 +120,7 @@ extern void scontrol_print_node (char *node_name, node_info_msg_t *node_info_ptr); extern void scontrol_print_node_list (char *node_list); extern void scontrol_print_part (char *partition_name); +extern void scontrol_print_node_select (char *block_name); extern void scontrol_print_res (char *reservation_name); extern void scontrol_print_step (char *job_step_id_str); extern void scontrol_print_topo (char *node_list); diff --git a/src/slurmctld/partition_mgr.c b/src/slurmctld/partition_mgr.c index 1b822f1ea4b..9b6b859d39e 100644 --- a/src/slurmctld/partition_mgr.c +++ b/src/slurmctld/partition_mgr.c @@ -723,7 +723,7 @@ extern void part_filter_clear(void) * NOTE: change slurm_load_part() in api/part_info.c if data format changes */ extern void pack_all_part(char **buffer_ptr, int *buffer_size, - uint16_t show_flags, uid_t uid) + uint16_t show_flags, uid_t uid) { ListIterator part_iterator; struct part_record *part_ptr; diff --git a/src/smap/partition_functions.c b/src/smap/partition_functions.c index 1fb4618ca35..571d80e6150 100644 --- a/src/smap/partition_functions.c +++ b/src/smap/partition_functions.c @@ -70,10 +70,6 @@ typedef struct { static List block_list = NULL; #endif -static char* _convert_conn_type(enum connection_type conn_type); -#ifdef HAVE_BGL -static char* _convert_node_use(enum node_use_type node_use); -#endif #ifdef HAVE_BG static int _marknodes(db2_block_info_t *block_ptr, int count); #endif @@ -223,7 +219,7 @@ extern void get_bg_part() } if (bg_info_ptr) { error_code = slurm_load_node_select(bg_info_ptr->last_update, - &new_bg_ptr); + &new_bg_ptr); if (error_code == SLURM_SUCCESS) node_select_info_msg_free(&bg_info_ptr); else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) { @@ -634,7 +630,7 @@ static int _print_text_part(partition_info_t *part_ptr, mvwprintw(text_win, main_ycord, main_xcord, "%.5s", - _convert_conn_type( + conn_type_string( db2_info_ptr-> bg_conn_type)); main_xcord += 7; @@ -642,7 +638,7 @@ static int _print_text_part(partition_info_t *part_ptr, mvwprintw(text_win, main_ycord, main_xcord, "%.9s", - _convert_node_use( + node_use_string( db2_info_ptr->bg_node_use)); main_xcord += 10; #endif @@ -768,10 +764,10 @@ static int _print_text_part(partition_info_t *part_ptr, printf("%8.8s ", tmp_char); printf("%8.8s ", db2_info_ptr->bg_user_name); - printf("%5.5s ", _convert_conn_type( + printf("%5.5s ", conn_type_string( db2_info_ptr->bg_conn_type)); #ifdef HAVE_BGL - printf("%9.9s ", _convert_node_use( + printf("%9.9s ", node_use_string( db2_info_ptr->bg_node_use)); #endif } @@ -977,51 +973,3 @@ static int _make_nodelist(char *nodes, List nodelist) } #endif - -static char* _convert_conn_type(enum connection_type conn_type) -{ -#ifdef HAVE_BG - switch (conn_type) { - case (SELECT_MESH): - return "MESH"; - case (SELECT_TORUS): - return "TORUS"; - case (SELECT_SMALL): - return "SMALL"; - case (SELECT_NAV): - return "NAV"; -#ifndef HAVE_BGL - case SELECT_HTC_S: - return "HTC_S"; - break; - case SELECT_HTC_D: - return "HTC_D"; - break; - case SELECT_HTC_V: - return "HTC_V"; - break; - case SELECT_HTC_L: - return "HTC_L"; - break; -#endif - default: - return "?"; - } -#endif - return "?"; -} - -#ifdef HAVE_BGL -static char* _convert_node_use(enum node_use_type node_use) -{ - switch (node_use) { - case (SELECT_COPROCESSOR_MODE): - return "COPROCESSOR"; - case (SELECT_VIRTUAL_NODE_MODE): - return "VIRTUAL"; - case (SELECT_NAV_MODE): - return "NAV"; - } - return "?"; -} -#endif diff --git a/src/sview/block_info.c b/src/sview/block_info.c index 6c758739ee2..f2ae269486f 100644 --- a/src/sview/block_info.c +++ b/src/sview/block_info.c @@ -111,7 +111,7 @@ static display_data_t display_data_block[] = { create_model_block, admin_edit_block}, {G_TYPE_STRING, SORTID_BLRTSIMAGE, "Blrts Image", FALSE, EDIT_NONE, refresh_block, create_model_block, admin_edit_block}, - {G_TYPE_STRING, SORTID_LINUXIMAGE, "linux Image", + {G_TYPE_STRING, SORTID_LINUXIMAGE, "Linux Image", FALSE, EDIT_NONE, refresh_block, create_model_block, admin_edit_block}, {G_TYPE_STRING, SORTID_RAMDISKIMAGE, "Ramdisk Image", FALSE, EDIT_NONE, refresh_block, create_model_block, admin_edit_block}, @@ -147,10 +147,6 @@ static display_data_t options_data_block[] = { static display_data_t *local_display_data = NULL; -static char* _convert_conn_type(enum connection_type conn_type); -#ifdef HAVE_BGL -static char* _convert_node_use(enum node_use_type node_use); -#endif static int _in_slurm_partition(int *part_inx, int *block_inx); static void _append_block_record(sview_block_info_t *block_ptr, GtkTreeStore *treestore, GtkTreeIter *iter, @@ -203,55 +199,6 @@ static int _in_slurm_partition(int *part_inx, int *bp_inx) return 1; } - -static char* _convert_conn_type(enum connection_type conn_type) -{ -#ifdef HAVE_BG - switch (conn_type) { - case (SELECT_MESH): - return "MESH"; - case (SELECT_TORUS): - return "TORUS"; - case (SELECT_SMALL): - return "SMALL"; - case (SELECT_NAV): - return "NAV"; -#ifndef HAVE_BGL - case SELECT_HTC_S: - return "HTC_S"; - break; - case SELECT_HTC_D: - return "HTC_D"; - break; - case SELECT_HTC_V: - return "HTC_V"; - break; - case SELECT_HTC_L: - return "HTC_L"; - break; -#endif - default: - return "?"; - } -#endif - return "?"; -} - -#ifdef HAVE_BGL -static char* _convert_node_use(enum node_use_type node_use) -{ - switch (node_use) { - case (SELECT_COPROCESSOR_MODE): - return "COPROCESSOR"; - case (SELECT_VIRTUAL_NODE_MODE): - return "VIRTUAL"; - case (SELECT_NAV_MODE): - return "NAV"; - } - return "?"; -} -#endif - static void _layout_block_record(GtkTreeView *treeview, sview_block_info_t *block_ptr, int update) @@ -290,13 +237,13 @@ static void _layout_block_record(GtkTreeView *treeview, add_display_treestore_line(update, treestore, &iter, find_col_name(display_data_block, SORTID_CONN), - _convert_conn_type( + 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_USE), - _convert_node_use(block_ptr->bg_node_use)); + node_use_string(block_ptr->bg_node_use)); #endif convert_num_unit((float)block_ptr->node_cnt, tmp_cnt, sizeof(tmp_cnt), UNIT_NONE); @@ -351,10 +298,10 @@ static void _update_block_record(sview_block_info_t *block_ptr, gtk_tree_store_set(treestore, iter, SORTID_JOB, tmp_cnt, -1); gtk_tree_store_set(treestore, iter, SORTID_CONN, - _convert_conn_type(block_ptr->bg_conn_type), -1); + conn_type_string(block_ptr->bg_conn_type), -1); #ifdef HAVE_BGL gtk_tree_store_set(treestore, iter, SORTID_USE, - _convert_node_use(block_ptr->bg_node_use), -1); + node_use_string(block_ptr->bg_node_use), -1); #endif convert_num_unit((float)block_ptr->node_cnt, tmp_cnt, sizeof(tmp_cnt), UNIT_NONE); -- GitLab