File: Slurmdb.xs

package info (click to toggle)
slurm-wlm 20.11.7%2Breally20.11.4-2%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 48,216 kB
  • sloc: ansic: 441,290; exp: 88,649; sh: 8,457; javascript: 6,528; perl: 4,586; makefile: 4,459; python: 882
file content (265 lines) | stat: -rw-r--r-- 6,337 bytes parent folder | download | duplicates (4)
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
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "ppport.h"

#include <slurm/slurm.h>
#include <slurm/slurmdb.h>
#include "slurmdb-perl.h"

#include "const-c.inc"

extern void slurmdb_destroy_assoc_cond(void *object);
extern void slurmdb_destroy_cluster_cond(void *object);
extern void slurmdb_destroy_job_cond(void *object);
extern void slurmdb_destroy_user_cond(void *object);


MODULE = Slurmdb	PACKAGE = Slurmdb	PREFIX=slurmdb_

INCLUDE: const-xs.inc
PROTOTYPES: ENABLE

void*
slurmdb_connection_get(persist_conn_flags = NULL)
	void* persist_conn_flags

int
slurmdb_connection_close(db_conn)
	void* db_conn

SV*
slurmdb_clusters_get(db_conn, conditions)
	void* db_conn
	HV*   conditions
    INIT:
	AV*   results;
	HV*   rh;
	List  list = NULL;
	ListIterator itr;
	slurmdb_cluster_cond_t *cluster_cond =
		xmalloc(sizeof(slurmdb_cluster_cond_t));
	slurmdb_init_cluster_cond(cluster_cond, 0);
	slurmdb_cluster_rec_t *rec = NULL;

	if (hv_to_cluster_cond(conditions, cluster_cond) < 0) {
		XSRETURN_UNDEF;
	}
	results = (AV*)sv_2mortal((SV*)newAV());
    CODE:
	list = slurmdb_clusters_get(db_conn, cluster_cond);
	if (list) {
	    itr = slurm_list_iterator_create(list);

	    while ((rec = slurm_list_next(itr))) {
		rh = (HV *)sv_2mortal((SV*)newHV());
		if (cluster_rec_to_hv(rec, rh) < 0) {
		    XSRETURN_UNDEF;
		}
		av_push(results, newRV((SV*)rh));
	    }
	    slurm_list_destroy(list);
	}
	RETVAL = newRV((SV*)results);
	slurmdb_destroy_cluster_cond(cluster_cond);
    OUTPUT:
        RETVAL

SV*
slurmdb_report_cluster_account_by_user(db_conn, assoc_condition)
	void* db_conn
	HV*   assoc_condition
    INIT:
	AV*   results;
	List  list = NULL;
	slurmdb_assoc_cond_t *assoc_cond =
		xmalloc(sizeof(slurmdb_assoc_cond_t));

	if (hv_to_assoc_cond(assoc_condition, assoc_cond) < 0) {
		XSRETURN_UNDEF;
	}
	results = (AV*)sv_2mortal((SV*)newAV());
    CODE:
	list = slurmdb_report_cluster_account_by_user(db_conn, assoc_cond);
	if (list) {
	    if (report_cluster_rec_list_to_av(list, results) < 0) {
		XSRETURN_UNDEF;
	    }
	    slurm_list_destroy(list);
	}
	RETVAL = newRV((SV*)results);
	slurmdb_destroy_assoc_cond(assoc_cond);
    OUTPUT:
        RETVAL

SV*
slurmdb_report_cluster_user_by_account(db_conn, assoc_condition)
	void* db_conn
	HV*   assoc_condition
    INIT:
	AV*   results;
	List  list = NULL;
	slurmdb_assoc_cond_t *assoc_cond =
		xmalloc(sizeof(slurmdb_assoc_cond_t));

	if (hv_to_assoc_cond(assoc_condition, assoc_cond) < 0) {
		XSRETURN_UNDEF;
	}
	results = (AV*)sv_2mortal((SV*)newAV());
    CODE:
	list = slurmdb_report_cluster_user_by_account(db_conn, assoc_cond);
	if (list) {
	    if (report_cluster_rec_list_to_av(list, results) < 0) {
		XSRETURN_UNDEF;
	    }
	    slurm_list_destroy(list);
	}
	RETVAL = newRV((SV*)results);
	slurmdb_destroy_assoc_cond(assoc_cond);
    OUTPUT:
        RETVAL

SV*
slurmdb_report_job_sizes_grouped_by_account(db_conn, job_condition, grouping_array, flat_view, acct_as_parent)
	void* db_conn
	HV*   job_condition
	AV*   grouping_array
	bool  flat_view
	bool  acct_as_parent
    INIT:
	AV*   results;
	List  list = NULL;
	List grouping_list = slurm_list_create(NULL);
	slurmdb_job_cond_t *job_cond =
		xmalloc(sizeof(slurmdb_job_cond_t));
	if (hv_to_job_cond(job_condition, job_cond) < 0) {
		XSRETURN_UNDEF;
	}
	if (av_to_cluster_grouping_list(grouping_array, grouping_list) < 0) {
		XSRETURN_UNDEF;
	}
	results = (AV*)sv_2mortal((SV*)newAV());
    CODE:
	list = slurmdb_report_job_sizes_grouped_by_account(db_conn,
	                   job_cond, grouping_list, flat_view, acct_as_parent);
	if (list) {
	    if (cluster_grouping_list_to_av(list, results) < 0) {
		XSRETURN_UNDEF;
	    }
	    slurm_list_destroy(list);
	}
	RETVAL = newRV((SV*)results);
	slurmdb_destroy_job_cond(job_cond);
	slurm_list_destroy(grouping_list);
    OUTPUT:
        RETVAL

SV*
slurmdb_report_user_top_usage(db_conn, user_condition, group_accounts)
	void* db_conn
	HV*   user_condition
	bool  group_accounts
    INIT:
	AV*   results;
	List  list = NULL;
	slurmdb_user_cond_t *user_cond =
		xmalloc(sizeof(slurmdb_user_cond_t));
	user_cond->assoc_cond =
		xmalloc(sizeof(slurmdb_assoc_cond_t));
	if (hv_to_user_cond(user_condition, user_cond) < 0) {
		XSRETURN_UNDEF;
	}
	results = (AV*)sv_2mortal((SV*)newAV());
    CODE:
	list = slurmdb_report_user_top_usage(db_conn, user_cond,
					     group_accounts);
	if (list) {
	    if (report_cluster_rec_list_to_av(list, results) < 0) {
		XSRETURN_UNDEF;
	    }
	    slurm_list_destroy(list);
	}
	RETVAL = newRV((SV*)results);
	slurmdb_destroy_user_cond(user_cond);
    OUTPUT:
        RETVAL

SV*
slurmdb_jobs_get(db_conn, conditions)
	void* db_conn
	HV*   conditions
    INIT:
	AV*   results;
	HV*   rh;
	List  list = NULL;
	ListIterator itr;
	slurmdb_job_cond_t *job_cond =
		xmalloc(sizeof(slurmdb_job_cond_t));
	slurmdb_job_rec_t *rec = NULL;

	if (hv_to_job_cond(conditions, job_cond) < 0) {
		XSRETURN_UNDEF;
	}
	results = (AV*)sv_2mortal((SV*)newAV());
    CODE:
	list = slurmdb_jobs_get(db_conn, job_cond);
	if (list) {
	    itr = slurm_list_iterator_create(list);

	    while ((rec = slurm_list_next(itr))) {
		rh = (HV *)sv_2mortal((SV*)newHV());
		if (job_rec_to_hv(rec, rh) < 0) {
		    XSRETURN_UNDEF;
		}
		av_push(results, newRV((SV*)rh));
	    }
	    slurm_list_destroy(list);
	}
	RETVAL = newRV((SV*)results);
	slurmdb_destroy_job_cond(job_cond);
    OUTPUT:
        RETVAL


SV*
slurmdb_qos_get(db_conn, conditions)
	void* db_conn
	HV*   conditions
    INIT:
	AV*   results;
	HV*   rh;
	List  list = NULL, all = NULL;
	ListIterator itr;
	slurmdb_qos_cond_t *qos_cond =
		xmalloc(sizeof(slurmdb_qos_cond_t));
	slurmdb_qos_rec_t *rec = NULL;

	if (hv_to_qos_cond(conditions, qos_cond) < 0) {
		XSRETURN_UNDEF;
	}
	results = (AV*)sv_2mortal((SV*)newAV());
    CODE:
	list = slurmdb_qos_get(db_conn, qos_cond);
	all = slurmdb_qos_get(db_conn, NULL);
	if (list) {
	    itr = slurm_list_iterator_create(list);

	    while ((rec = slurm_list_next(itr))) {
		rh = (HV *)sv_2mortal((SV*)newHV());
		if (qos_rec_to_hv(rec, rh, all) < 0) {
		    XSRETURN_UNDEF;
		}
		av_push(results, newRV((SV*)rh));
	    }
	    slurm_list_destroy(list);
	}
	RETVAL = newRV((SV*)results);
	slurmdb_destroy_qos_cond(qos_cond);
    OUTPUT:
        RETVAL

UV
slurmdb_find_tres_count_in_string(tres_str_in, id)
	char *tres_str_in
	int id