/src/common/slurm_protocol_api.c
C | 3803 lines | 2432 code | 469 blank | 902 comment | 444 complexity | 1d3b20f4ed4c4eb5bcf66e63a2d209a7 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0
Large files files are truncated, but you can click here to view the full file
- /*****************************************************************************\
- * slurm_protocol_api.c - high-level slurm communication functions
- *****************************************************************************
- * Copyright (C) 2002-2007 The Regents of the University of California.
- * Copyright (C) 2008-2010 Lawrence Livermore National Security.
- * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- * Written by Kevin Tew <tew1@llnl.gov>, et. al.
- * CODE-OCEC-09-009. All rights reserved.
- *
- * This file is part of SLURM, a resource management program.
- * For details, see <http://www.schedmd.com/slurmdocs/>.
- * 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.
- \*****************************************************************************/
- #if HAVE_CONFIG_H
- # include "config.h"
- #endif
- /* GLOBAL INCLUDES */
- #ifdef WITH_PTHREADS
- # include <pthread.h>
- #endif /* WITH_PTHREADS */
- #include <errno.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <time.h>
- #include <unistd.h>
- #include <ctype.h>
- /* PROJECT INCLUDES */
- #include "src/common/macros.h"
- #include "src/common/pack.h"
- #include "src/common/parse_spec.h"
- #include "src/common/read_config.h"
- #include "src/common/slurm_auth.h"
- #include "src/common/slurm_protocol_interface.h"
- #include "src/common/slurm_protocol_api.h"
- #include "src/common/slurm_protocol_common.h"
- #include "src/common/slurm_protocol_pack.h"
- #include "src/common/xmalloc.h"
- #include "src/common/xstring.h"
- #include "src/common/log.h"
- #include "src/common/forward.h"
- #include "src/slurmdbd/read_config.h"
- #include "src/common/slurm_accounting_storage.h"
- /* EXTERNAL VARIABLES */
- /* #DEFINES */
- #define _DEBUG 0
- #define MAX_SHUTDOWN_RETRY 5
- /* STATIC VARIABLES */
- /* static pthread_mutex_t config_lock = PTHREAD_MUTEX_INITIALIZER; */
- static slurm_protocol_config_t proto_conf_default;
- static slurm_protocol_config_t *proto_conf = &proto_conf_default;
- /* static slurm_ctl_conf_t slurmctld_conf; */
- static int message_timeout = -1;
- /* STATIC FUNCTIONS */
- static char *_global_auth_key(void);
- static void _remap_slurmctld_errno(void);
- static int _unpack_msg_uid(Buf buffer);
- #if _DEBUG
- static void _print_data(char *data, int len);
- #endif
- /* define the slurmdbd_options flag */
- slurm_dbd_conf_t *slurmdbd_conf = NULL;
- /**********************************************************************\
- * protocol configuration functions
- \**********************************************************************/
- /* slurm_set_api_config
- * sets the slurm_protocol_config object
- * NOT THREAD SAFE
- * IN protocol_conf - slurm_protocol_config object
- *
- * XXX: Why isn't the "config_lock" mutex used here?
- */
- int slurm_set_api_config(slurm_protocol_config_t * protocol_conf)
- {
- proto_conf = protocol_conf;
- return SLURM_SUCCESS;
- }
- /* slurm_get_api_config
- * returns a pointer to the current slurm_protocol_config object
- * RET slurm_protocol_config_t - current slurm_protocol_config object
- */
- slurm_protocol_config_t *slurm_get_api_config(void)
- {
- return proto_conf;
- }
- /* slurm_api_set_conf_file
- * set slurm configuration file to a non-default value
- * pathname IN - pathname of slurm configuration file to be used
- */
- extern void slurm_api_set_conf_file(char *pathname)
- {
- slurm_conf_reinit(pathname);
- return;
- }
- /* slurm_api_set_default_config
- * called by the send_controller_msg function to insure that at least
- * the compiled in default slurm_protocol_config object is initialized
- * RET int - return code
- */
- int slurm_api_set_default_config(void)
- {
- int rc = SLURM_SUCCESS;
- slurm_ctl_conf_t *conf;
- /*slurm_conf_init(NULL);*/
- conf = slurm_conf_lock();
- if (conf->control_addr == NULL) {
- error("Unable to establish controller machine");
- rc = SLURM_ERROR;
- goto cleanup;
- }
- if (conf->slurmctld_port == 0) {
- error("Unable to establish controller port");
- rc = SLURM_ERROR;
- goto cleanup;
- }
- slurm_set_addr(&proto_conf_default.primary_controller,
- conf->slurmctld_port,
- conf->control_addr);
- if (proto_conf_default.primary_controller.sin_port == 0) {
- error("Unable to establish control machine address");
- rc = SLURM_ERROR;
- goto cleanup;
- }
- if (conf->backup_addr) {
- slurm_set_addr(&proto_conf_default.secondary_controller,
- conf->slurmctld_port,
- conf->backup_addr);
- }
- proto_conf = &proto_conf_default;
- cleanup:
- slurm_conf_unlock();
- return rc;
- }
- /* slurm_api_clear_config
- * execute this only at program termination to free all memory */
- void slurm_api_clear_config(void)
- {
- slurm_conf_destroy();
- }
- /* slurm_get_complete_wait
- * RET CompleteWait value from slurm.conf
- */
- uint16_t slurm_get_complete_wait(void)
- {
- uint16_t complete_wait = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- complete_wait = conf->complete_wait;
- slurm_conf_unlock();
- }
- return complete_wait;
- }
- /* update internal configuration data structure as needed.
- * exit with lock set */
- /* static inline void _lock_update_config() */
- /* { */
- /* slurm_api_set_default_config(); */
- /* slurm_mutex_lock(&config_lock); */
- /* } */
- /* slurm_get_batch_start_timeout
- * RET BatchStartTimeout value from slurm.conf
- */
- uint16_t slurm_get_batch_start_timeout(void)
- {
- uint16_t batch_start_timeout = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- batch_start_timeout = conf->batch_start_timeout;
- slurm_conf_unlock();
- }
- return batch_start_timeout;
- }
- /* slurm_get_suspend_timeout
- * RET SuspendTimeout value from slurm.conf
- */
- uint16_t slurm_get_suspend_timeout(void)
- {
- uint16_t suspend_timeout = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- suspend_timeout = conf->suspend_timeout;
- slurm_conf_unlock();
- }
- return suspend_timeout;
- }
- /* slurm_get_resume_timeout
- * RET ResumeTimeout value from slurm.conf
- */
- uint16_t slurm_get_resume_timeout(void)
- {
- uint16_t resume_timeout = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- resume_timeout = conf->resume_timeout;
- slurm_conf_unlock();
- }
- return resume_timeout;
- }
- /* slurm_get_suspend_time
- * RET SuspendTime value from slurm.conf
- */
- uint32_t slurm_get_suspend_time(void)
- {
- uint32_t suspend_time = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- suspend_time = conf->suspend_time;
- slurm_conf_unlock();
- }
- return suspend_time;
- }
- /* slurm_get_def_mem_per_cpu
- * RET DefMemPerCPU/Node value from slurm.conf
- */
- uint32_t slurm_get_def_mem_per_cpu(void)
- {
- uint32_t mem_per_cpu = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- mem_per_cpu = conf->def_mem_per_cpu;
- slurm_conf_unlock();
- }
- return mem_per_cpu;
- }
- /* slurm_get_kill_on_bad_exit
- * RET KillOnBadExit value from slurm.conf
- */
- uint16_t slurm_get_kill_on_bad_exit(void)
- {
- uint16_t kill_on_bad_exit = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- kill_on_bad_exit = conf->kill_on_bad_exit;
- slurm_conf_unlock();
- }
- return kill_on_bad_exit;
- }
- /* slurm_get_debug_flags
- * RET DebugFlags value from slurm.conf
- */
- uint32_t slurm_get_debug_flags(void)
- {
- uint32_t debug_flags = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- debug_flags = conf->debug_flags;
- slurm_conf_unlock();
- }
- return debug_flags;
- }
- /* slurm_set_debug_flags
- */
- void slurm_set_debug_flags(uint32_t debug_flags)
- {
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- conf->debug_flags = debug_flags;
- slurm_conf_unlock();
- }
- }
- /* slurm_get_max_mem_per_cpu
- * RET MaxMemPerCPU/Node value from slurm.conf
- */
- uint32_t slurm_get_max_mem_per_cpu(void)
- {
- uint32_t mem_per_cpu = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- mem_per_cpu = conf->max_mem_per_cpu;
- slurm_conf_unlock();
- }
- return mem_per_cpu;
- }
- /* slurm_get_epilog_msg_time
- * RET EpilogMsgTime value from slurm.conf
- */
- uint32_t slurm_get_epilog_msg_time(void)
- {
- uint32_t epilog_msg_time = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- epilog_msg_time = conf->epilog_msg_time;
- slurm_conf_unlock();
- }
- return epilog_msg_time;
- }
- /* slurm_get_env_timeout
- * return default timeout for srun/sbatch --get-user-env option
- */
- extern int slurm_get_env_timeout(void)
- {
- int timeout = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- timeout = conf->get_env_timeout;
- slurm_conf_unlock();
- }
- return timeout;
- }
- /* slurm_get_mpi_default
- * get default mpi value from slurmctld_conf object
- * RET char * - mpi default value from slurm.conf, MUST be xfreed by caller
- */
- char *slurm_get_mpi_default(void)
- {
- char *mpi_default = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- mpi_default = xstrdup(conf->mpi_default);
- slurm_conf_unlock();
- }
- return mpi_default;
- }
- /* slurm_get_mpi_params
- * get mpi parameters value from slurmctld_conf object
- * RET char * - mpi default value from slurm.conf, MUST be xfreed by caller
- */
- char *slurm_get_mpi_params(void)
- {
- char *mpi_params = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- mpi_params = xstrdup(conf->mpi_params);
- slurm_conf_unlock();
- }
- return mpi_params;
- }
- /* slurm_get_msg_timeout
- * get default message timeout value from slurmctld_conf object
- */
- uint16_t slurm_get_msg_timeout(void)
- {
- uint16_t msg_timeout = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- msg_timeout = slurmdbd_conf->msg_timeout;
- } else {
- conf = slurm_conf_lock();
- msg_timeout = conf->msg_timeout;
- slurm_conf_unlock();
- #ifdef MEMORY_LEAK_DEBUG
- msg_timeout *= 4;
- #endif
- }
- return msg_timeout;
- }
- /* slurm_get_plugin_dir
- * get plugin directory from slurmctld_conf object
- * RET char * - plugin directory, MUST be xfreed by caller
- */
- char *slurm_get_plugin_dir(void)
- {
- char *plugin_dir = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- plugin_dir = xstrdup(slurmdbd_conf->plugindir);
- } else {
- conf = slurm_conf_lock();
- plugin_dir = xstrdup(conf->plugindir);
- slurm_conf_unlock();
- }
- return plugin_dir;
- }
- /* slurm_get_priority_decay_hl
- * returns the priority decay half life in seconds from slurmctld_conf object
- * RET uint32_t - decay_hl in secs.
- */
- uint32_t slurm_get_priority_decay_hl(void)
- {
- uint32_t priority_hl = NO_VAL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- priority_hl = conf->priority_decay_hl;
- slurm_conf_unlock();
- }
- return priority_hl;
- }
- /* slurm_get_priority_calc_period
- * returns the seconds between priority decay calculation from slurmctld_conf
- * RET uint32_t - calc_period in secs.
- */
- uint32_t slurm_get_priority_calc_period(void)
- {
- uint32_t calc_period = NO_VAL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- calc_period = conf->priority_calc_period;
- slurm_conf_unlock();
- }
- return calc_period;
- }
- /* slurm_get_priority_favor_small
- * returns weither or not we are favoring small jobs from slurmctld_conf object
- * RET bool - true if favor small, false else.
- */
- bool slurm_get_priority_favor_small(void)
- {
- bool factor = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- factor = conf->priority_favor_small;
- slurm_conf_unlock();
- }
- return factor;
- }
- /* slurm_get_priority_max_age
- * returns the priority age max in seconds from slurmctld_conf object
- * RET uint32_t - age_max in secs.
- */
- uint32_t slurm_get_priority_max_age(void)
- {
- uint32_t age = NO_VAL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- age = conf->priority_max_age;
- slurm_conf_unlock();
- }
- return age;
- }
- /* slurm_get_priority_reset_period
- * returns the priority usage reset period from slurmctld_conf object
- * RET uint16_t - flag, see PRIORITY_RESET_* in slurm/slurm.h.
- */
- uint16_t slurm_get_priority_reset_period(void)
- {
- uint16_t reset_period = (uint16_t) 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- reset_period = conf->priority_reset_period;
- slurm_conf_unlock();
- }
- return reset_period;
- }
- /* slurm_get_priority_type
- * returns the priority type from slurmctld_conf object
- * RET char * - priority type, MUST be xfreed by caller
- */
- char *slurm_get_priority_type(void)
- {
- char *priority_type = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- priority_type = xstrdup(conf->priority_type);
- slurm_conf_unlock();
- }
- return priority_type;
- }
- /* slurm_get_priority_weight_age
- * returns the priority weight for age from slurmctld_conf object
- * RET uint32_t - factor weight.
- */
- uint32_t slurm_get_priority_weight_age(void)
- {
- uint32_t factor = NO_VAL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- factor = conf->priority_weight_age;
- slurm_conf_unlock();
- }
- return factor;
- }
- /* slurm_get_priority_weight_fairshare
- * returns the priority weight for fairshare from slurmctld_conf object
- * RET uint32_t - factor weight.
- */
- uint32_t slurm_get_priority_weight_fairshare(void)
- {
- uint32_t factor = NO_VAL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- factor = conf->priority_weight_fs;
- slurm_conf_unlock();
- }
- return factor;
- }
- /* slurm_get_priority_weight_job_size
- * returns the priority weight for job size from slurmctld_conf object
- * RET uint32_t - factor weight.
- */
- uint32_t slurm_get_priority_weight_job_size(void)
- {
- uint32_t factor = NO_VAL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- factor = conf->priority_weight_js;
- slurm_conf_unlock();
- }
- return factor;
- }
- /* slurm_get_priority_weight_partition
- * returns the priority weight for partitions from slurmctld_conf object
- * RET uint32_t - factor weight.
- */
- uint32_t slurm_get_priority_weight_partition(void)
- {
- uint32_t factor = NO_VAL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- factor = conf->priority_weight_part;
- slurm_conf_unlock();
- }
- return factor;
- }
- /* slurm_get_priority_weight_qos
- * returns the priority weight for QOS from slurmctld_conf object
- * RET uint32_t - factor weight.
- */
- uint32_t slurm_get_priority_weight_qos(void)
- {
- uint32_t factor = NO_VAL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- factor = conf->priority_weight_qos;
- slurm_conf_unlock();
- }
- return factor;
- }
- /* slurm_get_private_data
- * get private data from slurmctld_conf object
- */
- uint16_t slurm_get_private_data(void)
- {
- uint16_t private_data = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- private_data = slurmdbd_conf->private_data;
- } else {
- conf = slurm_conf_lock();
- private_data = conf->private_data;
- slurm_conf_unlock();
- }
- return private_data;
- }
- /* slurm_get_state_save_location
- * get state_save_location from slurmctld_conf object from slurmctld_conf object
- * RET char * - state_save_location directory, MUST be xfreed by caller
- */
- char *slurm_get_state_save_location(void)
- {
- char *state_save_loc = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- state_save_loc = xstrdup(conf->state_save_location);
- slurm_conf_unlock();
- }
- return state_save_loc;
- }
- /* slurm_get_auth_type
- * returns the authentication type from slurmctld_conf object
- * RET char * - auth type, MUST be xfreed by caller
- */
- char *slurm_get_auth_type(void)
- {
- char *auth_type = NULL;
- slurm_ctl_conf_t *conf = NULL;
- if (slurmdbd_conf) {
- auth_type = xstrdup(slurmdbd_conf->auth_type);
- } else {
- conf = slurm_conf_lock();
- auth_type = xstrdup(conf->authtype);
- slurm_conf_unlock();
- }
- return auth_type;
- }
- /* slurm_get_checkpoint_type
- * returns the checkpoint_type from slurmctld_conf object
- * RET char * - checkpoint type, MUST be xfreed by caller
- */
- extern char *slurm_get_checkpoint_type(void)
- {
- char *checkpoint_type = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- checkpoint_type = xstrdup(conf->checkpoint_type);
- slurm_conf_unlock();
- }
- return checkpoint_type;
- }
- /* slurm_get_cluster_name
- * returns the cluster name from slurmctld_conf object
- * RET char * - cluster name, MUST be xfreed by caller
- */
- char *slurm_get_cluster_name(void)
- {
- char *name = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- name = xstrdup(conf->cluster_name);
- slurm_conf_unlock();
- }
- return name;
- }
- /* slurm_get_crypto_type
- * returns the crypto_type from slurmctld_conf object
- * RET char * - crypto type, MUST be xfreed by caller
- */
- extern char *slurm_get_crypto_type(void)
- {
- char *crypto_type = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- crypto_type = xstrdup(conf->crypto_type);
- slurm_conf_unlock();
- }
- return crypto_type;
- }
- /* slurm_get_topology_plugin
- * returns the value of topology_plugin in slurmctld_conf object
- * RET char * - topology type, MUST be xfreed by caller
- */
- extern char * slurm_get_topology_plugin(void)
- {
- char *topology_plugin = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- topology_plugin = xstrdup(conf->topology_plugin);
- slurm_conf_unlock();
- }
- return topology_plugin;
- }
- /* slurm_get_propagate_prio_process
- * return the PropagatePrioProcess flag from slurmctld_conf object
- */
- extern uint16_t slurm_get_propagate_prio_process(void)
- {
- uint16_t propagate_prio = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- propagate_prio = conf->propagate_prio_process;
- slurm_conf_unlock();
- }
- return propagate_prio;
- }
- /* slurm_get_fast_schedule
- * returns the value of fast_schedule in slurmctld_conf object
- */
- extern uint16_t slurm_get_fast_schedule(void)
- {
- uint16_t fast_val = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- fast_val = conf->fast_schedule;
- slurm_conf_unlock();
- }
- return fast_val;
- }
- /* slurm_get_track_wckey
- * returns the value of track_wckey in slurmctld_conf object
- */
- extern uint16_t slurm_get_track_wckey(void)
- {
- uint16_t track_wckey = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- track_wckey = slurmdbd_conf->track_wckey;
- } else {
- conf = slurm_conf_lock();
- track_wckey = conf->track_wckey;
- slurm_conf_unlock();
- }
- return track_wckey;
- }
- /* slurm_set_tree_width
- * sets the value of tree_width in slurmctld_conf object
- * RET 0 or error code
- */
- extern int slurm_set_tree_width(uint16_t tree_width)
- {
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- if (tree_width == 0) {
- error("can't have span count of 0");
- return SLURM_ERROR;
- }
- conf->tree_width = tree_width;
- slurm_conf_unlock();
- }
- return 0;
- }
- /* slurm_get_tree_width
- * returns the value of tree_width in slurmctld_conf object
- */
- extern uint16_t slurm_get_tree_width(void)
- {
- uint16_t tree_width = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- tree_width = conf->tree_width;
- slurm_conf_unlock();
- }
- return tree_width;
- }
- /* slurm_get_vsize_factor
- * returns the value of vsize_factor in slurmctld_conf object
- */
- extern uint16_t slurm_get_vsize_factor(void)
- {
- uint16_t vsize_factor = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- vsize_factor = conf->vsize_factor;
- slurm_conf_unlock();
- }
- return vsize_factor;
- }
- /* slurm_set_auth_type
- * set the authentication type in slurmctld_conf object
- * used for security testing purposes
- * RET 0 or error code
- */
- extern int slurm_set_auth_type(char *auth_type)
- {
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- xfree(slurmdbd_conf->auth_type);
- slurmdbd_conf->auth_type = xstrdup(auth_type);
- } else {
- conf = slurm_conf_lock();
- xfree(conf->authtype);
- conf->authtype = xstrdup(auth_type);
- slurm_conf_unlock();
- }
- return 0;
- }
- /* slurm_get_hash_val
- * get hash val of the slurm.conf from slurmctld_conf object from
- * slurmctld_conf object
- * RET uint32_t - hash_val
- */
- uint32_t slurm_get_hash_val(void)
- {
- uint32_t hash_val;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- hash_val = NO_VAL;
- } else {
- conf = slurm_conf_lock();
- hash_val = conf->hash_val;
- slurm_conf_unlock();
- }
- return hash_val;
- }
- /* slurm_get_health_check_program
- * get health_check_program from slurmctld_conf object from
- * slurmctld_conf object
- * RET char * - health_check_program, MUST be xfreed by caller
- */
- char *slurm_get_health_check_program(void)
- {
- char *health_check_program = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- health_check_program = xstrdup(conf->health_check_program);
- slurm_conf_unlock();
- }
- return health_check_program;
- }
- /* slurm_get_gres_plugins
- * get gres_plugins from slurmctld_conf object from
- * slurmctld_conf object
- * RET char * - gres_plugins, MUST be xfreed by caller
- */
- char *slurm_get_gres_plugins(void)
- {
- char *gres_plugins = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- gres_plugins = xstrdup(conf->gres_plugins);
- slurm_conf_unlock();
- }
- return gres_plugins;
- }
- /* slurm_get_job_submit_plugins
- * get job_submit_plugins from slurmctld_conf object from
- * slurmctld_conf object
- * RET char * - job_submit_plugins, MUST be xfreed by caller
- */
- char *slurm_get_job_submit_plugins(void)
- {
- char *job_submit_plugins = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- job_submit_plugins = xstrdup(conf->job_submit_plugins);
- slurm_conf_unlock();
- }
- return job_submit_plugins;
- }
- /* slurm_get_accounting_storage_type
- * returns the accounting storage type from slurmctld_conf object
- * RET char * - accounting storage type, MUST be xfreed by caller
- */
- char *slurm_get_accounting_storage_type(void)
- {
- char *accounting_type;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- accounting_type = xstrdup(slurmdbd_conf->storage_type);
- } else {
- conf = slurm_conf_lock();
- accounting_type = xstrdup(conf->accounting_storage_type);
- slurm_conf_unlock();
- }
- return accounting_type;
- }
- /* slurm_get_accounting_storage_user
- * returns the storage user from slurmctld_conf object
- * RET char * - storage user, MUST be xfreed by caller
- */
- char *slurm_get_accounting_storage_user(void)
- {
- char *storage_user;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- storage_user = xstrdup(slurmdbd_conf->storage_user);
- } else {
- conf = slurm_conf_lock();
- storage_user = xstrdup(conf->accounting_storage_user);
- slurm_conf_unlock();
- }
- return storage_user;
- }
- /* slurm_set_accounting_storage_user
- * IN: char *user (name of file or database)
- * RET 0 or error code
- */
- int slurm_set_accounting_storage_user(char *user)
- {
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- xfree(slurmdbd_conf->storage_user);
- slurmdbd_conf->storage_user = xstrdup(user);
- } else {
- conf = slurm_conf_lock();
- xfree(conf->accounting_storage_user);
- conf->accounting_storage_user = xstrdup(user);
- slurm_conf_unlock();
- }
- return 0;
- }
- /* slurm_get_accounting_storage_backup_host
- * returns the storage backup host from slurmctld_conf object
- * RET char * - storage backup host, MUST be xfreed by caller
- */
- char *slurm_get_accounting_storage_backup_host(void)
- {
- char *storage_host;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- storage_host = xstrdup(slurmdbd_conf->storage_backup_host);
- } else {
- conf = slurm_conf_lock();
- storage_host = xstrdup(conf->accounting_storage_backup_host);
- slurm_conf_unlock();
- }
- return storage_host;
- }
- /* slurm_get_accounting_storage_host
- * returns the storage host from slurmctld_conf object
- * RET char * - storage host, MUST be xfreed by caller
- */
- char *slurm_get_accounting_storage_host(void)
- {
- char *storage_host;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- storage_host = xstrdup(slurmdbd_conf->storage_host);
- } else {
- conf = slurm_conf_lock();
- storage_host = xstrdup(conf->accounting_storage_host);
- slurm_conf_unlock();
- }
- return storage_host;
- }
- /* slurm_set_accounting_storage_host
- * IN: char *host (name of file or database)
- * RET 0 or error code
- */
- int slurm_set_accounting_storage_host(char *host)
- {
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- xfree(slurmdbd_conf->storage_host);
- slurmdbd_conf->storage_host = xstrdup(host);
- } else {
- conf = slurm_conf_lock();
- xfree(conf->accounting_storage_host);
- conf->accounting_storage_host = xstrdup(host);
- slurm_conf_unlock();
- }
- return 0;
- }
- /* slurm_get_accounting_storage_loc
- * returns the storage location from slurmctld_conf object
- * RET char * - storage location, MUST be xfreed by caller
- */
- char *slurm_get_accounting_storage_loc(void)
- {
- char *storage_loc;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- storage_loc = xstrdup(slurmdbd_conf->storage_loc);
- } else {
- conf = slurm_conf_lock();
- storage_loc = xstrdup(conf->accounting_storage_loc);
- slurm_conf_unlock();
- }
- return storage_loc;
- }
- /* slurm_set_accounting_storage_loc
- * IN: char *loc (name of file or database)
- * RET 0 or error code
- */
- int slurm_set_accounting_storage_loc(char *loc)
- {
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- xfree(slurmdbd_conf->storage_loc);
- slurmdbd_conf->storage_loc = xstrdup(loc);
- } else {
- conf = slurm_conf_lock();
- xfree(conf->accounting_storage_loc);
- conf->accounting_storage_loc = xstrdup(loc);
- slurm_conf_unlock();
- }
- return 0;
- }
- /* slurm_get_accounting_storage_enforce
- * returns what level to enforce associations at
- */
- int slurm_get_accounting_storage_enforce(void)
- {
- int enforce = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- enforce = conf->accounting_storage_enforce;
- slurm_conf_unlock();
- }
- return enforce;
- }
- /* slurm_get_is_association_based_accounting
- * returns if we are doing accounting by associations
- */
- int slurm_get_is_association_based_accounting(void)
- {
- int enforce = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- return 1;
- } else {
- conf = slurm_conf_lock();
- if (!strcasecmp(conf->accounting_storage_type,
- "accounting_storage/slurmdbd") ||
- !strcasecmp(conf->accounting_storage_type,
- "accounting_storage/mysql") ||
- !strcasecmp(conf->accounting_storage_type,
- "accounting_storage/pgsql"))
- enforce = 1;
- slurm_conf_unlock();
- }
- return enforce;
- }
- /* slurm_get_accounting_storage_pass
- * returns the storage password from slurmctld_conf object
- * RET char * - storage password, MUST be xfreed by caller
- */
- char *slurm_get_accounting_storage_pass(void)
- {
- char *storage_pass;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- storage_pass = xstrdup(slurmdbd_conf->storage_pass);
- } else {
- conf = slurm_conf_lock();
- storage_pass = xstrdup(conf->accounting_storage_pass);
- slurm_conf_unlock();
- }
- return storage_pass;
- }
- /* _global_auth_key
- * returns the storage password from slurmctld_conf or slurmdbd_conf object
- * cache value in local buffer for best performance
- * RET char * - storage password
- */
- static char *_global_auth_key(void)
- {
- static bool loaded_storage_pass = false;
- static char storage_pass[512] = "\0";
- static char *storage_pass_ptr = NULL;
- slurm_ctl_conf_t *conf;
- if (loaded_storage_pass)
- return storage_pass_ptr;
- if (slurmdbd_conf) {
- if (slurmdbd_conf->auth_info) {
- if (strlen(slurmdbd_conf->auth_info) >
- sizeof(storage_pass))
- fatal("AuthInfo is too long");
- strncpy(storage_pass, slurmdbd_conf->auth_info,
- sizeof(storage_pass));
- storage_pass_ptr = storage_pass;
- }
- } else {
- conf = slurm_conf_lock();
- if (conf->accounting_storage_pass) {
- if (strlen(conf->accounting_storage_pass) >
- sizeof(storage_pass))
- fatal("AccountingStoragePass is too long");
- strncpy(storage_pass, conf->accounting_storage_pass,
- sizeof(storage_pass));
- storage_pass_ptr = storage_pass;
- }
- slurm_conf_unlock();
- }
- loaded_storage_pass = true;
- return storage_pass_ptr;
- }
- /* slurm_get_accounting_storage_port
- * returns the storage port from slurmctld_conf object
- * RET uint32_t - storage port
- */
- uint32_t slurm_get_accounting_storage_port(void)
- {
- uint32_t storage_port;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- storage_port = slurmdbd_conf->storage_port;
- } else {
- conf = slurm_conf_lock();
- storage_port = conf->accounting_storage_port;
- slurm_conf_unlock();
- }
- return storage_port;
- }
- /* slurm_set_accounting_storage_port
- * sets the storage port in slurmctld_conf object
- * RET 0 or error code
- */
- int slurm_set_accounting_storage_port(uint32_t storage_port)
- {
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- slurmdbd_conf->storage_port = storage_port;
- } else {
- conf = slurm_conf_lock();
- if (storage_port == 0) {
- error("can't have storage port of 0");
- return SLURM_ERROR;
- }
- conf->accounting_storage_port = storage_port;
- slurm_conf_unlock();
- }
- return 0;
- }
- /* slurm_get_preempt_mode
- * returns the PreemptMode value from slurmctld_conf object
- * RET uint16_t - PreemptMode value (See PREEMPT_MODE_* in slurm.h)
- */
- uint16_t slurm_get_preempt_mode(void)
- {
- uint16_t preempt_mode = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- preempt_mode = conf->preempt_mode;
- slurm_conf_unlock();
- }
- return preempt_mode;
- }
- /* slurm_get_jobacct_gather_type
- * returns the job accounting type from the slurmctld_conf object
- * RET char * - job accounting type, MUST be xfreed by caller
- */
- char *slurm_get_jobacct_gather_type(void)
- {
- char *jobacct_type = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- jobacct_type = xstrdup(conf->job_acct_gather_type);
- slurm_conf_unlock();
- }
- return jobacct_type;
- }
- /* slurm_get_jobacct_freq
- * returns the job accounting poll frequency from the slurmctld_conf object
- * RET int - job accounting frequency
- */
- uint16_t slurm_get_jobacct_gather_freq(void)
- {
- uint16_t freq = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- freq = conf->job_acct_gather_freq;
- slurm_conf_unlock();
- }
- return freq;
- }
- /* slurm_get_energy_accounting_type
- * get EnergyAccountingType from slurmctld_conf object
- * RET char * - energy_accounting type, MUST be xfreed by caller
- */
- char *slurm_get_acct_gather_energy_type(void)
- {
- char *acct_gather_energy_type = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- acct_gather_energy_type =
- xstrdup(conf->acct_gather_energy_type);
- slurm_conf_unlock();
- }
- return acct_gather_energy_type;
- }
- extern uint16_t slurm_get_acct_gather_node_freq(void)
- {
- uint16_t freq = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- freq = conf->acct_gather_node_freq;
- slurm_conf_unlock();
- }
- return freq;
- }
- /* slurm_get_jobcomp_type
- * returns the job completion logger type from slurmctld_conf object
- * RET char * - job completion type, MUST be xfreed by caller
- */
- char *slurm_get_jobcomp_type(void)
- {
- char *jobcomp_type = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- jobcomp_type = xstrdup(conf->job_comp_type);
- slurm_conf_unlock();
- }
- return jobcomp_type;
- }
- /* slurm_get_jobcomp_loc
- * returns the job completion loc from slurmctld_conf object
- * RET char * - job completion location, MUST be xfreed by caller
- */
- char *slurm_get_jobcomp_loc(void)
- {
- char *jobcomp_loc = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- jobcomp_loc = xstrdup(conf->job_comp_loc);
- slurm_conf_unlock();
- }
- return jobcomp_loc;
- }
- /* slurm_get_jobcomp_user
- * returns the storage user from slurmctld_conf object
- * RET char * - storage user, MUST be xfreed by caller
- */
- char *slurm_get_jobcomp_user(void)
- {
- char *storage_user = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- storage_user = xstrdup(conf->job_comp_user);
- slurm_conf_unlock();
- }
- return storage_user;
- }
- /* slurm_get_jobcomp_host
- * returns the storage host from slurmctld_conf object
- * RET char * - storage host, MUST be xfreed by caller
- */
- char *slurm_get_jobcomp_host(void)
- {
- char *storage_host = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- storage_host = xstrdup(conf->job_comp_host);
- slurm_conf_unlock();
- }
- return storage_host;
- }
- /* slurm_get_jobcomp_pass
- * returns the storage password from slurmctld_conf object
- * RET char * - storage password, MUST be xfreed by caller
- */
- char *slurm_get_jobcomp_pass(void)
- {
- char *storage_pass = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- storage_pass = xstrdup(conf->job_comp_pass);
- slurm_conf_unlock();
- }
- return storage_pass;
- }
- /* slurm_get_jobcomp_port
- * returns the storage port from slurmctld_conf object
- * RET uint32_t - storage port
- */
- uint32_t slurm_get_jobcomp_port(void)
- {
- uint32_t storage_port = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- storage_port = conf->job_comp_port;
- slurm_conf_unlock();
- }
- return storage_port;
- }
- /* slurm_set_jobcomp_port
- * sets the jobcomp port in slurmctld_conf object
- * RET 0 or error code
- */
- int slurm_set_jobcomp_port(uint32_t port)
- {
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- if (port == 0) {
- error("can't have jobcomp port of 0");
- return SLURM_ERROR;
- }
- conf->job_comp_port = port;
- slurm_conf_unlock();
- }
- return 0;
- }
- /* slurm_get_kill_wait
- * returns kill_wait from slurmctld_conf object
- * RET uint16_t - kill_wait
- */
- uint16_t slurm_get_kill_wait(void)
- {
- uint16_t kill_wait = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- kill_wait = conf->kill_wait;
- slurm_conf_unlock();
- }
- return kill_wait;
- }
- /* slurm_get_launch_type
- * get launch_type from slurmctld_conf object
- * RET char * - launch_type, MUST be xfreed by caller
- */
- char *slurm_get_launch_type(void)
- {
- char *launch_type = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- launch_type = xstrdup(conf->launch_type);
- slurm_conf_unlock();
- }
- return launch_type;
- }
- /* slurm_set_launch_type
- * set launch_type in slurmctld_conf object
- * RET 0 or error code
- */
- int slurm_set_launch_type(char *launch_type)
- {
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- xfree(conf->launch_type);
- conf->launch_type = xstrdup(launch_type);
- slurm_conf_unlock();
- }
- return 0;
- }
- /* slurm_get_preempt_type
- * get PreemptType from slurmctld_conf object
- * RET char * - preempt type, MUST be xfreed by caller
- */
- char *slurm_get_preempt_type(void)
- {
- char *preempt_type = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- preempt_type = xstrdup(conf->preempt_type);
- slurm_conf_unlock();
- }
- return preempt_type;
- }
- /* slurm_get_proctrack_type
- * get ProctrackType from slurmctld_conf object
- * RET char * - proctrack type, MUST be xfreed by caller
- */
- char *slurm_get_proctrack_type(void)
- {
- char *proctrack_type = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- proctrack_type = xstrdup(conf->proctrack_type);
- slurm_conf_unlock();
- }
- return proctrack_type;
- }
- /* slurm_get_slurmd_port
- * returns slurmd port from slurmctld_conf object
- * RET uint16_t - slurmd port
- */
- uint16_t slurm_get_slurmd_port(void)
- {
- uint16_t slurmd_port = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- slurmd_port = conf->slurmd_port;
- slurm_conf_unlock();
- }
- return slurmd_port;
- }
- /* slurm_get_slurm_user_id
- * returns slurm uid from slurmctld_conf object
- * RET uint32_t - slurm user id
- */
- uint32_t slurm_get_slurm_user_id(void)
- {
- uint32_t slurm_uid = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- slurm_uid = slurmdbd_conf->slurm_user_id;
- } else {
- conf = slurm_conf_lock();
- slurm_uid = conf->slurm_user_id;
- slurm_conf_unlock();
- }
- return slurm_uid;
- }
- /* slurm_get_slurmd_user_id
- * returns slurmd uid from slurmctld_conf object
- * RET uint32_t - slurmd user id
- */
- uint32_t slurm_get_slurmd_user_id(void)
- {
- uint32_t slurmd_uid = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- slurmd_uid = conf->slurmd_user_id;
- slurm_conf_unlock();
- }
- return slurmd_uid;
- }
- /* slurm_get_root_filter
- * RET uint16_t - Value of SchedulerRootFilter */
- extern uint16_t slurm_get_root_filter(void)
- {
- uint16_t root_filter = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- root_filter = conf->schedrootfltr;
- slurm_conf_unlock();
- }
- return root_filter;
- }
- /* slurm_get_sched_params
- * RET char * - Value of SchedulerParameters, MUST be xfreed by caller */
- extern char *slurm_get_sched_params(void)
- {
- char *params = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- params = xstrdup(conf->sched_params);
- slurm_conf_unlock();
- }
- return params;
- }
- /* slurm_get_sched_port
- * RET uint16_t - Value of SchedulerPort */
- extern uint16_t slurm_get_sched_port(void)
- {
- uint16_t port = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- port = conf->schedport;
- slurm_conf_unlock();
- }
- return port;
- }
- /* slurm_get_sched_type
- * get sched type from slurmctld_conf object
- * RET char * - sched type, MUST be xfreed by caller
- */
- char *slurm_get_sched_type(void)
- {
- char *sched_type = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- sched_type = xstrdup(conf->schedtype);
- slurm_conf_unlock();
- }
- return sched_type;
- }
- /* slurm_get_select_type
- * get select_type from slurmctld_conf object
- * RET char * - select_type, MUST be xfreed by caller
- */
- char *slurm_get_select_type(void)
- {
- char *select_type = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- select_type = xstrdup(conf->select_type);
- slurm_conf_unlock();
- }
- return select_type;
- }
- /* slurm_get_select_type_param
- * get select_type_param from slurmctld_conf object
- * RET uint16_t - select_type_param
- */
- uint16_t slurm_get_select_type_param(void)
- {
- uint16_t select_type_param = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- select_type_param = conf->select_type_param;
- slurm_conf_unlock();
- }
- return select_type_param;
- }
- /** Return true if (remote) system runs Cray XT/XE */
- bool is_cray_select_type(void)
- {
- bool result = false;
- if (slurmdbd_conf) {
- } else {
- slurm_ctl_conf_t *conf = slurm_conf_lock();
- result = strcasecmp(conf->select_type, "select/cray") == 0;
- slurm_conf_unlock();
- }
- return result;
- }
- /* slurm_get_switch_type
- * get switch type from slurmctld_conf object
- * RET char * - switch type, MUST be xfreed by caller
- */
- char *slurm_get_switch_type(void)
- {
- char *switch_type = NULL;
- slurm_ctl_conf_t *conf;
- conf = slurm_conf_lock();
- switch_type = xstrdup(conf->switch_type);
- slurm_conf_unlock();
- return switch_type;
- }
- /* slurm_get_wait_time
- * returns wait_time from slurmctld_conf object
- * RET uint16_t - wait_time
- */
- uint16_t slurm_get_wait_time(void)
- {
- uint16_t wait_time = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- wait_time = conf->wait_time;
- slurm_conf_unlock();
- }
- return wait_time;
- }
- /* slurm_get_srun_prolog
- * return the name of the srun prolog program
- * RET char * - name of prolog program, must be xfreed by caller
- */
- char *slurm_get_srun_prolog(void)
- {
- char *prolog = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- prolog = xstrdup(conf->srun_prolog);
- slurm_conf_unlock();
- }
- return prolog;
- }
- /* slurm_get_srun_epilog
- * return the name of the srun epilog program
- * RET char * - name of epilog program, must be xfreed by caller
- */
- char *slurm_get_srun_epilog(void)
- {
- char *epilog = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- epilog = xstrdup(conf->srun_epilog);
- slurm_conf_unlock();
- }
- return epilog;
- }
- /* slurm_get_task_epilog
- * RET task_epilog name, must be xfreed by caller */
- char *slurm_get_task_epilog(void)
- {
- char *task_epilog = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- task_epilog = xstrdup(conf->task_epilog);
- slurm_conf_unlock();
- }
- return task_epilog;
- }
- /* slurm_get_task_prolog
- * RET task_prolog name, must be xfreed by caller */
- char *slurm_get_task_prolog(void)
- {
- char *task_prolog = NULL;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- task_prolog = xstrdup(conf->task_prolog);
- slurm_conf_unlock();
- }
- return task_prolog;
- }
- /* slurm_get_task_plugin
- * RET task_plugin name, must be xfreed by caller */
- char *slurm_get_task_plugin(void)
- {
- char *task_plugin = NULL;
- slurm_ctl_conf_t *conf;
- conf = slurm_conf_lock();
- task_plugin = xstrdup(conf->task_plugin);
- slurm_conf_unlock();
- return task_plugin;
- }
- /* slurm_get_task_plugin_param */
- uint16_t slurm_get_task_plugin_param(void)
- {
- uint16_t task_plugin_param = 0;
- slurm_ctl_conf_t *conf;
- if (slurmdbd_conf) {
- } else {
- conf = slurm_conf_lock();
- task_plugin_param = conf->task_plugin_param;
- slurm_conf_unlock();
- }
- return task_plugin_param;
- }
- /* Change general slurm communication errors to slurmctld specific errors */
- static void _remap_slurmctld_errno(void)
- {
- int err = slurm_get_errno();
- if (err == SLURM_COMMUNICATIONS_CONNECTION_ERROR)
- slurm_seterrno(SLURMCTLD_COMMUNICATIONS_CONNECTION_ERROR);
- else if (err == SLURM_COMMUNICATIONS_SEND_ERROR)
- slurm_seterrno(SLURMCTLD_COMMUNICATIONS_SEND_ERROR);
- else if (err == SLURM_COMMUNICATIONS_RECEIVE_ERROR)
- slurm_seterrno(SLURMCTLD_COMMUNICATIONS_RECEIVE_ERROR);
- else if (err == SLURM_COMMUNICATIONS_SHUTDOWN_ERROR)
- slurm_seterrno(SLURMCTLD_COMMUNICATIONS_SHUTDOWN_ERROR);
- }
- /**********************************************************************\
- * general message management functions used by slurmctld, slurmd
- \**********************************************************************/
- /* In the socket implementation it creates a socket, binds to it, and
- * listens for connections.
- *
- * IN port - port to bind the msg server to
- * RET slurm_fd_t - file descriptor of the connection created
- */
- slurm_fd_t slurm_init_msg_engine_port(uint16_t port)
- {
- slurm_addr_t addr;
- slurm_set_addr_any(&addr, port);
- return _slurm_init_msg_engine(&addr);
- }
- /* In the socket implementation it creates a socket, binds to it, and
- * listens for connections.
- *
- * IN addr_name - address to bind the msg server to (NULL means any)
- * IN port - port to bind the msg server to
- * RET slurm_fd_t - file descriptor of the connection created
- */
- slurm_fd_t slurm_init_msg_engine_addrname_port(char *addr_name, uint16_t port)
- {
- slurm_addr_t addr;
- #ifdef BIND_SPECIFIC_ADDR
- if (addr_name != NULL)
- slurm_set_addr(&addr, port, addr_name);
- else
- slurm_set_addr_any(&addr, port);
- #else
- slurm_set_addr_any(&addr, port);
- #endif
- return _slurm_init_msg_engine(&addr);
- }
- /*
- * Same as above, but initialize using a slurm address "addr"
- *
- * IN addr - slurm_addr_t to bind the msg server to
- * RET slurm_fd_t - file descriptor of the connection created
- */
- slurm_fd_t slurm_init_msg_engine(slurm_addr_t *addr)
- {
- return _slurm_init_msg_engine(addr);
- }
- /*
- * Close an established message engine.
- * Returns SLURM_SUCCESS or SLURM_FAILURE.
- *
- * IN fd - an open file descriptor to close
- * RET int - the return code
- */
- int slurm_shutdown_msg_engine(slurm_fd_t fd)
- {
- int rc = _slurm_close(fd);
- if (rc)
- slurm_seterrno(SLURM_COMMUNICATIONS_SHUTDOWN_ERROR);
- return rc;
- }
- /*
- * Close an established message connection.
- * Returns SLURM_SUCCESS or SLURM_FAILURE.
- *
- * IN fd - an open file descriptor to close
- * RET int - the return code
- */
- int slurm_shutdown_msg_conn(slurm_fd_t fd)
- {
- return _slurm_close(fd);
- }
- /**********************************************************************\
- * msg connection establishment functions used by msg clients
- \**********************************************************************/
- /* In the bsd socket implementation it creates a SOCK_STREAM socket
- * and calls connect on it a SOCK_DGRAM socket called with connect
- * is defined to only receive messages from the address/port pair
- * argument of the connect call slurm_address - for now it is
- * really just a sockaddr_in
- * IN slurm_address - slurm_addr_t of the connection destination
- * RET slurm_fd - file descriptor of the connection created
- */
- slurm_fd_t slurm_open_msg_conn(slurm_addr_t * slurm_address)
- {
- return _slurm_open_msg_conn(slurm_address);
- }
- /* Calls connect to make a connection-less datagram connection to the
- * primary or secondary slurmctld message engine. If the controller
- * is very busy the connect may fail, so retry a couple of times.
- * IN/OUT addr - address of controller contacted
- * RET slurm_fd - file descriptor of the connection created
- */
- slurm_fd_t slurm_open_controller_conn(slurm_addr_t *addr)
- {
- slurm_fd_t fd = -1;
- slurm_ctl_conf_t *conf;
- slurm_protocol_config_t *myproto = NULL;
- int retry, have_backup = 0;
- if (!working_cluster_rec) {
- /* This means the addr wasn't set up already.
- */
- if (slurm_api_set_default_config() < 0)
- return SLURM_FAILURE;
- myproto = xmalloc(sizeof(slurm_protocol_config_t));
- memcpy(myproto, proto_conf, sizeof(slurm_protocol_config_t));
- myproto->primary_controller.sin_port =
- htons(slurmctld_conf.slurmctld_port +
- (((time(NULL) + getpid()) %
- slurmctld_conf.slurmctld_port_count)));
- myproto->secondary_controller.sin_port =
- myproto->primary_controller.sin_port;
- }
- for (retry=0; retry<slurm_get_msg_timeout(); retry++) {
- if (retry)
- sleep(1);
- if (working_cluster_rec) {
- if (working_cluster_rec->control_addr.sin_port == 0) {
- slurm_set_addr(
- &working_cluster_rec->control_addr,
- working_cluster_rec->control_port,
- working_cluster_rec->control_host);
- }
- addr = &working_cluster_rec->control_addr;
- fd = slurm_open_msg_conn(addr);
- if (fd >= 0)
- goto end_it;
- debug("Failed to contact controller: %m");
- } else {
- fd = slurm_open_msg_conn(&myproto->primary_controller);
- if (fd >= 0)
- goto end_it;
- debug("Failed to contact primary controller: %m");
- if (retry == 0) {
- conf = slurm_conf_lock();
- if (conf->backup_controller)
- have_backup = 1;
- slurm_conf_unlock();
- }
- if (have_backup) {
- fd = slurm_open_msg_conn(&myproto->
- secondary_controller);
- if (fd >= 0)
- goto end_it;
- debug("Failed to contact secondary "
- "controller: %m");
- }
- }
- }
- addr = NULL;
- slurm_seterrno_ret(SLURMCTLD_COMMUNICATIONS_CONNECTION_ERROR);
- end_it:
- xfree(myproto);
- return fd;
- }
- /* calls connect to make a connection-less datagram connection to the
- * primary or secondary slurmctld message engine
- * RET slurm_fd_t - file descriptor of the connection created
- * IN dest - controller to contact, primary or secondary
- */
- slurm_fd_t slurm_open_controller_conn_spec(enum controller_id dest)
- {
- slurm_addr_t *addr;
- slurm_fd_t rc;
- if (slurm_api_set_default_config() < 0) {
- debug3("Error: Unable to set default config");
- return SLURM_ERROR;
- }
- if (dest == PRIMARY_CONTROLLER)
- addr = &proto_conf->primary_controller;
- else { /* (dest == SECONDARY_CONTROLLER) */
- slurm_ctl_conf_t *conf;
- addr = NULL;
- conf = slurm_conf_lock();
- if (conf->backup_addr)
- addr = &proto_conf->secondary_controller;
- slurm_conf_unlock();
- if (!addr)
- return SLURM_ERROR;
- }
- rc = slurm_open_msg_conn(addr);
- if (rc == -1)
- _remap_slurmctld_errno();
- return rc;
- }
- /* gets the slurm_addr_t of the specified controller
- * primary or secondary slurmctld message engine
- * IN dest …
Large files files are truncated, but you can click here to view the full file