1/*****************************************************************************\
2 *  slurm.h - Definitions for all of the Slurm RPCs
3 *****************************************************************************
4 *  Copyright (C) 2002-2007 The Regents of the University of California.
5 *  Copyright (C) 2008-2010 Lawrence Livermore National Security.
6 *  Portions Copyright (C) 2010-2017 SchedMD LLC <https://www.schedmd.com>.
7 *  Portions Copyright (C) 2012-2013 Los Alamos National Security, LLC.
8 *  Portions Copyright 2013 Cray Inc. All Rights Reserved.
9 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
10 *  Written by Morris Jette <jette1@llnl.gov>, et. al.
11 *  CODE-OCEC-09-009. All rights reserved.
12 *
13 *  This file is part of Slurm, a resource management program.
14 *  For details, see <https://slurm.schedmd.com/>.
15 *  Please also read the included file: DISCLAIMER.
16 *
17 *  Slurm is free software; you can redistribute it and/or modify it under
18 *  the terms of the GNU General Public License as published by the Free
19 *  Software Foundation; either version 2 of the License, or (at your option)
20 *  any later version.
21 *
22 *  In addition, as a special exception, the copyright holders give permission
23 *  to link the code of portions of this program with the OpenSSL library under
24 *  certain conditions as described in each individual source file, and
25 *  distribute linked combinations including the two. You must obey the GNU
26 *  General Public License in all respects for all of the code used other than
27 *  OpenSSL. If you modify file(s) with this exception, you may extend this
28 *  exception to your version of the file(s), but you are not obligated to do
29 *  so. If you do not wish to do so, delete this exception statement from your
30 *  version.  If you delete this exception statement from all source files in
31 *  the program, then also delete it here.
32 *
33 *  Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
34 *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
35 *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
36 *  details.
37 *
38 *  You should have received a copy of the GNU General Public License along
39 *  with Slurm; if not, write to the Free Software Foundation, Inc.,
40 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
41\*****************************************************************************/
42
43#ifndef _SLURM_H
44#define _SLURM_H
45
46/* Number of dimensions the system has */
47#define SYSTEM_DIMENSIONS 1
48#define HIGHEST_DIMENSIONS 5
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54#include <slurm/slurm_errno.h>
55
56#include <inttypes.h>		/* for uint16_t, uint32_t definitions */
57#include <netinet/in.h>		/* struct sockaddr_in */
58#include <stdbool.h>
59#include <stdio.h>		/* for FILE definitions */
60#include <sys/types.h>		/* for uid_t definition */
61#include <time.h>		/* for time_t definitions */
62#include <unistd.h>
63
64/* Define slurm_addr_t below to avoid including extraneous slurm headers */
65typedef struct sockaddr_in slurm_addr_t;
66
67#ifndef __slurmdb_cluster_rec_t_defined
68#  define __slurmdb_cluster_rec_t_defined
69typedef struct slurmdb_cluster_rec slurmdb_cluster_rec_t;
70#endif
71
72#ifndef __slurm_cred_t_defined
73#  define __slurm_cred_t_defined
74typedef struct slurm_job_credential slurm_cred_t;
75#endif
76
77/* Define switch_jobinfo_t below to avoid including extraneous slurm headers */
78#ifndef __switch_jobinfo_t_defined
79#  define  __switch_jobinfo_t_defined
80typedef struct switch_jobinfo switch_jobinfo_t;	/* opaque data type */
81#endif
82
83/* Define job_resources_t below
84 * to avoid including extraneous slurm headers */
85#ifndef __job_resources_t_defined
86#  define  __job_resources_t_defined	/* Opaque data for select plugins */
87typedef struct job_resources job_resources_t;
88#endif
89
90/* Define select_jobinfo_t, select_nodeinfo_t below
91 * to avoid including extraneous slurm headers */
92#ifndef __select_jobinfo_t_defined
93#  define  __select_jobinfo_t_defined	/* Opaque data for select plugins */
94typedef struct select_jobinfo select_jobinfo_t;  /* for BlueGene */
95typedef struct select_nodeinfo select_nodeinfo_t;  /* for BlueGene */
96#endif
97
98/* Define jobacctinfo_t below to avoid including extraneous slurm headers */
99#ifndef __jobacctinfo_t_defined
100#  define  __jobacctinfo_t_defined
101typedef struct jobacctinfo jobacctinfo_t;     /* opaque data type */
102#endif
103
104/* Define allocation_msg_thread_t below to avoid including extraneous
105 * slurm headers */
106#ifndef __allocation_msg_thread_t_defined
107#  define  __allocation_msg_thread_t_defined
108typedef struct allocation_msg_thread allocation_msg_thread_t;
109#endif
110
111#ifndef __sbcast_cred_t_defined
112#  define  __sbcast_cred_t_defined
113typedef struct sbcast_cred sbcast_cred_t;		/* opaque data type */
114#endif
115
116/*****************************************************************************\
117 *      DEFINITIONS FOR VERSION MANAGEMENT
118\*****************************************************************************/
119/* Define Slurm version number.
120 * High-order byte is major version.
121 * Middle byte     is minor version.
122 * Low-order byte  is micro version (NOTE: excludes "-pre#" component
123 #                 of micro version used in pre-releases).
124 * Use SLURM_VERSION_NUM macro to compare versions, for example
125 * #if SLURM_VERSION_NUMBER > SLURM_VERSION_NUM(2,1,0)
126 */
127#undef  SLURM_VERSION_NUMBER
128#define SLURM_VERSION_NUM(a,b,c) (((a) << 16) + ((b) << 8) + (c))
129#define SLURM_VERSION_MAJOR(a)   (((a) >> 16) & 0xff)
130#define SLURM_VERSION_MINOR(a)   (((a) >>  8) & 0xff)
131#define SLURM_VERSION_MICRO(a)    ((a)        & 0xff)
132
133/*****************************************************************************\
134 *	DEFINITIONS FOR INPUT VALUES
135\*****************************************************************************/
136
137/* INFINITE is used to identify unlimited configurations,  */
138/* eg. the maximum count of nodes any job may use in some partition */
139#define	INFINITE8  (0xff)
140#define	INFINITE16 (0xffff)
141#define	INFINITE   (0xffffffff)
142#define	INFINITE64 (0xffffffffffffffff)
143#define NO_VAL8    (0xfe)
144#define NO_VAL16   (0xfffe)
145#define NO_VAL     (0xfffffffe)
146#define NO_VAL64   (0xfffffffffffffffe)
147#define NO_CONSUME_VAL64 (0xfffffffffffffffd)
148#define MAX_TASKS_PER_NODE 512
149#define MAX_JOB_ID (0x03FFFFFF) /* bits 0-25 */
150#define MAX_FED_CLUSTERS 63
151
152/* Job step ID of pending step */
153#define SLURM_PENDING_STEP (0xfffffffd)
154/* Job step ID of batch scripts */
155#define SLURM_BATCH_SCRIPT (0xfffffffe)
156/* Job step ID of external process container */
157#define SLURM_EXTERN_CONT  (0xffffffff)
158
159/* How many seconds to wait after eio_signal_shutdown() is called before
160 * terminating the job and abandoning any I/O remaining to be processed.
161 */
162#define DEFAULT_EIO_SHUTDOWN_WAIT 60
163
164/*
165 * SLURM_ID_HASH
166 * Description:
167 *  Creates a hash of a Slurm JOBID and STEPID
168 *  The JOB STEP ID is in the top 32 bits of the hash with the job id occupying
169 *  the lower 32 bits.
170 *
171 * IN  _jobid -- SLURM's JOB ID (uint32_t)
172 * IN  _stepid -- SLURM's JOB STEP ID (uint32_t)
173 * RET id_hash -- (uint64_t)
174 */
175#define SLURM_ID_HASH(_jobid, _stepid) \
176	(uint64_t)(((uint64_t)_stepid << 32) + _jobid)
177#define SLURM_ID_HASH_JOB_ID(hash_id) (uint32_t)(hash_id & 0x00000000FFFFFFFF)
178#define SLURM_ID_HASH_STEP_ID(hash_id) (uint32_t)(hash_id >> 32)
179
180/*
181 * Convert a hash ID to its legacy (pre-17.11) equivalent
182 * Used for backward compatibility for Cray PMI
183 */
184#define SLURM_ID_HASH_LEGACY(hash_id) \
185	((hash_id >> 32) * 10000000000 + (hash_id & 0x00000000FFFFFFFF))
186
187/* last entry must be JOB_END, keep in sync with job_state_string and
188 *	job_state_string_compact. values may be ORed with JOB_STATE_FLAGS
189 *	below.  */
190enum job_states {
191	JOB_PENDING,		/* queued waiting for initiation */
192	JOB_RUNNING,		/* allocated resources and executing */
193	JOB_SUSPENDED,		/* allocated resources, execution suspended */
194	JOB_COMPLETE,		/* completed execution successfully */
195	JOB_CANCELLED,		/* cancelled by user */
196	JOB_FAILED,		/* completed execution unsuccessfully */
197	JOB_TIMEOUT,		/* terminated on reaching time limit */
198	JOB_NODE_FAIL,		/* terminated on node failure */
199	JOB_PREEMPTED,		/* terminated due to preemption */
200	JOB_BOOT_FAIL,		/* terminated due to node boot failure */
201	JOB_DEADLINE,		/* terminated on deadline */
202	JOB_OOM,		/* experienced out of memory error */
203	JOB_END			/* not a real state, last entry in table */
204};
205#define	JOB_STATE_BASE	  0x000000ff	/* Used for job_states above */
206#define	JOB_STATE_FLAGS	  0xffffff00	/* Used for state flags below */
207
208#define JOB_LAUNCH_FAILED 0x00000100
209#define JOB_UPDATE_DB     0x00000200 /* Send job start to database again */
210#define JOB_REQUEUE       0x00000400 /* Requeue job in completing state */
211#define JOB_REQUEUE_HOLD  0x00000800 /* Requeue any job in hold */
212#define JOB_SPECIAL_EXIT  0x00001000 /* Requeue an exit job in hold */
213#define	JOB_RESIZING	  0x00002000 /* Size of job about to change, flag set
214					before calling accounting functions
215					immediately before job changes size */
216#define	JOB_CONFIGURING	  0x00004000 /* Allocated nodes booting */
217#define	JOB_COMPLETING	  0x00008000 /* Waiting for epilog completion */
218#define JOB_STOPPED       0x00010000 /* Job is stopped state (holding resources,
219					but sent SIGSTOP */
220#define JOB_RECONFIG_FAIL 0x00020000 /* Node configuration for job failed,
221					not job state, just job requeue flag */
222#define	JOB_POWER_UP_NODE 0x00040000 /* Allocated powered down nodes,
223				      * waiting for reboot */
224#define JOB_REVOKED       0x00080000 /* Sibling job revoked */
225#define JOB_REQUEUE_FED   0x00100000 /* Job is being requeued by federation */
226#define JOB_RESV_DEL_HOLD 0x00200000 /* Job is hold */
227#define JOB_SIGNALING     0x00400000 /* Outgoing signal is pending */
228#define JOB_STAGE_OUT     0x00800000 /* Staging out data (burst buffer) */
229
230#define READY_JOB_FATAL	   -2	/* fatal error */
231#define READY_JOB_ERROR    -1	/* ordinary error */
232#define READY_NODE_STATE 0x01	/* node is ready */
233#define READY_JOB_STATE  0x02	/* job is ready to execute */
234
235#define MAIL_JOB_BEGIN     0x0001	/* Notify when job begins */
236#define MAIL_JOB_END       0x0002	/* Notify when job ends */
237#define MAIL_JOB_FAIL      0x0004	/* Notify if job fails */
238#define MAIL_JOB_REQUEUE   0x0008	/* Notify if job requeued */
239#define MAIL_JOB_TIME100   0x0010	/* Notify on reaching 100% of time limit */
240#define MAIL_JOB_TIME90    0x0020	/* Notify on reaching 90% of time limit */
241#define MAIL_JOB_TIME80    0x0040	/* Notify on reaching 80% of time limit */
242#define MAIL_JOB_TIME50    0x0080	/* Notify on reaching 50% of time limit */
243#define MAIL_JOB_STAGE_OUT 0x0100	/* Notify on completion of burst buffer
244					 * stage out */
245#define MAIL_ARRAY_TASKS   0x0200	/* Send emails for each array task */
246
247/*
248 * job_array_struct_t array_flags definitions. ARRAY_TASK_REQUEUED could be
249 * substituted in the future to tot_requeued_tasks member in the struct, which
250 * would provide a more accurated array statistic.
251 */
252#define ARRAY_TASK_REQUEUED 0x0001	/* At least one task was requeued. */
253
254#define NICE_OFFSET 0x80000000		/* offset for job's nice value */
255
256/* Reason for job to be pending rather than executing or reason for job
257 * failure. If multiple reasons exists, only one is given for the sake of
258 * system efficiency */
259enum job_state_reason {
260/* Reasons for job to be pending */
261	WAIT_NO_REASON = 0,	/* not set or job not pending */
262	WAIT_PRIORITY,		/* higher priority jobs exist */
263	WAIT_DEPENDENCY,	/* dependent job has not completed */
264	WAIT_RESOURCES,		/* required resources not available */
265	WAIT_PART_NODE_LIMIT,	/* request exceeds partition node limit */
266	WAIT_PART_TIME_LIMIT,	/* request exceeds partition time limit */
267	WAIT_PART_DOWN,		/* requested partition is down */
268	WAIT_PART_INACTIVE,	/* requested partition is inactive */
269	WAIT_HELD,		/* job is held by administrator */
270	WAIT_TIME,		/* job waiting for specific begin time */
271	WAIT_LICENSES,		/* job is waiting for licenses */
272	WAIT_ASSOC_JOB_LIMIT,	/* user/bank job limit reached */
273	WAIT_ASSOC_RESOURCE_LIMIT,/* user/bank resource limit reached */
274	WAIT_ASSOC_TIME_LIMIT,  /* user/bank time limit reached */
275	WAIT_RESERVATION,	/* reservation not available */
276	WAIT_NODE_NOT_AVAIL,	/* required node is DOWN or DRAINED */
277	WAIT_HELD_USER,		/* job is held by user */
278	WAIT_FRONT_END,		/* Front end nodes are DOWN */
279	FAIL_DEFER,		/* individual submit time sched deferred */
280	FAIL_DOWN_PARTITION,	/* partition for job is DOWN */
281	FAIL_DOWN_NODE,		/* some node in the allocation failed */
282	FAIL_BAD_CONSTRAINTS,	/* constraints can not be satisfied */
283	FAIL_SYSTEM,		/* slurm system failure */
284	FAIL_LAUNCH,		/* unable to launch job */
285	FAIL_EXIT_CODE,		/* exit code was non-zero */
286	FAIL_TIMEOUT,		/* reached end of time limit */
287	FAIL_INACTIVE_LIMIT,	/* reached slurm InactiveLimit */
288	FAIL_ACCOUNT,		/* invalid account */
289	FAIL_QOS,	 	/* invalid QOS */
290	WAIT_QOS_THRES,	       	/* required QOS threshold has been breached */
291	WAIT_QOS_JOB_LIMIT,	/* QOS job limit reached */
292	WAIT_QOS_RESOURCE_LIMIT,/* QOS resource limit reached */
293	WAIT_QOS_TIME_LIMIT,	/* QOS time limit reached */
294	WAIT_BLOCK_MAX_ERR,     /* BLUEGENE Block has too many cnodes
295				 * in error state to allow more jobs. */
296	WAIT_BLOCK_D_ACTION,    /* BLUEGENE Block is being freed,
297				 * can't allow more jobs. */
298	WAIT_CLEANING,          /* If a job is requeued and it is
299				 * still cleaning up from the last run. */
300	WAIT_PROLOG,		/* Prolog is running */
301	WAIT_QOS,	 	/* QOS not allowed */
302	WAIT_ACCOUNT,	 	/* Account not allowed */
303	WAIT_DEP_INVALID,        /* Dependency condition invalid or never
304				  * satisfied
305				  */
306	WAIT_QOS_GRP_CPU,            /* QOS GrpTRES exceeded (CPU) */
307	WAIT_QOS_GRP_CPU_MIN,        /* QOS GrpTRESMins exceeded (CPU) */
308	WAIT_QOS_GRP_CPU_RUN_MIN,    /* QOS GrpTRESRunMins exceeded (CPU) */
309	WAIT_QOS_GRP_JOB,            /* QOS GrpJobs exceeded */
310	WAIT_QOS_GRP_MEM,            /* QOS GrpTRES exceeded (Memory) */
311	WAIT_QOS_GRP_NODE,           /* QOS GrpTRES exceeded (Node) */
312	WAIT_QOS_GRP_SUB_JOB,        /* QOS GrpSubmitJobs exceeded */
313	WAIT_QOS_GRP_WALL,           /* QOS GrpWall exceeded */
314	WAIT_QOS_MAX_CPU_PER_JOB,    /* QOS MaxTRESPerJob exceeded (CPU) */
315	WAIT_QOS_MAX_CPU_MINS_PER_JOB,/* QOS MaxTRESMinsPerJob exceeded (CPU) */
316	WAIT_QOS_MAX_NODE_PER_JOB,   /* QOS MaxTRESPerJob exceeded (Node) */
317	WAIT_QOS_MAX_WALL_PER_JOB,   /* QOS MaxWallDurationPerJob exceeded */
318	WAIT_QOS_MAX_CPU_PER_USER,   /* QOS MaxTRESPerUser exceeded (CPU) */
319	WAIT_QOS_MAX_JOB_PER_USER,   /* QOS MaxJobsPerUser exceeded */
320	WAIT_QOS_MAX_NODE_PER_USER,  /* QOS MaxTRESPerUser exceeded (Node) */
321	WAIT_QOS_MAX_SUB_JOB,        /* QOS MaxSubmitJobsPerUser exceeded */
322	WAIT_QOS_MIN_CPU,            /* QOS MinTRESPerJob not reached (CPU) */
323	WAIT_ASSOC_GRP_CPU,          /* ASSOC GrpTRES exceeded (CPU) */
324	WAIT_ASSOC_GRP_CPU_MIN,      /* ASSOC GrpTRESMins exceeded (CPU) */
325	WAIT_ASSOC_GRP_CPU_RUN_MIN,  /* ASSOC GrpTRESRunMins exceeded (CPU) */
326	WAIT_ASSOC_GRP_JOB,          /* ASSOC GrpJobs exceeded */
327	WAIT_ASSOC_GRP_MEM,          /* ASSOC GrpTRES exceeded (Memory) */
328	WAIT_ASSOC_GRP_NODE,         /* ASSOC GrpTRES exceeded (Node) */
329	WAIT_ASSOC_GRP_SUB_JOB,      /* ASSOC GrpSubmitJobs exceeded */
330	WAIT_ASSOC_GRP_WALL,         /* ASSOC GrpWall exceeded */
331	WAIT_ASSOC_MAX_JOBS,         /* ASSOC MaxJobs exceeded */
332	WAIT_ASSOC_MAX_CPU_PER_JOB,  /* ASSOC MaxTRESPerJob exceeded (CPU) */
333	WAIT_ASSOC_MAX_CPU_MINS_PER_JOB,/* ASSOC MaxTRESMinsPerJob
334					 * exceeded (CPU) */
335	WAIT_ASSOC_MAX_NODE_PER_JOB, /* ASSOC MaxTRESPerJob exceeded (NODE) */
336	WAIT_ASSOC_MAX_WALL_PER_JOB, /* ASSOC MaxWallDurationPerJob
337				      * exceeded */
338	WAIT_ASSOC_MAX_SUB_JOB,      /* ASSOC MaxSubmitJobsPerUser exceeded */
339
340	WAIT_MAX_REQUEUE,            /* MAX_BATCH_REQUEUE reached */
341	WAIT_ARRAY_TASK_LIMIT,       /* job array running task limit */
342	WAIT_BURST_BUFFER_RESOURCE,  /* Burst buffer resources */
343	WAIT_BURST_BUFFER_STAGING,   /* Burst buffer file stage-in */
344	FAIL_BURST_BUFFER_OP,	     /* Burst buffer operation failure */
345	WAIT_POWER_NOT_AVAIL,        /* not enough power available */
346	WAIT_POWER_RESERVED,         /* job is waiting for available power
347				      * because of power reservations */
348	WAIT_ASSOC_GRP_UNK,          /* ASSOC GrpTRES exceeded
349				      * (Unknown) */
350	WAIT_ASSOC_GRP_UNK_MIN,      /* ASSOC GrpTRESMins exceeded
351				      * (Unknown) */
352	WAIT_ASSOC_GRP_UNK_RUN_MIN,  /* ASSOC GrpTRESRunMins exceeded
353				      * (Unknown) */
354	WAIT_ASSOC_MAX_UNK_PER_JOB,  /* ASSOC MaxTRESPerJob exceeded
355				      * (Unknown) */
356	WAIT_ASSOC_MAX_UNK_PER_NODE,  /* ASSOC MaxTRESPerNode exceeded
357				       * (Unknown) */
358	WAIT_ASSOC_MAX_UNK_MINS_PER_JOB,/* ASSOC MaxTRESMinsPerJob
359					 * exceeded (Unknown) */
360	WAIT_ASSOC_MAX_CPU_PER_NODE,  /* ASSOC MaxTRESPerNode exceeded (CPU) */
361	WAIT_ASSOC_GRP_MEM_MIN,      /* ASSOC GrpTRESMins exceeded
362				      * (Memory) */
363	WAIT_ASSOC_GRP_MEM_RUN_MIN,  /* ASSOC GrpTRESRunMins exceeded
364				      * (Memory) */
365	WAIT_ASSOC_MAX_MEM_PER_JOB,  /* ASSOC MaxTRESPerJob exceeded (Memory) */
366	WAIT_ASSOC_MAX_MEM_PER_NODE,  /* ASSOC MaxTRESPerNode exceeded (CPU) */
367	WAIT_ASSOC_MAX_MEM_MINS_PER_JOB,/* ASSOC MaxTRESMinsPerJob
368					 * exceeded (Memory) */
369	WAIT_ASSOC_GRP_NODE_MIN,     /* ASSOC GrpTRESMins exceeded (Node) */
370	WAIT_ASSOC_GRP_NODE_RUN_MIN, /* ASSOC GrpTRESRunMins exceeded (Node) */
371	WAIT_ASSOC_MAX_NODE_MINS_PER_JOB,/* ASSOC MaxTRESMinsPerJob
372					  * exceeded (Node) */
373	WAIT_ASSOC_GRP_ENERGY,           /* ASSOC GrpTRES exceeded
374					  * (Energy) */
375	WAIT_ASSOC_GRP_ENERGY_MIN,       /* ASSOC GrpTRESMins exceeded
376					  * (Energy) */
377	WAIT_ASSOC_GRP_ENERGY_RUN_MIN,   /* ASSOC GrpTRESRunMins exceeded
378					  * (Energy) */
379	WAIT_ASSOC_MAX_ENERGY_PER_JOB,   /* ASSOC MaxTRESPerJob exceeded
380					  * (Energy) */
381	WAIT_ASSOC_MAX_ENERGY_PER_NODE,  /* ASSOC MaxTRESPerNode
382					  * exceeded (Energy) */
383	WAIT_ASSOC_MAX_ENERGY_MINS_PER_JOB,/* ASSOC MaxTRESMinsPerJob
384					    * exceeded (Energy) */
385	WAIT_ASSOC_GRP_GRES,          /* ASSOC GrpTRES exceeded (GRES) */
386	WAIT_ASSOC_GRP_GRES_MIN,      /* ASSOC GrpTRESMins exceeded (GRES) */
387	WAIT_ASSOC_GRP_GRES_RUN_MIN,  /* ASSOC GrpTRESRunMins exceeded (GRES) */
388	WAIT_ASSOC_MAX_GRES_PER_JOB,  /* ASSOC MaxTRESPerJob exceeded (GRES) */
389	WAIT_ASSOC_MAX_GRES_PER_NODE, /* ASSOC MaxTRESPerNode exceeded (GRES) */
390	WAIT_ASSOC_MAX_GRES_MINS_PER_JOB,/* ASSOC MaxTRESMinsPerJob
391					  * exceeded (GRES) */
392	WAIT_ASSOC_GRP_LIC,          /* ASSOC GrpTRES exceeded
393				      * (license) */
394	WAIT_ASSOC_GRP_LIC_MIN,      /* ASSOC GrpTRESMins exceeded
395				      * (license) */
396	WAIT_ASSOC_GRP_LIC_RUN_MIN,  /* ASSOC GrpTRESRunMins exceeded
397				      * (license) */
398	WAIT_ASSOC_MAX_LIC_PER_JOB,  /* ASSOC MaxTRESPerJob exceeded
399				      * (license) */
400	WAIT_ASSOC_MAX_LIC_MINS_PER_JOB,/* ASSOC MaxTRESMinsPerJob exceeded
401					 * (license) */
402	WAIT_ASSOC_GRP_BB,          /* ASSOC GrpTRES exceeded
403				     * (burst buffer) */
404	WAIT_ASSOC_GRP_BB_MIN,      /* ASSOC GrpTRESMins exceeded
405				     * (burst buffer) */
406	WAIT_ASSOC_GRP_BB_RUN_MIN,  /* ASSOC GrpTRESRunMins exceeded
407				     * (burst buffer) */
408	WAIT_ASSOC_MAX_BB_PER_JOB,  /* ASSOC MaxTRESPerJob exceeded
409				     * (burst buffer) */
410	WAIT_ASSOC_MAX_BB_PER_NODE, /* ASSOC MaxTRESPerNode exceeded
411				     * (burst buffer) */
412	WAIT_ASSOC_MAX_BB_MINS_PER_JOB,/* ASSOC MaxTRESMinsPerJob exceeded
413					* (burst buffer) */
414	WAIT_QOS_GRP_UNK,           /* QOS GrpTRES exceeded (Unknown) */
415	WAIT_QOS_GRP_UNK_MIN,       /* QOS GrpTRESMins exceeded (Unknown) */
416	WAIT_QOS_GRP_UNK_RUN_MIN,   /* QOS GrpTRESRunMins exceeded (Unknown) */
417	WAIT_QOS_MAX_UNK_PER_JOB,   /* QOS MaxTRESPerJob exceeded (Unknown) */
418	WAIT_QOS_MAX_UNK_PER_NODE,  /* QOS MaxTRESPerNode exceeded (Unknown) */
419	WAIT_QOS_MAX_UNK_PER_USER,  /* QOS MaxTRESPerUser exceeded (Unknown) */
420	WAIT_QOS_MAX_UNK_MINS_PER_JOB,/* QOS MaxTRESMinsPerJob
421				       * exceeded (Unknown) */
422	WAIT_QOS_MIN_UNK,           /* QOS MinTRESPerJob exceeded (Unknown) */
423	WAIT_QOS_MAX_CPU_PER_NODE,  /* QOS MaxTRESPerNode exceeded (CPU) */
424	WAIT_QOS_GRP_MEM_MIN,       /* QOS GrpTRESMins exceeded
425				     * (Memory) */
426	WAIT_QOS_GRP_MEM_RUN_MIN,   /* QOS GrpTRESRunMins exceeded
427				     * (Memory) */
428	WAIT_QOS_MAX_MEM_MINS_PER_JOB,/* QOS MaxTRESMinsPerJob
429				       * exceeded (Memory) */
430	WAIT_QOS_MAX_MEM_PER_JOB,   /* QOS MaxTRESPerJob exceeded (CPU) */
431	WAIT_QOS_MAX_MEM_PER_NODE,  /* QOS MaxTRESPerNode exceeded (MEM) */
432	WAIT_QOS_MAX_MEM_PER_USER,  /* QOS MaxTRESPerUser exceeded (CPU) */
433	WAIT_QOS_MIN_MEM,           /* QOS MinTRESPerJob not reached (Memory) */
434	WAIT_QOS_GRP_ENERGY,        /* QOS GrpTRES exceeded (Energy) */
435	WAIT_QOS_GRP_ENERGY_MIN,    /* QOS GrpTRESMins exceeded (Energy) */
436	WAIT_QOS_GRP_ENERGY_RUN_MIN, /* QOS GrpTRESRunMins exceeded (Energy) */
437	WAIT_QOS_MAX_ENERGY_PER_JOB, /* QOS MaxTRESPerJob exceeded (Energy) */
438	WAIT_QOS_MAX_ENERGY_PER_NODE,/* QOS MaxTRESPerNode exceeded (Energy) */
439	WAIT_QOS_MAX_ENERGY_PER_USER,/* QOS MaxTRESPerUser exceeded (Energy) */
440	WAIT_QOS_MAX_ENERGY_MINS_PER_JOB,/* QOS MaxTRESMinsPerJob
441					  * exceeded (Energy) */
442	WAIT_QOS_MIN_ENERGY,        /* QOS MinTRESPerJob not reached (Energy) */
443	WAIT_QOS_GRP_NODE_MIN,     /* QOS GrpTRESMins exceeded (Node) */
444	WAIT_QOS_GRP_NODE_RUN_MIN, /* QOS GrpTRESRunMins exceeded (Node) */
445	WAIT_QOS_MAX_NODE_MINS_PER_JOB,  /* QOS MaxTRESMinsPerJob
446					  * exceeded (Node) */
447	WAIT_QOS_MIN_NODE,          /* QOS MinTRESPerJob not reached (Node) */
448	WAIT_QOS_GRP_GRES,          /* QOS GrpTRES exceeded (GRES) */
449	WAIT_QOS_GRP_GRES_MIN,      /* QOS GrpTRESMins exceeded (GRES) */
450	WAIT_QOS_GRP_GRES_RUN_MIN,  /* QOS GrpTRESRunMins exceeded (GRES) */
451	WAIT_QOS_MAX_GRES_PER_JOB,  /* QOS MaxTRESPerJob exceeded (GRES) */
452	WAIT_QOS_MAX_GRES_PER_NODE, /* QOS MaxTRESPerNode exceeded (GRES) */
453	WAIT_QOS_MAX_GRES_PER_USER, /* QOS MaxTRESPerUser exceeded
454				     * (GRES) */
455	WAIT_QOS_MAX_GRES_MINS_PER_JOB,/* QOS MaxTRESMinsPerJob
456					* exceeded (GRES) */
457	WAIT_QOS_MIN_GRES,          /* QOS MinTRESPerJob not reached (CPU) */
458	WAIT_QOS_GRP_LIC,           /* QOS GrpTRES exceeded (license) */
459	WAIT_QOS_GRP_LIC_MIN,       /* QOS GrpTRESMins exceeded (license) */
460	WAIT_QOS_GRP_LIC_RUN_MIN,   /* QOS GrpTRESRunMins exceeded (license) */
461	WAIT_QOS_MAX_LIC_PER_JOB,   /* QOS MaxTRESPerJob exceeded (license) */
462	WAIT_QOS_MAX_LIC_PER_USER,  /* QOS MaxTRESPerUser exceeded (license) */
463	WAIT_QOS_MAX_LIC_MINS_PER_JOB,/* QOS MaxTRESMinsPerJob exceeded
464				       * (license) */
465	WAIT_QOS_MIN_LIC,           /* QOS MinTRESPerJob not reached
466				     * (license) */
467	WAIT_QOS_GRP_BB,            /* QOS GrpTRES exceeded
468				     * (burst buffer) */
469	WAIT_QOS_GRP_BB_MIN,        /* QOS GrpTRESMins exceeded
470				     * (burst buffer) */
471	WAIT_QOS_GRP_BB_RUN_MIN,    /* QOS GrpTRESRunMins exceeded
472				     * (burst buffer) */
473	WAIT_QOS_MAX_BB_PER_JOB,   /* QOS MaxTRESPerJob exceeded
474				    * (burst buffer) */
475	WAIT_QOS_MAX_BB_PER_NODE,  /* QOS MaxTRESPerNode exceeded
476				    * (burst buffer) */
477	WAIT_QOS_MAX_BB_PER_USER,  /* QOS MaxTRESPerUser exceeded
478				    * (burst buffer) */
479	WAIT_QOS_MAX_BB_MINS_PER_JOB,/* QOS MaxTRESMinsPerJob exceeded
480				      * (burst buffer) */
481	WAIT_QOS_MIN_BB,           /* QOS MinTRESPerJob not reached
482				    * (burst buffer) */
483	FAIL_DEADLINE,              /* reached deadline */
484	/* QOS MaxTRESPerAccount */
485	WAIT_QOS_MAX_BB_PER_ACCT,     /* exceeded burst buffer */
486	WAIT_QOS_MAX_CPU_PER_ACCT,    /* exceeded CPUs */
487	WAIT_QOS_MAX_ENERGY_PER_ACCT, /* exceeded Energy */
488	WAIT_QOS_MAX_GRES_PER_ACCT,   /* exceeded GRES */
489	WAIT_QOS_MAX_NODE_PER_ACCT,   /* exceeded Nodes */
490	WAIT_QOS_MAX_LIC_PER_ACCT,    /* exceeded Licenses */
491	WAIT_QOS_MAX_MEM_PER_ACCT,    /* exceeded Memory */
492	WAIT_QOS_MAX_UNK_PER_ACCT,    /* exceeded Unknown */
493	/********************/
494	WAIT_QOS_MAX_JOB_PER_ACCT,    /* QOS MaxJobPerAccount exceeded */
495	WAIT_QOS_MAX_SUB_JOB_PER_ACCT,/* QOS MaxJobSubmitSPerAccount exceeded */
496	WAIT_PART_CONFIG,	      /* Generic partition configuration reason */
497	WAIT_ACCOUNT_POLICY,          /* Generic accounting policy reason */
498
499	WAIT_FED_JOB_LOCK,            /* Can't get fed job lock */
500	FAIL_OOM,		      /* Exhausted memory */
501	WAIT_PN_MEM_LIMIT,	      /* MaxMemPer[CPU|Node] exceeded */
502
503	/* exceeded Billing TRES limits */
504	WAIT_ASSOC_GRP_BILLING,             /* GrpTRES           */
505	WAIT_ASSOC_GRP_BILLING_MIN,         /* GrpTRESMins       */
506	WAIT_ASSOC_GRP_BILLING_RUN_MIN,     /* GrpTRESRunMins    */
507	WAIT_ASSOC_MAX_BILLING_PER_JOB,     /* MaxTRESPerJob     */
508	WAIT_ASSOC_MAX_BILLING_PER_NODE,    /* MaxTRESPerNode    */
509	WAIT_ASSOC_MAX_BILLING_MINS_PER_JOB,/* MaxTRESMinsPerJob */
510
511	WAIT_QOS_GRP_BILLING,               /* GrpTRES           */
512	WAIT_QOS_GRP_BILLING_MIN,           /* GrpTRESMins       */
513	WAIT_QOS_GRP_BILLING_RUN_MIN,       /* GrpTRESRunMins    */
514	WAIT_QOS_MAX_BILLING_PER_JOB,       /* MaxTRESPerJob     */
515	WAIT_QOS_MAX_BILLING_PER_NODE,      /* MaxTRESPerNode    */
516	WAIT_QOS_MAX_BILLING_PER_USER,      /* MaxTRESPerUser    */
517	WAIT_QOS_MAX_BILLING_MINS_PER_JOB,  /* MaxTRESMinsPerJob */
518	WAIT_QOS_MAX_BILLING_PER_ACCT,      /* MaxTRESPerAcct    */
519	WAIT_QOS_MIN_BILLING,               /* MinTRESPerJob     */
520
521	WAIT_RESV_DELETED	      /* Reservation was deleted */
522};
523
524enum job_acct_types {
525	JOB_START,
526	JOB_STEP,
527	JOB_SUSPEND,
528	JOB_TERMINATED
529};
530
531/* Partition state flags */
532#define PARTITION_SUBMIT	0x01	/* Allow job submission to partition */
533#define PARTITION_SCHED 	0x02	/* Allow job startup from partition */
534
535/* Actual partition states based upon state flags */
536#define PARTITION_DOWN		(PARTITION_SUBMIT)
537#define PARTITION_UP		(PARTITION_SUBMIT | PARTITION_SCHED)
538#define PARTITION_DRAIN		(PARTITION_SCHED)
539#define PARTITION_INACTIVE	0x00
540
541/* Partition enforce flags for jobs */
542#define PARTITION_ENFORCE_NONE 0
543#define PARTITION_ENFORCE_ALL  1 /* job limit must be valid for ALL
544				  * partitions */
545#define PARTITION_ENFORCE_ANY  2 /* job limit must be valid for ANY
546				  * partition */
547
548/* Auth plugin (id) used for communication */
549enum auth_plugin_type {
550	AUTH_PLUGIN_NONE	= 100,
551	AUTH_PLUGIN_MUNGE	= 101,
552	AUTH_PLUGIN_JWT		= 102,
553};
554
555/* Select plugin (id) in use by cluster */
556enum select_plugin_type {
557	/* 100 unused (originally for BlueGene) */
558	SELECT_PLUGIN_CONS_RES       = 101, /* Cons Res on a normal system */
559	SELECT_PLUGIN_LINEAR         = 102, /* Linear on a normal system */
560	/* 103 unused (originally used for BGQ) */
561	/* 104 unused (originally used for Cray/ALPS with select/linear) */
562	/* 105 unused (originally used for Cray/ALPS with select/cons_res) */
563	SELECT_PLUGIN_SERIAL         = 106, /* Serial */
564	SELECT_PLUGIN_CRAY_LINEAR    = 107, /* Linear on a Native Cray */
565	SELECT_PLUGIN_CRAY_CONS_RES  = 108, /* Cons Res on a Native Cray */
566	SELECT_PLUGIN_CONS_TRES      = 109, /* Cons TRES on a normal system */
567	SELECT_PLUGIN_CRAY_CONS_TRES = 110  /* Cons TRES on a Native Cray */
568};
569
570/* switch plugin (id) in use by cluster */
571enum switch_plugin_type {
572	SWITCH_PLUGIN_NONE         = 100, /* NONE */
573	SWITCH_PLUGIN_GENERIC      = 101, /* Generic */
574	SWITCH_PLUGIN_CRAY         = 102, /* Cray */
575	/* 103 unused (originally used for NRT) */
576};
577
578enum select_jobdata_type {
579	SELECT_JOBDATA_PAGG_ID	= 14,	/* data-> uint64_t job container ID */
580	SELECT_JOBDATA_PTR	= 15,	/* data-> select_jobinfo_t *jobinfo */
581	SELECT_JOBDATA_CLEANING	= 22,	/* data-> uint16_t if the job is in
582					 * cleaning state or not. */
583	SELECT_JOBDATA_NETWORK	= 23,	/* data-> char * network info */
584	SELECT_JOBDATA_RELEASED	= 24,	/* if job resources have been released */
585};
586
587enum select_nodedata_type {
588	SELECT_NODEDATA_SUBCNT = 2,		/* data-> uint16_t */
589	SELECT_NODEDATA_PTR = 5,		/* data-> select_nodeinfo_t *nodeinfo */
590	SELECT_NODEDATA_MEM_ALLOC = 8,		/* data-> uint32_t */
591	SELECT_NODEDATA_TRES_ALLOC_FMT_STR = 9,	/* data-> char *,
592						 * free with xfree */
593	SELECT_NODEDATA_TRES_ALLOC_WEIGHTED = 10, /* data-> double */
594};
595
596enum select_print_mode {
597	SELECT_PRINT_HEAD,	/* Print just the header */
598	SELECT_PRINT_DATA,	/* Print just the data */
599	SELECT_PRINT_MIXED,	/* Print "field=value" */
600	SELECT_PRINT_MIXED_SHORT,/* Print less "field=value" */
601	SELECT_PRINT_BG_ID,	/* Print just the BG_ID */
602	SELECT_PRINT_NODES,	/* Print the nodelist */
603	SELECT_PRINT_CONNECTION,/* Print just the CONNECTION type */
604	SELECT_PRINT_ROTATE,    /* Print just the ROTATE */
605	SELECT_PRINT_GEOMETRY,	/* Print just the GEO */
606	SELECT_PRINT_START,	/* Print just the START location */
607	SELECT_PRINT_BLRTS_IMAGE,/* Print just the BLRTS IMAGE */
608	SELECT_PRINT_LINUX_IMAGE,/* Print just the LINUX IMAGE */
609	SELECT_PRINT_MLOADER_IMAGE,/* Print just the MLOADER IMAGE */
610	SELECT_PRINT_RAMDISK_IMAGE,/* Print just the RAMDISK IMAGE */
611	SELECT_PRINT_REBOOT,	/* Print just the REBOOT */
612	SELECT_PRINT_RESV_ID,	/* Print just Cray/BASIL reservation ID */
613	SELECT_PRINT_START_LOC	/* Print just the start location */
614};
615
616enum select_node_cnt {
617	SELECT_GET_NODE_SCALING,      /* Give scaling factor for node count */
618	SELECT_GET_NODE_CPU_CNT,      /* Give how many cpus are on a node */
619	SELECT_GET_MP_CPU_CNT,        /* Give how many cpus are on a
620				       * base partition */
621	SELECT_APPLY_NODE_MIN_OFFSET, /* Apply min offset to variable */
622	SELECT_APPLY_NODE_MAX_OFFSET, /* Apply max offset to variable */
623	SELECT_SET_NODE_CNT,	      /* Set altered node cnt */
624	SELECT_SET_MP_CNT             /* Given a node cnt return the
625				       * base partition count */
626};
627
628enum acct_gather_profile_info {
629	ACCT_GATHER_PROFILE_DIR,     /* Give directory profiling is stored */
630	ACCT_GATHER_PROFILE_DEFAULT, /* What is being collected for
631				      * profiling by default */
632	ACCT_GATHER_PROFILE_RUNNING  /* What is actually be collected
633				      * wither it be user or
634				      * default. (Only works in the slurmstepd)
635				      */
636};
637
638#define ACCT_GATHER_PROFILE_NOT_SET 0x00000000
639#define ACCT_GATHER_PROFILE_NONE    0x00000001
640#define ACCT_GATHER_PROFILE_ENERGY  0x00000002
641#define ACCT_GATHER_PROFILE_TASK    0x00000004
642#define ACCT_GATHER_PROFILE_LUSTRE  0x00000008
643#define ACCT_GATHER_PROFILE_NETWORK 0x00000010
644#define ACCT_GATHER_PROFILE_ALL     0xffffffff
645
646/* jobacct data types */
647enum jobacct_data_type {
648	JOBACCT_DATA_TOTAL,	/* data-> jobacctinfo_t * */
649	JOBACCT_DATA_PIPE,      /* data-> file descriptor */
650	JOBACCT_DATA_RUSAGE,	/* data-> rusage set user_cpu_sec,
651				 * user_cpu_usec, sys_cpu_sec, sys_cpu_usec */
652	JOBACCT_DATA_TOT_VSIZE = 5,	/* data-> uint64_t vsize */
653	JOBACCT_DATA_TOT_RSS = 8,	/* data-> uint64_t psize */
654};
655
656enum acct_energy_type {
657	ENERGY_DATA_JOULES_TASK,
658	ENERGY_DATA_STRUCT,
659	ENERGY_DATA_RECONFIG,
660	ENERGY_DATA_PROFILE,
661	ENERGY_DATA_LAST_POLL,
662	ENERGY_DATA_SENSOR_CNT,
663	ENERGY_DATA_NODE_ENERGY,
664	ENERGY_DATA_NODE_ENERGY_UP,
665	ENERGY_DATA_STEP_PTR
666};
667
668/*
669 * Task distribution states/methods
670 *
671 * Symbol format is SLURM_DIST_<node>_<socket>_<core>
672 *
673 * <node>   = Method for distributing tasks to nodes.
674 *            This determines the order in which task ids are
675 *            distributed to the nodes selected for the job/step.
676 * <socket> = Method for distributing allocated lllps across sockets.
677 *            This determines the order in which allocated lllps are
678 *            distributed across sockets for binding to tasks.
679 * <core>   = Method for distributing allocated lllps across cores.
680 *            This determines the order in which allocated lllps are
681 *            distributed across cores for binding to tasks.
682 *
683 * Note that the socket and core distributions apply only to task affinity.
684 */
685typedef enum task_dist_states {
686	/* NOTE: start SLURM_DIST_CYCLIC at 1 for HP MPI */
687	SLURM_DIST_CYCLIC               = 0x0001,
688	SLURM_DIST_BLOCK                = 0x0002,
689	SLURM_DIST_ARBITRARY            = 0x0003,
690	SLURM_DIST_PLANE                = 0x0004,
691	SLURM_DIST_CYCLIC_CYCLIC        = 0x0011,
692	SLURM_DIST_CYCLIC_BLOCK         = 0x0021,
693	SLURM_DIST_CYCLIC_CFULL         = 0x0031,
694	SLURM_DIST_BLOCK_CYCLIC         = 0x0012,
695	SLURM_DIST_BLOCK_BLOCK          = 0x0022,
696	SLURM_DIST_BLOCK_CFULL          = 0x0032,
697	SLURM_DIST_CYCLIC_CYCLIC_CYCLIC = 0x0111,
698	SLURM_DIST_CYCLIC_CYCLIC_BLOCK  = 0x0211,
699	SLURM_DIST_CYCLIC_CYCLIC_CFULL  = 0x0311,
700	SLURM_DIST_CYCLIC_BLOCK_CYCLIC  = 0x0121,
701	SLURM_DIST_CYCLIC_BLOCK_BLOCK   = 0x0221,
702	SLURM_DIST_CYCLIC_BLOCK_CFULL   = 0x0321,
703	SLURM_DIST_CYCLIC_CFULL_CYCLIC  = 0x0131,
704	SLURM_DIST_CYCLIC_CFULL_BLOCK   = 0x0231,
705	SLURM_DIST_CYCLIC_CFULL_CFULL   = 0x0331,
706	SLURM_DIST_BLOCK_CYCLIC_CYCLIC  = 0x0112,
707	SLURM_DIST_BLOCK_CYCLIC_BLOCK   = 0x0212,
708	SLURM_DIST_BLOCK_CYCLIC_CFULL   = 0x0312,
709	SLURM_DIST_BLOCK_BLOCK_CYCLIC   = 0x0122,
710	SLURM_DIST_BLOCK_BLOCK_BLOCK    = 0x0222,
711	SLURM_DIST_BLOCK_BLOCK_CFULL    = 0x0322,
712	SLURM_DIST_BLOCK_CFULL_CYCLIC   = 0x0132,
713	SLURM_DIST_BLOCK_CFULL_BLOCK    = 0x0232,
714	SLURM_DIST_BLOCK_CFULL_CFULL    = 0x0332,
715
716	SLURM_DIST_NODECYCLIC           = 0x0001,
717	SLURM_DIST_NODEBLOCK            = 0x0002,
718	SLURM_DIST_SOCKCYCLIC           = 0x0010,
719	SLURM_DIST_SOCKBLOCK            = 0x0020,
720	SLURM_DIST_SOCKCFULL            = 0x0030,
721	SLURM_DIST_CORECYCLIC           = 0x0100,
722	SLURM_DIST_COREBLOCK            = 0x0200,
723	SLURM_DIST_CORECFULL            = 0x0300,
724
725	SLURM_DIST_NO_LLLP              = 0x1000,
726	SLURM_DIST_UNKNOWN              = 0x2000
727} task_dist_states_t;
728
729#define SLURM_DIST_STATE_BASE		0x00FFFF
730#define SLURM_DIST_STATE_FLAGS		0xFF0000
731#define SLURM_DIST_PACK_NODES		0x800000
732#define SLURM_DIST_NO_PACK_NODES	0x400000
733
734#define SLURM_DIST_NODEMASK               0xF00F
735#define SLURM_DIST_SOCKMASK               0xF0F0
736#define SLURM_DIST_COREMASK               0xFF00
737#define SLURM_DIST_NODESOCKMASK           0xF0FF
738
739/* Open stdout/err file mode, 0 for system default (JobFileAppend) */
740#define OPEN_MODE_APPEND	1
741#define OPEN_MODE_TRUNCATE	2
742
743typedef enum cpu_bind_type {	/* cpu binding type from --cpu-bind=... */
744	/* verbose can be set with any other flag */
745	CPU_BIND_VERBOSE    = 0x0001, /* =v, */
746	/* the following auto-binding flags are mutually exclusive */
747	CPU_BIND_TO_THREADS = 0x0002, /* =threads */
748	CPU_BIND_TO_CORES   = 0x0004, /* =cores */
749	CPU_BIND_TO_SOCKETS = 0x0008, /* =sockets */
750	CPU_BIND_TO_LDOMS   = 0x0010, /* locality domains */
751	CPU_BIND_TO_BOARDS  = 0x1000, /* =boards */
752	/* the following manual binding flags are mutually exclusive */
753	/* CPU_BIND_NONE needs to be the lowest value among manual bindings */
754	CPU_BIND_NONE	    = 0x0020, /* =no */
755	CPU_BIND_RANK  	    = 0x0040, /* =rank */
756	CPU_BIND_MAP	    = 0x0080, /* =map_cpu:<list of CPU IDs> */
757	CPU_BIND_MASK	    = 0x0100, /* =mask_cpu:<list of CPU masks> */
758	CPU_BIND_LDRANK     = 0x0200, /* =locality domain rank */
759	CPU_BIND_LDMAP	    = 0x0400, /* =map_ldom:<list of locality domains> */
760	CPU_BIND_LDMASK	    = 0x0800, /* =mask_ldom:<list of ldom masks> */
761
762	/* the following is used primarily for the
763	   --hint=nomultithread when -mblock:block is requested. */
764	CPU_BIND_ONE_THREAD_PER_CORE = 0x2000,/* Only bind to one
765					       * thread of a core */
766
767	/* the following is used only as a flag for expressing
768	 * the contents of TaskPluginParams */
769	CPU_BIND_CPUSETS   = 0x8000,
770
771	/* default binding if auto binding doesn't match. */
772	CPU_AUTO_BIND_TO_THREADS = 0x04000,
773	CPU_AUTO_BIND_TO_CORES   = 0x10000,
774	CPU_AUTO_BIND_TO_SOCKETS = 0x20000,
775
776	/* the following is used only as a flag for expressing
777	 * the contents of TaskPluginParams */
778	SLURMD_OFF_SPEC            = 0x40000,
779	CPU_BIND_OFF               = 0x80000	/* Disable binding */
780} cpu_bind_type_t;
781
782/* Flag to indicate that cpu_freq is a range: low,medium,high,high-1
783 * instead of an integer value in kilohertz */
784#define CPU_FREQ_RANGE_FLAG		0x80000000
785#define CPU_FREQ_LOW			0x80000001
786#define CPU_FREQ_MEDIUM			0x80000002
787#define CPU_FREQ_HIGH			0x80000003
788#define CPU_FREQ_HIGHM1			0x80000004
789#define CPU_FREQ_CONSERVATIVE		0x88000000
790#define CPU_FREQ_ONDEMAND		0x84000000
791#define CPU_FREQ_PERFORMANCE		0x82000000
792#define CPU_FREQ_POWERSAVE		0x81000000
793#define CPU_FREQ_USERSPACE		0x80800000
794#define CPU_FREQ_GOV_MASK   		0x8ff00000
795/* Vestigial values for transition from v14.11 systems */
796#define CPU_FREQ_PERFORMANCE_OLD	0x80000005
797#define CPU_FREQ_POWERSAVE_OLD		0x80000006
798#define CPU_FREQ_USERSPACE_OLD		0x80000007
799#define CPU_FREQ_ONDEMAND_OLD		0x80000008
800#define CPU_FREQ_CONSERVATIVE_OLD	0x80000009
801
802typedef enum mem_bind_type {    /* memory binding type from --mem-bind=... */
803	/* verbose can be set with any other flag */
804	MEM_BIND_VERBOSE= 0x01,	/* =v, */
805	/* the following five manual binding flags are mutually exclusive */
806	/* MEM_BIND_NONE needs to be the first in this sub-list */
807	MEM_BIND_NONE   = 0x02,	/* =no */
808	MEM_BIND_RANK   = 0x04,	/* =rank */
809	MEM_BIND_MAP    = 0x08,	/* =map_mem:<list of NUMA IDs> */
810	MEM_BIND_MASK   = 0x10,	/* =mask_mem:<list of NUMA masks> */
811	MEM_BIND_LOCAL  = 0x20,	/* =local */
812	/* sort and prefer can be set with any other flags */
813	MEM_BIND_SORT	= 0x40,	/* =sort */
814	MEM_BIND_PREFER = 0x80	/* =prefer */
815} mem_bind_type_t;
816
817typedef enum accel_bind_type {    /* accelerator binding from --accel_bind= */
818	ACCEL_BIND_VERBOSE         = 0x01, /* 'v' verbose */
819	ACCEL_BIND_CLOSEST_GPU     = 0x02, /* 'g' Use closest GPU to the CPU */
820	ACCEL_BIND_CLOSEST_MIC     = 0x04, /* 'm' Use closest NIC to CPU */
821	ACCEL_BIND_CLOSEST_NIC     = 0x08  /* 'n' Use closest NIC to CPU */
822} accel_bind_type_t;
823
824/* The last entry in node_states must be STATE_END, keep in sync with
825 * node_state_string. values may be ORed with NODE_STATE_FLAGS below.
826 * Node states typically alternate between NODE_STATE_IDLE and
827 * NODE_STATE_ALLOCATED. The NODE_STATE_COMPLETING flag will be set
828 * when jobs are in the process of terminating. */
829enum node_states {
830	NODE_STATE_UNKNOWN,	/* node's initial state, unknown */
831	NODE_STATE_DOWN,	/* node in non-usable state */
832	NODE_STATE_IDLE,	/* node idle and available for use */
833	NODE_STATE_ALLOCATED,	/* node has been allocated to a job */
834	NODE_STATE_ERROR,	/* UNUSED - node is in an error state */
835	NODE_STATE_MIXED,	/* node has a mixed state */
836	NODE_STATE_FUTURE,	/* node slot reserved for future use */
837	NODE_STATE_END		/* last entry in table */
838};
839#define NODE_STATE_BASE       0x0000000f
840#define NODE_STATE_FLAGS      0xfffffff0
841#define NODE_STATE_NET        0x00000010 /* If a node is using Cray's
842					  * Network Performance
843					  * Counters but isn't in a
844					  * allocation. */
845#define NODE_STATE_RES        0x00000020 /* If a node is in a
846					  * reservation (used primarily
847					  * to note a node isn't idle
848					  * for non-reservation jobs) */
849#define NODE_STATE_UNDRAIN    0x00000040 /* Clear DRAIN flag for a node */
850#define NODE_STATE_CLOUD      0x00000080 /* node comes from cloud */
851#define NODE_RESUME           0x00000100 /* Restore a DRAINED, DRAINING, DOWN
852					  * or FAILING node to service (e.g.
853					  * IDLE or ALLOCATED). Used in
854					  * slurm_update_node() request */
855#define NODE_STATE_DRAIN      0x00000200 /* do not allocated new work */
856#define NODE_STATE_COMPLETING 0x00000400 /* node is completing allocated job */
857#define NODE_STATE_NO_RESPOND 0x00000800 /* node is not responding */
858#define NODE_STATE_POWER_SAVE 0x00001000 /* node is powered down by slurm */
859#define NODE_STATE_FAIL       0x00002000 /* node is failing, do not allocate
860					  * new work */
861#define NODE_STATE_POWER_UP   0x00004000 /* restore power or otherwise
862					  * configure a node */
863#define NODE_STATE_MAINT      0x00008000 /* node in maintenance reservation */
864#define NODE_STATE_REBOOT     0x00010000 /* node reboot requested */
865#define NODE_STATE_CANCEL_REBOOT 0x00020000 /* cancel pending reboot */
866#define NODE_STATE_POWERING_DOWN 0x00040000 /* node is powering down */
867
868/* used to define the size of the credential.signature size
869 * used to define the key size of the io_stream_header_t
870 */
871#define SLURM_SSL_SIGNATURE_LENGTH 128
872
873/* Used as show_flags for slurm_get_ and slurm_load_ function calls.
874 * Values can be ORed */
875#define SHOW_ALL	0x0001	/* Show info for "hidden" partitions */
876#define SHOW_DETAIL	0x0002	/* Show detailed resource information */
877/*  was SHOW_DETAIL2	0x0004     Removed v19.05 */
878#define SHOW_MIXED	0x0008	/* Automatically set node MIXED state */
879#define SHOW_LOCAL	0x0010	/* Show only local information, even on
880				 * federated cluster */
881#define SHOW_SIBLING	0x0020	/* Show sibling jobs on a federated cluster */
882#define SHOW_FEDERATION	0x0040	/* Show federated state information.
883				 * Shows local info if not in federation */
884#define SHOW_FUTURE	0x0080	/* Show future nodes */
885
886/* Define keys for ctx_key argument of slurm_step_ctx_get() */
887enum ctx_keys {
888	SLURM_STEP_CTX_STEPID,	/* get the created job step id */
889	SLURM_STEP_CTX_TASKS,	/* get array of task count on each node */
890	SLURM_STEP_CTX_TID,	/* get array of task IDs for specified node */
891	SLURM_STEP_CTX_RESP,	/* get job step create response message */
892	SLURM_STEP_CTX_CRED,
893	SLURM_STEP_CTX_SWITCH_JOB,
894	SLURM_STEP_CTX_NUM_HOSTS,
895	SLURM_STEP_CTX_HOST,
896	SLURM_STEP_CTX_JOBID,
897	SLURM_STEP_CTX_USER_MANAGED_SOCKETS,
898	SLURM_STEP_CTX_NODE_LIST,	/* step's node list, must xfree */
899	SLURM_STEP_CTX_TIDS,	/* get array of task IDs for all nodes */
900	SLURM_STEP_CTX_DEF_CPU_BIND_TYPE
901};
902
903/* CR_CPU, CR_SOCKET and CR_CORE are mutually exclusive
904 * CR_MEMORY may be added to any of the above values or used by itself
905 * CR_ONE_TASK_PER_CORE may also be added to any of the above values */
906#define CR_CPU		0x0001	/* Resources are shared down to the level of
907				 * logical processors which can be socket,
908				 * core, or thread depending on the system. */
909#define CR_SOCKET	0x0002	/* Resources are shared down to the socket
910				 * level. Jobs will not be co-allocated
911				 * within a socket. */
912#define CR_CORE		0x0004	/* Resources are shared down to the core level.
913				 * Jobs will not be co-allocated within a
914				 * core. */
915#define CR_BOARD	0x0008	/* Resources are shared down to the board
916				 * level. Jobs will not be co-allocated
917				 * within a board. */
918#define CR_MEMORY	0x0010	/* Memory as consumable resources. Memory is
919				 * not over-commited when selected as a CR. */
920#define CR_OTHER_CONS_RES    0x0020 /* if layering select plugins use
921				     * cons_res instead of linear (default)
922				     */
923/* was CR_NHC_STEP_NO 0x0040, removed v19.05 */
924/* was CR_NHC_NO 0x0080, removed v19.05 */
925
926/* By default, schedule only one task per core.
927 * Without this option, tasks would be allocated threads. */
928#define CR_ONE_TASK_PER_CORE 0x0100
929
930/* Pack tasks tightly onto allocated nodes rather than distributing them evenly
931 * across available nodes */
932#define CR_PACK_NODES  0x0200
933
934/* was CR_NHC_ABSOLUTELY_NO 0x0400, removed v19.05 */
935#define CR_OTHER_CONS_TRES   0x0800 /* if layering select plugins use
936				     * cons_tres instead of linear (default)
937				     */
938/* By default, distribute cores using a block approach inside the nodes */
939#define CR_CORE_DEFAULT_DIST_BLOCK 0x1000
940#define CR_LLN		0x4000  /* Select nodes by "least loaded." */
941
942#define MEM_PER_CPU  0x8000000000000000
943#define SHARED_FORCE 0x8000
944
945#define PRIVATE_DATA_JOBS	  0x0001 /* job/step data is private */
946#define PRIVATE_DATA_NODES	  0x0002 /* node data is private */
947#define PRIVATE_DATA_PARTITIONS	  0x0004 /* partition data is private */
948#define PRIVATE_DATA_USAGE	  0x0008 /* accounting usage data is private */
949#define PRIVATE_DATA_USERS	  0x0010 /* accounting user data is private */
950#define PRIVATE_DATA_ACCOUNTS	  0x0020 /* accounting account data is private*/
951#define PRIVATE_DATA_RESERVATIONS 0x0040 /* reservation data is private */
952#define PRIVATE_CLOUD_NODES	  0x0080 /* hide powered down nodes in cloud */
953#define PRIVATE_DATA_EVENTS	  0x0100 /* events are private */
954
955#define PRIORITY_RESET_NONE	0x0000	/* never clear */
956#define PRIORITY_RESET_NOW	0x0001	/* clear now (when slurmctld restarts) */
957#define PRIORITY_RESET_DAILY	0x0002	/* clear daily at midnight */
958#define PRIORITY_RESET_WEEKLY	0x0003	/* clear weekly at Sunday 00:00 */
959#define PRIORITY_RESET_MONTHLY	0x0004	/* clear monthly on first at 00:00 */
960#define PRIORITY_RESET_QUARTERLY 0x0005	/* clear quarterly on first at 00:00 */
961#define PRIORITY_RESET_YEARLY	0x0006	/* clear yearly on first at 00:00 */
962
963#define PROP_PRIO_OFF		0x0000	/* Do not propagage user nice value */
964#define PROP_PRIO_ON		0x0001	/* Propagate user nice value */
965#define PROP_PRIO_NICER		0x0002	/* Ensure that user tasks have a nice
966					 * value that is higher than slurmd */
967
968#define PRIORITY_FLAGS_ACCRUE_ALWAYS	0x00000001 /* Flag to always accrue age
969						    * priority to pending jobs
970						    * ignoring dependencies or
971						    * holds */
972#define PRIORITY_FLAGS_MAX_TRES 	0x00000002 /* Calculate billed_tres as
973						    * the MAX of TRES on a node
974						    * rather than the sum or
975						    * TRES. */
976#define PRIORITY_FLAGS_SIZE_RELATIVE	0x00000004 /* Enable job size
977						    * measurement relative to
978						    * its time limit */
979#define PRIORITY_FLAGS_DEPTH_OBLIVIOUS	0x00000008 /* Flag to use depth
980						    * oblivious formula for
981						    * computing hierarchical
982						    * fairshare */
983#define PRIORITY_FLAGS_CALCULATE_RUNNING 0x00000010 /* Calculate priorities for
984						     * running jobs, not only
985						     * the pending jobs. */
986#define PRIORITY_FLAGS_FAIR_TREE	0x00000020 /* Prioritize by level in
987						    * account hierarchy. */
988#define PRIORITY_FLAGS_INCR_ONLY	0x00000040 /* Priority can only
989						    * increase, never decrease
990						    * in value */
991
992#define PRIORITY_FLAGS_NO_NORMAL_ASSOC	0x00000080
993#define PRIORITY_FLAGS_NO_NORMAL_PART	0x00000100
994#define PRIORITY_FLAGS_NO_NORMAL_QOS	0x00000200
995#define PRIORITY_FLAGS_NO_NORMAL_TRES	0x00000400
996
997/* These bits are set in the bitflags field of job_desc_msg_t */
998#define KILL_INV_DEP       0x00000001	/* Kill job on invalid dependency */
999#define NO_KILL_INV_DEP    0x00000002	/* Don't kill job on invalid dependency */
1000#define HAS_STATE_DIR      0x00000004	/* Used by slurmctld to track state dir */
1001#define BACKFILL_TEST      0x00000008	/* Backfill test in progress */
1002#define GRES_ENFORCE_BIND  0x00000010	/* Enforce CPU/GRES binding */
1003#define TEST_NOW_ONLY      0x00000020	/* Test for immediately start only */
1004#define NODE_MEM_CALC      0x00000040	/* Per-node memory limit calculated */
1005#define NODE_REBOOT        0x00000080	/* Waiting for node reboot */
1006#define SPREAD_JOB         0x00000100	/* Spread job across max node count */
1007#define USE_MIN_NODES      0x00000200	/* Prefer minimum node count */
1008#define JOB_KILL_HURRY     0x00000400	/* Avoid burst buffer stage out */
1009#define TRES_STR_CALC      0x00000800   /* Avoid calculating TRES strings at the
1010					 * end of a job. */
1011#define SIB_JOB_FLUSH      0x00001000   /* Don't send complete to origin */
1012#define HET_JOB_FLAG       0x00002000	/* Heterogeneous job management flag */
1013#define JOB_NTASKS_SET     0x00004000	/* --ntasks explicitly set */
1014#define JOB_CPUS_SET       0x00008000	/* --cpus-per-tasks explicitly set */
1015#define BF_WHOLE_NODE_TEST 0x00010000	/* Backfill test in progress */
1016#define TOP_PRIO_TMP       0x00020000	/* Temporary flag for top priority job
1017					 * operation */
1018#define JOB_ACCRUE_OVER    0x00040000	/* We have cleared the accrual count of
1019					 * a job. */
1020#define GRES_DISABLE_BIND  0x00080000	/* Disable CPU/GRES binding */
1021#define JOB_WAS_RUNNING    0x00100000  /* Job was running */
1022#define RESET_ACCRUE_TIME  0x00200000   /* Reset the job's accrue time */
1023/*                         0x00400000      Unused */
1024#define JOB_MEM_SET        0x00800000	/* Memory limit explicity set by job */
1025#define JOB_RESIZED        0x01000000	/* Running job added/removed nodes */
1026#define USE_DEFAULT_ACCT   0x02000000	/* Job submitted to default account */
1027#define USE_DEFAULT_PART   0x04000000	/* Job submitted to default partition */
1028#define USE_DEFAULT_QOS    0x08000000	/* Job submitted with default QOS */
1029#define USE_DEFAULT_WCKEY  0x10000000	/* Job submitted with default WCKEY */
1030#define JOB_DEPENDENT      0x20000000	/* Job dependent or invalid depend */
1031#define JOB_PROM           0x40000000	/* Job attempting to run in a
1032					 * promiscuous reservation */
1033
1034#define X11_FORWARD_ALL		0x0001	/* all nodes should setup forward */
1035#define X11_FORWARD_BATCH	0x0002  /* only the batch node */
1036#define X11_FORWARD_FIRST	0x0004	/* only the first node */
1037#define X11_FORWARD_LAST	0x0008	/* only the last node */
1038
1039/*****************************************************************************\
1040 *      SLURM HOSTLIST FUNCTIONS
1041\*****************************************************************************/
1042
1043/* The hostlist opaque data type
1044 *
1045 * A hostlist is a list of hostnames optimized for a prefixXXXX style
1046 * naming convention, where XXXX  is a decimal, numeric suffix.
1047 */
1048#ifndef   __hostlist_t_defined
1049#  define __hostlist_t_defined
1050typedef struct hostlist * hostlist_t;
1051#endif
1052
1053/*
1054 * slurm_hostlist_create():
1055 *
1056 * Create a new hostlist from a string representation.
1057 *
1058 * The string representation (str) may contain one or more hostnames or
1059 * bracketed hostlists separated by either `,' or whitespace. A bracketed
1060 * hostlist is denoted by a common prefix followed by a list of numeric
1061 * ranges contained within brackets: e.g. "tux[0-5,12,20-25]"
1062 *
1063 * To support systems with 3-D topography, a rectangular prism may
1064 * be described using two three digit numbers separated by "x": e.g.
1065 * "bgl[123x456]". This selects all nodes between 1 and 4 inclusive
1066 * in the first dimension, between 2 and 5 in the second, and between
1067 * 3 and 6 in the third dimension for a total of 4*4*4=64 nodes
1068 *
1069 * Note: if this module is compiled with WANT_RECKLESS_HOSTRANGE_EXPANSION
1070 * defined, a much more loose interpretation of host ranges is used.
1071 * Reckless hostrange expansion allows all of the following (in addition to
1072 * bracketed hostlists):
1073 *
1074 *  o tux0-5,tux12,tux20-25
1075 *  o tux0-tux5,tux12,tux20-tux25
1076 *  o tux0-5,12,20-25
1077 *
1078 * If str is NULL, and empty hostlist is created and returned.
1079 *
1080 * If the create fails, hostlist_create() returns NULL.
1081 *
1082 * The returned hostlist must be freed with hostlist_destroy()
1083 *
1084 */
1085extern hostlist_t slurm_hostlist_create(const char *hostlist);
1086
1087/* slurm_hostlist_count():
1088 *
1089 * Return the number of hosts in hostlist hl.
1090 */
1091extern int slurm_hostlist_count(hostlist_t hl);
1092
1093/*
1094 * slurm_hostlist_destroy():
1095 *
1096 * Destroy a hostlist object. Frees all memory allocated to the hostlist.
1097 */
1098extern void slurm_hostlist_destroy(hostlist_t hl);
1099
1100/* slurm_hostlist_find():
1101 *
1102 * Searches hostlist hl for the first host matching hostname
1103 * and returns position in list if found.
1104 *
1105 * Returns -1 if host is not found.
1106 */
1107extern int slurm_hostlist_find(hostlist_t hl, const char *hostname);
1108
1109/* slurm_hostlist_push():
1110 *
1111 * push a string representation of hostnames onto a hostlist.
1112 *
1113 * The hosts argument may take the same form as in slurm_hostlist_create()
1114 *
1115 * Returns the number of hostnames inserted into the list,
1116 * or 0 on failure.
1117 */
1118extern int slurm_hostlist_push(hostlist_t hl, const char *hosts);
1119
1120/* slurm_hostlist_push_host():
1121 *
1122 * Push a single host onto the hostlist hl.
1123 * This function is more efficient than slurm_hostlist_push() for a single
1124 * hostname, since the argument does not need to be checked for ranges.
1125 *
1126 * return value is 1 for success, 0 for failure.
1127 */
1128extern int slurm_hostlist_push_host(hostlist_t hl, const char *host);
1129
1130/* slurm_hostlist_ranged_string():
1131 *
1132 * Write the string representation of the hostlist hl into buf,
1133 * writing at most n chars. Returns the number of bytes written,
1134 * or -1 if truncation occurred.
1135 *
1136 * The result will be NULL terminated.
1137 *
1138 * slurm_hostlist_ranged_string() will write a bracketed hostlist representation
1139 * where possible.
1140 */
1141extern ssize_t slurm_hostlist_ranged_string(hostlist_t hl, size_t n, char *buf);
1142
1143/* slurm_hostlist_ranged_string_malloc():
1144 *
1145 * Return the string representation of the hostlist hl.
1146 *
1147 * The result must be released using free();
1148 */
1149extern char *slurm_hostlist_ranged_string_malloc(hostlist_t hl);
1150
1151/* hostlist_ranged_string_xmalloc():
1152 *
1153 * Wrapper of hostlist_ranged_string(), with result buffer dynamically
1154 * allocated using xmalloc().
1155 * The result will be NULL on failure (out of memory).
1156 *
1157 * Caller should free the result string using xfree().
1158 */
1159extern char *slurm_hostlist_ranged_string_xmalloc(hostlist_t hl);
1160
1161/*
1162 * slurm_hostlist_shift():
1163 *
1164 * Returns the string representation of the first host in the hostlist
1165 * or NULL if the hostlist is empty or there was an error allocating memory.
1166 * The host is removed from the hostlist.
1167 *
1168 * Note: Caller is responsible for freeing the returned memory.
1169 */
1170extern char *slurm_hostlist_shift(hostlist_t hl);
1171
1172/* slurm_hostlist_uniq():
1173 *
1174 * Sort the hostlist hl and remove duplicate entries.
1175 *
1176 */
1177extern void slurm_hostlist_uniq(hostlist_t hl);
1178
1179/*****************************************************************************\
1180 *      SLURM LIST FUNCTIONS
1181\*****************************************************************************/
1182
1183#ifndef   __list_datatypes_defined
1184#  define __list_datatypes_defined
1185typedef struct xlist * List;
1186/*
1187 *  List opaque data type.
1188 */
1189
1190typedef struct listIterator * ListIterator;
1191/*
1192 *  List Iterator opaque data type.
1193 */
1194
1195typedef void (*ListDelF) (void *x);
1196/*
1197 *  Function prototype to deallocate data stored in a list.
1198 *    This function is responsible for freeing all memory associated
1199 *    with an item, including all subordinate items (if applicable).
1200 */
1201
1202typedef int (*ListCmpF) (void *x, void *y);
1203/*
1204 *  Function prototype for comparing two items in a list.
1205 *  Returns less-than-zero if (x<y), zero if (x==y), and
1206 *    greather-than-zero if (x>y).
1207 */
1208
1209typedef int (*ListFindF) (void *x, void *key);
1210/*
1211 *  Function prototype for matching items in a list.
1212 *  Returns non-zero if (x==key); o/w returns zero.
1213 */
1214
1215typedef int (*ListForF) (void *x, void *arg);
1216/*
1217 *  Function prototype for operating on each item in a list.
1218 *  Returns less-than-zero on error.
1219 */
1220#endif
1221
1222/* slurm_list_append():
1223 *
1224 *  Inserts data [x] at the end of list [l].
1225 *  Returns the data's ptr.
1226 */
1227extern void *slurm_list_append(List l, void *x);
1228
1229/* slurm_list_count():
1230 *
1231 *  Returns the number of items in list [l].
1232 */
1233extern int slurm_list_count(List l);
1234
1235/* slurm_list_create():
1236 *
1237 *  Creates and returns a new empty list.
1238 *  The deletion function [f] is used to deallocate memory used by items
1239 *    in the list; if this is NULL, memory associated with these items
1240 *    will not be freed when the list is destroyed.
1241 *  Note: Abandoning a list without calling slurm_list_destroy() will result
1242 *    in a memory leak.
1243 */
1244extern List slurm_list_create(ListDelF f);
1245
1246/* slurm_list_destroy():
1247 *
1248 *  Destroys list [l], freeing memory used for list iterators and the
1249 *    list itself; if a deletion function was specified when the list
1250 *    was created, it will be called for each item in the list.
1251 */
1252extern void slurm_list_destroy(List l);
1253
1254/* slurm_list_find():
1255 *
1256 *  Traverses the list from the point of the list iterator [i]
1257 *    using [f] to match each item with [key].
1258 *  Returns a ptr to the next item for which the function [f]
1259 *    returns non-zero, or NULL once the end of the list is reached.
1260 *  Example: i=slurm_list_iterator_reset(i);
1261 *	     while ((x=slurm_list_find(i,f,k))) {...}
1262 */
1263extern void *slurm_list_find(ListIterator i, ListFindF f, void *key);
1264
1265/* slurm_list_is_empty():
1266 *
1267 *  Returns non-zero if list [l] is empty; o/w returns zero.
1268 */
1269extern int slurm_list_is_empty(List l);
1270
1271/*
1272 *  Creates and returns a list iterator for non-destructively traversing
1273 *    list [l].
1274 */
1275extern ListIterator slurm_list_iterator_create(List l);
1276
1277/* slurm_list_iterator_reset():
1278 *
1279 *  Resets the list iterator [i] to start traversal at the beginning
1280 *    of the list.
1281 */
1282extern void slurm_list_iterator_reset(ListIterator i);
1283
1284/*
1285 *  Destroys the list iterator [i]; list iterators not explicitly destroyed
1286 *    in this manner will be destroyed when the list is deallocated via
1287 *    list_destroy().
1288 */
1289extern void slurm_list_iterator_destroy(ListIterator i);
1290
1291/* slurm_list_next():
1292 *
1293 *  Returns a ptr to the next item's data,
1294 *    or NULL once the end of the list is reached.
1295 *  Example: i=slurm_list_iterator_create(i);
1296 *	     while ((x=slurm_list_next(i))) {...}
1297 */
1298extern void *slurm_list_next(ListIterator i);
1299
1300/* slurm_list_sort():
1301 *
1302 *  Sorts list [l] into ascending order according to the function [f].
1303 *  Note: Sorting a list resets all iterators associated with the list.
1304 *  Note: The sort algorithm is stable.
1305 */
1306extern void slurm_list_sort(List l, ListCmpF f);
1307
1308/* slurm_list_pop():
1309 *
1310 *  Pops the data item at the top of the stack [l].
1311 *  Returns the data's ptr, or NULL if the stack is empty.
1312 */
1313extern void *slurm_list_pop(List l);
1314
1315/*****************************************************************************\
1316 *      SLURM BITSTR FUNCTIONS
1317\*****************************************************************************/
1318
1319#ifndef   __bitstr_datatypes_defined
1320#  define __bitstr_datatypes_defined
1321
1322typedef int64_t bitstr_t;
1323#define BITSTR_SHIFT 		BITSTR_SHIFT_WORD64
1324
1325typedef bitstr_t bitoff_t;
1326
1327#endif
1328
1329#define ALLOC_SID_ADMIN_HOLD	0x00000001	/* admin job hold */
1330#define ALLOC_SID_USER_HOLD	0x00000002	/* user job hold */
1331
1332#define JOB_SHARED_NONE         0x0000
1333#define JOB_SHARED_OK           0x0001
1334#define JOB_SHARED_USER         0x0002
1335#define JOB_SHARED_MCS          0x0003
1336
1337#define SLURM_POWER_FLAGS_LEVEL 0x0001		/* Equal power cap on all nodes */
1338
1339/*****************************************************************************\
1340 *	PROTOCOL DATA STRUCTURE DEFINITIONS
1341\*****************************************************************************/
1342typedef struct dynamic_plugin_data {
1343	void *data;
1344	uint32_t plugin_id;
1345} dynamic_plugin_data_t;
1346
1347typedef struct acct_gather_energy {
1348	uint32_t ave_watts;	  /* average power consump of node, in watts */
1349	uint64_t base_consumed_energy;
1350	uint64_t consumed_energy; /* total energy consumed by node, in joules */
1351	uint32_t current_watts;	  /* current power consump of node, in watts */
1352	uint64_t previous_consumed_energy;
1353	time_t poll_time;         /* When information was last retrieved */
1354} acct_gather_energy_t;
1355
1356typedef struct ext_sensors_data {
1357	uint64_t consumed_energy;    /* total energy consumed, in joules */
1358	uint32_t temperature;	     /* temperature, in celsius */
1359	time_t   energy_update_time; /* last update time for consumed_energy */
1360	uint32_t current_watts;      /* current power consumption, in watts */
1361} ext_sensors_data_t;
1362
1363typedef struct power_mgmt_data {
1364	uint32_t cap_watts;	/* power consumption limit of node, in watts */
1365	uint32_t current_watts;	/* current power consumption, in watts */
1366	uint64_t joule_counter;	/* total energy consumption by node, in joules */
1367	uint32_t new_cap_watts;	/* new power consumption limit of node, in watts */
1368	uint32_t max_watts;	/* maximum power consumption by node, in watts */
1369	uint32_t min_watts;	/* minimum power consumption by node, in watts */
1370	time_t new_job_time;	/* set when a new job has been scheduled on the
1371				 * node, used to trigger higher cap */
1372	uint16_t state;		/* Power state information */
1373	uint64_t time_usec;	/* Data timestamp in microseconds since start
1374				 * of the day */
1375} power_mgmt_data_t;
1376
1377#define CORE_SPEC_THREAD 0x8000	/* If set, this is a thread count not core count */
1378
1379/*
1380 * Update:
1381 * _copy_job_desc_to_job_record()
1382 * slurm_free_job_desc_msg()
1383 */
1384typedef struct job_descriptor {	/* For submit, allocate, and update requests */
1385	char *account;		/* charge to specified account */
1386	char *acctg_freq;	/* accounting polling intervals (seconds) */
1387	char *admin_comment;	/* administrator's arbitrary comment (update only) */
1388	char *alloc_node;	/* node making resource allocation request
1389				 * NOTE: Normally set by slurm_submit* or
1390				 * slurm_allocate* function */
1391	uint16_t alloc_resp_port; /* port to send allocation confirmation to */
1392	uint32_t alloc_sid;	/* local sid making resource allocation request
1393				 * NOTE: Normally set by slurm_submit* or
1394				 * slurm_allocate* function
1395				 * NOTE: Also used for update flags, see
1396				 * ALLOC_SID_* flags */
1397	uint32_t argc;		/* number of arguments to the script */
1398	char **argv;		/* arguments to the script */
1399	char *array_inx;	/* job array index values */
1400	void *array_bitmap;	/* NOTE: Set by slurmctld */
1401	char *batch_features;	/* features required for batch script's node */
1402	time_t begin_time;	/* delay initiation until this time */
1403	uint32_t bitflags;      /* bitflags */
1404	char *burst_buffer;	/* burst buffer specifications */
1405	char *clusters;		/* cluster names used for multi-cluster jobs */
1406	char *cluster_features;	/* required cluster feature specification,
1407				 * default NONE */
1408	char *comment;		/* arbitrary comment */
1409	uint16_t contiguous;	/* 1 if job requires contiguous nodes,
1410				 * 0 otherwise,default=0 */
1411	uint16_t core_spec;	/* specialized core/thread count,
1412				 * see CORE_SPEC_THREAD */
1413	char *cpu_bind;		/* binding map for map/mask_cpu - This
1414				 * currently does not matter to the
1415				 * job allocation, setting this does
1416				 * not do anything for steps. */
1417	uint16_t cpu_bind_type;	/* see cpu_bind_type_t - This
1418				 * currently does not matter to the
1419				 * job allocation, setting this does
1420				 * not do anything for steps. */
1421	uint32_t cpu_freq_min;  /* Minimum cpu frequency  */
1422	uint32_t cpu_freq_max;  /* Maximum cpu frequency  */
1423	uint32_t cpu_freq_gov;  /* cpu frequency governor */
1424	char *cpus_per_tres;	/* semicolon delimited list of TRES=# values */
1425	time_t deadline;	/* deadline */
1426	uint32_t delay_boot;	/* delay boot for desired node state */
1427	char *dependency;	/* synchronize job execution with other jobs */
1428	time_t end_time;	/* time by which job must complete, used for
1429				 * job update only now, possible deadline
1430				 * scheduling in the future */
1431	char **environment;	/* environment variables to set for job,
1432				 *  name=value pairs, one per line */
1433	uint32_t env_size;	/* element count in environment */
1434	char *extra;		/* unused */
1435	char *exc_nodes;	/* comma separated list of nodes excluded
1436				 * from job's allocation, default NONE */
1437	char *features;		/* required feature specification,
1438				 * default NONE */
1439	uint64_t fed_siblings_active; /* Bitmap of active fed sibling ids */
1440	uint64_t fed_siblings_viable; /* Bitmap of viable fed sibling ids */
1441	uint32_t group_id;	/* group to assume, if run as root. */
1442	uint32_t het_job_offset; /* HetJob component offset */
1443	uint16_t immediate;	/* 1 if allocate to run or fail immediately,
1444				 * 0 if to be queued awaiting resources */
1445	uint32_t job_id;	/* job ID, default set by Slurm */
1446	char * job_id_str;      /* string representation of the jobid */
1447	uint16_t kill_on_node_fail; /* 1 if node failure to kill job,
1448				     * 0 otherwise,default=1 */
1449	char *licenses;		/* licenses required by the job */
1450	uint16_t mail_type;	/* see MAIL_JOB_ definitions above */
1451	char *mail_user;	/* user to receive notification */
1452	char *mcs_label;	/* mcs_label if mcs plugin in use */
1453	char *mem_bind;		/* binding map for map/mask_cpu */
1454	uint16_t mem_bind_type;	/* see mem_bind_type_t */
1455	char *mem_per_tres;	/* semicolon delimited list of TRES=# values */
1456	char *name;		/* name of the job, default "" */
1457	char *network;		/* network use spec */
1458	uint32_t nice;		/* requested priority change,
1459				 * NICE_OFFSET == no change */
1460	uint32_t num_tasks;	/* number of tasks to be started,
1461				 * for batch only */
1462	uint8_t open_mode;	/* out/err open mode truncate or append,
1463				 * see OPEN_MODE_* */
1464	char *origin_cluster;	/* cluster name that initiated the job. */
1465	uint16_t other_port;	/* port to send various notification msg to */
1466	uint8_t overcommit;	/* over subscribe resources, for batch only */
1467	char *partition;	/* name of requested partition,
1468				 * default in Slurm config */
1469	uint16_t plane_size;	/* plane size when task_dist =
1470				   SLURM_DIST_PLANE */
1471	uint8_t power_flags;	/* power management flags,
1472				 * see SLURM_POWER_FLAGS_ */
1473	uint32_t priority;	/* relative priority of the job,
1474				 * explicitly set only for user root,
1475				 * 0 == held (don't initiate) */
1476	uint32_t profile;	/* Level of acct_gather_profile {all | none} */
1477	char *qos;		/* Quality of Service */
1478	uint16_t reboot;	/* force node reboot before startup */
1479	char *resp_host;	/* NOTE: Set by slurmctld */
1480	uint16_t restart_cnt;	/* count of job restarts */
1481	char *req_nodes;	/* comma separated list of required nodes
1482				 * default NONE */
1483	uint16_t requeue;	/* enable or disable job requeue option */
1484	char *reservation;	/* name of reservation to use */
1485	char *script;		/* the actual job script, default NONE */
1486	void *script_buf;	/* job script as mmap buf */
1487	uint16_t shared;	/* 2 if the job can only share nodes with other
1488				 *   jobs owned by that user,
1489				 * 1 if job can share nodes with other jobs,
1490				 * 0 if job needs exclusive access to the node,
1491				 * or NO_VAL to accept the system default.
1492				 * SHARED_FORCE to eliminate user control. */
1493	uint32_t site_factor;	/* factor to consider in priority */
1494	char **spank_job_env;	/* environment variables for job prolog/epilog
1495				 * scripts as set by SPANK plugins */
1496	uint32_t spank_job_env_size; /* element count in spank_env */
1497	uint32_t task_dist;	/* see enum task_dist_state */
1498	uint32_t time_limit;	/* maximum run time in minutes, default is
1499				 * partition limit */
1500	uint32_t time_min;	/* minimum run time in minutes, default is
1501				 * time_limit */
1502	char *tres_bind;	/* Task to TRES binding directives */
1503	char *tres_freq;	/* TRES frequency directives */
1504	char *tres_per_job;	/* semicolon delimited list of TRES=# values */
1505	char *tres_per_node;	/* semicolon delimited list of TRES=# values */
1506	char *tres_per_socket;	/* semicolon delimited list of TRES=# values */
1507	char *tres_per_task;	/* semicolon delimited list of TRES=# values */
1508	uint32_t user_id;	/* set only if different from current UID,
1509				 * can only be explicitly set by user root */
1510	uint16_t wait_all_nodes;/* 0 to start job immediately after allocation
1511				 * 1 to start job after all nodes booted
1512				 * or NO_VAL to use system default */
1513	uint16_t warn_flags;	/* flags  related to job signals
1514				 * (eg. KILL_JOB_BATCH) */
1515	uint16_t warn_signal;	/* signal to send when approaching end time */
1516	uint16_t warn_time;	/* time before end to send signal (seconds) */
1517	char *work_dir;		/* pathname of working directory */
1518
1519	/* job constraints: */
1520	uint16_t cpus_per_task;	/* number of processors required for
1521				 * each task */
1522	uint32_t min_cpus;	/* minimum number of processors required,
1523				 * default=0 */
1524	uint32_t max_cpus;	/* maximum number of processors required,
1525				 * default=0 */
1526	uint32_t min_nodes;	/* minimum number of nodes required by job,
1527				 * default=0 */
1528	uint32_t max_nodes;	/* maximum number of nodes usable by job,
1529				 * default=0 */
1530	uint16_t boards_per_node; /* boards per node required by job  */
1531	uint16_t sockets_per_board;/* sockets per board required by job */
1532	uint16_t sockets_per_node;/* sockets per node required by job */
1533	uint16_t cores_per_socket;/* cores per socket required by job */
1534	uint16_t threads_per_core;/* threads per core required by job */
1535	uint16_t ntasks_per_node;/* number of tasks to invoke on each node */
1536	uint16_t ntasks_per_socket;/* number of tasks to invoke on
1537				    * each socket */
1538	uint16_t ntasks_per_core;/* number of tasks to invoke on each core */
1539	uint16_t ntasks_per_board;/* number of tasks to invoke on each board */
1540	uint16_t pn_min_cpus;    /* minimum # CPUs per node, default=0 */
1541	uint64_t pn_min_memory;  /* minimum real memory per node OR
1542				  * real memory per CPU | MEM_PER_CPU,
1543				  * default=0 (no limit) */
1544	uint32_t pn_min_tmp_disk;/* minimum tmp disk per node,
1545				  * default=0 */
1546
1547	uint32_t req_switch;    /* Minimum number of switches */
1548	dynamic_plugin_data_t *select_jobinfo; /* opaque data type,
1549					   * Slurm internal use only */
1550	char *std_err;		/* pathname of stderr */
1551	char *std_in;		/* pathname of stdin */
1552	char *std_out;		/* pathname of stdout */
1553	uint64_t *tres_req_cnt; /* used internally in the slurmctld,
1554				   DON'T PACK */
1555	uint32_t wait4switch;   /* Maximum time to wait for minimum switches */
1556	char *wckey;            /* wckey for job */
1557	uint16_t x11;		/* --x11 flags */
1558	char *x11_magic_cookie;	/* automatically stolen from submit node */
1559	char *x11_target;	/* target hostname, or unix socket if port == 0 */
1560	uint16_t x11_target_port; /* target tcp port, 6000 + the display number */
1561} job_desc_msg_t;
1562
1563typedef struct job_info {
1564	char *account;		/* charge to specified account */
1565	time_t accrue_time;	/* time job is eligible for running */
1566	char *admin_comment;	/* administrator's arbitrary comment */
1567	char    *alloc_node;	/* local node making resource alloc */
1568	uint32_t alloc_sid;	/* local sid making resource alloc */
1569	void *array_bitmap;	/* NOTE: set on unpack */
1570	uint32_t array_job_id;	/* job_id of a job array or 0 if N/A */
1571	uint32_t array_task_id;	/* task_id of a job array */
1572	uint32_t array_max_tasks; /* Maximum number of running tasks */
1573	char *array_task_str;	/* string expression of task IDs in this record */
1574	uint32_t assoc_id;	/* association id for job */
1575	char *batch_features;	/* features required for batch script's node */
1576	uint16_t batch_flag;	/* 1 if batch: queued job with script */
1577	char *batch_host;	/* name of host running batch script */
1578	uint32_t bitflags;      /* Various job flags */
1579	uint16_t boards_per_node;  /* boards per node required by job   */
1580	char *burst_buffer;	/* burst buffer specifications */
1581	char *burst_buffer_state; /* burst buffer state info */
1582	char *cluster;		/* name of cluster that the job is on */
1583	char *cluster_features;	/* comma separated list of required cluster
1584				 * features */
1585	char *command;		/* command to be executed, built from submitted
1586				 * job's argv and NULL for salloc command */
1587	char *comment;		/* arbitrary comment */
1588	uint16_t contiguous;	/* 1 if job requires contiguous nodes */
1589	uint16_t core_spec;	/* specialized core count */
1590	uint16_t cores_per_socket; /* cores per socket required by job  */
1591	double billable_tres;	/* billable TRES cache. updated upon resize */
1592	uint16_t cpus_per_task;	/* number of processors required for
1593				 * each task */
1594	uint32_t cpu_freq_min;  /* Minimum cpu frequency  */
1595	uint32_t cpu_freq_max;  /* Maximum cpu frequency  */
1596	uint32_t cpu_freq_gov;  /* cpu frequency governor */
1597	char *cpus_per_tres;	/* semicolon delimited list of TRES=# values */
1598	time_t deadline;	/* deadline */
1599	uint32_t delay_boot;	/* delay boot for desired node state */
1600	char *dependency;	/* synchronize job execution with other jobs */
1601	uint32_t derived_ec;	/* highest exit code of all job steps */
1602	time_t eligible_time;	/* time job is eligible for running */
1603	time_t end_time;	/* time of termination, actual or expected */
1604	char *exc_nodes;	/* comma separated list of excluded nodes */
1605	int32_t *exc_node_inx;	/* excluded list index pairs into node_table:
1606				 * start_range_1, end_range_1,
1607				 * start_range_2, .., -1  */
1608	uint32_t exit_code;	/* exit code for job (status from wait call) */
1609	char *features;		/* comma separated list of required features */
1610	char *fed_origin_str;	/* Origin cluster's name */
1611	uint64_t fed_siblings_active;  /* bitmap of active fed sibling ids */
1612	char *fed_siblings_active_str; /* string of active sibling names */
1613	uint64_t fed_siblings_viable;  /* bitmap of viable fed sibling ids */
1614	char *fed_siblings_viable_str; /* string of viable sibling names */
1615	uint32_t gres_detail_cnt; /* Count of gres_detail_str records,
1616				 * one per allocated node */
1617	char **gres_detail_str;	/* Details of GRES count/index alloc per node */
1618	char *gres_total;       /* Total count of gres used with names */
1619	uint32_t group_id;	/* group job submitted as */
1620	uint32_t het_job_id;	/* job ID of hetjob leader */
1621	char *het_job_id_set;	/* job IDs for all components */
1622	uint32_t het_job_offset; /* HetJob component offset from leader */
1623	uint32_t job_id;	/* job ID */
1624	job_resources_t *job_resrcs; /* opaque data type, job resources */
1625	uint32_t job_state;	/* state of the job, see enum job_states */
1626	time_t last_sched_eval; /* last time job was evaluated for scheduling */
1627	char *licenses;		/* licenses required by the job */
1628	uint16_t mail_type;	/* see MAIL_JOB_ definitions above */
1629	char *mail_user;	/* user to receive notification */
1630	uint32_t max_cpus;	/* maximum number of cpus usable by job */
1631	uint32_t max_nodes;	/* maximum number of nodes usable by job */
1632	char *mcs_label;	/* mcs_label if mcs plugin in use */
1633	char *mem_per_tres;	/* semicolon delimited list of TRES=# values */
1634	char *name;		/* name of the job */
1635	char *network;		/* network specification */
1636	char *nodes;		/* list of nodes allocated to job */
1637	uint32_t nice;	  	/* requested priority change */
1638	int32_t *node_inx;	/* list index pairs into node_table for *nodes:
1639				 * start_range_1, end_range_1,
1640				 * start_range_2, .., -1  */
1641	uint16_t ntasks_per_core;/* number of tasks to invoke on each core */
1642	uint16_t ntasks_per_node;/* number of tasks to invoke on each node */
1643	uint16_t ntasks_per_socket;/* number of tasks to invoke on each socket*/
1644	uint16_t ntasks_per_board; /* number of tasks to invoke on each board */
1645	uint32_t num_cpus;	/* minimum number of cpus required by job */
1646	uint32_t num_nodes;	/* minimum number of nodes required by job */
1647	uint32_t num_tasks;	/* requested task count */
1648	char *partition;	/* name of assigned partition */
1649	uint64_t pn_min_memory; /* minimum real memory per node, default=0 */
1650	uint16_t pn_min_cpus;   /* minimum # CPUs per node, default=0 */
1651	uint32_t pn_min_tmp_disk; /* minimum tmp disk per node, default=0 */
1652	uint8_t power_flags;	/* power management flags,
1653				 * see SLURM_POWER_FLAGS_ */
1654	time_t preempt_time;	/* preemption signal time */
1655	time_t preemptable_time;/* job becomes preemptable from
1656				 *  PreemptExemptTime */
1657	time_t pre_sus_time;	/* time job ran prior to last suspend */
1658	uint32_t priority;	/* relative priority of the job,
1659				 * 0=held, 1=required nodes DOWN/DRAINED */
1660	uint32_t profile;	/* Level of acct_gather_profile {all | none} */
1661	char *qos;		/* Quality of Service */
1662	uint8_t reboot;		/* node reboot requested before start */
1663	char *req_nodes;	/* comma separated list of required nodes */
1664	int32_t *req_node_inx;	/* required list index pairs into node_table:
1665				 * start_range_1, end_range_1,
1666				 * start_range_2, .., -1  */
1667	uint32_t req_switch;    /* Minimum number of switches */
1668	uint16_t requeue;       /* enable or disable job requeue option */
1669	time_t resize_time;	/* time of latest size change */
1670	uint16_t restart_cnt;	/* count of job restarts */
1671	char *resv_name;	/* reservation name */
1672	char *sched_nodes;	/* list of nodes scheduled to be used for job */
1673	dynamic_plugin_data_t *select_jobinfo; /* opaque data type,
1674						* process using
1675						* slurm_get_select_jobinfo()
1676						*/
1677	uint16_t shared;	/* 1 if job can share nodes with other jobs */
1678	uint16_t show_flags;	/* conveys level of details requested */
1679	uint32_t site_factor;	/* factor to consider in priority */
1680	uint16_t sockets_per_board;/* sockets per board required by job */
1681	uint16_t sockets_per_node; /* sockets per node required by job  */
1682	time_t start_time;	/* time execution begins, actual or expected */
1683	uint16_t start_protocol_ver; /* Slurm version step was started with
1684				      *	either srun or the lowest slurmd version
1685				      *	it is talking to */
1686	char *state_desc;	/* optional details for state_reason */
1687	uint16_t state_reason;	/* reason job still pending or failed, see
1688				 * slurm.h:enum job_state_reason */
1689	char *std_err;		/* pathname of job's stderr file */
1690	char *std_in;		/* pathname of job's stdin file */
1691	char *std_out;		/* pathname of job's stdout file */
1692	time_t submit_time;	/* time of job submission */
1693	time_t suspend_time;	/* time job last suspended or resumed */
1694	char *system_comment;	/* slurmctld's arbitrary comment */
1695	uint32_t time_limit;	/* maximum run time in minutes or INFINITE */
1696	uint32_t time_min;	/* minimum run time in minutes or INFINITE */
1697	uint16_t threads_per_core; /* threads per core required by job  */
1698	char *tres_bind;	/* Task to TRES binding directives */
1699	char *tres_freq;	/* TRES frequency directives */
1700	char *tres_per_job;	/* semicolon delimited list of TRES=# values */
1701	char *tres_per_node;	/* semicolon delimited list of TRES=# values */
1702	char *tres_per_socket;	/* semicolon delimited list of TRES=# values */
1703	char *tres_per_task;	/* semicolon delimited list of TRES=# values */
1704	char *tres_req_str;	/* tres reqeusted in the job */
1705	char *tres_alloc_str;   /* tres used in the job */
1706	uint32_t user_id;	/* user the job runs as */
1707	char *user_name;	/* user_name or null. not always set, but
1708				 * accurate if set (and can avoid a local
1709				 * lookup call) */
1710	uint32_t wait4switch;   /* Maximum time to wait for minimum switches */
1711	char *wckey;            /* wckey for job */
1712	char *work_dir;		/* pathname of working directory */
1713} slurm_job_info_t;
1714
1715typedef struct priority_factors_object {
1716	char *cluster_name;	/* Cluster name ONLY set in federation */
1717	uint32_t job_id;
1718	char *partition;
1719	uint32_t user_id;
1720
1721	double	 priority_age;
1722	double	 priority_assoc;
1723	double	 priority_fs;
1724	double	 priority_js;
1725	double	 priority_part;
1726	double	 priority_qos;
1727	double   direct_prio;   /* manually set priority */
1728	uint32_t priority_site;
1729
1730	double   *priority_tres;/* tres priorities with weights applied. */
1731	uint32_t  tres_cnt;     /* number of configured tres' on system. */
1732	char    **tres_names;	/* packed as assoc_mgr_tres_names[] */
1733	double   *tres_weights; /* PriorityWeightTRES weights as an array */
1734
1735	uint32_t nice;
1736} priority_factors_object_t;
1737
1738typedef struct priority_factors_response_msg {
1739	List	 priority_factors_list;	/* priority_factors_object_t list */
1740} priority_factors_response_msg_t;
1741
1742#ifndef __PERMAPI__H__
1743/* If on an IBM PERCS machine the libpermapi.so file we generate in
1744 * the switch/nrt plugin will need to link to this file and the
1745 * permapi.h file which both have a job_info_t structure defined in
1746 * it.  So to avoid conflict only define job_info_t if we haven't
1747 * included that file first.  Then when in the libpermapi environment
1748 * we can use slurm_job_info_t to access the job_info_t data.  If not
1749 * in that environment we should never know anything changed.
1750 */
1751typedef slurm_job_info_t job_info_t;
1752#endif
1753
1754typedef struct job_info_msg {
1755	time_t last_update;	/* time of latest info */
1756	uint32_t record_count;	/* number of records */
1757	slurm_job_info_t *job_array;	/* the job records */
1758} job_info_msg_t;
1759
1760typedef struct step_update_request_msg {
1761	time_t end_time;	/* step end time */
1762	uint32_t exit_code;	/* exit code for job (status from wait call) */
1763	uint32_t job_id;
1764	jobacctinfo_t *jobacct;
1765	char *name;             /* step name */
1766	time_t start_time;	/* step start time */
1767	uint32_t step_id;
1768	uint32_t time_limit;	/* In minutes */
1769} step_update_request_msg_t;
1770
1771typedef struct {
1772	char *node_list; /* nodelist corresponding to task layout */
1773	uint16_t *cpus_per_node; /* cpus per node */
1774	uint32_t *cpu_count_reps; /* how many nodes have same cpu count */
1775	uint32_t num_hosts; /* number of hosts we have */
1776	uint32_t num_tasks; /* number of tasks to distribute across these cpus*/
1777	uint16_t *cpus_per_task; /* number of cpus per task */
1778	uint32_t *cpus_task_reps; /* how many nodes have same per task count */
1779	uint32_t task_dist; /* type of distribution we are using */
1780	uint16_t plane_size; /* plane size (only needed for plane distribution*/
1781} slurm_step_layout_req_t;
1782
1783typedef struct slurm_step_layout {
1784	char *front_end;	/* If a front-end architecture, the name of
1785				 * of the node running all tasks,
1786				 * NULL otherwise */
1787	uint32_t node_cnt;	/* node count */
1788	char *node_list;        /* list of nodes in step */
1789	uint16_t plane_size;	/* plane size when task_dist =
1790				 * SLURM_DIST_PLANE */
1791	uint16_t start_protocol_ver; /* Slurm version step was started with
1792				      *	either srun or the lowest slurmd version
1793				      *	it is talking to */
1794	/* Array of length "node_cnt". Each element of the array
1795	 * is the number of tasks assigned to the corresponding node */
1796	uint16_t *tasks;
1797	uint32_t task_cnt;	/* total number of tasks in the step */
1798	uint32_t task_dist;	/* see enum task_dist_state */
1799	/* Array (of length "node_cnt") of task ID arrays.  The length
1800	 * of each subarray is designated by the corresponding value in
1801	 * the tasks array. */
1802	uint32_t **tids;	/* host id => task id mapping */
1803} slurm_step_layout_t;
1804
1805typedef struct slurm_step_io_fds {
1806	struct {
1807		int fd;
1808		uint32_t taskid;
1809		uint32_t nodeid;
1810	} input, out, err;
1811} slurm_step_io_fds_t;
1812
1813#define SLURM_STEP_IO_FDS_INITIALIZER {{0, (uint32_t)-1, (uint32_t)-1},	\
1814		{1, (uint32_t)-1, (uint32_t)-1},			\
1815		{2, (uint32_t)-1, (uint32_t)-1}}
1816
1817typedef struct launch_tasks_response_msg {
1818	uint32_t job_id;
1819	uint32_t step_id;
1820	uint32_t return_code;
1821	char    *node_name;
1822	uint32_t srun_node_id;
1823	uint32_t count_of_pids;
1824	uint32_t *local_pids;
1825	uint32_t *task_ids; /* array of length count_of_pids */
1826} launch_tasks_response_msg_t;
1827
1828typedef struct task_ext_msg {
1829	uint32_t num_tasks;
1830	uint32_t *task_id_list;
1831	uint32_t return_code;
1832	uint32_t job_id;
1833	uint32_t step_id;
1834} task_exit_msg_t;
1835
1836typedef struct {
1837	uint32_t job_id;	/* slurm job_id */
1838	uint32_t flags;		/* flags */
1839	uint16_t port;		/* target TCP port */
1840	char *target;		/* target host or UNIX socket */
1841} net_forward_msg_t;
1842
1843typedef struct srun_ping_msg {
1844	uint32_t job_id;	/* slurm job_id */
1845	uint32_t step_id;	/* step_id or NO_VAL */
1846} srun_ping_msg_t;
1847
1848typedef struct srun_job_complete_msg {
1849	uint32_t job_id;        /* slurm job_id */
1850	uint32_t step_id;       /* step_id or NO_VAL */
1851} srun_job_complete_msg_t;
1852
1853typedef struct srun_timeout_msg {
1854	uint32_t job_id;	/* slurm job_id */
1855	uint32_t step_id;	/* step_id or NO_VAL */
1856	time_t   timeout;	/* when job scheduled to be killed */
1857} srun_timeout_msg_t;
1858
1859typedef struct srun_user_msg {
1860	uint32_t job_id;	/* slurm job_id */
1861	char *msg;		/* message to user's srun */
1862} srun_user_msg_t;
1863
1864typedef struct srun_node_fail_msg {
1865	uint32_t job_id;	/* slurm job_id */
1866	char *nodelist;		/* name of failed node(s) */
1867	uint32_t step_id;	/* step_id or NO_VAL */
1868} srun_node_fail_msg_t;
1869
1870typedef struct srun_step_missing_msg {
1871	uint32_t job_id;	/* slurm job_id */
1872	char *nodelist;		/* name of node(s) lacking this step */
1873	uint32_t step_id;	/* step_id or NO_VAL */
1874} srun_step_missing_msg_t;
1875
1876enum suspend_opts {
1877	SUSPEND_JOB,		/* Suspend a job now */
1878	RESUME_JOB		/* Resume a job now */
1879};
1880
1881/* NOTE: Set either job_id_str (NULL by default) or job_id */
1882typedef struct suspend_msg {
1883	uint16_t op;		/* suspend operation, see enum suspend_opts */
1884	uint32_t job_id;	/* slurm job ID (number) */
1885	char *   job_id_str;	/* slurm job ID (string) */
1886} suspend_msg_t;
1887
1888/* NOTE: Set either job_id_str (NULL by default) or job_id */
1889typedef struct top_job_msg {
1890	uint16_t op;		/* suspend operation, see enum suspend_opts */
1891	uint32_t job_id;	/* slurm job ID (number) */
1892	char *   job_id_str;	/* slurm job ID (string) */
1893} top_job_msg_t;
1894
1895typedef struct {
1896	uint32_t cpu_count;	/* number of required processors */
1897	uint32_t cpu_freq_min;	/* Minimum cpu frequency  */
1898	uint32_t cpu_freq_max;	/* Maximum cpu frequency  */
1899	uint32_t cpu_freq_gov;	/* cpu frequency governor */
1900	char *cpus_per_tres;	/* semicolon delimited list of TRES=# values */
1901	uint16_t exclusive;	/* 1 if CPUs not shared with other steps */
1902	char *features;		/* required node features, default NONE */
1903	uint16_t immediate;	/* 1 if allocate to run or fail immediately,
1904				 * 0 if to be queued awaiting resources */
1905	uint32_t job_id;	/* job ID */
1906	uint64_t pn_min_memory; /* minimum real memory per node OR
1907				 * real memory per CPU | MEM_PER_CPU,
1908				 * default=0 (use job limit) */
1909	char *name;		/* name of the job step */
1910	char *network;		/* network use spec */
1911	uint32_t profile;	/* Level of acct_gather_profile {all | none} */
1912	uint8_t no_kill;	/* 1 if no kill on node failure */
1913	uint32_t min_nodes;	/* minimum number of nodes required by job,
1914				 * default=0 */
1915	uint32_t max_nodes;	/* maximum number of nodes usable by job,
1916				 * default=0 */
1917	char *mem_per_tres;	/* semicolon delimited list of TRES=# values */
1918	char *node_list;	/* list of required nodes */
1919	bool overcommit;	/* "true" to allow the allocation of more tasks
1920				 * to a node than available processors,
1921				 * "false" to accept at most one task per
1922				 * processor. "false" by default. */
1923	uint16_t plane_size;	/* plane size when task_dist =
1924				 * SLURM_DIST_PLANE */
1925	uint16_t relative;	/* first node to use of job's allocation */
1926	uint16_t resv_port_cnt;	/* reserve ports if set */
1927	uint32_t step_id;	/* desired step ID or NO_VAL */
1928	uint32_t task_count;	/* number of tasks required */
1929	uint32_t task_dist;	/* see enum task_dist_state, default
1930				 * is SLURM_DIST_CYCLIC */
1931	uint32_t time_limit;	/* step time limit */
1932	char *tres_bind;	/* Task to TRES binding directives */
1933	char *tres_freq;	/* TRES frequency directives */
1934	char *tres_per_step;	/* semicolon delimited list of TRES=# values */
1935	char *tres_per_node;	/* semicolon delimited list of TRES=# values */
1936	char *tres_per_socket;	/* semicolon delimited list of TRES=# values */
1937	char *tres_per_task;	/* semicolon delimited list of TRES=# values */
1938	uid_t uid;		/* user ID */
1939	uint16_t verbose_level; /* for extra logging decisions in step
1940				 * launch api */
1941} slurm_step_ctx_params_t;
1942
1943typedef struct {
1944	char *alias_list;	/* node name/address/hostname aliases */
1945	uint32_t argc;
1946	char **argv;
1947	uint32_t envc;
1948	char **env;
1949	char *cwd;
1950	bool user_managed_io;
1951	uint32_t msg_timeout; /* timeout set for sending message */
1952	uint16_t ntasks_per_board;/* number of tasks to invoke on each board */
1953	uint16_t ntasks_per_core; /* number of tasks to invoke on each core */
1954	uint16_t ntasks_per_socket;/* number of tasks to invoke on
1955				    * each socket */
1956
1957	/* START - only used if user_managed_io is false */
1958	bool buffered_stdio;
1959	bool labelio;
1960	char *remote_output_filename;
1961	char *remote_error_filename;
1962	char *remote_input_filename;
1963	slurm_step_io_fds_t local_fds;
1964	/*  END  - only used if user_managed_io is false */
1965
1966	uint32_t gid;
1967	bool multi_prog;
1968	bool no_alloc;
1969	uint32_t slurmd_debug;  /* remote slurmd debug level */
1970	uint32_t het_job_node_offset;	/* Hetjob node offset or NO_VAL */
1971	uint32_t het_job_id;	/* Hetjob ID or NO_VAL */
1972	uint32_t het_job_nnodes;/* total task count for entire hetjob */
1973	uint32_t het_job_ntasks;/* total task count for entire hetjob */
1974	uint32_t het_job_step_cnt;/* total step count for entire hetjob */
1975	uint16_t *het_job_task_cnts; /* Number of tasks on each node in hetjob */
1976	uint32_t **het_job_tids;	/* Task IDs on each node in hetjob */
1977	uint32_t *het_job_tid_offsets;/* map of tasks (by id) to originating
1978				       * hetjob */
1979	uint32_t het_job_offset;/* Hetjob offset or NO_VAL */
1980	uint32_t het_job_task_offset; /* Hetjob task offset or NO_VAL */
1981	char *het_job_node_list;	/* Hetjob step node list */
1982	bool parallel_debug;
1983	uint32_t profile;	/* Level of acct_gather_profile {all | none} */
1984	char *task_prolog;
1985	char *task_epilog;
1986	uint16_t cpu_bind_type;	/* use cpu_bind_type_t */
1987	char *cpu_bind;
1988	uint32_t cpu_freq_min;	/* Minimum cpu frequency  */
1989	uint32_t cpu_freq_max;	/* Maximum cpu frequency  */
1990	uint32_t cpu_freq_gov;	/* cpu frequency governor */
1991	uint16_t mem_bind_type;	/* use mem_bind_type_t */
1992	char *mem_bind;
1993	uint16_t accel_bind_type; /* --accel-bind= */
1994
1995	uint16_t max_sockets;
1996	uint16_t max_cores;
1997	uint16_t max_threads;
1998	uint16_t cpus_per_task;
1999	uint32_t task_dist;
2000	char *partition;
2001	bool preserve_env;
2002
2003	char *mpi_plugin_name;
2004	uint8_t open_mode;
2005	char *acctg_freq;
2006	bool pty;
2007	char **spank_job_env;	/* environment variables for job prolog/epilog
2008				 * scripts as set by SPANK plugins */
2009	uint32_t spank_job_env_size;	/* element count in spank_env */
2010	char *tres_bind;
2011	char *tres_freq;
2012} slurm_step_launch_params_t;
2013
2014typedef struct {
2015	void (*step_complete)(srun_job_complete_msg_t *);
2016	void (*step_signal)(int);
2017	void (*step_timeout)(srun_timeout_msg_t *);
2018	void (*task_start)(launch_tasks_response_msg_t *);
2019	void (*task_finish)(task_exit_msg_t *);
2020} slurm_step_launch_callbacks_t;
2021
2022typedef struct {
2023	void (*ping)(srun_ping_msg_t *);
2024	void (*job_complete)(srun_job_complete_msg_t *);
2025	void (*timeout)(srun_timeout_msg_t *);
2026	void (*user_msg)(srun_user_msg_t *);
2027	void (*node_fail)(srun_node_fail_msg_t *);
2028	void (*job_suspend)(suspend_msg_t *);
2029} slurm_allocation_callbacks_t;
2030
2031typedef struct {
2032	void (*acct_full)();
2033	void (*dbd_fail)();
2034	void (*dbd_resumed)();
2035	void (*db_fail)();
2036	void (*db_resumed)();
2037} slurm_trigger_callbacks_t;
2038
2039typedef struct {
2040	uint32_t array_job_id;	/* job_id of a job array or 0 if N/A */
2041	uint32_t array_task_id;	/* task_id of a job array */
2042	char *cluster;		/* cluster that the step is running on. */
2043	uint32_t cpu_freq_min;	/* Minimum cpu frequency  */
2044	uint32_t cpu_freq_max;	/* Maximum cpu frequency  */
2045	uint32_t cpu_freq_gov;	/* cpu frequency governor */
2046	char *cpus_per_tres;	/* comma delimited list of TRES=# values */
2047	uint32_t job_id;	/* job ID */
2048	char *mem_per_tres;	/* comma delimited list of TRES=# values */
2049	char *name;		/* name of job step */
2050	char *network;		/* network specs for job step */
2051	char *nodes;		/* list of nodes allocated to job_step */
2052	int32_t *node_inx;	/* list index pairs into node_table for *nodes:
2053				 * start_range_1, end_range_1,
2054				 * start_range_2, .., -1  */
2055	uint32_t num_cpus;	/* how many cpus are being used by step */
2056	uint32_t num_tasks;	/* number of tasks */
2057	char *partition;	/* name of assigned partition */
2058	char *resv_ports;	/* ports allocated for MPI */
2059	time_t run_time;	/* net run time (factor out time suspended) */
2060	dynamic_plugin_data_t *select_jobinfo; /* opaque data type,
2061						* process using
2062						* slurm_get_select_jobinfo()
2063						*/
2064	char *srun_host;	/* host of srun command */
2065	uint32_t srun_pid;	/* PID of srun command */
2066	time_t start_time;	/* step start time */
2067	uint16_t start_protocol_ver; /* Slurm version step was started with
2068				      *	either srun or the lowest slurmd version
2069				      *	it is talking to */
2070	uint32_t state;		/* state of the step, see enum job_states */
2071	uint32_t step_id;	/* step ID */
2072	uint32_t task_dist;	/* see enum task_dist_state */
2073	uint32_t time_limit;	/* step time limit */
2074	char *tres_alloc_str;   /* tres used in the job */
2075	char *tres_bind;	/* Task to TRES binding directives */
2076	char *tres_freq;	/* TRES frequency directives */
2077	char *tres_per_step;	/* comma delimited list of TRES=# values */
2078	char *tres_per_node;	/* comma delimited list of TRES=# values */
2079	char *tres_per_socket;	/* comma delimited list of TRES=# values */
2080	char *tres_per_task;	/* comma delimited list of TRES=# values */
2081	uint32_t user_id;	/* user the job runs as */
2082} job_step_info_t;
2083
2084typedef struct job_step_info_response_msg {
2085	time_t last_update;		/* time of latest info */
2086	uint32_t job_step_count;	/* number of records */
2087	job_step_info_t *job_steps;	/* the job step records */
2088} job_step_info_response_msg_t;
2089
2090typedef struct {
2091   	char *node_name;
2092	uint32_t *pid;
2093	uint32_t pid_cnt;
2094} job_step_pids_t;
2095
2096typedef struct {
2097	uint32_t job_id;
2098	List pid_list; /* List of job_step_pids_t *'s */
2099	uint32_t step_id;
2100} job_step_pids_response_msg_t;
2101
2102typedef struct {
2103	jobacctinfo_t *jobacct;
2104	uint32_t num_tasks;
2105   	uint32_t return_code;
2106	job_step_pids_t *step_pids;
2107} job_step_stat_t;
2108
2109typedef struct {
2110	uint32_t job_id;	/* job ID */
2111	List stats_list;	/* List of job_step_stat_t *'s */
2112	uint32_t step_id;
2113} job_step_stat_response_msg_t;
2114
2115typedef struct node_info {
2116	char *arch;		/* computer architecture */
2117	char *bcast_address;	/* BcastAddr (optional) */
2118	uint16_t boards;        /* total number of boards per node  */
2119	time_t boot_time;	/* time of node boot */
2120	char *cluster_name;	/* Cluster name ONLY set in federation */
2121	uint16_t cores;         /* number of cores per socket       */
2122	uint16_t core_spec_cnt; /* number of specialized cores on node */
2123	uint32_t cpu_bind;	/* Default task binding */
2124	uint32_t cpu_load;	/* CPU load * 100 */
2125	uint64_t free_mem;	/* free memory in MiB */
2126	uint16_t cpus;		/* configured count of cpus running on
2127				 * the node */
2128	char *cpu_spec_list;	/* node's specialized cpus */
2129	acct_gather_energy_t *energy;	 /* energy data */
2130	ext_sensors_data_t *ext_sensors; /* external sensor data */
2131	power_mgmt_data_t *power;        /* power management data */
2132	char *features;		/* list of a node's available features */
2133	char *features_act;	/* list of a node's current active features,
2134				 * Same as "features" if NULL */
2135	char *gres;		/* list of a node's generic resources */
2136	char *gres_drain;	/* list of drained GRES */
2137	char *gres_used;	/* list of GRES in current use */
2138	char *mcs_label;	/* mcs label if mcs plugin in use */
2139	uint64_t mem_spec_limit; /* MB memory limit for specialization */
2140	char *name;		/* node name to slurm */
2141	uint32_t next_state;	/* state after reboot (enum node_states) */
2142	char *node_addr;	/* communication name (optional) */
2143	char *node_hostname;	/* node's hostname (optional) */
2144	uint32_t node_state;	/* see enum node_states */
2145	char *os;		/* operating system currently running */
2146	uint32_t owner;		/* User allowed to use this node or NO_VAL */
2147	char *partitions;	/* Comma separated list of partitions containing
2148				 * this node, NOT supplied by slurmctld, but
2149				 * populated by scontrol */
2150	uint16_t port;		/* TCP port number of the slurmd */
2151	uint64_t real_memory;	/* configured MB of real memory on the node */
2152	char *reason;		/* reason for node being DOWN or DRAINING */
2153	time_t reason_time;	/* Time stamp when reason was set, ignore if
2154				 * no reason is set. */
2155	uint32_t reason_uid;   	/* User that set the reason, ignore if
2156				 * no reason is set. */
2157	dynamic_plugin_data_t *select_nodeinfo;  /* opaque data structure,
2158						  * use
2159						  * slurm_get_select_nodeinfo()
2160						  * to access contents */
2161	time_t slurmd_start_time;/* time of slurmd startup */
2162	uint16_t sockets;       /* total number of sockets per node */
2163	uint16_t threads;       /* number of threads per core */
2164	uint32_t tmp_disk;	/* configured MB of total disk in TMP_FS */
2165	uint32_t weight;	/* arbitrary priority of node for scheduling */
2166	char *tres_fmt_str;	/* str representing configured TRES on node */
2167	char *version;		 /* Slurm version number */
2168} node_info_t;
2169
2170typedef struct node_info_msg {
2171	time_t last_update;		/* time of latest info */
2172	uint32_t record_count;		/* number of records */
2173	node_info_t *node_array;	/* the node records */
2174} node_info_msg_t;
2175
2176typedef struct front_end_info {
2177	char *allow_groups;		/* allowed group string */
2178	char *allow_users;		/* allowed user string */
2179	time_t boot_time;		/* Time of node boot,
2180					 * computed from up_time */
2181	char *deny_groups;		/* denied group string */
2182	char *deny_users;		/* denied user string */
2183	char *name;			/* node name */
2184	uint32_t node_state;		/* see enum node_states */
2185	char *reason;			/* reason for node being DOWN or
2186					 * DRAINING */
2187	time_t reason_time;		/* Time stamp when reason was set,
2188					 * ignore if no reason is set. */
2189	uint32_t reason_uid;   		/* User that set the reason,
2190					 * ignore if no reason is set. */
2191	time_t slurmd_start_time;	/* Time of slurmd startup */
2192	char *version;			/* Slurm version number */
2193} front_end_info_t;
2194
2195typedef struct front_end_info_msg {
2196	time_t last_update;		/* time of latest info */
2197	uint32_t record_count;		/* number of records */
2198	front_end_info_t *front_end_array;	/* the front_end records */
2199} front_end_info_msg_t;
2200
2201typedef struct topo_info {
2202	uint16_t level;			/* level in hierarchy, leaf=0 */
2203	uint32_t link_speed;		/* link speed, arbitrary units */
2204	char *name;			/* switch name */
2205	char *nodes;			/* name if direct descendent nodes */
2206	char *switches;			/* name if direct descendent switches */
2207} topo_info_t;
2208
2209typedef struct topo_info_response_msg {
2210	uint32_t record_count;		/* number of records */
2211	topo_info_t *topo_array;	/* the switch topology records */
2212} topo_info_response_msg_t;
2213
2214typedef struct job_alloc_info_msg {
2215	uint32_t job_id;	/* job ID */
2216	char    *req_cluster;   /* requesting cluster */
2217} job_alloc_info_msg_t;
2218
2219typedef struct layout_info_msg {
2220	uint32_t record_count;	/* number of char* */
2221	char** records;		/* layout or list of layouts */
2222} layout_info_msg_t;
2223
2224typedef struct update_layout_msg {
2225	char* layout;
2226	char* arg;
2227} update_layout_msg_t;
2228
2229typedef struct step_alloc_info_msg {
2230	uint32_t het_job_offset;	/* HetJob component index (or NO_VAL) */
2231	uint32_t job_id;		/* job ID (or hetjob ID) */
2232	uint32_t step_id;		/* step ID (or NO_VAL for whole job) */
2233} step_alloc_info_msg_t;
2234
2235typedef struct powercap_info_msg {
2236	uint32_t power_cap;	/* power cap value in watts */
2237	uint32_t power_floor;	/* power floor value in watts */
2238	uint32_t power_change;	/* power change rate limit in watts/minute */
2239	uint32_t min_watts;	/* min consumption of the cluster in watts */
2240	uint32_t cur_max_watts;	/* current max consumption of the cluster in
2241				 * watts */
2242	uint32_t adj_max_watts;	/* adjusted (removing DownNodes) max consumption
2243				 * of the cluster in watts */
2244	uint32_t max_watts;	/* max consumption of the cluster in watts */
2245} powercap_info_msg_t;
2246
2247typedef struct powercap_info_msg update_powercap_msg_t;
2248
2249typedef struct acct_gather_node_resp_msg {
2250	acct_gather_energy_t *energy;
2251	char *node_name;	  /* node name */
2252	uint16_t sensor_cnt;
2253} acct_gather_node_resp_msg_t;
2254
2255typedef struct acct_gather_energy_req_msg {
2256	uint16_t context_id;
2257	uint16_t delta;
2258} acct_gather_energy_req_msg_t;
2259
2260#define JOB_DEF_CPU_PER_GPU	0x0001
2261#define JOB_DEF_MEM_PER_GPU	0x0002
2262typedef struct job_defaults {
2263	uint16_t type;	/* See JOB_DEF_* above */
2264	uint64_t value;	/* Value */
2265} job_defaults_t;
2266
2267/* Current partition state information and used to set partition options
2268 * using slurm_update_partition(). */
2269#define PART_FLAG_DEFAULT	0x0001	/* Set if default partition */
2270#define PART_FLAG_HIDDEN	0x0002	/* Set if partition is hidden */
2271#define PART_FLAG_NO_ROOT	0x0004	/* Set if user root jobs disabled */
2272#define PART_FLAG_ROOT_ONLY	0x0008	/* Set if only root can submit jobs */
2273#define PART_FLAG_REQ_RESV	0x0010	/* Set if reservation is required */
2274#define PART_FLAG_LLN		0x0020	/* Set if least loaded node selection
2275					 * is desired */
2276#define PART_FLAG_EXCLUSIVE_USER 0x0040	/* Set if nodes allocated exclusively
2277					 * by user */
2278/* Used with slurm_update_partition() to clear flags associated with existing
2279 * partitions. For example, if a partition is currently hidden and you want
2280 * to make it visible then set flags to PART_FLAG_HIDDEN_CLR and call
2281 * slurm_update_partition(). */
2282#define PART_FLAG_DEFAULT_CLR	0x0100	/* Clear DEFAULT partition flag */
2283#define PART_FLAG_HIDDEN_CLR	0x0200	/* Clear HIDDEN partition flag */
2284#define PART_FLAG_NO_ROOT_CLR	0x0400	/* Clear NO_ROOT partition flag */
2285#define PART_FLAG_ROOT_ONLY_CLR	0x0800	/* Clear ROOT_ONLY partition flag */
2286#define PART_FLAG_REQ_RESV_CLR	0x1000	/* Clear RES_REQ partition flag */
2287#define PART_FLAG_LLN_CLR	0x2000	/* Clear LLN partition flag */
2288#define PART_FLAG_EXC_USER_CLR	0x4000	/* Clear EXCLUSIVE_USER flag */
2289
2290typedef struct partition_info {
2291	char *allow_alloc_nodes;/* list names of allowed allocating
2292				 * nodes */
2293	char *allow_accounts;   /* comma delimited list of accounts,
2294				 * null indicates all */
2295	char *allow_groups;	/* comma delimited list of groups,
2296				 * null indicates all */
2297	char *allow_qos;	/* comma delimited list of qos,
2298				 * null indicates all */
2299	char *alternate; 	/* name of alternate partition */
2300	char *billing_weights_str;/* per TRES billing weights string */
2301	char *cluster_name;	/* Cluster name ONLY set in federation */
2302	uint16_t cr_type;	/* see CR_* values */
2303	uint32_t cpu_bind;	/* Default task binding */
2304	uint64_t def_mem_per_cpu; /* default MB memory per allocated CPU */
2305	uint32_t default_time;	/* minutes, NO_VAL or INFINITE */
2306	char *deny_accounts;    /* comma delimited list of denied accounts */
2307	char *deny_qos;		/* comma delimited list of denied qos */
2308	uint16_t flags;		/* see PART_FLAG_* above */
2309	uint32_t grace_time; 	/* preemption grace time in seconds */
2310	List job_defaults_list;	/* List of job_defaults_t elements */
2311	char *job_defaults_str;	/* String of job defaults,
2312				 * used only for partition update RPC */
2313	uint32_t max_cpus_per_node; /* maximum allocated CPUs per node */
2314	uint64_t max_mem_per_cpu; /* maximum MB memory per allocated CPU */
2315	uint32_t max_nodes;	/* per job or INFINITE */
2316	uint16_t max_share;	/* number of jobs to gang schedule */
2317	uint32_t max_time;	/* minutes or INFINITE */
2318	uint32_t min_nodes;	/* per job */
2319	char *name;		/* name of the partition */
2320	int32_t *node_inx;	/* list index pairs into node_table:
2321				 * start_range_1, end_range_1,
2322				 * start_range_2, .., -1  */
2323	char *nodes;		/* list names of nodes in partition */
2324	uint16_t over_time_limit; /* job's time limit can be exceeded by this
2325				   * number of minutes before cancellation */
2326	uint16_t preempt_mode;	/* See PREEMPT_MODE_* in slurm/slurm.h */
2327	uint16_t priority_job_factor;	/* job priority weight factor */
2328	uint16_t priority_tier;	/* tier for scheduling and preemption */
2329	char *qos_char;	        /* The partition QOS name */
2330	uint16_t state_up;	/* see PARTITION_ states above */
2331	uint32_t total_cpus;	/* total number of cpus in the partition */
2332	uint32_t total_nodes;	/* total number of nodes in the partition */
2333	char    *tres_fmt_str;	/* str of configured TRES in partition */
2334} partition_info_t;
2335
2336typedef struct delete_partition_msg {
2337	char *name;		/* name of partition to be delete */
2338} delete_part_msg_t;
2339
2340typedef struct resource_allocation_response_msg {
2341	char *account;          /* allocation account */
2342	uint32_t job_id;	/* assigned job id */
2343	char *alias_list;	/* node name/address/hostname aliases */
2344	uint32_t cpu_freq_min;  /* Minimum cpu frequency  */
2345	uint32_t cpu_freq_max;  /* Maximum cpu frequency  */
2346	uint32_t cpu_freq_gov;  /* cpu frequency governor */
2347	uint16_t *cpus_per_node;/* cpus per node */
2348	uint32_t *cpu_count_reps;/* how many nodes have same cpu count */
2349	uint32_t env_size;	/* element count in environment */
2350	char **environment;	/* environment variables to set for job,
2351				 *  name=value pairs, one per line */
2352	uint32_t error_code;	/* error code for warning message */
2353	char *job_submit_user_msg;/* job_submit plugin user_msg */
2354	slurm_addr_t *node_addr;  /* network addresses */
2355	uint32_t node_cnt;	/* count of nodes */
2356	char *node_list;	/* assigned list of nodes */
2357	uint16_t ntasks_per_board;/* number of tasks to invoke on each board */
2358	uint16_t ntasks_per_core; /* number of tasks to invoke on each core */
2359	uint16_t ntasks_per_socket;/* number of tasks to invoke on
2360				    * each socket */
2361	uint32_t num_cpu_groups;/* size of cpus_per_node and cpu_count_reps */
2362	char *partition;	/* name of partition used to run job */
2363	uint64_t pn_min_memory;  /* minimum real memory per node OR
2364				  * real memory per CPU | MEM_PER_CPU,
2365				  * default=0 (no limit) */
2366	char *qos;               /* allocation qos */
2367	char *resv_name;         /* allocation reservation */
2368	dynamic_plugin_data_t *select_jobinfo;	/* opaque data structure,
2369						 * use
2370						 * slurm_get_select_jobinfo()
2371						 * to access contents */
2372	void *working_cluster_rec; /* Cluster to direct remaining messages to.
2373				    * slurmdb_cluster_rec_t* because slurm.h
2374				    * doesn't know about slurmdb.h. */
2375} resource_allocation_response_msg_t;
2376
2377typedef struct partition_info_msg {
2378	time_t last_update;	/* time of latest info */
2379	uint32_t record_count;	/* number of records */
2380	partition_info_t *partition_array; /* the partition records */
2381} partition_info_msg_t;
2382
2383typedef struct will_run_response_msg {
2384	uint32_t job_id;	/* ID of job to start */
2385	char *job_submit_user_msg; /* job submit plugin user_msg */
2386	char *node_list;	/* nodes where job will start */
2387	char *part_name;	/* partition where job will start */
2388	List preemptee_job_id;	/* jobs preempted to start this job */
2389	uint32_t proc_cnt;	/* CPUs allocated to job at start */
2390	time_t start_time;	/* time when job will start */
2391	double sys_usage_per;	/* System usage percentage */
2392} will_run_response_msg_t;
2393
2394/*********************************/
2395
2396/*
2397 * Resource reservation data structures.
2398 * Create, show, modify and delete functions are required
2399 */
2400#define RESERVE_FLAG_MAINT	   0x0000000000000001	/* Set MAINT flag */
2401#define RESERVE_FLAG_NO_MAINT	   0x0000000000000002	/* Clear MAINT flag */
2402#define RESERVE_FLAG_DAILY	   0x0000000000000004	/* Set DAILY flag */
2403#define RESERVE_FLAG_NO_DAILY	   0x0000000000000008	/* Clear DAILY flag */
2404#define RESERVE_FLAG_WEEKLY	   0x0000000000000010	/* Set WEEKLY flag */
2405#define RESERVE_FLAG_NO_WEEKLY	   0x0000000000000020	/* Clear WEEKLY flag */
2406#define RESERVE_FLAG_IGN_JOBS	   0x0000000000000040	/* Ignore running jobs */
2407#define RESERVE_FLAG_NO_IGN_JOB	   0x0000000000000080	/* Clear ignore running
2408							 * jobs flag */
2409#define RESERVE_FLAG_ANY_NODES	   0x0000000000000100	/* Use any compute
2410							 * nodes */
2411#define RESERVE_FLAG_NO_ANY_NODES  0x0000000000000200	/* Clear any compute
2412							 * node flag */
2413#define RESERVE_FLAG_STATIC        0x0000000000000400	/* Static node allocation */
2414#define RESERVE_FLAG_NO_STATIC     0x0000000000000800	/* Clear static node
2415							 * allocation */
2416#define RESERVE_FLAG_PART_NODES	   0x0000000000001000	/* Use partition nodes
2417							 * only */
2418#define RESERVE_FLAG_NO_PART_NODES 0x0000000000002000	/* Clear partition
2419							 * nodes only flag */
2420#define RESERVE_FLAG_OVERLAP	   0x0000000000004000	/* Permit to overlap
2421							 * others */
2422#define RESERVE_FLAG_SPEC_NODES	   0x0000000000008000	/* Contains specific
2423							 * nodes */
2424#define RESERVE_FLAG_FIRST_CORES   0x0000000000010000	/* Use only first cores
2425							 * on each node */
2426#define RESERVE_FLAG_TIME_FLOAT	   0x0000000000020000	/* Time offset is
2427							 * relative */
2428#define RESERVE_FLAG_REPLACE	   0x0000000000040000	/* Replace resources
2429							 * as assigned to jobs */
2430#define RESERVE_FLAG_ALL_NODES	   0x0000000000080000	/* Use all compute
2431							 * nodes */
2432#define RESERVE_FLAG_PURGE_COMP	   0x0000000000100000	/* Purge reservation
2433							 * after last job done */
2434#define RESERVE_FLAG_WEEKDAY	   0x0000000000200000	/* Set WEEKDAY flag */
2435#define RESERVE_FLAG_NO_WEEKDAY	   0x0000000000400000	/* Clear WEEKDAY flag */
2436#define RESERVE_FLAG_WEEKEND	   0x0000000000800000	/* Set WEEKEND flag */
2437#define RESERVE_FLAG_NO_WEEKEND	   0x0000000001000000	/* Clear WEEKEND flag */
2438#define RESERVE_FLAG_FLEX	   0x0000000002000000	/* Set FLEX flag */
2439#define RESERVE_FLAG_NO_FLEX	   0x0000000004000000	/* Clear FLEX flag */
2440#define RESERVE_FLAG_DUR_PLUS	   0x0000000008000000	/* Add duration time,
2441							 * only used on
2442							 * modifying a
2443							 * reservation */
2444#define RESERVE_FLAG_DUR_MINUS	   0x0000000010000000	/* Remove duration time,
2445							 * only used on
2446							 * modifying a
2447							 * reservation */
2448#define RESERVE_FLAG_NO_HOLD_JOBS  0x0000000020000000	/* No hold jobs after
2449							 * end of reservation */
2450#define RESERVE_FLAG_REPLACE_DOWN  0x0000000040000000	/* Replace DOWN or
2451							 * DRAINED nodes */
2452#define RESERVE_FLAG_NO_PURGE_COMP 0x0000000080000000	/* Clear PURGE flag */
2453
2454#define RESERVE_FLAG_PROM	   0x0000000100000000	/* Allow jobs to run
2455							 * without specifying
2456							 * the reservation name
2457							 * if they meet
2458							 * eligibility status */
2459#define RESERVE_FLAG_NO_PROM	   0x0000000200000000	/* Clear PROM flag */
2460
2461typedef struct resv_core_spec {
2462	char *node_name;	/* Name of reserved node */
2463	char *core_id;		/* IDs of reserved cores */
2464} resv_core_spec_t;
2465
2466typedef struct reserve_info {
2467	char *accounts;		/* names of accounts permitted to use */
2468	char *burst_buffer;	/* burst buffer resources to be included */
2469	uint32_t core_cnt;	/* count of cores required */
2470	uint32_t core_spec_cnt;	/* count of core_spec records */
2471	resv_core_spec_t *core_spec; /* reserved cores specification */
2472	time_t end_time;	/* end time of reservation */
2473	char *features;		/* required node features */
2474	uint64_t flags;		/* see RESERVE_FLAG_* above */
2475	char *licenses;		/* names of licenses to be reserved */
2476	uint32_t max_start_delay;/* Maximum delay in which jobs outside of the
2477				  * reservation will be permitted to overlap
2478				  * once any jobs are queued for the
2479				  * reservation */
2480	char *name;		/* name of reservation */
2481	uint32_t node_cnt;	/* count of nodes required */
2482	int32_t *node_inx;	/* list index pairs into node_table for *nodes:
2483				 * start_range_1, end_range_1,
2484				 * start_range_2, .., -1  */
2485	char *node_list;	/* list of reserved nodes or ALL */
2486	char *partition;	/* name of partition to be used */
2487	uint32_t purge_comp_time; /* If PURGE_COMP flag is set the amount of
2488				   * minutes this reservation will sit idle
2489				   * until it is revoked.
2490				   */
2491	time_t start_time;	/* start time of reservation */
2492	uint32_t resv_watts;    /* amount of power to reserve  */
2493	char *tres_str;         /* list of TRES's used by reservation */
2494	char *users;		/* names of users permitted to use */
2495} reserve_info_t;
2496
2497typedef struct reserve_info_msg {
2498	time_t last_update;	/* time of latest info */
2499	uint32_t record_count;	/* number of records */
2500	reserve_info_t *reservation_array; /* the reservation records */
2501} reserve_info_msg_t;
2502
2503typedef struct resv_desc_msg {
2504	char *accounts;		/* names of accounts permitted to use */
2505	char *burst_buffer;	/* burst buffer resources to be included */
2506	uint32_t *core_cnt;	/* Count of cores required */
2507	uint32_t duration;	/* duration of reservation in minutes */
2508	time_t end_time;	/* end time of reservation */
2509	char *features;		/* required node features */
2510	uint64_t flags;		/* see RESERVE_FLAG_* above */
2511	char *licenses;		/* names of licenses to be reserved */
2512	uint32_t max_start_delay;/* Maximum delay in which jobs outside of the
2513				  * reservation will be permitted to overlap
2514				  * once any jobs are queued for the
2515				  * reservation */
2516	char *name;		/* name of reservation (optional on create) */
2517	uint32_t *node_cnt;	/* Count of nodes required. Specify set of job
2518				 * sizes with trailing zero to optimize layout
2519				 * for those jobs just specify their total size
2520				 * to ignore optimized topology. For example,
2521				 * {512,512,1024,0} OR {2048,0}. */
2522	char *node_list;	/* list of reserved nodes or ALL */
2523	char *partition;	/* name of partition to be used */
2524	uint32_t purge_comp_time; /* If PURGE_COMP flag is set the amount of
2525				   * minutes this reservation will sit idle
2526				   * until it is revoked.
2527				   */
2528	time_t start_time;	/* start time of reservation */
2529	uint32_t resv_watts;    /* amount of power to reserve  */
2530	char *tres_str;         /* list of TRES's used by reservation */
2531	char *users;		/* names of users permitted to use */
2532} resv_desc_msg_t;
2533
2534typedef struct reserve_response_msg {
2535	char *name;		/* name of reservation */
2536} reserve_response_msg_t;
2537
2538typedef struct reservation_name_msg {
2539	char *name;		/* name of reservation just created or
2540				 * to be delete */
2541} reservation_name_msg_t;
2542
2543
2544#define DEBUG_FLAG_SELECT_TYPE	0x0000000000000001 /* SelectType plugin */
2545#define DEBUG_FLAG_STEPS	0x0000000000000002 /* slurmctld steps */
2546#define DEBUG_FLAG_TRIGGERS	0x0000000000000004 /* slurmctld triggers */
2547#define DEBUG_FLAG_CPU_BIND	0x0000000000000008 /* CPU binding */
2548#define DEBUG_FLAG_WIKI		0x0000000000000010 /* unused, was wiki plugin */
2549#define DEBUG_FLAG_NO_CONF_HASH	0x0000000000000020 /* no warning about
2550						    * slurm.conf files checksum
2551						    * mismatch */
2552#define DEBUG_FLAG_GRES		0x0000000000000040 /* Generic Resource info */
2553#define DEBUG_FLAG_TRES_NODE    0x0000000000000080 /* Print debug for limits
2554						    * dealing with TRES=NODE */
2555#define DEBUG_FLAG_DATA 	0x0000000000000100 /* data_t logging */
2556#define DEBUG_FLAG_WORKQ 	0x0000000000000200 /* Work Queue */
2557#define DEBUG_FLAG_NET		0x0000000000000400 /* Network logging */
2558#define DEBUG_FLAG_PRIO 	0x0000000000000800 /* debug for priority
2559						    * plugin */
2560#define DEBUG_FLAG_BACKFILL	0x0000000000001000 /* debug for
2561						    * sched/backfill */
2562#define DEBUG_FLAG_GANG		0x0000000000002000 /* debug gang scheduler */
2563#define DEBUG_FLAG_RESERVATION	0x0000000000004000 /* advanced reservations */
2564#define DEBUG_FLAG_FRONT_END	0x0000000000008000 /* front-end nodes */
2565#define DEBUG_FLAG_NO_REALTIME	0x0000000000010000 /* get debug when the
2566						    * realtime server dies
2567						    * on a bluegene system */
2568#define DEBUG_FLAG_SWITCH	0x0000000000020000 /* SwitchType plugin */
2569#define DEBUG_FLAG_ENERGY	0x0000000000040000 /* AcctGatherEnergy plugin */
2570#define DEBUG_FLAG_EXT_SENSORS	0x0000000000080000 /* ExtSensorsType plugin */
2571#define DEBUG_FLAG_LICENSE	0x0000000000100000 /* AcctGatherProfile
2572						    * plugin */
2573#define DEBUG_FLAG_PROFILE	0x0000000000200000 /* AcctGatherProfile
2574						    * plugin */
2575#define DEBUG_FLAG_INTERCONNECT	0x0000000000400000 /* AcctGatherInterconnect
2576						    * plugin */
2577#define DEBUG_FLAG_FILESYSTEM 	0x0000000000800000 /* AcctGatherFilesystem
2578						    * plugin */
2579#define DEBUG_FLAG_JOB_CONT 	0x0000000001000000 /* JobContainer plugin */
2580#define DEBUG_FLAG_TASK 	0x0000000002000000 /* TaskType plugin */
2581#define DEBUG_FLAG_PROTOCOL	0x0000000004000000 /* Communication protocol */
2582#define DEBUG_FLAG_BACKFILL_MAP	0x0000000008000000 /* Backfill scheduler node
2583						    * map */
2584#define DEBUG_FLAG_TRACE_JOBS   0x0000000010000000 /* Trace jobs by id
2585						    * and state */
2586#define DEBUG_FLAG_ROUTE 	0x0000000020000000 /* Route plugin */
2587#define DEBUG_FLAG_DB_ASSOC     0x0000000040000000 /* Association debug */
2588#define DEBUG_FLAG_DB_EVENT     0x0000000080000000 /* Event debug */
2589#define DEBUG_FLAG_DB_JOB       0x0000000100000000 /* Database job debug */
2590#define DEBUG_FLAG_DB_QOS       0x0000000200000000 /* QOS debug */
2591#define DEBUG_FLAG_DB_QUERY     0x0000000400000000 /* Database query debug */
2592#define DEBUG_FLAG_DB_RESV      0x0000000800000000 /* Reservation debug */
2593#define DEBUG_FLAG_DB_RES       0x0000001000000000 /* Resource debug */
2594#define DEBUG_FLAG_DB_STEP      0x0000002000000000 /* Database step debug */
2595#define DEBUG_FLAG_DB_USAGE     0x0000004000000000 /* Usage/Rollup debug */
2596#define DEBUG_FLAG_DB_WCKEY     0x0000008000000000 /* Database WCKey debug */
2597#define DEBUG_FLAG_BURST_BUF    0x0000010000000000 /* Burst buffer plugin */
2598#define DEBUG_FLAG_CPU_FREQ     0x0000020000000000 /* --cpu_freq debug */
2599#define DEBUG_FLAG_POWER        0x0000040000000000 /* Power plugin debug */
2600#define DEBUG_FLAG_TIME_CRAY    0x0000080000000000 /* Time Cray components */
2601#define DEBUG_FLAG_DB_ARCHIVE	0x0000100000000000 /* DBD Archiving/Purging */
2602#define DEBUG_FLAG_DB_TRES      0x0000200000000000 /* Database TRES debug */
2603#define DEBUG_FLAG_ESEARCH      0x0000400000000000 /* Elasticsearch debug */
2604#define DEBUG_FLAG_NODE_FEATURES 0x0000800000000000 /* Node Features debug */
2605#define DEBUG_FLAG_FEDR         0x0001000000000000 /* Federation debug */
2606#define DEBUG_FLAG_HETJOB	0x0002000000000000 /* Heterogeneous job debug */
2607#define DEBUG_FLAG_ACCRUE       0x0004000000000000 /* Accrue counters debug */
2608#define DEBUG_FLAG_POWER_SAVE   0x0008000000000000 /* Power Save debug */
2609#define DEBUG_FLAG_AGENT	0x0010000000000000 /* RPC Agent debug */
2610#define DEBUG_FLAG_DEPENDENCY	0x0020000000000000 /* Dependency debug */
2611
2612#define PREEMPT_MODE_OFF	0x0000	/* disable job preemption */
2613#define PREEMPT_MODE_SUSPEND	0x0001	/* suspend jobs to preempt */
2614#define PREEMPT_MODE_REQUEUE	0x0002	/* requeue or kill jobs to preempt */
2615
2616#define PREEMPT_MODE_CANCEL	0x0008	/* always cancel the job */
2617#define PREEMPT_MODE_GANG	0x8000	/* enable gang scheduling */
2618
2619#define RECONFIG_KEEP_PART_INFO 0x0001 /* keep dynamic partition info on scontrol reconfig */
2620#define RECONFIG_KEEP_PART_STAT 0x0002 /* keep dynamic partition state on scontrol reconfig */
2621
2622#define HEALTH_CHECK_NODE_IDLE	0x0001	/* execute on idle nodes */
2623#define HEALTH_CHECK_NODE_ALLOC	0x0002	/* execute on fully allocated nodes */
2624#define HEALTH_CHECK_NODE_MIXED	0x0004	/* execute on partially allocated nodes */
2625#define HEALTH_CHECK_CYCLE	0x8000	/* cycle through nodes node */
2626#define HEALTH_CHECK_NODE_ANY	0x000f	/* execute on all node states */
2627
2628#define PROLOG_FLAG_ALLOC	0x0001 /* execute prolog upon allocation */
2629#define PROLOG_FLAG_NOHOLD	0x0002 /* don't block salloc/srun until
2630					* slurmctld knows the prolog has
2631					* run on each node in the allocation */
2632#define PROLOG_FLAG_CONTAIN 	0x0004 /* Use proctrack plugin to create a
2633					* container upon allocation */
2634#define PROLOG_FLAG_SERIAL 	0x0008 /* serially execute prolog/epilog */
2635#define PROLOG_FLAG_X11		0x0010 /* enable slurm x11 forwarding support */
2636
2637#define CTL_CONF_OR             0x00000001 /*SlurmdParameters=config_overrides*/
2638#define CTL_CONF_SJC            0x00000002 /* AccountingStoreJobComment */
2639#define CTL_CONF_DRJ            0x00000004 /* DisableRootJobs */
2640#define CTL_CONF_ASRU           0x00000008 /* AllowSpecResourcesUsage */
2641#define CTL_CONF_PAM            0x00000010 /* UsePam */
2642#define CTL_CONF_WCKEY          0x00000020 /* TrackWCKey */
2643
2644#define LOG_FMT_ISO8601_MS      0
2645#define LOG_FMT_ISO8601         1
2646#define LOG_FMT_RFC5424_MS      2
2647#define LOG_FMT_RFC5424         3
2648#define LOG_FMT_CLOCK           4
2649#define LOG_FMT_SHORT           5
2650#define LOG_FMT_THREAD_ID       6
2651
2652typedef struct slurm_ctl_conf {
2653	time_t last_update;	/* last update time of the build parameters */
2654	char *accounting_storage_tres; /* list of tres */
2655	uint16_t accounting_storage_enforce; /* job requires valid association:
2656					      * user/account/partition/cluster */
2657	char *accounting_storage_backup_host;	/* accounting storage
2658						 * backup host */
2659	char *accounting_storage_ext_host; /* accounting storage ext host */
2660	char *accounting_storage_host;	/* accounting storage host */
2661	char *accounting_storage_loc;	/* accounting storage (db table)
2662					 * location */
2663	char *accounting_storage_pass;	/* accounting storage
2664					 * password */
2665	uint32_t accounting_storage_port;/* node accounting storage port */
2666	char *accounting_storage_type; /* accounting storage type */
2667	char *accounting_storage_user; /* accounting storage user */
2668	void *acct_gather_conf; /* account gather config */
2669	char *acct_gather_energy_type; /* energy accounting type */
2670	char *acct_gather_profile_type; /* profile accounting type */
2671	char *acct_gather_interconnect_type; /* interconnect accounting type */
2672	char *acct_gather_filesystem_type; /* filesystem accounting type */
2673	uint16_t acct_gather_node_freq; /* secs between node acct request */
2674	char *authalttypes;	/* alternate authentication types */
2675	char *authinfo;		/* authentication info */
2676	char *authtype;		/* authentication type */
2677	uint16_t batch_start_timeout;	/* max secs for batch job to start */
2678	char *bb_type;		/* burst buffer plugin type */
2679	time_t boot_time;	/* time slurmctld last booted */
2680	void *cgroup_conf;	/* cgroup support config file */
2681	char *cli_filter_plugins; /* List of cli_filter plugins to use */
2682	char *core_spec_plugin;	/* core specialization plugin name */
2683	char *cluster_name;     /* general name of the entire cluster */
2684	char *comm_params;     /* Communication parameters */
2685	uint16_t complete_wait;	/* seconds to wait for job completion before
2686				 * scheduling another job */
2687	uint32_t conf_flags;   	/* various CTL_CONF_* flags to determine
2688				 * settings */
2689	char **control_addr;	/* comm path of slurmctld
2690				 * primary server and backups */
2691	uint32_t control_cnt;	/* Length of control_addr & control_machine */
2692	char **control_machine;	/* name of slurmctld primary
2693				 * server and backups */
2694	uint32_t cpu_freq_def;	/* default cpu frequency / governor */
2695	uint32_t cpu_freq_govs;	/* cpu freq governors allowed */
2696	char *cred_type;	/* credential signature plugin */
2697	uint64_t debug_flags;	/* see DEBUG_FLAG_* above for values */
2698	uint64_t def_mem_per_cpu; /* default MB memory per allocated CPU */
2699	char *dependency_params; /* DependencyParameters */
2700	uint16_t eio_timeout;     /* timeout for the eio thread */
2701	uint16_t enforce_part_limits;	/* if set, reject job exceeding
2702					 * partition size and/or time limits */
2703	char *epilog;		/* pathname of job epilog */
2704	uint32_t epilog_msg_time;  /* usecs for slurmctld to process an
2705				    * epilog complete message */
2706	char *epilog_slurmctld;	/* pathname of job epilog run by slurmctld */
2707	char *ext_sensors_type; /* external sensors plugin type */
2708	uint16_t ext_sensors_freq; /* secs between ext sensors sampling */
2709	void *ext_sensors_conf; /* external sensors config file*/
2710	char *fed_params;       /* Federation parameters */
2711	uint32_t first_job_id;	/* first slurm generated job_id to assign */
2712	uint16_t fs_dampening_factor; /* dampening for Fairshare factor */
2713	uint16_t get_env_timeout; /* timeout for srun --get-user-env option */
2714	char * gres_plugins;	/* list of generic resource plugins */
2715	uint16_t group_time;    /* update group time interval */
2716	uint16_t group_force;   /* update group/partition info even if no change
2717				 * detected */
2718	char *gpu_freq_def;	/* default GPU frequency / voltage */
2719	uint32_t hash_val;      /* Hash value of the slurm.conf file */
2720	uint16_t health_check_interval;	/* secs between health checks */
2721	uint16_t health_check_node_state; /* Node states on which to execute
2722				 * health check program, see
2723				 * HEALTH_CHECK_NODE_* above */
2724	char * health_check_program;	/* pathname of health check program */
2725	uint16_t inactive_limit;/* seconds of inactivity before a
2726				 * inactive resource allocation is released */
2727	char *job_acct_gather_freq; /* poll frequency for job accounting
2728					* gather plugins */
2729	char *job_acct_gather_type; /* job accounting gather type */
2730	char *job_acct_gather_params; /* job accounting gather parameters */
2731	uint16_t job_acct_oom_kill; /* Enforce mem limit at runtime y|n */
2732	char *job_comp_host;	/* job completion logging host */
2733	char *job_comp_loc;	/* job completion logging location */
2734	char *job_comp_params;	/* job completion parameters for plugin */
2735	char *job_comp_pass;	/* job completion storage password */
2736	uint32_t job_comp_port;	/* job completion storage port */
2737	char *job_comp_type;	/* job completion storage type */
2738	char *job_comp_user;	/* job completion storage user */
2739	char *job_container_plugin; /* job container plugin type */
2740	char *job_credential_private_key;	/* path to private key */
2741	char *job_credential_public_certificate;/* path to public certificate*/
2742	List job_defaults_list;	/* List of job_defaults_t elements */
2743	uint16_t job_file_append; /* if set, append to stdout/err file */
2744	uint16_t job_requeue;	/* If set, jobs get requeued on node failre */
2745	char *job_submit_plugins;  /* List of job_submit plugins to use */
2746	uint16_t keep_alive_time;  /* Keep alive time for srun I/O sockets */
2747	uint16_t kill_on_bad_exit; /* If set, the job will be
2748				    * terminated immediately when one of
2749				    * the processes is aborted or crashed */
2750	uint16_t kill_wait;	/* seconds between SIGXCPU to SIGKILL
2751				 * on job termination */
2752	char *launch_params;	/* step launcher plugin options */
2753	char *launch_type;	/* type of step launcher to use */
2754	char *layouts;		/* comma separted list of layouts plugins */
2755	char *licenses;		/* licenses available on this cluster */
2756	uint16_t log_fmt;       /* Log file timestamp format */
2757	char *mail_domain;	/* default domain to append to usernames */
2758	char *mail_prog;	/* pathname of mail program */
2759	uint32_t max_array_sz;	/* Maximum job array size */
2760	uint32_t max_dbd_msgs;	/* maximum number of messages queued while DBD
2761				 * is not connected */
2762	uint32_t max_job_cnt;	/* maximum number of active jobs */
2763	uint32_t max_job_id;	/* maximum job id before using first_job_id */
2764	uint64_t max_mem_per_cpu; /* maximum MB memory per allocated CPU */
2765	uint32_t max_step_cnt;	/* maximum number of steps per job */
2766	uint16_t max_tasks_per_node; /* maximum tasks per node */
2767	char *mcs_plugin; /* mcs plugin type */
2768	char *mcs_plugin_params; /* mcs plugin parameters */
2769	uint32_t min_job_age;	/* COMPLETED jobs over this age (secs)
2770				 * purged from in memory records */
2771	char *mpi_default;	/* Default version of MPI in use */
2772	char *mpi_params;	/* MPI parameters */
2773	char *msg_aggr_params;  /* Message aggregation parameters */
2774	uint16_t msg_timeout;	/* message timeout */
2775	uint16_t tcp_timeout;	/* tcp timeout */
2776	uint32_t next_job_id;	/* next slurm generated job_id to assign */
2777	void *node_features_conf; /* Node Features Plugin config file */
2778	char *node_features_plugins; /* List of node_features plugins to use */
2779	char *node_prefix;      /* prefix of nodes in partition, only set in
2780				   bluegene clusters NULL otherwise */
2781	uint16_t over_time_limit; /* job's time limit can be exceeded by this
2782				   * number of minutes before cancellation */
2783	char *plugindir;	/* pathname to plugins */
2784	char *plugstack;        /* pathname to plugin stack config file */
2785	char *power_parameters;	/* power management parameters */
2786	char *power_plugin;	/* power management plugin type */
2787	uint32_t preempt_exempt_time; /* Time before jobs are preemptable */
2788	uint16_t preempt_mode;	/* See PREEMPT_MODE_* in slurm/slurm.h */
2789	char *preempt_type;	/* job preemption selection plugin */
2790	char *prep_params;	/* PrEp parameters */
2791	char *prep_plugins;	/* PrEp plugins */
2792	uint32_t priority_decay_hl; /* priority decay half life in
2793				     * seconds */
2794	uint32_t priority_calc_period; /* seconds between priority decay
2795					* calculation */
2796	uint16_t priority_favor_small; /* favor small jobs over large */
2797	uint16_t priority_flags; /* set some flags for priority configuration,
2798				  * see PRIORITY_FLAGS_* above */
2799	uint32_t priority_max_age; /* time when not to add any more
2800				    * priority to a job if reached */
2801    	char *priority_params;	/* priority plugin parameters */
2802	uint16_t priority_reset_period; /* when to clear usage,
2803					 * see PRIORITY_RESET_* */
2804	char *priority_type;    /* priority type plugin */
2805	uint32_t priority_weight_age; /* weight for age factor */
2806	uint32_t priority_weight_assoc; /* weight for assoc factor */
2807	uint32_t priority_weight_fs; /* weight for Fairshare factor */
2808	uint32_t priority_weight_js; /* weight for Job Size factor */
2809	uint32_t priority_weight_part; /* weight for Partition factor */
2810	uint32_t priority_weight_qos; /* weight for QOS factor */
2811	char    *priority_weight_tres; /* weights (str) for different TRES' */
2812	uint16_t private_data;	/* block viewing of information,
2813				 * see PRIVATE_DATA_* */
2814	char *proctrack_type;	/* process tracking plugin type */
2815	char *prolog;		/* pathname of job prolog run by slurmd */
2816	uint16_t prolog_epilog_timeout; /* prolog/epilog timeout */
2817	char *prolog_slurmctld;	/* pathname of job prolog run by slurmctld */
2818	uint16_t propagate_prio_process; /* process priority propagation,
2819					  * see PROP_PRIO_* */
2820	uint16_t prolog_flags; /* set some flags for prolog configuration
2821				  see PROLOG_FLAG_* */
2822	char *propagate_rlimits;/* Propagate (all/specific) resource limits */
2823	char *propagate_rlimits_except;/* Propagate all rlimits except these */
2824	char *reboot_program;	/* program to reboot the node */
2825	uint16_t reconfig_flags;/* see RECONFIG_* */
2826	char *requeue_exit;      /* requeue exit values */
2827	char *requeue_exit_hold; /* requeue exit hold values */
2828	char *resume_fail_program; /* program to handle failed resume tries */
2829	char *resume_program;	/* program to make nodes full power */
2830	uint16_t resume_rate;	/* nodes to make full power, per minute */
2831	uint16_t resume_timeout;/* time required in order to perform a node
2832				 * resume operation */
2833	char *resv_epilog;	/* path of reservation epilog run by slurmctld */
2834	uint16_t resv_over_run;	/* how long a running job can exceed
2835				 * reservation time */
2836	char *resv_prolog;	/* path of reservation prolog run by slurmctld */
2837	uint16_t ret2service;	/* 1 return DOWN node to service at
2838				 * registration */
2839	char *route_plugin;     /* route plugin */
2840	char *salloc_default_command; /* default salloc command */
2841	char *sbcast_parameters; /* sbcast command options */
2842	char *sched_logfile;    /* where slurm Scheduler log gets written */
2843	uint16_t sched_log_level;  /* configured level of slurm Scheduler log */
2844	char *sched_params;	/* SchedulerParameters OR
2845				 * contents of scheduler plugin config file */
2846	uint16_t sched_time_slice;	/* gang scheduler slice time, secs */
2847	char *schedtype;	/* type of scheduler to use */
2848	char *select_type;	/* type of node selector to use */
2849	void *select_conf_key_pairs; /* key-pair list which can be
2850				      * listed with slurm_print_key_pairs() */
2851	uint16_t select_type_param; /* Parameters
2852				     * describing the select_type plugin */
2853	char *site_factor_plugin; /* PrioritySiteFactorPlugin */
2854	char *site_factor_params; /* PrioritySiteFactorParameters */
2855	char *slurm_conf;	/* pathname of slurm config file */
2856	uint32_t slurm_user_id;	/* uid of slurm_user_name */
2857	char *slurm_user_name;	/* user that slurmctld runs as */
2858	uint32_t slurmd_user_id;/* uid of slurmd_user_name */
2859	char *slurmd_user_name;	/* user that slurmd runs as */
2860	char *slurmctld_addr;	/* Address used for communications to the
2861				 * currently active slurmctld daemon */
2862	uint16_t slurmctld_debug; /* slurmctld logging level */
2863	char *slurmctld_logfile;/* where slurmctld error log gets written */
2864	char *slurmctld_pidfile;/* where to put slurmctld pidfile         */
2865	char *slurmctld_plugstack;/* generic slurmctld plugins */
2866	void *slurmctld_plugstack_conf ;/* generic slurmctld plugins configs */
2867	uint32_t slurmctld_port;  /* default communications port to slurmctld */
2868	uint16_t slurmctld_port_count; /* number of slurmctld comm ports */
2869	char *slurmctld_primary_off_prog; /* Run when becomes slurmctld backup */
2870	char *slurmctld_primary_on_prog;  /* Run when becomes slurmctld primary */
2871	uint16_t slurmctld_syslog_debug; /* slurmctld output to
2872					  * local logfile and syslog*/
2873	uint16_t slurmctld_timeout;/* seconds that backup controller waits
2874				    * on non-responding primarly controller */
2875	char *slurmctld_params;	/* SlurmctldParameters */
2876	uint16_t slurmd_debug;	/* slurmd logging level */
2877	char *slurmd_logfile;	/* where slurmd error log gets written */
2878	char *slurmd_params;	/* SlurmdParameters */
2879	char *slurmd_pidfile;   /* where to put slurmd pidfile           */
2880	uint32_t slurmd_port;	/* default communications port to slurmd */
2881	char *slurmd_spooldir;	/* where slurmd put temporary state info */
2882	uint16_t slurmd_syslog_debug; /* slurmd output to
2883				       * local logfile and syslog*/
2884	uint16_t slurmd_timeout;/* how long slurmctld waits for slurmd before
2885				 * considering node DOWN */
2886	char *srun_epilog;      /* srun epilog program */
2887	uint16_t *srun_port_range; /* port range for srun */
2888	char *srun_prolog;      /* srun prolog program */
2889	char *state_save_location;/* pathname of slurmctld state save
2890				   * directory */
2891	char *suspend_exc_nodes;/* nodes to not make power saving */
2892	char *suspend_exc_parts;/* partitions to not make power saving */
2893	char *suspend_program;	/* program to make nodes power saving */
2894	uint16_t suspend_rate;	/* nodes to make power saving, per minute */
2895	uint32_t suspend_time;	/* node idle for this long before power save mode */
2896	uint16_t suspend_timeout;/* time required in order to perform a node
2897				  * suspend operation */
2898	char *switch_type;	/* switch or interconnect type */
2899	char *task_epilog;	/* pathname of task launch epilog */
2900	char *task_plugin;	/* task launch plugin */
2901	uint32_t task_plugin_param;	/* see CPU_BIND_* */
2902	char *task_prolog;	/* pathname of task launch prolog */
2903	char *tmp_fs;		/* pathname of temporary file system */
2904	char *topology_param;	/* network topology parameters */
2905	char *topology_plugin;	/* network topology plugin */
2906	uint16_t tree_width;    /* number of threads per node to span */
2907	char *unkillable_program; /* program run by the slurmstepd when
2908				   * processes in a job step are unkillable */
2909	uint16_t unkillable_timeout; /* time in seconds, after processes in a
2910				      * job step have been signaled, before
2911				      * they are considered "unkillable". */
2912	char *version;		/* version of slurmctld */
2913	uint16_t vsize_factor;	/* virtual memory limit size factor */
2914	uint16_t wait_time;	/* default job --wait time */
2915	char *x11_params;	/* X11Parameters */
2916} slurm_ctl_conf_t;
2917
2918typedef struct slurmd_status_msg {
2919	time_t booted;			/* when daemon was started */
2920	time_t last_slurmctld_msg;	/* time of last slurmctld message */
2921	uint16_t slurmd_debug;		/* logging level */
2922	uint16_t actual_cpus;		/* actual logical processor count */
2923	uint16_t actual_boards;	 	/* actual total boards count      */
2924	uint16_t actual_sockets;	/* actual total sockets count     */
2925	uint16_t actual_cores;		/* actual core per socket count   */
2926	uint16_t actual_threads;	/* actual thread per core count */
2927	uint64_t actual_real_mem;	/* actual real memory in MB */
2928	uint32_t actual_tmp_disk;	/* actual temp disk space in MB */
2929	uint32_t pid;			/* process ID */
2930	char *hostname;			/* local hostname */
2931	char *slurmd_logfile;		/* slurmd log file location */
2932	char *step_list;		/* list of active job steps */
2933	char *version;			/* version running */
2934} slurmd_status_t;
2935
2936typedef struct submit_response_msg {
2937	uint32_t job_id;	/* job ID */
2938	uint32_t step_id;	/* step ID */
2939	uint32_t error_code;	/* error code for warning message */
2940	char *job_submit_user_msg; /* job submit plugin user_msg */
2941} submit_response_msg_t;
2942
2943/* NOTE: If setting node_addr and/or node_hostname then comma separate names
2944 * and include an equal number of node_names */
2945typedef struct slurm_update_node_msg {
2946	uint32_t cpu_bind;	/* default CPU binding type */
2947	char *features;		/* new available feature for node */
2948	char *features_act;	/* new active feature for node */
2949	char *gres;		/* new generic resources for node */
2950	char *node_addr;	/* communication name (optional) */
2951	char *node_hostname;	/* node's hostname (optional) */
2952	char *node_names;	/* nodelist expression */
2953	uint32_t node_state;	/* see enum node_states */
2954	char *reason;		/* reason for node being DOWN or DRAINING */
2955	uint32_t reason_uid;	/* user ID of sending (needed if user
2956				 * root is sending message) */
2957	uint32_t weight;	/* new weight for node */
2958} update_node_msg_t;
2959
2960typedef struct slurm_update_front_end_msg {
2961	char *name;		/* comma separated list of front end nodes */
2962	uint32_t node_state;	/* see enum node_states */
2963	char *reason;		/* reason for node being DOWN or DRAINING */
2964	uint32_t reason_uid;	/* user ID of sending (needed if user
2965				 * root is sending message) */
2966} update_front_end_msg_t;
2967
2968typedef struct partition_info update_part_msg_t;
2969
2970typedef struct job_sbcast_cred_msg {
2971	uint32_t      job_id;		/* assigned job id */
2972	slurm_addr_t  *node_addr;	/* network addresses */
2973	uint32_t      node_cnt;		/* count of nodes */
2974	char         *node_list;	/* assigned list of nodes */
2975	sbcast_cred_t *sbcast_cred;	/* opaque data structure */
2976} job_sbcast_cred_msg_t;
2977
2978typedef struct {
2979	uint32_t lifespan;
2980	char *username;
2981} token_request_msg_t;
2982
2983typedef struct {
2984	char *token;
2985} token_response_msg_t;
2986
2987/* Opaque data type for slurm_step_ctx_* functions */
2988typedef struct slurm_step_ctx_struct slurm_step_ctx_t;
2989
2990#define STAT_COMMAND_RESET	0x0000
2991#define STAT_COMMAND_GET	0x0001
2992typedef struct stats_info_request_msg {
2993	uint16_t command_id;
2994} stats_info_request_msg_t;
2995
2996typedef struct stats_info_response_msg {
2997	uint32_t parts_packed;
2998	time_t req_time;
2999	time_t req_time_start;
3000	uint32_t server_thread_count;
3001	uint32_t agent_queue_size;
3002	uint32_t agent_count;
3003	uint32_t agent_thread_count;
3004	uint32_t dbd_agent_queue_size;
3005	uint32_t gettimeofday_latency;
3006
3007	uint32_t schedule_cycle_max;
3008	uint32_t schedule_cycle_last;
3009	uint32_t schedule_cycle_sum;
3010	uint32_t schedule_cycle_counter;
3011	uint32_t schedule_cycle_depth;
3012	uint32_t schedule_queue_len;
3013
3014	uint32_t jobs_submitted;
3015	uint32_t jobs_started;
3016	uint32_t jobs_completed;
3017	uint32_t jobs_canceled;
3018	uint32_t jobs_failed;
3019
3020	uint32_t jobs_pending;
3021	uint32_t jobs_running;
3022	time_t   job_states_ts;
3023
3024	uint32_t bf_backfilled_jobs;
3025	uint32_t bf_last_backfilled_jobs;
3026	uint32_t bf_backfilled_het_jobs;
3027	uint32_t bf_cycle_counter;
3028	uint64_t bf_cycle_sum;
3029	uint32_t bf_cycle_last;
3030	uint32_t bf_cycle_max;
3031	uint32_t bf_last_depth;
3032	uint32_t bf_last_depth_try;
3033	uint32_t bf_depth_sum;
3034	uint32_t bf_depth_try_sum;
3035	uint32_t bf_queue_len;
3036	uint32_t bf_queue_len_sum;
3037	uint32_t bf_table_size;
3038	uint32_t bf_table_size_sum;
3039	time_t   bf_when_last_cycle;
3040	uint32_t bf_active;
3041
3042	uint32_t rpc_type_size;
3043	uint16_t *rpc_type_id;
3044	uint32_t *rpc_type_cnt;
3045	uint64_t *rpc_type_time;
3046
3047	uint32_t rpc_user_size;
3048	uint32_t *rpc_user_id;
3049	uint32_t *rpc_user_cnt;
3050	uint64_t *rpc_user_time;
3051
3052	uint32_t rpc_queue_type_count;
3053	uint32_t *rpc_queue_type_id;
3054	uint32_t *rpc_queue_count;
3055
3056	uint32_t rpc_dump_count;
3057	uint32_t *rpc_dump_types;
3058	char **rpc_dump_hostlist;
3059} stats_info_response_msg_t;
3060
3061#define TRIGGER_FLAG_PERM		0x0001
3062
3063#define TRIGGER_RES_TYPE_JOB            0x0001
3064#define TRIGGER_RES_TYPE_NODE           0x0002
3065#define TRIGGER_RES_TYPE_SLURMCTLD      0x0003
3066#define TRIGGER_RES_TYPE_SLURMDBD       0x0004
3067#define TRIGGER_RES_TYPE_DATABASE       0x0005
3068#define TRIGGER_RES_TYPE_FRONT_END      0x0006
3069#define TRIGGER_RES_TYPE_OTHER          0x0007
3070
3071#define TRIGGER_TYPE_UP                 0x00000001
3072#define TRIGGER_TYPE_DOWN               0x00000002
3073#define TRIGGER_TYPE_FAIL               0x00000004
3074#define TRIGGER_TYPE_TIME               0x00000008
3075#define TRIGGER_TYPE_FINI               0x00000010
3076#define TRIGGER_TYPE_RECONFIG           0x00000020
3077/*  was TRIGGER_TYPE_BLOCK_ERR          0x00000040, removed v18.08 */
3078#define TRIGGER_TYPE_IDLE               0x00000080
3079#define TRIGGER_TYPE_DRAINED            0x00000100
3080#define TRIGGER_TYPE_PRI_CTLD_FAIL      0x00000200
3081#define TRIGGER_TYPE_PRI_CTLD_RES_OP    0x00000400
3082#define TRIGGER_TYPE_PRI_CTLD_RES_CTRL  0x00000800
3083#define TRIGGER_TYPE_PRI_CTLD_ACCT_FULL 0x00001000
3084#define TRIGGER_TYPE_BU_CTLD_FAIL       0x00002000
3085#define TRIGGER_TYPE_BU_CTLD_RES_OP     0x00004000
3086#define TRIGGER_TYPE_BU_CTLD_AS_CTRL    0x00008000
3087#define TRIGGER_TYPE_PRI_DBD_FAIL       0x00010000
3088#define TRIGGER_TYPE_PRI_DBD_RES_OP     0x00020000
3089#define TRIGGER_TYPE_PRI_DB_FAIL        0x00040000
3090#define TRIGGER_TYPE_PRI_DB_RES_OP      0x00080000
3091#define TRIGGER_TYPE_BURST_BUFFER       0x00100000
3092
3093
3094typedef struct trigger_info {
3095	uint16_t flags;		/* TRIGGER_FLAG_* */
3096	uint32_t trig_id;	/* trigger ID */
3097	uint16_t res_type;	/* TRIGGER_RES_TYPE_* */
3098	char *   res_id;	/* resource ID */
3099	uint32_t control_inx;	/* controller index */
3100	uint32_t trig_type;	/* TRIGGER_TYPE_* */
3101	uint16_t offset;	/* seconds from trigger, 0x8000 origin */
3102	uint32_t user_id;	/* user requesting trigger */
3103	char *   program;	/* program to execute */
3104} trigger_info_t;
3105
3106typedef struct trigger_info_msg {
3107	uint32_t record_count;		/* number of records */
3108	trigger_info_t *trigger_array;	/* the trigger records */
3109} trigger_info_msg_t;
3110
3111
3112/* Individual license information
3113 */
3114typedef struct slurm_license_info {
3115	char *name;          /* license name */
3116	uint32_t total;      /* total number of available licenses */
3117	uint32_t in_use;     /* number of license in use */
3118	uint32_t available;  /* number of available license */
3119	uint8_t remote;      /* non-zero if remote license (not
3120			      * defined in slurm.conf) */
3121} slurm_license_info_t;
3122
3123/* License information array as returned by the controller.
3124 */
3125typedef struct license_info_msg {
3126	time_t last_update;
3127	uint32_t num_lic;
3128	slurm_license_info_t *lic_array;
3129} license_info_msg_t;
3130
3131typedef struct {
3132	uint32_t  job_array_count;
3133	char    **job_array_id; /* Note: The string may be truncated */
3134	uint32_t *error_code;
3135} job_array_resp_msg_t;
3136
3137/* Association manager state running in the slurmctld */
3138typedef struct {
3139	List assoc_list; /* list of slurmdb_assoc_rec_t with usage packed */
3140	List qos_list;   /* list of slurmdb_qos_rec_t with usage packed */
3141	uint32_t tres_cnt;
3142	char **tres_names;
3143	List user_list;  /* list of slurmdb_user_rec_t */
3144} assoc_mgr_info_msg_t;
3145
3146#define ASSOC_MGR_INFO_FLAG_ASSOC 0x00000001
3147#define ASSOC_MGR_INFO_FLAG_USERS 0x00000002
3148#define ASSOC_MGR_INFO_FLAG_QOS   0x00000004
3149
3150typedef struct {
3151	List acct_list; /* char * list of account names */
3152	uint32_t flags; /* flags determining what is returned */
3153	List qos_list;  /* char * list of qos names */
3154	List user_list; /* char * list of user names */
3155} assoc_mgr_info_request_msg_t;
3156
3157typedef struct network_callerid_msg {
3158	unsigned char ip_src[16];
3159	unsigned char ip_dst[16];
3160	uint32_t port_src;
3161	uint32_t port_dst;
3162	int32_t af;	/* NOTE: un/packed as uint32_t */
3163} network_callerid_msg_t;
3164
3165/*****************************************************************************\
3166 *	RESOURCE ALLOCATION FUNCTIONS
3167\*****************************************************************************/
3168
3169/*
3170 * slurm_init_job_desc_msg - initialize job descriptor with
3171 *	default values
3172 * OUT job_desc_msg - user defined job descriptor
3173 */
3174extern void slurm_init_job_desc_msg(job_desc_msg_t *job_desc_msg);
3175
3176/*
3177 * slurm_allocate_resources - allocate resources for a job request
3178 *   If the requested resources are not immediately available, the slurmctld
3179 *   will send the job_alloc_resp_msg to the specified node and port.
3180 * IN job_desc_msg - description of resource allocation request
3181 * OUT job_alloc_resp_msg - response to request.  This only represents
3182 *   a job allocation if resources are immediately.  Otherwise it just contains
3183 *   the job id of the enqueued job request.
3184 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3185 * NOTE: free the response using slurm_free_resource_allocation_response_msg()
3186 */
3187extern int slurm_allocate_resources(job_desc_msg_t *job_desc_msg,
3188				    resource_allocation_response_msg_t **job_alloc_resp_msg);
3189
3190/*
3191 * slurm_allocate_resources_blocking
3192 *	allocate resources for a job request.  This call will block until
3193 *	the allocation is granted, or the specified timeout limit is reached.
3194 * IN req - description of resource allocation request
3195 * IN timeout - amount of time, in seconds, to wait for a response before
3196 * 	giving up.
3197 *	A timeout of zero will wait indefinitely.
3198 * IN pending_callback - If the allocation cannot be granted immediately,
3199 *      the controller will put the job in the PENDING state.  If
3200 *      pending callback is not NULL, it will be called with the job_id
3201 *      of the pending job as the sole parameter.
3202 *
3203 * RET allocation structure on success, NULL on error set errno to
3204 *	indicate the error (errno will be ETIMEDOUT if the timeout is reached
3205 *      with no allocation granted)
3206 * NOTE: free the response using slurm_free_resource_allocation_response_msg()
3207 */
3208extern resource_allocation_response_msg_t *slurm_allocate_resources_blocking(
3209	const job_desc_msg_t *user_req,
3210	time_t timeout,
3211	void (*pending_callback)(uint32_t job_id));
3212
3213/*
3214 * slurm_free_resource_allocation_response_msg - free slurm resource
3215 *	allocation response message
3216 * IN msg - pointer to allocation response message
3217 * NOTE: buffer is loaded by slurm_allocate_resources
3218 */
3219extern void slurm_free_resource_allocation_response_msg(resource_allocation_response_msg_t *msg);
3220
3221/*
3222 * slurm_allocate_het_job_blocking
3223 *	allocate resources for a list of job requests.  This call will block
3224 *	until the entire allocation is granted, or the specified timeout limit
3225 *	is reached.
3226 * IN job_req_list - List of resource allocation requests, type job_desc_msg_t
3227 * IN timeout - amount of time, in seconds, to wait for a response before
3228 * 	giving up.
3229 *	A timeout of zero will wait indefinitely.
3230 * IN pending_callback - If the allocation cannot be granted immediately,
3231 *      the controller will put the job in the PENDING state.  If
3232 *      pending callback is not NULL, it will be called with the job_id
3233 *      of the pending job as the sole parameter.
3234 *
3235 * RET List of allocation structures on success, NULL on error set errno to
3236 *	indicate the error (errno will be ETIMEDOUT if the timeout is reached
3237 *      with no allocation granted)
3238 * NOTE: free the response using list_destroy()
3239 */
3240List slurm_allocate_het_job_blocking(List job_req_list, time_t timeout,
3241				      void(*pending_callback)(uint32_t job_id));
3242
3243/*
3244 * slurm_allocation_lookup - retrieve info for an existing resource
3245 *			     allocation
3246 * IN job_id - job allocation identifier
3247 * OUT resp - job allocation information
3248 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3249 * NOTE: free the response using slurm_free_resource_allocation_response_msg()
3250 */
3251extern int slurm_allocation_lookup(uint32_t job_id,
3252				   resource_allocation_response_msg_t **resp);
3253
3254/*
3255 * slurm_het_job_lookup - retrieve info for an existing heterogeneous job
3256 * 			   allocation without the addrs and such
3257 * IN jobid - job allocation identifier
3258 * OUT resp - list of job allocation information, type
3259 *	      resource_allocation_response_msg_t
3260 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3261 * NOTE: returns information an individual job as well
3262 * NOTE: free the response using list_destroy()
3263 */
3264extern int slurm_het_job_lookup(uint32_t jobid, List *resp);
3265
3266/*
3267 * slurm_read_hostfile - Read a Slurm hostfile specified by "filename".
3268 *	"filename" must contain a list of Slurm NodeNames, one per line.
3269 *	Reads up to "n" number of hostnames from the file. Returns a
3270 *	string representing a hostlist ranged string of the contents of
3271 *	the file.  This is a helper function, it does not contact any
3272 *	Slurm daemons.
3273 *
3274 * IN filename - name of Slurm Hostlist file to be read.
3275 * IN n - number of NodeNames required
3276 * RET - a string representing the hostlist.  Returns NULL if there are
3277 *	fewer than "n" hostnames in the file, or if an error occurs.
3278 *
3279 * NOTE: Returned string must be freed with free().
3280 */
3281extern char *slurm_read_hostfile(const char *filename, int n);
3282
3283/*
3284 * slurm_allocation_msg_thr_create - startup a message handler talking
3285 * with the controller dealing with messages from the controller during an
3286 * allocation.
3287 * IN port - port we are listening for messages on from the controller
3288 * IN callbacks - callbacks for different types of messages
3289 * RET allocation_msg_thread_t * or NULL on failure
3290 */
3291extern allocation_msg_thread_t *slurm_allocation_msg_thr_create(uint16_t *port,
3292				const slurm_allocation_callbacks_t *callbacks);
3293
3294/*
3295 * slurm_allocation_msg_thr_destroy - shutdown the message handler talking
3296 * with the controller dealing with messages from the controller during an
3297 * allocation.
3298 * IN msg_thr - allocation_msg_thread_t pointer allocated with
3299 *              slurm_allocation_msg_thr_create
3300 */
3301extern void slurm_allocation_msg_thr_destroy(allocation_msg_thread_t *msg_thr);
3302
3303/*
3304 * slurm_submit_batch_job - issue RPC to submit a job for later execution
3305 * NOTE: free the response using slurm_free_submit_response_response_msg
3306 * IN job_desc_msg - description of batch job request
3307 * OUT slurm_alloc_msg - response to request
3308 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3309 */
3310extern int slurm_submit_batch_job(job_desc_msg_t *job_desc_msg,
3311				  submit_response_msg_t **slurm_alloc_msg);
3312
3313/*
3314 * slurm_submit_batch_het_job - issue RPC to submit a heterogeneous job for
3315 *				 later execution
3316 * NOTE: free the response using slurm_free_submit_response_response_msg
3317 * IN job_req_list - List of resource allocation requests, type job_desc_msg_t
3318 * OUT slurm_alloc_msg - response to request
3319 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3320 */
3321extern int slurm_submit_batch_het_job(List job_req_list,
3322				      submit_response_msg_t **slurm_alloc_msg);
3323
3324/*
3325 * slurm_free_submit_response_response_msg - free slurm
3326 *	job submit response message
3327 * IN msg - pointer to job submit response message
3328 * NOTE: buffer is loaded by slurm_submit_batch_job
3329 */
3330extern void slurm_free_submit_response_response_msg(submit_response_msg_t *msg);
3331
3332/*
3333 * slurm_job_batch_script - retrieve the batch script for a given jobid
3334 * returns SLURM_SUCCESS, or appropriate error code
3335 */
3336extern int slurm_job_batch_script(FILE *out, uint32_t jobid);
3337
3338/*
3339 * slurm_job_will_run - determine if a job would execute immediately if
3340 *	submitted now
3341 * IN job_desc_msg - description of resource allocation request
3342 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3343 */
3344extern int slurm_job_will_run(job_desc_msg_t *job_desc_msg);
3345
3346/*
3347 * slurm_het_job_will_run - determine if a heterogeneous job would execute
3348 *	immediately if submitted now
3349 * IN job_req_list - List of job_desc_msg_t structures describing the resource
3350 *		allocation request
3351 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3352 */
3353extern int slurm_het_job_will_run(List job_req_list);
3354
3355
3356/*
3357 * slurm_job_will_run2 - determine if a job would execute immediately if
3358 *      submitted now
3359 * IN job_desc_msg - description of resource allocation request
3360 * OUT will_run_resp - job run time data
3361 *      free using slurm_free_will_run_response_msg()
3362 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3363 */
3364extern int slurm_job_will_run2(job_desc_msg_t *req,
3365			       will_run_response_msg_t **will_run_resp);
3366
3367/*
3368 * slurm_sbcast_lookup - retrieve info for an existing resource allocation
3369 *	including a credential needed for sbcast
3370 * IN job_id - job allocation identifier (or hetjob ID)
3371 * IN het_job_offset - hetjob index (or NO_VAL if not hetjob)
3372 * IN step_id - step allocation identifier (or NO_VAL for entire job)
3373 * OUT info - job allocation information including a credential for sbcast
3374 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3375 * NOTE: free the "resp" using slurm_free_sbcast_cred_msg
3376 */
3377extern int slurm_sbcast_lookup(uint32_t job_id, uint32_t het_job_offset,
3378			       uint32_t step_id, job_sbcast_cred_msg_t **info);
3379
3380extern void slurm_free_sbcast_cred_msg(job_sbcast_cred_msg_t *msg);
3381
3382/* slurm_load_licenses()
3383 *
3384 * Retrieve license information from the controller.
3385 * IN feature - feature name or NULL
3386 * OUT
3387 *
3388 */
3389extern int slurm_load_licenses(time_t, license_info_msg_t **, uint16_t);
3390extern void slurm_free_license_info_msg(license_info_msg_t *);
3391
3392/* get the running assoc_mgr info
3393 * IN assoc_mgr_info_request_msg_t: request filtering data returned
3394 * OUT assoc_mgr_info_msg_t: returned structure filled in with
3395 * assoc_mgr lists, must be freed by slurm_free_assoc_mgr_info_msg
3396 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3397 */
3398extern int slurm_load_assoc_mgr_info(assoc_mgr_info_request_msg_t *,
3399				     assoc_mgr_info_msg_t **);
3400extern void slurm_free_assoc_mgr_info_msg(assoc_mgr_info_msg_t *);
3401extern void slurm_free_assoc_mgr_info_request_members(assoc_mgr_info_request_msg_t *);
3402extern void slurm_free_assoc_mgr_info_request_msg(assoc_mgr_info_request_msg_t *);
3403
3404
3405/*****************************************************************************\
3406 *	JOB/STEP SIGNALING FUNCTIONS
3407\*****************************************************************************/
3408
3409typedef struct job_step_kill_msg {
3410	uint32_t job_id;
3411	char *sjob_id;
3412	uint32_t job_step_id;
3413	uint16_t signal;
3414	uint16_t flags;
3415	char *sibling;
3416} job_step_kill_msg_t;
3417
3418/*
3419 * NOTE:  See _signal_batch_job() controller and _rpc_signal_tasks() in slurmd.
3420 */
3421#define KILL_JOB_BATCH	 0x0001	/* signal batch shell only */
3422#define KILL_JOB_ARRAY	 0x0002	/* kill all elements of a job array */
3423#define KILL_STEPS_ONLY	 0x0004	/* Do not signal batch script */
3424#define KILL_FULL_JOB	 0x0008	/* Signal all steps, including batch script */
3425#define KILL_FED_REQUEUE 0x0010 /* Mark job as requeued when requeued */
3426#define KILL_HURRY	 0x0020	/* Skip burst buffer stage out */
3427#define KILL_OOM	 0x0040	/* Kill due to Out-Of-Memory */
3428#define KILL_NO_SIBS	 0x0080	/* Don't kill other sibling jobs */
3429#define KILL_JOB_RESV	 0x0100	/* Job is willing to run on nodes in a
3430				 * promiscuous reservation. */
3431
3432/* Use top bit of uint16_t in conjuction with KILL_* flags to indicate signal
3433 * has been sent to job previously. Does not need to be passed to slurmd. */
3434#define WARN_SENT	 0x8000  /* warn already sent, clear this on requeue */
3435
3436/*
3437 * slurm_kill_job - send the specified signal to all steps of an existing job
3438 * IN job_id     - the job's id
3439 * IN signal     - signal number
3440 * IN flags      - see KILL_JOB_* flags above
3441 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3442 */
3443extern int slurm_kill_job(uint32_t job_id, uint16_t signal, uint16_t flags);
3444
3445/*
3446 * slurm_kill_job_step - send the specified signal to an existing job step
3447 * IN job_id  - the job's id
3448 * IN step_id - the job step's id
3449 * IN signal  - signal number
3450 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3451 */
3452extern int slurm_kill_job_step(uint32_t job_id,
3453			       uint32_t step_id,
3454			       uint16_t signal);
3455/*
3456 * slurm_kill_job2()
3457 */
3458extern int slurm_kill_job2(const char *job_id, uint16_t signal, uint16_t flags);
3459
3460/*
3461 * slurm_kill_job_msg - send kill msg to and existing job or step.
3462 *
3463 * IN msg_type - msg_type to send
3464 * IN kill_msg - job_step_kill_msg_t parameters.
3465 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3466 */
3467extern int slurm_kill_job_msg(uint16_t msg_type, job_step_kill_msg_t *kill_msg);
3468
3469/*
3470 * slurm_signal_job - send the specified signal to all steps of an existing job
3471 * IN job_id     - the job's id
3472 * IN signal     - signal number
3473 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3474 */
3475extern int slurm_signal_job(uint32_t job_id, uint16_t signal);
3476
3477/*
3478 * slurm_signal_job_step - send the specified signal to an existing job step
3479 * IN job_id  - the job's id
3480 * IN step_id - the job step's id - use SLURM_BATCH_SCRIPT as the step_id
3481 *              to send a signal to a job's batch script
3482 * IN signal  - signal number
3483 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3484 */
3485extern int slurm_signal_job_step(uint32_t job_id,
3486				 uint32_t step_id,
3487				 uint32_t signal);
3488
3489
3490/*****************************************************************************\
3491 *	JOB/STEP COMPLETION FUNCTIONS
3492\*****************************************************************************/
3493
3494/*
3495 * slurm_complete_job - note the completion of a job and all of its steps
3496 * IN job_id - the job's id
3497 * IN job_return_code - the highest exit code of any task of the job
3498 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3499 */
3500extern int slurm_complete_job(uint32_t job_id, uint32_t job_return_code);
3501
3502/*
3503 * slurm_terminate_job_step - terminates a job step by sending a
3504 * 	REQUEST_TERMINATE_TASKS rpc to all slurmd of a job step, and then
3505 *	calls slurm_complete_job_step() after verifying that all
3506 *	nodes in the job step no longer have running tasks from the job
3507 *	step.  (May take over 35 seconds to return.)
3508 * IN job_id  - the job's id
3509 * IN step_id - the job step's id - use SLURM_BATCH_SCRIPT as the step_id
3510 *              to terminate a job's batch script
3511 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3512 */
3513extern int slurm_terminate_job_step(uint32_t job_id, uint32_t step_id);
3514
3515/*****************************************************************************\
3516 *	SLURM TASK SPAWNING FUNCTIONS
3517\*****************************************************************************/
3518
3519/*
3520 * slurm_step_ctx_params_t_init - This initializes parameters
3521 *	in the structure that you will pass to slurm_step_ctx_create().
3522 *	This function will NOT allocate any new memory.
3523 * IN ptr - pointer to a structure allocated by the user.  The structure will
3524 *      be initialized.
3525 */
3526extern void slurm_step_ctx_params_t_init(slurm_step_ctx_params_t *ptr);
3527
3528/*
3529 * slurm_step_ctx_create - Create a job step and its context.
3530 * IN step_params - job step parameters
3531 * RET the step context or NULL on failure with slurm errno set
3532 * NOTE: Free allocated memory using slurm_step_ctx_destroy.
3533 */
3534extern slurm_step_ctx_t *slurm_step_ctx_create(const slurm_step_ctx_params_t *step_params);
3535
3536/*
3537 * slurm_step_ctx_create_timeout - Create a job step and its context.
3538 * IN step_params - job step parameters
3539 * IN timeout - in milliseconds
3540 * RET the step context or NULL on failure with slurm errno set
3541 * NOTE: Free allocated memory using slurm_step_ctx_destroy.
3542 */
3543extern slurm_step_ctx_t *slurm_step_ctx_create_timeout(const slurm_step_ctx_params_t *step_params,
3544						       int timeout);
3545
3546/*
3547 * Return TRUE if the job step create request should be retried later
3548 * (i.e. the errno set by slurm_step_ctx_create_timeout() is recoverable).
3549 */
3550extern bool slurm_step_retry_errno(int rc);
3551
3552/*
3553 * slurm_step_ctx_create_no_alloc - Create a job step and its context without
3554 *                                  getting an allocation.
3555 * IN step_params - job step parameters
3556 * IN step_id     - since we are faking it give me the id to use
3557 * RET the step context or NULL on failure with slurm errno set
3558 * NOTE: Free allocated memory using slurm_step_ctx_destroy.
3559 */
3560extern slurm_step_ctx_t *slurm_step_ctx_create_no_alloc(const slurm_step_ctx_params_t *step_params,
3561							uint32_t step_id);
3562
3563/*
3564 * slurm_step_ctx_get - get parameters from a job step context.
3565 * IN ctx - job step context generated by slurm_step_ctx_create
3566 * RET SLURM_SUCCESS or SLURM_ERROR (with slurm_errno set)
3567 */
3568extern int slurm_step_ctx_get(slurm_step_ctx_t *ctx, int ctx_key, ...);
3569
3570/*
3571 * slurm_jobinfo_ctx_get - get parameters from jobinfo context.
3572 * IN jobinfo - job information from context, returned by slurm_step_ctx_get()
3573 * IN data_type - type of data required, specific to the switch type
3574 * OUT data - the requested data type
3575 * RET SLURM_SUCCESS or SLURM_ERROR (with slurm_errno set)
3576 */
3577extern int slurm_jobinfo_ctx_get(dynamic_plugin_data_t *jobinfo,
3578				 int data_type,
3579				 void *data);
3580
3581/*
3582 * slurm_step_ctx_daemon_per_node_hack - Hack the step context
3583 *	to run a single process per node, regardless of the settings
3584 *	selected at slurm_step_ctx_create time.
3585 *
3586 *	This is primarily used when launching 1 task per node as done
3587 * 	with IBM's PE where we want to launch a single pmd daemon
3588 *	on each node regardless of the number of tasks running on each
3589 *	node.
3590 * IN ctx - job step context generated by slurm_step_ctx_create
3591 * IN node_list - node list of nodes to run on
3592 * IN node_cnt - number of nodes to run on
3593 * IN/OUT curr_task_num - task_id of newest task, initialze to zero
3594 * RET SLURM_SUCCESS or SLURM_ERROR (with slurm_errno set)
3595 */
3596extern int slurm_step_ctx_daemon_per_node_hack(slurm_step_ctx_t *ctx,
3597					       char *node_list,
3598					       uint32_t node_cnt,
3599					       uint32_t *curr_task_num);
3600
3601/*
3602 * slurm_step_ctx_destroy - free allocated memory for a job step context.
3603 * IN ctx - job step context generated by slurm_step_ctx_create
3604 * RET SLURM_SUCCESS or SLURM_ERROR (with slurm_errno set)
3605 */
3606extern int slurm_step_ctx_destroy(slurm_step_ctx_t *ctx);
3607
3608/*
3609 * slurm_step_launch_params_t_init - initialize a user-allocated
3610 *      slurm_step_launch_params_t structure with default values.
3611 *	default values.  This function will NOT allocate any new memory.
3612 * IN ptr - pointer to a structure allocated by the use.  The structure will
3613 *      be initialized.
3614 */
3615extern void slurm_step_launch_params_t_init(slurm_step_launch_params_t *ptr);
3616
3617/*
3618 * slurm_step_launch - launch a parallel job step
3619 * IN ctx - job step context generated by slurm_step_ctx_create
3620 * IN params - job step parameters
3621 * IN callbacks - Identify functions to be called when various events occur
3622 * IN het_job_step_cnt - Total count of hetjob steps to be launched, -1 otherwise
3623 * RET SLURM_SUCCESS or SLURM_ERROR (with errno set)
3624 */
3625extern int slurm_step_launch(slurm_step_ctx_t *ctx,
3626			     const slurm_step_launch_params_t *params,
3627			     const slurm_step_launch_callbacks_t *callbacks);
3628
3629/*
3630 * slurm_step_launch_add - Add tasks to a step that was already started
3631 * IN ctx - job step context generated by slurm_step_ctx_create
3632 * IN first_ctx - job step context generated by slurm_step_ctx_create for
3633 *		first component of the job step
3634 * IN params - job step parameters
3635 * IN node_list - list of extra nodes to add
3636 * IN start_nodeid - in the global scheme which node id is the first
3637 *                   node in node_list.
3638 * RET SLURM_SUCCESS or SLURM_ERROR (with errno set)
3639 */
3640extern int slurm_step_launch_add(slurm_step_ctx_t *ctx,
3641				 slurm_step_ctx_t *first_ctx,
3642				 const slurm_step_launch_params_t *params,
3643				 char *node_list, int start_nodeid);
3644
3645/*
3646 * Block until all tasks have started.
3647 */
3648extern int slurm_step_launch_wait_start(slurm_step_ctx_t *ctx);
3649
3650/*
3651 * Block until all tasks have finished (or failed to start altogether).
3652 */
3653extern void slurm_step_launch_wait_finish(slurm_step_ctx_t *ctx);
3654
3655/*
3656 * Abort an in-progress launch, or terminate the fully launched job step.
3657 *
3658 * Can be called from a signal handler.
3659 */
3660extern void slurm_step_launch_abort(slurm_step_ctx_t *ctx);
3661
3662/*
3663 * Forward a signal to all those nodes with running tasks
3664 */
3665extern void slurm_step_launch_fwd_signal(slurm_step_ctx_t *ctx, int signo);
3666
3667/*
3668 * Wake tasks stopped for debugging on nodes with running tasks
3669 */
3670extern void slurm_step_launch_fwd_wake(slurm_step_ctx_t *ctx);
3671
3672/*
3673 * Specify the plugin name to be used. This may be needed to specify the
3674 * non-default MPI plugin when using Slurm API to launch tasks.
3675 * IN plugin name - "none", "pmi2", etc.
3676 * RET SLURM_SUCCESS or SLURM_ERROR (with errno set)
3677 */
3678extern int slurm_mpi_plugin_init(char *plugin_name);
3679
3680/*****************************************************************************\
3681 *	SLURM CONTROL CONFIGURATION READ/PRINT/UPDATE FUNCTIONS
3682\*****************************************************************************/
3683
3684/*
3685 * slurm_api_version - Return a single number reflecting the Slurm API's
3686 *	version number. Use the macros SLURM_VERSION_NUM, SLURM_VERSION_MAJOR,
3687 *	SLURM_VERSION_MINOR, and SLURM_VERSION_MICRO to work with this value
3688 * RET API's version number
3689 */
3690extern long slurm_api_version(void);
3691
3692/*
3693 * slurm_load_ctl_conf - issue RPC to get slurm control configuration
3694 *	information if changed since update_time
3695 * IN update_time - time of current configuration data
3696 * IN slurm_ctl_conf_ptr - place to store slurm control configuration
3697 *	pointer
3698 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
3699 * NOTE: free the response using slurm_free_ctl_conf
3700 */
3701extern int slurm_load_ctl_conf(time_t update_time,
3702			       slurm_ctl_conf_t **slurm_ctl_conf_ptr);
3703
3704/*
3705 * slurm_free_ctl_conf - free slurm control information response message
3706 * IN msg - pointer to slurm control information response message
3707 * NOTE: buffer is loaded by slurm_load_ctl_conf
3708 */
3709extern void slurm_free_ctl_conf(slurm_ctl_conf_t *slurm_ctl_conf_ptr);
3710
3711/*
3712 * slurm_print_ctl_conf - output the contents of slurm control configuration
3713 *	message as loaded using slurm_load_ctl_conf
3714 * IN out - file to write to
3715 * IN slurm_ctl_conf_ptr - slurm control configuration pointer
3716 */
3717extern void slurm_print_ctl_conf(FILE *out,
3718				 slurm_ctl_conf_t *slurm_ctl_conf_ptr);
3719
3720/*
3721 * slurm_write_ctl_conf - write the contents of slurm control configuration
3722 *	message as loaded using slurm_load_ctl_conf to a file
3723 * IN out - file to write to
3724 * IN slurm_ctl_conf_ptr - slurm control configuration pointer
3725 * IN node_info_ptr - pointer to node table of information
3726 * IN part_info_ptr - pointer to partition information
3727 */
3728extern void slurm_write_ctl_conf(slurm_ctl_conf_t *slurm_ctl_conf_ptr,
3729				 node_info_msg_t *node_info_ptr,
3730				 partition_info_msg_t *part_info_ptr);
3731
3732/*
3733 * slurm_ctl_conf_2_key_pairs - put the slurm_ctl_conf_t variables into
3734 *	a List of opaque data type config_key_pair_t
3735 * IN slurm_ctl_conf_ptr - slurm control configuration pointer
3736 * RET List of opaque data type config_key_pair_t
3737 */
3738extern void *slurm_ctl_conf_2_key_pairs(slurm_ctl_conf_t *slurm_ctl_conf_ptr);
3739
3740/*
3741 * slurm_print_key_pairs - output the contents of key_pairs
3742 * which is a list of opaque data type config_key_pair_t
3743 * IN out - file to write to
3744 * IN key_pairs - List containing key pairs to be printed
3745 * IN title - title of key pair list
3746 */
3747extern void slurm_print_key_pairs(FILE *out, void *key_pairs, char *title);
3748
3749/*
3750 * slurm_load_slurmd_status - issue RPC to get the status of slurmd
3751 *	daemon on this machine
3752 * IN slurmd_status_ptr - place to store slurmd status information
3753 * RET 0 or -1 on error
3754 * NOTE: free the response using slurm_free_slurmd_status()
3755 */
3756extern int slurm_load_slurmd_status(slurmd_status_t **slurmd_status_ptr);
3757
3758/*
3759 * slurm_free_slurmd_status - free slurmd state information
3760 * IN msg - pointer to slurmd state information
3761 * NOTE: buffer is loaded by slurm_load_slurmd_status
3762 */
3763extern void slurm_free_slurmd_status(slurmd_status_t* slurmd_status_ptr);
3764
3765/*
3766 * slurm_print_slurmd_status - output the contents of slurmd status
3767 *	message as loaded using slurm_load_slurmd_status
3768 * IN out - file to write to
3769 * IN slurmd_status_ptr - slurmd status pointer
3770 */
3771void slurm_print_slurmd_status(FILE *out, slurmd_status_t *slurmd_status_ptr);
3772
3773/*
3774 * slurm_init_update_step_msg - initialize step update message with default
3775 *	values before calling slurm_update_step()
3776 * OUT step_msg - step update messasge descriptor
3777 */
3778extern void slurm_init_update_step_msg(step_update_request_msg_t *step_msg);
3779
3780/* Get scheduling statistics */
3781extern int slurm_get_statistics(stats_info_response_msg_t **buf,
3782				stats_info_request_msg_t *req);
3783
3784/* Reset scheduling statistics */
3785extern int slurm_reset_statistics(stats_info_request_msg_t *req);
3786
3787/*****************************************************************************\
3788 *	SLURM JOB RESOURCES READ/PRINT FUNCTIONS
3789\*****************************************************************************/
3790
3791/*
3792 * slurm_job_cpus_allocated_on_node_id -
3793 *                        get the number of cpus allocated to a job
3794 *			  on a node by node id
3795 * IN job_resrcs_ptr	- pointer to job_resources structure
3796 * IN node_id		- zero-origin node id in allocation
3797 * RET number of CPUs allocated to job on this node or -1 on error
3798 */
3799extern int slurm_job_cpus_allocated_on_node_id(job_resources_t *job_resrcs_ptr,
3800					       int node_id);
3801
3802/*
3803 * slurm_job_cpus_allocated_on_node -
3804 *                        get the number of cpus allocated to a job
3805 *			  on a node by node name
3806 * IN job_resrcs_ptr	- pointer to job_resources structure
3807 * IN node_name		- name of node
3808 * RET number of CPUs allocated to job on this node or -1 on error
3809 */
3810extern int slurm_job_cpus_allocated_on_node(job_resources_t *job_resrcs_ptr,
3811					    const char *node_name);
3812
3813/*
3814 * slurm_job_cpus_allocated_str_on_node_id -
3815 *                        get the string representation of cpus allocated
3816 *                        to a job on a node by node id
3817 * IN cpus		- str where the resulting cpu list is returned
3818 * IN cpus_len		- max size of cpus str
3819 * IN job_resrcs_ptr	- pointer to job_resources structure
3820 * IN node_id		- zero-origin node id in allocation
3821 * RET 0 on success or -1 on error
3822 */
3823extern int slurm_job_cpus_allocated_str_on_node_id(char *cpus,
3824						   size_t cpus_len,
3825						   job_resources_t *job_resrcs_ptr,
3826						   int node_id);
3827
3828/*
3829 * slurm_job_cpus_allocated_str_on_node -
3830 *                        get the string representation of cpus allocated
3831 *                        to a job on a node by node name
3832 * IN cpus		- str where the resulting cpu list is returned
3833 * IN cpus_len		- max size of cpus str
3834 * IN job_resrcs_ptr	- pointer to job_resources structure
3835 * IN node_name		- name of node
3836 * RET 0 on success or -1 on error
3837 */
3838extern int slurm_job_cpus_allocated_str_on_node(char *cpus,
3839						size_t cpus_len,
3840						job_resources_t *job_resrcs_ptr,
3841						const char *node_name);
3842
3843/*****************************************************************************\
3844 *	SLURM JOB CONTROL CONFIGURATION READ/PRINT/UPDATE FUNCTIONS
3845\*****************************************************************************/
3846
3847/*
3848 * slurm_free_job_info_msg - free the job information response message
3849 * IN msg - pointer to job information response message
3850 * NOTE: buffer is loaded by slurm_load_jobs()
3851 */
3852extern void slurm_free_job_info_msg(job_info_msg_t *job_buffer_ptr);
3853
3854/*
3855 * slurm_free_priority_factors_response_msg - free the job priority factor
3856 *	information response message
3857 * IN msg - pointer to job priority information response message
3858 * NOTE: buffer is loaded by slurm_load_job_prio()
3859 */
3860extern void slurm_free_priority_factors_response_msg(
3861	priority_factors_response_msg_t *factors_resp);
3862
3863/*
3864 * slurm_get_end_time - get the expected end time for a given slurm job
3865 * IN jobid     - slurm job id
3866 * end_time_ptr - location in which to store scheduled end time for job
3867 * RET 0 or -1 on error
3868 */
3869extern int slurm_get_end_time(uint32_t jobid, time_t *end_time_ptr);
3870
3871/* Given a job record pointer, return its stderr path */
3872extern void slurm_get_job_stderr(char *buf, int buf_size, job_info_t *job_ptr);
3873
3874/* Given a job record pointer, return its stdin path */
3875extern void slurm_get_job_stdin(char *buf, int buf_size, job_info_t *job_ptr);
3876
3877/* Given a job record pointer, return its stdout path */
3878extern void slurm_get_job_stdout(char *buf, int buf_size, job_info_t *job_ptr);
3879
3880/*
3881 * slurm_get_rem_time - get the expected time remaining for a given job
3882 * IN jobid     - slurm job id
3883 * RET remaining time in seconds or -1 on error
3884 */
3885extern long slurm_get_rem_time(uint32_t jobid);
3886
3887/*
3888 * slurm_job_node_ready - report if nodes are ready for job to execute now
3889 * IN job_id - slurm job id
3890 * RET: READY_* values defined above
3891 */
3892extern int slurm_job_node_ready(uint32_t job_id);
3893
3894/*
3895 * slurm_load_job - issue RPC to get job information for one job ID
3896 * IN job_info_msg_pptr - place to store a job configuration pointer
3897 * IN job_id -  ID of job we want information about
3898 * IN show_flags - job filtering options
3899 * RET 0 or -1 on error
3900 * NOTE: free the response using slurm_free_job_info_msg
3901 */
3902extern int slurm_load_job(job_info_msg_t **resp,
3903			  uint32_t job_id,
3904			  uint16_t show_flags);
3905
3906/*
3907 * slurm_load_job_prio - issue RPC to get job priority information for
3908 *	jobs which pass filter test
3909 * OUT factors_resp - job priority factors
3910 * IN job_id_list - list of job IDs to be reported
3911 * IN partitions - comma delimited list of partition names to be reported
3912 * IN uid_list - list of user IDs to be reported
3913 * IN show_flags -  job filtering option: 0 or SHOW_LOCAL
3914 * RET 0 or -1 on error
3915 * NOTE: free the response using slurm_free_priority_factors_response_msg()
3916 */
3917extern int slurm_load_job_prio(priority_factors_response_msg_t **factors_resp,
3918			       List job_id_list, char *partitions,
3919			       List uid_list, uint16_t show_flags);
3920
3921/*
3922 * slurm_load_job_user - issue RPC to get slurm information about all jobs
3923 *	to be run as the specified user
3924 * IN/OUT job_info_msg_pptr - place to store a job configuration pointer
3925 * IN user_id - ID of user we want information for
3926 * IN show_flags - job filtering options
3927 * RET 0 or -1 on error
3928 * NOTE: free the response using slurm_free_job_info_msg
3929 */
3930extern int slurm_load_job_user(job_info_msg_t **job_info_msg_pptr,
3931			       uint32_t user_id,
3932			       uint16_t show_flags);
3933
3934/*
3935 * slurm_load_jobs - issue RPC to get slurm all job configuration
3936 *	information if changed since update_time
3937 * IN update_time - time of current configuration data
3938 * IN/OUT job_info_msg_pptr - place to store a job configuration pointer
3939 * IN show_flags - job filtering options
3940 * RET 0 or -1 on error
3941 * NOTE: free the response using slurm_free_job_info_msg
3942 */
3943extern int slurm_load_jobs(time_t update_time,
3944			   job_info_msg_t **job_info_msg_pptr,
3945			   uint16_t show_flags);
3946
3947/*
3948 * slurm_notify_job - send message to the job's stdout,
3949 *	usable only by user root
3950 * IN job_id - slurm job_id or 0 for all jobs
3951 * IN message - arbitrary message
3952 * RET 0 or -1 on error
3953 */
3954extern int slurm_notify_job(uint32_t job_id, char *message);
3955
3956/*
3957 * slurm_pid2jobid - issue RPC to get the slurm job_id given a process_id
3958 *	on this machine
3959 * IN job_pid - process_id of interest on this machine
3960 * OUT job_id_ptr - place to store a slurm job_id
3961 * RET 0 or -1 on error
3962 */
3963extern int slurm_pid2jobid(pid_t job_pid, uint32_t *job_id_ptr);
3964
3965/*
3966 * slurm_print_job_info - output information about a specific Slurm
3967 *	job based upon message as loaded using slurm_load_jobs
3968 * IN out - file to write to
3969 * IN job_ptr - an individual job information record pointer
3970 * IN one_liner - print as a single line if true
3971 */
3972extern void slurm_print_job_info(FILE *out,
3973				 slurm_job_info_t *job_ptr,
3974				 int one_liner);
3975
3976/*
3977 * slurm_print_job_info_msg - output information about all Slurm
3978 *	jobs based upon message as loaded using slurm_load_jobs
3979 * IN out - file to write to
3980 * IN job_info_msg_ptr - job information message pointer
3981 * IN one_liner - print as a single line if true
3982 */
3983extern void slurm_print_job_info_msg(FILE *out,
3984				     job_info_msg_t *job_info_msg_ptr,
3985				     int one_liner);
3986
3987/*
3988 * slurm_sprint_job_info - output information about a specific Slurm
3989 *	job based upon message as loaded using slurm_load_jobs
3990 * IN job_ptr - an individual job information record pointer
3991 * IN one_liner - print as a single line if true
3992 * RET out - char * containing formatted output (must be freed after call)
3993 *           NULL is returned on failure.
3994 */
3995extern char *slurm_sprint_job_info(slurm_job_info_t *job_ptr,
3996				   int one_liner);
3997
3998/*
3999 * slurm_update_job - issue RPC to a job's configuration per request,
4000 *	only usable by user root or (for some parameters) the job's owner
4001 * IN job_msg - description of job updates
4002 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4003 */
4004extern int slurm_update_job(job_desc_msg_t *job_msg);
4005
4006/*
4007 * slurm_update_job2 - issue RPC to a job's configuration per request,
4008 *	only usable by user root or (for some parameters) the job's owner
4009 * IN job_msg - description of job updates
4010 * OUT resp - per task response to the request,
4011 *	      free using slurm_free_job_array_resp()
4012 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4013 */
4014extern int slurm_update_job2(job_desc_msg_t *job_msg,
4015			     job_array_resp_msg_t **resp);
4016
4017/*
4018 * slurm_xlate_job_id - Translate a Slurm job ID string into a slurm job ID
4019 *	number. If this job ID contains an array index, map this to the
4020 *	equivalent Slurm job ID number (e.g. "123_2" to 124)
4021 *
4022 * IN job_id_str - String containing a single job ID number
4023 * RET - equivalent job ID number or 0 on error
4024 */
4025extern uint32_t slurm_xlate_job_id(char *job_id_str);
4026
4027
4028/*****************************************************************************\
4029 *	SLURM JOB STEP CONFIGURATION READ/PRINT/UPDATE FUNCTIONS
4030\*****************************************************************************/
4031
4032/*
4033 * slurm_get_job_steps - issue RPC to get specific slurm job step
4034 *	configuration information if changed since update_time.
4035 *	a job_id value of NO_VAL implies all jobs, a step_id value of
4036 *	NO_VAL implies all steps
4037 * IN update_time - time of current configuration data
4038 * IN job_id - get information for specific job id, NO_VAL for all jobs
4039 * IN step_id - get information for specific job step id, NO_VAL for all
4040 *	job steps
4041 * IN step_response_pptr - place to store a step response pointer
4042 * IN show_flags - job step filtering options
4043 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4044 * NOTE: free the response using slurm_free_job_step_info_response_msg
4045 */
4046extern int slurm_get_job_steps(time_t update_time,
4047			       uint32_t job_id,
4048			       uint32_t step_id,
4049			       job_step_info_response_msg_t **step_response_pptr,
4050			       uint16_t show_flags);
4051
4052/*
4053 * slurm_free_job_step_info_response_msg - free the job step
4054 *	information response message
4055 * IN msg - pointer to job step information response message
4056 * NOTE: buffer is loaded by slurm_get_job_steps.
4057 */
4058extern void slurm_free_job_step_info_response_msg(job_step_info_response_msg_t *msg);
4059
4060/*
4061 * slurm_print_job_step_info_msg - output information about all Slurm
4062 *	job steps based upon message as loaded using slurm_get_job_steps
4063 * IN out - file to write to
4064 * IN job_step_info_msg_ptr - job step information message pointer
4065 * IN one_liner - print as a single line if true
4066 */
4067extern void slurm_print_job_step_info_msg(FILE *out,
4068					  job_step_info_response_msg_t *job_step_info_msg_ptr,
4069					  int one_liner);
4070
4071/*
4072 * slurm_print_job_step_info - output information about a specific Slurm
4073 *	job step based upon message as loaded using slurm_get_job_steps
4074 * IN out - file to write to
4075 * IN job_ptr - an individual job step information record pointer
4076 * IN one_liner - print as a single line if true
4077 */
4078extern void slurm_print_job_step_info(FILE *out,
4079				      job_step_info_t *step_ptr,
4080				      int one_liner);
4081
4082/*
4083 * slurm_job_step_layout_get - get the slurm_step_layout_t structure for
4084 *      a particular job step
4085 *
4086 * IN job_id
4087 * IN step_id
4088 * RET pointer to a slurm_step_layout_t (free with
4089 *   slurm_free_step_layout) on success, and NULL on error.
4090 */
4091extern slurm_step_layout_t *slurm_job_step_layout_get(uint32_t job_id,
4092						      uint32_t step_id);
4093
4094/*
4095 * slurm_sprint_job_step_info - output information about a specific Slurm
4096 *	job step based upon message as loaded using slurm_get_job_steps
4097 * IN job_ptr - an individual job step information record pointer
4098 * IN one_liner - print as a single line if true
4099 * RET out - char * containing formatted output (must be freed after call)
4100 *           NULL is returned on failure.
4101 */
4102extern char *slurm_sprint_job_step_info(job_step_info_t *step_ptr,
4103					int one_liner);
4104
4105/*
4106 * slurm_job_step_stat - status a current step
4107 *
4108 * IN job_id
4109 * IN step_id
4110 * IN node_list, optional, if NULL then all nodes in step are returned.
4111 * OUT resp
4112 * RET SLURM_SUCCESS on success SLURM_ERROR else
4113 */
4114extern int slurm_job_step_stat(uint32_t job_id,
4115			       uint32_t step_id,
4116			       char *node_list,
4117			       uint16_t use_protocol_ver,
4118			       job_step_stat_response_msg_t **resp);
4119
4120/*
4121 * slurm_job_step_get_pids - get the complete list of pids for a given
4122 *      job step
4123 *
4124 * IN job_id
4125 * IN step_id
4126 * OUT resp
4127 * RET SLURM_SUCCESS on success SLURM_ERROR else
4128 */
4129extern int slurm_job_step_get_pids(uint32_t job_id,
4130				   uint32_t step_id,
4131				   char *node_list,
4132				   job_step_pids_response_msg_t **resp);
4133
4134extern void slurm_job_step_layout_free(slurm_step_layout_t *layout);
4135extern void slurm_job_step_pids_free(job_step_pids_t *object);
4136extern void slurm_job_step_pids_response_msg_free(void *object);
4137extern void slurm_job_step_stat_free(job_step_stat_t *object);
4138extern void slurm_job_step_stat_response_msg_free(void *object);
4139
4140/* Update the time limit of a job step,
4141 * IN step_msg - step update messasge descriptor
4142 * RET 0 or -1 on error */
4143extern int slurm_update_step(step_update_request_msg_t *step_msg);
4144
4145/*****************************************************************************\
4146 *	SLURM NODE CONFIGURATION READ/PRINT/UPDATE FUNCTIONS
4147\*****************************************************************************/
4148
4149/*
4150 * slurm_load_node - issue RPC to get slurm all node configuration information
4151 *	if changed since update_time
4152 * IN update_time - time of current configuration data
4153 * OUT resp - place to store a node configuration pointer
4154 * IN show_flags - node filtering options (e.g. SHOW_FEDERATION)
4155 * RET 0 or a slurm error code
4156 * NOTE: free the response using slurm_free_node_info_msg
4157 */
4158extern int slurm_load_node(time_t update_time, node_info_msg_t **resp,
4159			   uint16_t show_flags);
4160
4161/*
4162 * slurm_load_node2 - equivalent to slurm_load_node() with addition
4163 *	of cluster record for communications in a federation
4164 */
4165extern int slurm_load_node2(time_t update_time, node_info_msg_t **resp,
4166			    uint16_t show_flags,
4167			    slurmdb_cluster_rec_t *cluster);
4168
4169/*
4170 * slurm_load_node_single - issue RPC to get slurm configuration information
4171 *	for a specific node
4172 * OUT resp - place to store a node configuration pointer
4173 * IN node_name - name of the node for which information is requested
4174 * IN show_flags - node filtering options
4175 * RET 0 or a slurm error code
4176 * NOTE: free the response using slurm_free_node_info_msg
4177 */
4178extern int slurm_load_node_single(node_info_msg_t **resp, char *node_name,
4179				  uint16_t show_flags);
4180
4181/*
4182 * slurm_load_node_single2 - equivalent to slurm_load_node_single() with
4183 *	addition of cluster record for communications in a federation
4184 */
4185extern int slurm_load_node_single2(node_info_msg_t **resp, char *node_name,
4186				   uint16_t show_flags,
4187				   slurmdb_cluster_rec_t *cluster);
4188
4189/* Given data structures containing information about nodes and partitions,
4190 * populate the node's "partitions" field */
4191void
4192slurm_populate_node_partitions(node_info_msg_t *node_buffer_ptr,
4193			       partition_info_msg_t *part_buffer_ptr);
4194
4195/*
4196 * slurm_get_node_energy - issue RPC to get the energy data of all
4197 * configured sensors on the target machine
4198 * IN  host  - name of node to query, NULL if localhost
4199 * IN  delta - Use cache if data is newer than this in seconds
4200 * OUT sensor_cnt - number of sensors
4201 * OUT energy - array of acct_gather_energy_t structures on success or
4202 *                NULL other wise
4203 * RET 0 on success or a slurm error code
4204 * NOTE: free the response using xfree
4205 */
4206extern int slurm_get_node_energy(char *host,
4207				 uint16_t context_id,
4208				 uint16_t delta,
4209				 uint16_t *sensors_cnt,
4210				 acct_gather_energy_t **energy);
4211
4212/*
4213 * slurm_free_node_info_msg - free the node information response message
4214 * IN msg - pointer to node information response message
4215 * NOTE: buffer is loaded by slurm_load_node.
4216 */
4217extern void slurm_free_node_info_msg(node_info_msg_t *node_buffer_ptr);
4218
4219/*
4220 * slurm_print_node_info_msg - output information about all Slurm nodes
4221 *	based upon message as loaded using slurm_load_node
4222 * IN out - file to write to
4223 * IN node_info_msg_ptr - node information message pointer
4224 * IN one_liner - print as a single line if true
4225 */
4226extern void slurm_print_node_info_msg(FILE *out,
4227				      node_info_msg_t *node_info_msg_ptr,
4228				      int one_liner);
4229
4230/*
4231 * slurm_print_node_table - output information about a specific Slurm nodes
4232 *	based upon message as loaded using slurm_load_node
4233 * IN out - file to write to
4234 * IN node_ptr - an individual node information record pointer
4235 * IN one_liner - print as a single line if true
4236 */
4237extern void slurm_print_node_table(FILE *out,
4238				   node_info_t *node_ptr,
4239				   int one_liner);
4240
4241/*
4242 * slurm_sprint_node_table - output information about a specific Slurm nodes
4243 *	based upon message as loaded using slurm_load_node
4244 * IN node_ptr - an individual node information record pointer
4245 * IN one_liner - print as a single line if true
4246 * RET out - char * containing formatted output (must be freed after call)
4247 *           NULL is returned on failure.
4248 */
4249extern char *slurm_sprint_node_table(node_info_t *node_ptr,
4250				     int one_liner);
4251
4252/*
4253 * slurm_init_update_node_msg - initialize node update message
4254 * OUT update_node_msg - user defined node descriptor
4255 */
4256void slurm_init_update_node_msg(update_node_msg_t *update_node_msg);
4257
4258/*
4259 * slurm_update_node - issue RPC to a node's configuration per request,
4260 *	only usable by user root
4261 * IN node_msg - description of node updates
4262 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4263 */
4264extern int slurm_update_node(update_node_msg_t *node_msg);
4265
4266
4267/*****************************************************************************\
4268 *	SLURM FRONT_END CONFIGURATION READ/PRINT/UPDATE FUNCTIONS
4269\*****************************************************************************/
4270
4271/*
4272 * slurm_load_front_end - issue RPC to get slurm all front_end configuration
4273 *	information if changed since update_time
4274 * IN update_time - time of current configuration data
4275 * IN front_end_info_msg_pptr - place to store a front_end configuration pointer
4276 * RET 0 or a slurm error code
4277 * NOTE: free the response using slurm_free_front_end_info_msg
4278 */
4279extern int slurm_load_front_end(time_t update_time,
4280				front_end_info_msg_t **resp);
4281
4282/*
4283 * slurm_free_front_end_info_msg - free the front_end information response
4284 *	message
4285 * IN msg - pointer to front_end information response message
4286 * NOTE: buffer is loaded by slurm_load_front_end.
4287 */
4288extern void slurm_free_front_end_info_msg(front_end_info_msg_t *front_end_buffer_ptr);
4289
4290/*
4291 * slurm_print_front_end_info_msg - output information about all Slurm
4292 *	front_ends based upon message as loaded using slurm_load_front_end
4293 * IN out - file to write to
4294 * IN front_end_info_msg_ptr - front_end information message pointer
4295 * IN one_liner - print as a single line if true
4296 */
4297extern void slurm_print_front_end_info_msg(FILE *out,
4298					   front_end_info_msg_t *front_end_info_msg_ptr,
4299					   int one_liner);
4300/*
4301 * slurm_print_front_end_table - output information about a specific Slurm
4302 *	front_ends based upon message as loaded using slurm_load_front_end
4303 * IN out - file to write to
4304 * IN front_end_ptr - an individual front_end information record pointer
4305 * IN one_liner - print as a single line if true
4306 */
4307extern void slurm_print_front_end_table(FILE *out,
4308					front_end_info_t *front_end_ptr,
4309					int one_liner);
4310
4311/*
4312 * slurm_sprint_front_end_table - output information about a specific Slurm
4313 *	front_end based upon message as loaded using slurm_load_front_end
4314 * IN front_end_ptr - an individual front_end information record pointer
4315 * IN one_liner - print as a single line if true
4316 * RET out - char * containing formatted output (must be freed after call)
4317 *           NULL is returned on failure.
4318 */
4319extern char *slurm_sprint_front_end_table(front_end_info_t *front_end_ptr,
4320					  int one_liner);
4321
4322/*
4323 * slurm_init_update_front_end_msg - initialize front_end node update message
4324 * OUT update_front_end_msg - user defined node descriptor
4325 */
4326void slurm_init_update_front_end_msg(update_front_end_msg_t *update_front_end_msg);
4327
4328/*
4329 * slurm_update_front_end - issue RPC to a front_end node's configuration per
4330 *	request, only usable by user root
4331 * IN front_end_msg - description of front_end node updates
4332 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4333 */
4334extern int slurm_update_front_end(update_front_end_msg_t *front_end_msg);
4335
4336
4337/*****************************************************************************\
4338 *	SLURM SWITCH TOPOLOGY CONFIGURATION READ/PRINT FUNCTIONS
4339\*****************************************************************************/
4340
4341/*
4342 * slurm_load_topo - issue RPC to get slurm all switch topology configuration
4343 *	information
4344 * IN node_info_msg_pptr - place to store a node configuration pointer
4345 * RET 0 or a slurm error code
4346 * NOTE: free the response using slurm_free_topo_info_msg
4347 */
4348extern int slurm_load_topo(topo_info_response_msg_t **topo_info_msg_pptr);
4349
4350/*
4351 * slurm_free_topo_info_msg - free the switch topology configuration
4352 *	information response message
4353 * IN msg - pointer to switch topology configuration response message
4354 * NOTE: buffer is loaded by slurm_load_topo.
4355 */
4356extern void slurm_free_topo_info_msg(topo_info_response_msg_t *msg);
4357
4358/*
4359 * slurm_print_topo_info_msg - output information about all switch topology
4360 *	configuration information based upon message as loaded using
4361 *	slurm_load_topo
4362 * IN out - file to write to
4363 * IN topo_info_msg_ptr - switch topology information message pointer
4364 * IN one_liner - print as a single line if not zero
4365 */
4366extern void slurm_print_topo_info_msg(FILE *out,
4367				      topo_info_response_msg_t *topo_info_msg_ptr,
4368				      int one_liner);
4369
4370/*
4371 * slurm_print_topo_record - output information about a specific Slurm topology
4372 *	record based upon message as loaded using slurm_load_topo
4373 * IN out - file to write to
4374 * IN topo_ptr - an individual switch information record pointer
4375 * IN one_liner - print as a single line if not zero
4376 * RET out - char * containing formatted output (must be freed after call)
4377 *	   NULL is returned on failure.
4378 */
4379extern void slurm_print_topo_record(FILE *out,
4380				    topo_info_t *topo_ptr,
4381				    int one_liner);
4382
4383/*****************************************************************************\
4384 *	SLURM POWERCAPPING READ/PRINT/UPDATE FUNCTIONS
4385\*****************************************************************************/
4386
4387/*
4388 * slurm_load_powercap - issue RPC to get slurm powercapping details
4389 * IN powercap_info_msg_pptr - place to store a pointer to the result
4390 * RET 0 or a slurm error code
4391 * NOTE: free the response using slurm_free_powercap_info_msg
4392 */
4393extern int slurm_load_powercap(powercap_info_msg_t **powercap_info_msg_pptr);
4394
4395/*
4396 * slurm_free_powercap_info_msg - free the powercapping information
4397 *	response message
4398 * IN msg - pointer to powercapping information response message
4399 * NOTE: buffer is loaded by slurm_load_powercap.
4400 */
4401extern void slurm_free_powercap_info_msg(powercap_info_msg_t *msg);
4402
4403/*
4404 * slurm_print_powercap_info_msg - output information about powercapping
4405 *	configuration based upon message as loaded using slurm_load_powercap
4406 * IN out - file to write to
4407 * IN powercap_info_msg_ptr - powercapping information message pointer
4408 * IN one_liner - print as a single line if not zero
4409 */
4410extern void slurm_print_powercap_info_msg(FILE *out,
4411					  powercap_info_msg_t *powercap_info_msg_ptr,
4412					  int one_liner);
4413
4414/*
4415 * slurm_update_powercap - issue RPC to update powercapping cap
4416 * IN powercap_msg - description of powercapping updates
4417 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4418 */
4419extern int slurm_update_powercap(update_powercap_msg_t *powercap_msg);
4420
4421/*****************************************************************************\
4422 *	SLURM SELECT READ/PRINT/UPDATE FUNCTIONS
4423\*****************************************************************************/
4424
4425/*
4426 * slurm_get_select_nodeinfo - get data from a select node credential
4427 * IN nodeinfo  - updated select node credential
4428 * IN data_type - type of data to enter into node credential
4429 * IN state     - state of node query
4430 * IN/OUT data  - the data to enter into node credential
4431 * RET 0 or -1 on error
4432 */
4433extern int slurm_get_select_nodeinfo(dynamic_plugin_data_t *nodeinfo,
4434				     enum select_nodedata_type data_type,
4435				     enum node_states state,
4436				     void *data);
4437
4438/*****************************************************************************\
4439 *	SLURM PARTITION CONFIGURATION READ/PRINT/UPDATE FUNCTIONS
4440\*****************************************************************************/
4441
4442/*
4443 * slurm_init_part_desc_msg - initialize partition descriptor with
4444 *	default values
4445 * IN/OUT update_part_msg - user defined partition descriptor
4446 */
4447extern void slurm_init_part_desc_msg(update_part_msg_t *update_part_msg);
4448
4449/*
4450 * slurm_load_partitions - issue RPC to get slurm all partition configuration
4451 *	information if changed since update_time
4452 * IN update_time - time of current configuration data
4453 * IN partition_info_msg_pptr - place to store a partition configuration
4454 *	pointer
4455 * IN show_flags - partitions filtering options (e.g. SHOW_FEDERATION)
4456 * RET 0 or a slurm error code
4457 * NOTE: free the response using slurm_free_partition_info_msg
4458 */
4459extern int slurm_load_partitions(time_t update_time,
4460				 partition_info_msg_t **part_buffer_ptr,
4461				 uint16_t show_flags);
4462
4463/*
4464 * slurm_load_partitions2 - equivalent to slurm_load_partitions() with addition
4465 *	of cluster record for communications in a federation
4466 */
4467extern int slurm_load_partitions2(time_t update_time,
4468				  partition_info_msg_t **resp,
4469				  uint16_t show_flags,
4470				  slurmdb_cluster_rec_t *cluster);
4471
4472/*
4473 * slurm_free_partition_info_msg - free the partition information
4474 *	response message
4475 * IN msg - pointer to partition information response message
4476 * NOTE: buffer is loaded by slurm_load_partitions
4477 */
4478extern void slurm_free_partition_info_msg(partition_info_msg_t *part_info_ptr);
4479
4480/*
4481 * slurm_print_partition_info_msg - output information about all Slurm
4482 *	partitions based upon message as loaded using slurm_load_partitions
4483 * IN out - file to write to
4484 * IN part_info_ptr - partitions information message pointer
4485 * IN one_liner - print as a single line if true
4486 */
4487extern void slurm_print_partition_info_msg(FILE *out, partition_info_msg_t *part_info_ptr, int one_liner);
4488
4489/*
4490 * slurm_print_partition_info - output information about a specific Slurm
4491 *	partition based upon message as loaded using slurm_load_partitions
4492 * IN out - file to write to
4493 * IN part_ptr - an individual partition information record pointer
4494 * IN one_liner - print as a single line if true
4495 */
4496extern void slurm_print_partition_info(FILE *out,
4497				       partition_info_t *part_ptr,
4498				       int one_liner);
4499
4500/*
4501 * slurm_sprint_partition_info - output information about a specific Slurm
4502 *	partition based upon message as loaded using slurm_load_partitions
4503 * IN part_ptr - an individual partition information record pointer
4504 * IN one_liner - print as a single line if true
4505 * RET out - char * with formatted output (must be freed after call)
4506 *           NULL is returned on failure.
4507 */
4508extern char *slurm_sprint_partition_info(partition_info_t *part_ptr,
4509					 int one_liner);
4510
4511/*
4512 * slurm_create_partition - create a new partition, only usable by user root
4513 * IN part_msg - description of partition configuration
4514 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4515 */
4516extern int slurm_create_partition(update_part_msg_t *part_msg);
4517
4518/*
4519 * slurm_update_partition - issue RPC to update a partition's configuration
4520 *	per request, only usable by user root
4521 * IN part_msg - description of partition updates
4522 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4523 */
4524extern int slurm_update_partition(update_part_msg_t *part_msg);
4525
4526/*
4527 * slurm_delete_partition - issue RPC to delete a partition, only usable
4528 *	by user root
4529 * IN part_msg - description of partition to delete
4530 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4531 */
4532extern int slurm_delete_partition(delete_part_msg_t *part_msg);
4533
4534/*****************************************************************************\
4535 *      SLURM LAYOUT PRINT/UPDATE FUNCTIONS
4536\*****************************************************************************/
4537extern void slurm_print_layout_info(FILE* out,
4538				    layout_info_msg_t *layout_info_ptr,
4539				    int one_liner );
4540
4541extern int slurm_load_layout(char *layout_type,
4542			     char *entities,
4543			     char *type,
4544			     uint32_t no_relation,
4545			     layout_info_msg_t **resp);
4546
4547extern int slurm_update_layout(update_layout_msg_t *layout_info_msg);
4548
4549extern void slurm_free_layout_info_msg(layout_info_msg_t *layout_info_msg);
4550
4551/*****************************************************************************\
4552 *	SLURM RESERVATION CONFIGURATION READ/PRINT/UPDATE FUNCTIONS
4553\*****************************************************************************/
4554
4555/*
4556 * slurm_init_resv_desc_msg - initialize reservation descriptor with
4557 *	default values
4558 * OUT job_desc_msg - user defined partition descriptor
4559 */
4560extern void slurm_init_resv_desc_msg(resv_desc_msg_t *update_resv_msg);
4561/*
4562 * slurm_create_reservation - create a new reservation, only usable by user root
4563 * IN resv_msg - description of reservation
4564 * RET name of reservation on success (caller must free the memory),
4565 *	otherwise return NULL and set errno to indicate the error
4566 */
4567extern char *slurm_create_reservation(resv_desc_msg_t *resv_msg);
4568
4569/*
4570 * slurm_update_reservation - modify an existing reservation, only usable by
4571 *	user root
4572 * IN resv_msg - description of reservation
4573 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4574 */
4575extern int slurm_update_reservation(resv_desc_msg_t *resv_msg);
4576
4577/*
4578 * slurm_delete_reservation - issue RPC to delete a reservation, only usable
4579 *	by user root
4580 * IN resv_msg - description of reservation to delete
4581 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4582 */
4583extern int slurm_delete_reservation(reservation_name_msg_t *resv_msg);
4584
4585/*
4586 * slurm_load_reservations - issue RPC to get all slurm reservation
4587 *	configuration information if changed since update_time
4588 * IN update_time - time of current configuration data
4589 * IN reserve_info_msg_pptr - place to store a reservation configuration
4590 *	pointer
4591 * RET 0 or a slurm error code
4592 * NOTE: free the response using slurm_free_reservation_info_msg
4593 */
4594extern int slurm_load_reservations(time_t update_time,
4595				   reserve_info_msg_t **resp);
4596
4597/*
4598 * slurm_print_reservation_info_msg - output information about all Slurm
4599 *	reservations based upon message as loaded using slurm_load_reservation
4600 * IN out - file to write to
4601 * IN resv_info_ptr - reservation information message pointer
4602 * IN one_liner - print as a single line if true
4603 */
4604void slurm_print_reservation_info_msg(FILE* out,
4605				      reserve_info_msg_t *resv_info_ptr,
4606				      int one_liner);
4607
4608/*
4609 * slurm_print_reservation_info - output information about a specific Slurm
4610 *	reservation based upon message as loaded using slurm_load_reservation
4611 * IN out - file to write to
4612 * IN resv_ptr - an individual reservation information record pointer
4613 * IN one_liner - print as a single line if true
4614 */
4615void slurm_print_reservation_info(FILE* out,
4616				  reserve_info_t *resv_ptr,
4617				  int one_liner);
4618
4619/*
4620 * slurm_sprint_reservation_info - output information about a specific Slurm
4621 *	reservation based upon message as loaded using slurm_load_reservations
4622 * IN resv_ptr - an individual reservation information record pointer
4623 * IN one_liner - print as a single line if true
4624 * RET out - char * containing formatted output (must be freed after call)
4625 *           NULL is returned on failure.
4626 */
4627char *slurm_sprint_reservation_info(reserve_info_t *resv_ptr, int one_liner);
4628
4629/*
4630 * slurm_free_reservation_info_msg - free the reservation information
4631 *	response message
4632 * IN msg - pointer to reservation information response message
4633 * NOTE: buffer is loaded by slurm_load_reservation
4634 */
4635extern void slurm_free_reservation_info_msg(reserve_info_msg_t *resv_info_ptr);
4636
4637/*****************************************************************************\
4638 *	SLURM PING/RECONFIGURE/SHUTDOWN FUNCTIONS
4639\*****************************************************************************/
4640
4641/*
4642 * slurm_ping - issue RPC to have Slurm controller (slurmctld)
4643 * IN dest - controller to contact (0=primary, 1=backup, 2=backup2, etc.)
4644 * RET 0 or a slurm error code
4645 */
4646extern int slurm_ping(int dest);
4647
4648/*
4649 * slurm_reconfigure - issue RPC to have Slurm controller (slurmctld)
4650 *	reload its configuration file
4651 * RET 0 or a slurm error code
4652 */
4653extern int slurm_reconfigure(void);
4654
4655/*
4656 * slurm_shutdown - issue RPC to have Slurm controller (slurmctld)
4657 *	cease operations, both the primary and all backup controllers
4658 *	are shutdown.
4659 * IN options - 0: all slurm daemons are shutdown
4660 *              1: slurmctld generates a core file
4661 *              2: only the slurmctld is shutdown (no core file)
4662 * RET 0 or a slurm error code
4663 */
4664extern int slurm_shutdown(uint16_t options);
4665
4666/*
4667 * slurm_takeover - issue RPC to have a Slurm backup controller take over the
4668 *                  primary controller. REQUEST_CONTROL is sent by the backup
4669 *                  to the primary controller to take control
4670 * backup_inx IN - Index of BackupController to assume controller (typically 1)
4671 * RET 0 or a slurm error code
4672 */
4673extern int slurm_takeover(int backup_inx);
4674
4675/*
4676 * slurm_set_debugflags - issue RPC to set slurm controller debug flags
4677 * IN debug_flags_plus  - debug flags to be added
4678 * IN debug_flags_minus - debug flags to be removed
4679 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4680 */
4681extern int slurm_set_debugflags(uint64_t debug_flags_plus,
4682				uint64_t debug_flags_minus);
4683
4684/*
4685 * slurm_set_debug_level - issue RPC to set slurm controller debug level
4686 * IN debug_level - requested debug level
4687 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4688 */
4689extern int slurm_set_debug_level(uint32_t debug_level);
4690
4691/*
4692 * slurm_set_schedlog_level - issue RPC to set slurm scheduler log level
4693 * IN schedlog_level - requested scheduler log level
4694 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4695 */
4696extern int slurm_set_schedlog_level(uint32_t schedlog_level);
4697
4698/*
4699 * slurm_set_fs_dampeningfactor - issue RPC to set slurm fs dampening factor
4700 * IN factor - requested fs dampening factor
4701 * RET SLURM_SUCCESS on success, otherwise return SLURM_ERROR with errno set
4702 */
4703extern int slurm_set_fs_dampeningfactor(uint16_t factor);
4704
4705/*****************************************************************************\
4706 *      SLURM JOB SUSPEND FUNCTIONS
4707\*****************************************************************************/
4708
4709/*
4710 * slurm_suspend - suspend execution of a job.
4711 * IN job_id  - job on which to perform operation
4712 * RET 0 or a slurm error code
4713 */
4714extern int slurm_suspend(uint32_t job_id);
4715
4716/*
4717 * slurm_suspend2 - suspend execution of a job.
4718 * IN job_id in string form  - job on which to perform operation, may be job
4719 *            array specification (e.g. "123_1-20,44");
4720 * OUT resp - per task response to the request,
4721 *	      free using slurm_free_job_array_resp()
4722 * RET 0 or a slurm error code
4723 */
4724extern int slurm_suspend2(char *job_id, job_array_resp_msg_t **resp);
4725
4726/*
4727 * slurm_resume - resume execution of a previously suspended job.
4728 * IN job_id  - job on which to perform operation
4729 * RET 0 or a slurm error code
4730 */
4731extern int slurm_resume(uint32_t job_id);
4732
4733/*
4734 * slurm_resume2 - resume execution of a previously suspended job.
4735 * IN job_id in string form  - job on which to perform operation, may be job
4736 *            array specification (e.g. "123_1-20,44");
4737 * OUT resp - per task response to the request,
4738 *	      free using slurm_free_job_array_resp()
4739 * RET 0 or a slurm error code
4740 */
4741extern int slurm_resume2(char *job_id, job_array_resp_msg_t **resp);
4742
4743/* Free job array oriented response with individual return codes by task ID */
4744extern void slurm_free_job_array_resp(job_array_resp_msg_t *resp);
4745
4746/*
4747 * slurm_requeue - re-queue a batch job, if already running
4748 *	then terminate it first
4749 * IN job_id  - job on which to perform operation
4750 * IN flags - JOB_SPECIAL_EXIT - job should be placed special exit state and
4751 *		  held.
4752 *            JOB_REQUEUE_HOLD - job should be placed JOB_PENDING state and
4753 *		  held.
4754 *            JOB_RECONFIG_FAIL - Node configuration for job failed
4755 *            JOB_RUNNING - Operate only on jobs in a state of
4756 *		  CONFIGURING, RUNNING, STOPPED or SUSPENDED.
4757 * RET 0 or a slurm error code
4758 */
4759extern int slurm_requeue(uint32_t job_id, uint32_t flags);
4760
4761/*
4762 * slurm_requeue2 - re-queue a batch job, if already running
4763 *	then terminate it first
4764 * IN job_id in string form  - job on which to perform operation, may be job
4765 *            array specification (e.g. "123_1-20,44");
4766 * IN flags - JOB_SPECIAL_EXIT - job should be placed special exit state and
4767 *		  held.
4768 *            JOB_REQUEUE_HOLD - job should be placed JOB_PENDING state and
4769 *		  held.
4770 *            JOB_RECONFIG_FAIL - Node configuration for job failed
4771 *            JOB_RUNNING - Operate only on jobs in a state of
4772 *		  CONFIGURING, RUNNING, STOPPED or SUSPENDED.
4773 * OUT resp - per task response to the request,
4774 *	      free using slurm_free_job_array_resp()
4775 * RET 0 or a slurm error code
4776 */
4777extern int slurm_requeue2(char *job_id, uint32_t flags,
4778			  job_array_resp_msg_t **resp);
4779
4780/*****************************************************************************\
4781 *      SLURM TRIGGER FUNCTIONS
4782\*****************************************************************************/
4783
4784/*
4785 * slurm_set_trigger - Set an event trigger
4786 * RET 0 or a slurm error code
4787 */
4788extern int slurm_set_trigger(trigger_info_t *trigger_set);
4789
4790/*
4791 * slurm_clear_trigger - Clear (remove) an existing event trigger
4792 * RET 0 or a slurm error code
4793 */
4794extern int slurm_clear_trigger(trigger_info_t *trigger_clear);
4795
4796/*
4797 * slurm_get_triggers - Get all event trigger information
4798 * Use slurm_free_trigger_msg() to free the memory allocated by this function
4799 * RET 0 or a slurm error code
4800 */
4801extern int slurm_get_triggers(trigger_info_msg_t **trigger_get);
4802
4803/*
4804 * slurm_pull_trigger - Pull an event trigger
4805 * RET 0 or a slurm error code
4806 */
4807extern int slurm_pull_trigger(trigger_info_t *trigger_pull);
4808
4809/*
4810 * slurm_free_trigger_msg - Free data structure returned by
4811 * slurm_get_triggers()
4812 */
4813extern void slurm_free_trigger_msg(trigger_info_msg_t *trigger_free);
4814
4815/*
4816 * slurm_init_trigger_msg - initialize trigger clear/update message
4817 * OUT trigger_info_msg - user defined trigger descriptor
4818 */
4819void slurm_init_trigger_msg(trigger_info_t *trigger_info_msg);
4820
4821/*****************************************************************************\
4822 *      SLURM BURST BUFFER FUNCTIONS
4823\*****************************************************************************/
4824#define BB_FLAG_DISABLE_PERSISTENT	0x0001	/* Disable regular user to create
4825						 * and destroy persistent burst
4826						 * buffers */
4827#define BB_FLAG_ENABLE_PERSISTENT	0x0002	/* Allow regular user to create
4828						 * and destroy persistent burst
4829						 * buffers */
4830#define BB_FLAG_EMULATE_CRAY		0x0004	/* Using dw_wlm_cli emulator */
4831#define BB_FLAG_PRIVATE_DATA		0x0008	/* Buffers only visible to owner */
4832#define BB_FLAG_TEARDOWN_FAILURE	0x0010	/* Teardown after failed staged in/out */
4833#define BB_FLAG_SET_EXEC_HOST		0x0020	/* Set execute host */
4834
4835#define BB_SIZE_IN_NODES	0x8000000000000000
4836#define BB_STATE_PENDING	0x0000		/* Placeholder: no action started */
4837#define BB_STATE_ALLOCATING	0x0001		/* Cray: bbs_setup started */
4838#define BB_STATE_ALLOCATED	0x0002		/* Cray: bbs_setup started */
4839#define BB_STATE_DELETING	0x0005		/* Cray: bbs_setup started */
4840#define BB_STATE_DELETED	0x0006		/* Cray: bbs_setup started */
4841#define BB_STATE_STAGING_IN	0x0011		/* Cray: bbs_data_in started */
4842#define BB_STATE_STAGED_IN	0x0012		/* Cray: bbs_data_in complete */
4843#define BB_STATE_PRE_RUN	0x0018		/* Cray: bbs_pre_run started */
4844#define BB_STATE_ALLOC_REVOKE	0x001a		/* Cray: allocation revoked */
4845#define BB_STATE_RUNNING	0x0021		/* Job is running */
4846#define BB_STATE_SUSPEND	0x0022		/* Job is suspended (future) */
4847#define BB_STATE_POST_RUN	0x0029		/* Cray: bbs_post_run started */
4848#define BB_STATE_STAGING_OUT	0x0031		/* Cray: bbs_data_out started */
4849#define BB_STATE_STAGED_OUT	0x0032		/* Cray: bbs_data_out complete */
4850#define BB_STATE_TEARDOWN	0x0041		/* Cray: bbs_teardown started */
4851#define BB_STATE_TEARDOWN_FAIL	0x0043		/* Cray: bbs_teardown failed, retrying */
4852#define BB_STATE_COMPLETE	0x0045		/* Cray: bbs_teardown complete */
4853
4854/* Information about alternate pools or other burst buffer resources */
4855typedef struct {
4856	uint64_t granularity;	/* Granularity of resource allocation size */
4857	char *name;		/* Resource (pool) name */
4858	uint64_t total_space;	/* Total size of available resources, unused
4859				 * by burst_buffer_resv_t */
4860	uint64_t used_space;	/* Allocated space, in bytes */
4861	uint64_t unfree_space;	/* used plus drained space, units are bytes */
4862} burst_buffer_pool_t;
4863
4864typedef struct {
4865	char *account;		/* Associated account (for limits) */
4866	uint32_t array_job_id;
4867	uint32_t array_task_id;
4868	time_t create_time;	/* Time of creation */
4869	uint32_t job_id;
4870	char *name;		/* Name of persistent burst buffer */
4871	char *partition;	/* Associated partition (for limits) */
4872	char *pool;		/* Resource (pool) name */
4873	char *qos;		/* Associated QOS (for limits) */
4874	uint64_t size;		/* In bytes by default */
4875	uint16_t state;		/* See BB_STATE_* */
4876	uint32_t user_id;
4877} burst_buffer_resv_t;
4878
4879typedef struct {
4880	uint32_t user_id;
4881	uint64_t used;
4882} burst_buffer_use_t;
4883
4884typedef struct {
4885	char *allow_users;
4886	char *default_pool;		/* Name of default pool to use */
4887	char *create_buffer;
4888	char *deny_users;
4889	char *destroy_buffer;
4890	uint32_t flags;			/* See BB_FLAG_* above */
4891	char *get_sys_state;
4892	char *get_sys_status;
4893	uint64_t granularity;		/* Granularity of resource allocation */
4894	uint32_t pool_cnt;		/* Count of records in pool_ptr */
4895	burst_buffer_pool_t *pool_ptr;
4896	char *name;			/* Plugin name */
4897	uint32_t other_timeout;		/* Seconds or zero */
4898	uint32_t stage_in_timeout;	/* Seconds or zero */
4899	uint32_t stage_out_timeout;	/* Seconds or zero */
4900	char *start_stage_in;
4901	char *start_stage_out;
4902	char *stop_stage_in;
4903	char *stop_stage_out;
4904	uint64_t total_space;		/* In bytes */
4905	uint64_t unfree_space;		/* Allocated or drained, in bytes */
4906	uint64_t used_space;		/* Allocated, in bytes */
4907	uint32_t validate_timeout;	/* Seconds or zero */
4908
4909	uint32_t  buffer_count;
4910	burst_buffer_resv_t *burst_buffer_resv_ptr;
4911
4912	uint32_t  use_count;
4913	burst_buffer_use_t *burst_buffer_use_ptr;
4914} burst_buffer_info_t;
4915
4916typedef struct {
4917	burst_buffer_info_t *burst_buffer_array;
4918	uint32_t  record_count;		/* Elements in burst_buffer_array */
4919} burst_buffer_info_msg_t;
4920
4921/*
4922 * slurm_burst_buffer_state_string - translate burst buffer state number to
4923 *	it string equivalent
4924 */
4925extern char *slurm_burst_buffer_state_string(uint16_t state);
4926
4927/*
4928 * slurm_load_burst_buffer_stat - issue RPC to get burst buffer status
4929 * IN argc - count of status request options
4930 * IN argv - status request options
4931 * OUT status_resp - status response, memory must be released using xfree()
4932 * RET 0 or a slurm error code
4933 */
4934extern int slurm_load_burst_buffer_stat(int argc, char **argv,
4935					char **status_resp);
4936
4937/*
4938 * slurm_load_burst_buffer_info - issue RPC to get slurm all burst buffer plugin
4939 *	information
4940 * OUT burst_buffer_info_msg_pptr - place to store a burst buffer configuration
4941 *	pointer
4942 * RET 0 or a slurm error code
4943 * NOTE: free the response using slurm_free_burst_buffer_info_msg
4944 */
4945extern int slurm_load_burst_buffer_info(burst_buffer_info_msg_t **burst_buffer_info_msg_pptr);
4946
4947/*
4948 * slurm_free_burst_buffer_info_msg - free buffer returned by
4949 *	slurm_load_burst_buffer
4950 * IN burst_buffer_info_msg_ptr - pointer to burst_buffer_info_msg_t
4951 * RET 0 or a slurm error code
4952 */
4953extern void slurm_free_burst_buffer_info_msg(burst_buffer_info_msg_t *burst_buffer_info_msg);
4954
4955/*
4956 * slurm_print_burst_buffer_info_msg - output information about burst buffers
4957 *	based upon message as loaded using slurm_load_burst_buffer
4958 * IN out - file to write to
4959 * IN info_ptr - burst_buffer information message pointer
4960 * IN one_liner - print as a single line if true
4961 * IN verbose - higher values to log additional details
4962 */
4963extern void slurm_print_burst_buffer_info_msg(FILE *out,
4964					      burst_buffer_info_msg_t *info_ptr,
4965					      int one_liner,
4966					      int verbosity);
4967
4968/*
4969 * slurm_print_burst_buffer_record - output information about a specific Slurm
4970 *	burst_buffer record based upon message as loaded using
4971 *	slurm_load_burst_buffer_info()
4972 * IN out - file to write to
4973 * IN burst_buffer_ptr - an individual burst buffer record pointer
4974 * IN one_liner - print as a single line if not zero
4975 * IN verbose - higher values to log additional details
4976 * RET out - char * containing formatted output (must be freed after call)
4977 *	   NULL is returned on failure.
4978 */
4979extern void slurm_print_burst_buffer_record(FILE *out,
4980					    burst_buffer_info_t *burst_buffer_ptr,
4981			 		    int one_liner,
4982					    int verbose);
4983
4984/*
4985 * slurm_network_callerid - issue RPC to get the job id of a job from a remote
4986 * slurmd based upon network socket information.
4987 *
4988 * IN req - Information about network connection in question
4989 * OUT job_id -  ID of the job or NO_VAL
4990 * OUT node_name - name of the remote slurmd
4991 * IN node_name_size - size of the node_name buffer
4992 * RET SLURM_SUCCESS or SLURM_ERROR on error
4993 */
4994extern int slurm_network_callerid(network_callerid_msg_t req,
4995				  uint32_t *job_id,
4996				  char *node_name,
4997				  int node_name_size);
4998
4999/*
5000 * Move the specified job ID to the top of the queue for a given user ID,
5001 *	partition, account, and QOS.
5002 * IN job_id_str - a job id
5003 * RET 0 or -1 on error */
5004extern int slurm_top_job(char *job_id_str);
5005
5006/*
5007 * Fetch an auth token for a given username.
5008 * IN username - NULL, or a specific username if run as SlurmUser/root.
5009 * IN lifespan - lifespan the token should be valid for.
5010 */
5011extern char *slurm_fetch_token(char *username, int lifespan);
5012
5013/*****************************************************************************\
5014 *      SLURM FEDERATION FUNCTIONS
5015\*****************************************************************************/
5016
5017/*
5018 * slurm_load_federation - issue RPC to get federation status from controller
5019 * IN/OUT fed_pptr - place to store returned federation information.
5020 * 		     slurmdb_federation_rec_t treated as a void pointer to since
5021 * 		     slurm.h doesn't have ties to slurmdb.h.
5022 * NOTE: Use slurm_destroy_federation_rec() to release the returned memory
5023 * RET 0 or -1 on error
5024 */
5025extern int slurm_load_federation(void **fed_pptr);
5026
5027/*
5028 * slurm_print_federation - prints slurmdb_federation_rec_t (passed as void*
5029 * 			    since slurm.h doesn't know about slurmdb.h).
5030 */
5031extern void slurm_print_federation(void *fed);
5032
5033/*
5034 * slurm_destroy_federation_rec - Release memory allocated by
5035 *				  slurm_load_federation()
5036 */
5037extern void slurm_destroy_federation_rec(void *fed);
5038
5039#ifdef __cplusplus
5040}
5041#endif
5042
5043#endif
5044