1Slurm API(3) Slurm administrative functions Slurm API(3)
2
3
4
6 slurm_create_partition, slurm_create_reservation, slurm_delete_parti‐
7 tion, slurm_delete_reservation, slurm_init_part_desc_msg,
8 slurm_init_resv_desc_msg, slurm_reconfigure, slurm_shutdown,
9 slurm_takeover, ,slurm_init_update_node_msg slurm_update_node,
10 slurm_update_partition, slurm_update_reservation - Slurm administrative
11 functions
12
14 #include <slurm/slurm.h>
15
16 int slurm_create_partition (
17 update_part_msg_t *update_part_msg_ptr
18 );
19
20 int slurm_create_reservation (
21 resv_desc_msg_t *update_resv_msg_ptr
22 );
23
24 int slurm_delete_partition (
25 delete_part_msg_t *delete_part_msg_ptr
26 );
27
28 int slurm_delete_reservation (
29 reservation_name_msg_t *delete_resv_msg_ptr
30 );
31
32 void slurm_init_front_end_msg (
33 update_front_end_msg_t *update_front_end_msg_ptr
34 );
35
36 void slurm_init_part_desc_msg (
37 update_part_msg_t *update_part_msg_ptr
38 );
39
40 void slurm_init_resv_desc_msg (
41 resv_desc_msg_t *update_resv_msg_ptr
42 );
43
44 void slurm_init_update_node_msg(
45 update_node_msg_t *update_node_msg_ptr
46 );
47
48 int slurm_reconfigure ( );
49
50 int slurm_shutdown (
51 uint16_t shutdown_options
52 );
53
54 int slurm_takeover ( );
55
56 int slurm_update_front_end (
57 update_front_end_msg_t *update_front_end_msg_ptr
58 );
59
60 int slurm_update_node (
61 update_node_msg_t *update_node_msg_ptr
62 );
63
64 int slurm_update_partition (
65 update_part_msg_t *update_part_msg_ptr
66 );
67
68 int slurm_update_reservation (
69 resv_desc_msg_t *update_resv_msg_ptr
70 );
71
73 shutdown_options
74 0: all slurm daemons are shutdown
75 1: slurmctld generates a core file
76 2: only the slurmctld is shutdown (no core file)
77
78 delete_part_msg_ptr
79 Specifies the pointer to a partition delete request specifica‐
80 tion. See slurm.h for full details on the data structure's con‐
81 tents.
82
83 delete_resv_msg_ptr
84 Specifies the pointer to a reservation delete request specifica‐
85 tion. See slurm.h for full details on the data structure's con‐
86 tents.
87
88 update_front_end_msg_ptr
89 Specifies the pointer to a front end node update request speci‐
90 fication. See slurm.h for full details on the data structure's
91 contents.
92
93 update_node_msg_ptr
94 Specifies the pointer to a node update request specification.
95 See slurm.h for full details on the data structure's contents.
96
97 update_part_msg_ptr
98 Specifies the pointer to a partition create or update request
99 specification. See slurm.h for full details on the data struc‐
100 ture's contents.
101
102 update_resv_msg_ptr
103 Specifies the pointer to a reservation create or update request
104 specification. See slurm.h for full details on the data struc‐
105 ture's contents.
106
107
109 slurm_create_partition Request that a new partition be created. Ini‐
110 tialize the data structure using the slurm_init_part_desc_msg function
111 prior to setting values of the parameters to be changed. Note:
112 slurm_init_part_desc_msg is not equivalent to setting the data struc‐
113 ture values to zero. A partition name must be set for the call to suc‐
114 ceed. This function may only be successfully executed by user root.
115
116 slurm_create_reservation Request that a new reservation be created.
117 Initialize the data structure using the slurm_init_resv_desc_msg func‐
118 tion prior to setting values of the parameters to be changed. Note:
119 slurm_init_resv_desc_msg is not equivalent to setting the data struc‐
120 ture values to zero. The reservation's time limits, user or account
121 restrictions, and node names or a node count must be specified for the
122 call to succeed. This function may only be successfully executed by
123 user root.
124
125 slurm_delete_partition Request that the specified partition be deleted.
126 All jobs associated with the identified partition will be terminated
127 and purged. This function may only be successfully executed by user
128 root.
129
130 slurm_delete_reservation Request that the specified reservation be
131 deleted. This function may only be successfully executed by user root.
132
133 slurm_init_update_front_end_msg Initialize the contents of an update
134 front end node descriptor with default values. Note:
135 slurm_init_update_front_end_msg is not equivalent to setting the data
136 structure values to zero. Execute this function before executing
137 slurm_update_front_end.
138
139 slurm_init_part_desc_msg Initialize the contents of a partition
140 descriptor with default values. Note: slurm_init_part_desc_msg is not
141 equivalent to setting the data structure values to zero. Execute this
142 function before executing slurm_create_partition or slurm_update_parti‐
143 tion.
144
145 slurm_init_resv_desc_msg Initialize the contents of a reservation
146 descriptor with default values. Note: slurm_init_resv_desc_msg is not
147 equivalent to setting the data structure values to zero. Execute this
148 function before executing slurm_create_reservation or
149 slurm_update_reservation.
150
151 slurm_init_update_node_msg Initialize the contents of an update node
152 descriptor with default values. Note: slurm_init_update_node_msg is not
153 equivalent to setting the data structure values to zero. Execute this
154 function before executing slurm_update_node.
155
156 slurm_reconfigure Request that the Slurm controller re-read its config‐
157 uration file. The new configuration parameters take effect immediately.
158 This function may only be successfully executed by user root.
159
160 slurm_shutdown Request that the Slurm controller terminate. This func‐
161 tion may only be successfully executed by user root.
162
163 slurm_takeover Request that the Slurm primary controller shutdown imme‐
164 diately and the backup controller take over. This function may only be
165 successfully executed by user root.
166
167 slurm_update_front_end Request that the state of one or more front end
168 nodes be updated. This function may only be successfully executed by
169 user root. If used by some autonomous program, the state value most
170 likely to be used is NODE_STATE_DRAIN.
171
172 slurm_update_node Request that the state of one or more nodes be
173 updated. Note that the state of a node (e.g. DRAINING, IDLE, etc.) may
174 be changed, but its hardware configuration may not be changed by this
175 function. If the hardware configuration of a node changes, update the
176 Slurm configuration file and execute the slurm_reconfigure function.
177 This function may only be successfully executed by user root. If used
178 by some autonomous program, the state value most likely to be used is
179 NODE_STATE_DRAIN or NODE_STATE_FAILING. The node state flag
180 NODE_STATE_NO_RESPOND may be specified without changing the underlying
181 node state. Note that the node's NODE_STATE_NO_RESPOND flag will be
182 cleared as soon as the slurmd daemon on that node communicates with the
183 slurmctld daemon. Likewise the state NODE_STATE_DOWN indicates that
184 the slurmd daemon is not responding (and has not responded for an
185 interval at least as long as the SlurmdTimeout configuration parame‐
186 ter). The node will leave the NODE_STATE_DOWN state as soon as the
187 slurmd daemon communicates.
188
189 slurm_update_partition Request that the configuration of a partition be
190 updated. Note that most, but not all parameters of a partition may be
191 changed by this function. Initialize the data structure using the
192 slurm_init_part_desc_msg function prior to setting values of the param‐
193 eters to be changed. Note: slurm_init_part_desc_msg is not equivalent
194 to setting the data structure values to zero. This function may only be
195 successfully executed by user root.
196
197 slurm_update_reservation Request that the configuration of a reserva‐
198 tion be updated. Initialize the data structure using the
199 slurm_init_resv_desc_msg function prior to setting values of the param‐
200 eters to be changed. Note: slurm_init_resv_desc_msg is not equivalent
201 to setting the data structure values to zero. This function may only be
202 successfully executed by user root.
203
204
206 On success, zero is returned. On error, -1 is returned, and the Slurm
207 error code is set appropriately.
208
209 Exception: A successful slurm_create_reservation call returns a string
210 containing the name of the reservation, in memory to be freed by the
211 caller. A failed call returns NULL and sets the Slurm error code.
212
214 SLURM_PROTOCOL_VERSION_ERROR Protocol version has changed, re-link your
215 code.
216
217 ESLURM_INVALID_NODE_NAME The requested node name(s) is/are not valid.
218
219 ESLURM_INVALID_NODE_STATE The specified state node state or requested
220 node state transition is not valid.
221
222 ESLURM_INVALID_PARTITION_NAME The requested partition name is not
223 valid.
224
225 ESLURM_INVALID_AUTHTYPE_CHANGE The AuthType parameter can not be
226 changed using the slurm_reconfigure function, but all Slurm daemons and
227 commands must be restarted. See slurm.conf(5) for more information.
228
229 ESLURM_INVALID_SCHEDTYPE_CHANGE The SchedulerType parameter can not be
230 changed using the slurm_reconfigure function, but the slurmctld daemon
231 must be restarted. Manual changes to existing job parameters may also
232 be required. See slurm.conf(5) for more information.
233
234 ESLURM_INVALID_SWITCHTYPE_CHANGE The SwitchType parameter can not be
235 changed using the slurm_reconfigure function, but all Slurm daemons and
236 commands must be restarted. All previously running jobs will be lost.
237 See slurm.conf(5) for more information.
238
239 ESLURM_ACCESS_DENIED The requesting user lacks authorization for the
240 requested action (e.g. trying to delete or modify another user's job).
241
242 SLURM_PROTOCOL_SOCKET_IMPL_TIMEOUT Timeout in communicating with Slurm
243 controller.
244
245 ESLURM_RESERVATION_ACCESS Requestor is not authorized to access the
246 reservation.
247
248 ESLURM_RESERVATION_INVALID Invalid reservation parameter given, e.g.
249 wrong name given.
250
251 ESLURM_INVALID_TIME_VALUE Invalid time value.
252
253 ESLURM_RESERVATION_BUSY Reservation is busy, e.g. trying to delete a
254 reservation while in use.
255
256 ESLURM_RESERVATION_NOT_USABLE Reservation not usable, e.g. trying to
257 use an expired reservation.
258
260 #include <stdio.h>
261 #include <stdlib.h>
262 #include <slurm/slurm.h>
263 #include <slurm/slurm_errno.h>
264
265 int main (int argc, char *argv[])
266 {
267 update_node_msg_t update_node_msg;
268 update_part_msg_t update_part_msg;
269 delete_part_msg_t delete_part_msg;
270 resv_desc_msg_t resv_msg;
271 char *resv_name = NULL;
272
273 if (slurm_reconfigure ( )) {
274 slurm_perror ("slurm_reconfigure error");
275 exit (1);
276 }
277
278 slurm_init_part_desc_msg ( &update_part_msg );
279 update_part_msg.name = "test.partition";
280 update_part_msg.state_up = 0; /* partition down */
281 if (slurm_create_partition (&update_part_msg)) {
282 slurm_perror ("slurm_create_partition error");
283 exit (1);
284 }
285
286 update_part_msg.state_up = 1; /* partition up */
287 if (slurm_update_partition (&update_part_msg)) {
288 slurm_perror ("slurm_update_partition error");
289 exit (1);
290 }
291
292 delete_part_msg.name = "test.partition";
293 if (slurm_delete_partition (&delete_part_msg)) {
294 slurm_perror ("slurm_delete_partition error");
295 exit (1);
296 }
297
298 slurm_init_update_node_msg (&update_node_msg);
299 update_node_msg.node_names = "lx[10-12]";
300 update_node_msg.node_state = NODE_STATE_DRAIN ;
301 if (slurm_update_node (&update_node_msg)) {
302 slurm_perror ("slurm_update_node error");
303 exit (1);
304 }
305
306 slurm_init_resv_desc_msg ( &resv_msg );
307 resv_msg.start_time = time(NULL) + 60*60; /* One hour from now */
308 resv_msg.duration = 720; /* 12 hours/720 minutes */
309 resv_msg.node_cnt = 10;
310 resv_msg.accounts = "admin";
311 resv_name = slurm_create_reservation (&resv_msg);
312 if (!resv_name) {
313 slurm_perror ("slurm_create_reservation error");
314 exit (1);
315 }
316 free(resv_name);
317 exit (0);
318 }
319
320
322 These functions are included in the libslurm library, which must be
323 linked to your process for use (e.g. "cc -lslurm myprog.c").
324
325
327 Copyright (C) 2002-2007 The Regents of the University of California.
328 Copyright (C) 2008-2010 Lawrence Livermore National Security. Produced
329 at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
330 CODE-OCEC-09-009. All rights reserved.
331
332 This file is part of Slurm, a resource management program. For
333 details, see <https://slurm.schedmd.com/>.
334
335 Slurm is free software; you can redistribute it and/or modify it under
336 the terms of the GNU General Public License as published by the Free
337 Software Foundation; either version 2 of the License, or (at your
338 option) any later version.
339
340 Slurm is distributed in the hope that it will be useful, but WITHOUT
341 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
342 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
343 for more details.
344
346 scontrol(1), slurm_get_errno(3), slurm_init_job_desc_msg(3), slurm_per‐
347 ror(3), slurm_strerror(3), slurm.conf(5)
348
349
350
351April 2015 Slurm administrative functions Slurm API(3)