1Slurm API(3) Slurm host list functions Slurm API(3)
2
3
4
6 slurm_hostlist_create, slurm_hostlist_shift, slurm_hostlist_destroy -
7 Slurm host list support functions
8
9
11 #include <slurm/slurm.h>
12
13 hostlist_t slurm_hostlist_create (
14 char *node_list
15 );
16
17 char * slurm_hostlist_shift (
18 hostlist_t host_list
19 );
20
21 void slurm_hostlist_destroy (
22 hostlist_t host_list
23 );
24
25
27 node_list
28 A list of nodes as returned by the slurm_job_step_create func‐
29 tions. The returned value may include a simple range format to
30 describe numeric ranges of values and/or multiple numeric values
31 (e.g. "linux[1-3,6]" represents "linux1", "linux2", "linux3",
32 and "linux6").
33
34 host_list
35 A hostlist created by the slurm_hostlist_create function.
36
37
39 slurm_hostlist_create creates a database of node names from a range
40 format describing node names. Use slurm_hostlist_destroy to release
41 storage associated with the database when no longer required.
42
43 slurm_hostlist_shift extracts the first entry from the host list data‐
44 base created by the slurm_hostlist_create function.
45
46 slurm_hostlist_destroy releases storage associated with a database cre‐
47 ated by slurm_hostlist_create when no longer required.
48
49
51 slurm_hostlist_create returns the host list database or NULL if memory
52 can not be allocated for the database.
53
54
55 slurm_hostlist_shift returns a character string or NULL if no entries
56 remain in the database.
57
58
60 #include <stdio.h>
61 #include <hostlist.h>
62 #include <slurm.h>
63
64 int main (int argc, char *argv[])
65 {
66 hostlist_t my_hostlist;
67 char *hostnames, *host;
68
69 /* generate a list of hostnames, possibly using a */
70 /* slurm job step creation function */
71
72 my_hostlist = slurm_hostlist_create (hostnames);
73 if (my_hostlist == NULL) {
74 fprintf (stderr, "No memory\n");
75 exit (1);
76 }
77
78 while ( (host = slurm_hostlist_shift(my_hostlist)) ) {
79 printf ("host = %s\n", host);
80 free(host);
81 }
82
83 slurm_hostlist_destroy (my_hostlist) ;
84 exit (0);
85 }
86
87
89 These functions are included in the libslurm library, which must be
90 linked to your process for use (e.g. "cc -lslurm myprog.c").
91
92
94 Copyright (C) 2002-2006 The Regents of the University of California.
95 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
96 CODE-OCEC-09-009. All rights reserved.
97
98 This file is part of Slurm, a resource management program. For
99 details, see <https://slurm.schedmd.com/>.
100
101 Slurm is free software; you can redistribute it and/or modify it under
102 the terms of the GNU General Public License as published by the Free
103 Software Foundation; either version 2 of the License, or (at your
104 option) any later version.
105
106 Slurm is distributed in the hope that it will be useful, but WITHOUT
107 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
108 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
109 for more details.
110
111
113 slurm_get_job_steps(3), slurm_load_jobs(3), slurm_load_partitions(3)
114
115
116
117April 2015 Slurm host list functions Slurm API(3)