-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathslurm_php.h
381 lines (338 loc) · 13.4 KB
/
slurm_php.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
/*****************************************************************************\
* slurm_php.h - php interface to slurm.
*
*****************************************************************************
* Copyright (C) 2011 - Trinity Centre for High Performance Computing
* Copyright (C) 2011 - Trinity College Dublin
* Written By : Vermeulen Peter <HoWest><Belgium>
*
* This file is part of php-slurm, a resource management program.
* Please also read the included file: DISCLAIMER.
*
* php-slurm is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* In addition, as a special exception, the copyright holders give permission
* to link the code of portions of this program with the OpenSSL library under
* certain conditions as described in each individual source file, and
* distribute linked combinations including the two. You must obey the GNU
* General Public License in all respects for all of the code used other than
* OpenSSL. If you modify file(s) with this exception, you may extend this
* exception to your version of the file(s), but you are not obligated to do
* so. If you do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source files in
* the program, then also delete it here.
*
* php-slurm is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with php-slurm; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\*****************************************************************************/
#ifndef SLURM_PHP_H
#define SLURM_PHP_H 1
#define SLURM_PHP_VERSION "1.0.2.1"
#define SLURM_PHP_EXTNAME "slurm"
/*
* Adjust this value to change the format of the returned string
* values.
*
* For more information on formatting options :
* http://www.java2s.com/Tutorial/C/0460__time.h/strftime.htm
*/
#define TIME_FORMAT_STRING "%c"
#include <php.h>
#include <slurm/slurm.h>
#include <slurm/slurmdb.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
extern zend_module_entry slurm_php_module_entry;
/*****************************************************************************\
* TYPEDEFS
\*****************************************************************************/
typedef struct key_value {
char *name; /* key */
char *value; /* value */
} key_pair_t;
/* define functions needed to avoid warnings (they are defined in
* src/common/xstring.h) If you can figure out a way to make it so we
* don't have to make these declarations that would be awesome. I
* didn't have time to spend on it when I was working on it. -da
*/
/*
** strdup which uses xmalloc routines
*/
char *slurm_xstrdup(const char *str);
/*
** strdup formatted which uses xmalloc routines
*/
char *slurm_xstrdup_printf(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
/*****************************************************************************\
* SLURM PHP HOSTLIST FUNCTIONS
\*****************************************************************************/
/*
* slurm_hostlist_to_array - converts a hostlist string to
* a numerically indexed array.
*
* IN host_list - string value containing the hostlist
* RET numerically indexed array containing the names of the nodes
*/
PHP_FUNCTION(slurm_hostlist_to_array);
/*
* slurm_array_to_hostlist - convert an array of nodenames into a hostlist
* string
*
* IN node_arr - Numerically indexed array containing a nodename on each index
* RET String variable containing the hostlist string
*/
PHP_FUNCTION(slurm_array_to_hostlist);
/*****************************************************************************\
* SLURM STATUS FUNCTIONS
\*****************************************************************************/
/*
* slurm_ping - Issues the slurm interface to return the status of the slurm
* primary and secondary controller
*
* RET associative array containing the status ( status = 0 if online, = -1 if
* offline ) of both controllers
* NOTE : the error codes and their meaning are described in the section
* labelled EXTRA
*/
PHP_FUNCTION(slurm_ping);
/*
* slurm_slurmd_status - Issues the slurm interface to return the
* status of the slave daemon ( running on this machine )
*
* RET associative array containing the status or a negative long variable
* containing an error code
* NOTE : the error codes and their meaning are described in the section
* labelled EXTRA
*/
PHP_FUNCTION(slurm_slurmd_status);
/*
* slurm_version - Returns the slurm version number in the requested format
*
* IN option - long/integer value linking to the formatting of the version
* number
* RET long value containing the specific formatted version number a numeric
* array containing the version number or a negative long variable
* containing an error code.
* NOTE : the possible cases and their meaning are described in the section
* labelled EXTRA
*/
PHP_FUNCTION(slurm_version);
/*****************************************************************************\
* SLURM PARTITION READ FUNCTIONS
\*****************************************************************************/
/*
* slurm_print_partition_names - Creates and returns a numerically
* indexed array containing the names of the partitions
*
* RET numerically indexed array containing the partitionnames or a
* negative long variable containing an error code NOTE : the
* error codes and their meaning are described in the section
* labelled EXTRA
*/
PHP_FUNCTION(slurm_print_partition_names);
/*
* slurm_get_specific_partition_info - Searches for the requested
* partition and if found it returns an associative array
* containing the information about this specific partition
*
* IN name - a string variable containing the partitionname
* OPTIONAL IN lngth - a long variable containing the length of the
* partitionname
* RET an associative array containing the information about a
* specific partition, or a negative long value containing an
* error code
* NOTE : the error codes and their meaning are described in the
* section labelled EXTRA
*/
PHP_FUNCTION(slurm_get_specific_partition_info);
/*
* slurm_get_partition_node_names - Searches for the requested partition and
* if found it parses the nodes into a numerically indexed array, which is
* then returned to the calling function.
*
* IN name - a string variable containing the partitionname
*
* OPTIONAL IN lngth - a long variable containing the length of the
* partitionname
*
* RET a numerically indexed array containing the names of all the
* nodes connected to this partition, or a negative long value
* containing an error code
*
* NOTE : the error codes and their meaning are described in the
* section labelled EXTRA
*/
PHP_FUNCTION(slurm_get_partition_node_names);
/*****************************************************************************\
* SLURM NODE CONFIGURATION READ FUNCTIONS
\*****************************************************************************/
/*
* slurm_get_node_names - Creates and returns a numerically index array
* containing the nodenames.
*
* RET a numerically indexed array containing the requested nodenames,
* or a negative long value containing an error code
* NOTE : the error codes and their meaning are described in the
* section labelled EXTRA
*/
PHP_FUNCTION(slurm_get_node_names);
/*
* slurm_get_node_elements - Creates and returns an associative array
* containing all the nodes indexed by nodename and as value an
* associative array containing their information.
*
* RET an associative array containing the nodes as keys and their
* information as value, or a long value containing an error code
* NOTE : the error codes and their meaning are described in the
* section labelled EXTRA
*/
PHP_FUNCTION(slurm_get_node_elements);
/*
* slurm_get_node_element_by_name - Searches for the requested node
* and if found it parses its information into an associative
* array, which is then returned to the calling function.
*
* IN name - a string variable containing the nodename
* OPTIONAL IN lngth - a long variable containing the length of the nodename
* RET an assocative array containing the requested information or a
* long value containing an error code
* NOTE : the error codes and their meaning are described in the
* section labelled EXTRA
*/
PHP_FUNCTION(slurm_get_node_element_by_name);
/*
* slurm_get_node_state_by_name - Searches for the requested node and
* if found it returns the state of that node
*
* IN name - a string variable containing the nodename
* OPTIONAL IN lngth - a long variable containing the length of the nodename
* RET a long value containing the state of the node [0-7] or a
* negative long value containing the error code
* NOTE : the error codes and their meaning are described in the
* section labelled EXTRA
*/
PHP_FUNCTION(slurm_get_node_state_by_name);
/*
* slurm_get_node_states - Creates a numerically indexed array
* containing the state of each node ( only the state ! ) as a
* long value. This function could be used to create a summary of
* the node states without having to do a lot of processing ( or
* having to deal with overlapping nodes between partitions ).
*
* RET a numerically indexed array containing node states
*/
PHP_FUNCTION(slurm_get_node_states);
/*****************************************************************************\
* SLURM CONFIGURATION READ FUNCTIONS
\*****************************************************************************/
/*
* Due to the configuration being quite large, i decided to create 2 functions
* to return the keys and values separately. ( to prevent a buffer overflow )
*/
/*
* slurm_get_control_configuration_keys - Retreives the configuration
* from the slurm daemon and parses it into a numerically indexed
* array containg the keys that link to the values ( the values
* are retreived by the slurm_get_control_configuration_values
* function )
*
* RET a numerically indexed array containing keys that describe the
* values of the configuration of the slurm daemon, or a long
* value containing an error code
*
* NOTE : the error codes and their meaning are described in the
* section labelled EXTRA
*/
PHP_FUNCTION(slurm_get_control_configuration_keys);
/*
* slurm_get_control_configuration_values - Retreives the
* configuration from the slurm daemon and parses it into a
* numerically indexed array containg the values that link to the
* keys ( the keys are retreived by the
* slurm_get_control_configuration_keys function )
*
* RET a numerically indexed array containing the values of the
* configuration of the slurm daemon, or a long value containing
* an error code
* NOTE : the error codes and their meaning are described in the
* section labelled EXTRA
*/
PHP_FUNCTION(slurm_get_control_configuration_values);
/*****************************************************************************\
* SLURM JOB READ FUNCTIONS
\*****************************************************************************/
/*
* slurm_load_job_information - Loads the information of all the jobs,
* parses it and returns the values as an associative array where
* each key is the job id linking to an associative array with
* the information of the job
*
* RET an associative array containing the information of all jobs, or
* a long value containing an error code.
*
* NOTE : the error codes and their meaning are described in the
* section labelled EXTRA
*/
PHP_FUNCTION(slurm_load_job_information);
/*
* slurm_load_partition_jobs - Retreive the information of all the
* jobs running on a single partition.
*
* IN pname - The partition name as a string value
* OPTIONAL IN lngth - a long variable containing the length of the
* partitionname
* RET an associative array containing the information of all the jobs
* running on this partition. Or a long value containing an error
* code
* NOTE : the error codes and their meaning are described in the
* section labelled EXTRA
*/
PHP_FUNCTION(slurm_load_partition_jobs);
/*****************************************************************************\
* EXTRA
*****************************************************************************
*
* [ERROR CODES]
*
* -3 : no/incorrect variables where passed on
* -2 : An error occurred whilst trying to communicate
* with the daemon
* -1 : Your query produced no results
*
* [VERSION FORMATTING OPTIONS]
*
* 0 : major of the version number
* 1 : minor of the version number
* 2 : micro of the version number
* default : full version number
*
* [EXPLANATION]
*
* Consider the version number 2.2.3,
* if we were to split this into an array
* where the "." sign is the delimiter
* we would receive the following
*
* [2] => MAJOR
* [2] => MINOR
* [3] => MICRO
*
* When requesting the major you would
* only receive the major, when requesting
* the full version you would receive the array
* as depicted above.
*
\*****************************************************************************/
#define phpext_slurm_php_ptr &slurm_php_module_entry
#endif