From 94c998e3fbe34a0888a94ebb55e8cd7325301799 Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Thu, 19 May 2005 21:34:59 +0000 Subject: [PATCH] Load bluegene.conf and federation.conf based upon SLURM_CONF env var (if set). --- NEWS | 5 ++++ src/plugins/select/bluegene/bluegene.c | 30 +++++++++++++++++++--- src/plugins/switch/federation/federation.c | 28 ++++++++++++++++++-- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 59e505519e3..c54460aa5de 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,11 @@ This file describes changes in recent versions of SLURM. It primarily documents those changes that are of interest to users and admins. +* Changes in SLURM 0.5.0-pre6 +============================= + -- Load bluegene.conf and federation.conf based upon SLURM_CONF env + var (if set). + * Changes in SLURM 0.5.0-pre5 ============================= -- Modify slurmctld node hashing function to reduce collisions. diff --git a/src/plugins/select/bluegene/bluegene.c b/src/plugins/select/bluegene/bluegene.c index 3409b071450..de9328cffed 100644 --- a/src/plugins/select/bluegene/bluegene.c +++ b/src/plugins/select/bluegene/bluegene.c @@ -36,7 +36,7 @@ #define _DEBUG 0 -char* bgl_conf = BLUEGENE_CONFIG_FILE; +char* bgl_conf = NULL; /* Global variables */ rm_BGL_t *bgl; @@ -670,7 +670,7 @@ extern int create_static_partitions(List part_list) #endif /* Here we are adding a partition that in for the entire machine - just incase it isn't in the bluegene.conf file. + just in case it isn't in the bluegene.conf file. */ reset_pa_system(); @@ -1173,6 +1173,28 @@ static int _delete_old_partitions(void) return SLURM_SUCCESS; } +static char *_get_bgl_conf(void) +{ + char *val = getenv("SLURM_CONF"); + char *rc; + int i; + + if (!val) + return xstrdup(BLUEGENE_CONFIG_FILE); + + /* Replace file name on end of path */ + i = strlen(val) - strlen("slurm.conf") + strlen("bluegene.conf") + 1; + rc = xmalloc(i); + strcpy(rc, val); + val = strrchr(rc, (int)'/'); + if (val) /* absolute path */ + val++; + else /* not absolute path */ + val = rc; + strcpy(val, "bluegene.conf"); + return rc; +} + /* * Read and process the bluegene.conf configuration file so to interpret what * partitions are static/dynamic, torus/mesh, etc. @@ -1190,7 +1212,7 @@ extern int read_bgl_conf(void) /* check if config file has changed */ if (!bgl_conf) - fatal("bluegene.conf file not defined"); + bgl_conf = _get_bgl_conf(); if (stat(bgl_conf, &config_stat) < 0) fatal("can't stat bluegene.conf file %s: %m", bgl_conf); if (last_config_update) { @@ -1222,6 +1244,7 @@ extern int read_bgl_conf(void) error("_read_bgl_config line %d, of input file %s " "too long", line_num, bgl_conf); fclose(bgl_spec_file); + xfree(bgl_conf); return E2BIG; } @@ -1251,6 +1274,7 @@ extern int read_bgl_conf(void) report_leftover(in_line, line_num); } fclose(bgl_spec_file); + xfree(bgl_conf); if (!bluegene_blrts) fatal("BlrtsImage not configured in bluegene.conf"); diff --git a/src/plugins/switch/federation/federation.c b/src/plugins/switch/federation/federation.c index 30adc079e18..d455e63b259 100644 --- a/src/plugins/switch/federation/federation.c +++ b/src/plugins/switch/federation/federation.c @@ -65,7 +65,7 @@ #define ZERO 48 #define BUFSIZE 4096 -char* fed_conf = FEDERATION_CONFIG_FILE; +char* fed_conf = NULL; /* * Data structures specific to Federation @@ -398,6 +398,28 @@ static int _set_up_adapter(fed_adapter_t *fed_adapter, char *adapter_name) return SLURM_SUCCESS; } +static char *_get_fed_conf(void) +{ + char *val = getenv("SLURM_CONF"); + char *rc; + int i; + + if (!val) + return xstrdup(FEDERATION_CONFIG_FILE); + + /* Replace file name on end of path */ + i = strlen(val) - strlen("slurm.conf") + strlen("federation.conf") + 1; + rc = xmalloc(i); + strcpy(rc, val); + val = strrchr(rc, (int)'/'); + if (val) /* absolute path */ + val++; + else /* not absolute path */ + val = rc; + strcpy(val, "federation.conf"); + return rc; +} + static int _parse_fed_file(hostlist_t *adapter_list) { FILE *fed_spec_file; /* pointer to input data file */ @@ -409,7 +431,7 @@ static int _parse_fed_file(hostlist_t *adapter_list) debug("Reading the federation.conf file"); if (!fed_conf) - fatal("federation.conf file not defined"); + fed_conf = _get_fed_conf(); fed_spec_file = fopen(fed_conf, "r"); if (fed_spec_file == NULL) fatal("_get_adapters error opening file %s, %m", @@ -423,6 +445,7 @@ static int _parse_fed_file(hostlist_t *adapter_list) error("_get_adapters line %d, of input file %s " "too long", line_num, fed_conf); fclose(fed_spec_file); + xfree(fed_conf); return E2BIG; } @@ -444,6 +467,7 @@ static int _parse_fed_file(hostlist_t *adapter_list) report_leftover(in_line, line_num); } fclose(fed_spec_file); + xfree(fed_conf); return SLURM_SUCCESS; } -- GitLab