1 /*****************************************************************************\ 2 * slurmdb.h - Interface codes and functions for slurm 3 ****************************************************************************** 4 * Copyright (C) 2010 Lawrence Livermore National Security. 5 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). 6 * Written by Danny Auble da@llnl.gov, et. al. 7 * CODE-OCEC-09-009. All rights reserved. 8 * 9 * This file is part of Slurm, a resource management program. 10 * For details, see <https://slurm.schedmd.com/>. 11 * Please also read the included file: DISCLAIMER. 12 * 13 * Slurm is free software; you can redistribute it and/or modify it under 14 * the terms of the GNU General Public License as published by the Free 15 * Software Foundation; either version 2 of the License, or (at your option) 16 * any later version. 17 * 18 * In addition, as a special exception, the copyright holders give permission 19 * to link the code of portions of this program with the OpenSSL library under 20 * certain conditions as described in each individual source file, and 21 * distribute linked combinations including the two. You must obey the GNU 22 * General Public License in all respects for all of the code used other than 23 * OpenSSL. If you modify file(s) with this exception, you may extend this 24 * exception to your version of the file(s), but you are not obligated to do 25 * so. If you do not wish to do so, delete this exception statement from your 26 * version. If you delete this exception statement from all source files in 27 * the program, then also delete it here. 28 * 29 * Slurm is distributed in the hope that it will be useful, but WITHOUT ANY 30 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 31 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 32 * details. 33 * 34 * You should have received a copy of the GNU General Public License along 35 * with Slurm; if not, write to the Free Software Foundation, Inc., 36 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 37 \*****************************************************************************/ 38 #ifndef _SLURMDB_H 39 #define _SLURMDB_H 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 #include <slurm/slurm.h> 46 47 typedef enum { 48 SLURMDB_ADMIN_NOTSET, 49 SLURMDB_ADMIN_NONE, 50 SLURMDB_ADMIN_OPERATOR, 51 SLURMDB_ADMIN_SUPER_USER 52 } slurmdb_admin_level_t; 53 54 typedef enum { 55 SLURMDB_CLASS_NONE, /* no class given */ 56 SLURMDB_CLASS_CAPABILITY, /* capability cluster */ 57 SLURMDB_CLASS_CAPACITY, /* capacity cluster */ 58 SLURMDB_CLASS_CAPAPACITY, /* a cluster that is both capability 59 * and capacity */ 60 } slurmdb_classification_type_t; 61 62 typedef enum { 63 SLURMDB_EVENT_ALL, 64 SLURMDB_EVENT_CLUSTER, 65 SLURMDB_EVENT_NODE 66 } slurmdb_event_type_t; 67 68 typedef enum { 69 SLURMDB_PROBLEM_NOT_SET, 70 SLURMDB_PROBLEM_ACCT_NO_ASSOC, 71 SLURMDB_PROBLEM_ACCT_NO_USERS, 72 SLURMDB_PROBLEM_USER_NO_ASSOC, 73 SLURMDB_PROBLEM_USER_NO_UID, 74 } slurmdb_problem_type_t; 75 76 typedef enum { 77 SLURMDB_REPORT_SORT_TIME, 78 SLURMDB_REPORT_SORT_NAME 79 } slurmdb_report_sort_t; 80 81 typedef enum { 82 SLURMDB_REPORT_TIME_SECS, 83 SLURMDB_REPORT_TIME_MINS, 84 SLURMDB_REPORT_TIME_HOURS, 85 SLURMDB_REPORT_TIME_PERCENT, 86 SLURMDB_REPORT_TIME_SECS_PER, 87 SLURMDB_REPORT_TIME_MINS_PER, 88 SLURMDB_REPORT_TIME_HOURS_PER, 89 } slurmdb_report_time_format_t; 90 91 typedef enum { 92 SLURMDB_RESOURCE_NOTSET, 93 SLURMDB_RESOURCE_LICENSE 94 } slurmdb_resource_type_t; 95 96 typedef enum { 97 SLURMDB_UPDATE_NOTSET, 98 SLURMDB_ADD_USER, 99 SLURMDB_ADD_ASSOC, 100 SLURMDB_ADD_COORD, 101 SLURMDB_MODIFY_USER, 102 SLURMDB_MODIFY_ASSOC, 103 SLURMDB_REMOVE_USER, 104 SLURMDB_REMOVE_ASSOC, 105 SLURMDB_REMOVE_COORD, 106 SLURMDB_ADD_QOS, 107 SLURMDB_REMOVE_QOS, 108 SLURMDB_MODIFY_QOS, 109 SLURMDB_ADD_WCKEY, 110 SLURMDB_REMOVE_WCKEY, 111 SLURMDB_MODIFY_WCKEY, 112 SLURMDB_ADD_CLUSTER, 113 SLURMDB_REMOVE_CLUSTER, 114 SLURMDB_REMOVE_ASSOC_USAGE, 115 SLURMDB_ADD_RES, 116 SLURMDB_REMOVE_RES, 117 SLURMDB_MODIFY_RES, 118 SLURMDB_REMOVE_QOS_USAGE, 119 SLURMDB_ADD_TRES, 120 SLURMDB_UPDATE_FEDS, 121 } slurmdb_update_type_t; 122 123 /* Define QOS flags */ 124 #define QOS_FLAG_BASE 0x0fffffff 125 #define QOS_FLAG_NOTSET 0x10000000 126 #define QOS_FLAG_ADD 0x20000000 127 #define QOS_FLAG_REMOVE 0x40000000 128 129 #define QOS_FLAG_PART_MIN_NODE 0x00000001 130 #define QOS_FLAG_PART_MAX_NODE 0x00000002 131 #define QOS_FLAG_PART_TIME_LIMIT 0x00000004 132 #define QOS_FLAG_ENFORCE_USAGE_THRES 0x00000008 133 #define QOS_FLAG_NO_RESERVE 0x00000010 134 #define QOS_FLAG_REQ_RESV 0x00000020 135 #define QOS_FLAG_DENY_LIMIT 0x00000040 136 #define QOS_FLAG_OVER_PART_QOS 0x00000080 137 #define QOS_FLAG_NO_DECAY 0x00000100 138 #define QOS_FLAG_USAGE_FACTOR_SAFE 0x00000200 139 140 /* Define Server Resource flags */ 141 #define SLURMDB_RES_FLAG_BASE 0x0fffffff /* apply to get real flags */ 142 #define SLURMDB_RES_FLAG_NOTSET 0x10000000 143 #define SLURMDB_RES_FLAG_ADD 0x20000000 144 #define SLURMDB_RES_FLAG_REMOVE 0x40000000 145 146 /* Define Federation flags */ 147 #define FEDERATION_FLAG_BASE 0x0fffffff 148 #define FEDERATION_FLAG_NOTSET 0x10000000 149 #define FEDERATION_FLAG_ADD 0x20000000 150 #define FEDERATION_FLAG_REMOVE 0x40000000 151 152 /* SLURM CLUSTER FEDERATION STATES */ 153 enum cluster_fed_states { 154 CLUSTER_FED_STATE_NA, 155 CLUSTER_FED_STATE_ACTIVE, 156 CLUSTER_FED_STATE_INACTIVE 157 }; 158 #define CLUSTER_FED_STATE_BASE 0x000f 159 #define CLUSTER_FED_STATE_FLAGS 0xfff0 160 #define CLUSTER_FED_STATE_DRAIN 0x0010 /* drain cluster by not accepting 161 any new jobs and waiting for all 162 federated jobs to complete.*/ 163 #define CLUSTER_FED_STATE_REMOVE 0x0020 /* remove cluster from federation 164 once cluster is drained of 165 federated jobs */ 166 167 /* flags and types of resources */ 168 /* when we come up with some */ 169 170 /* 171 * Translation of db_flags in job_record_t and flag 172 * slurmdb_job_[rec|cond]_t 173 */ 174 #define SLURMDB_JOB_FLAG_NONE 0x00000000 /* No flags */ 175 #define SLURMDB_JOB_CLEAR_SCHED 0x0000000f /* clear scheduling bits */ 176 #define SLURMDB_JOB_FLAG_NOTSET 0x00000001 /* Not set */ 177 #define SLURMDB_JOB_FLAG_SUBMIT 0x00000002 /* Job was started on submit */ 178 #define SLURMDB_JOB_FLAG_SCHED 0x00000004 /* Job was started from main 179 * scheduler */ 180 #define SLURMDB_JOB_FLAG_BACKFILL 0x00000008 /* Job was started from backfill */ 181 182 /* 183 * Slurm job condition flags 184 * slurmdb_job_cond_t 185 */ 186 #define JOBCOND_FLAG_DUP 0x00000001 /* Report duplicate job entries */ 187 #define JOBCOND_FLAG_NO_STEP 0x00000002 /* Don't report job step info */ 188 #define JOBCOND_FLAG_NO_TRUNC 0x00000004 /* Report info. without truncating 189 * the time to the usage_start and 190 * usage_end */ 191 #define JOBCOND_FLAG_RUNAWAY 0x00000008 /* Report runaway jobs only */ 192 #define JOBCOND_FLAG_WHOLE_HETJOB 0x00000010 /* Report info about all hetjob 193 * components 194 */ 195 #define JOBCOND_FLAG_NO_WHOLE_HETJOB 0x00000020 /* Only report info about 196 * requested hetjob components 197 */ 198 #define JOBCOND_FLAG_NO_WAIT 0x00000040 /* Tell dbd plugin not to wait 199 * around for result. 200 */ 201 #define JOBCOND_FLAG_NO_DEFAULT_USAGE 0x00000080 /* Use usage_time as the 202 * submit_time of the job. 203 */ 204 #define JOBCOND_FLAG_DBD_UID 0x00000100 /* give me the uid from the dbd 205 * instead of filling it in 206 * later. 207 */ 208 209 /* Archive / Purge time flags */ 210 #define SLURMDB_PURGE_BASE 0x0000ffff /* Apply to get the number 211 * of units */ 212 #define SLURMDB_PURGE_FLAGS 0xffff0000 /* apply to get the flags */ 213 #define SLURMDB_PURGE_HOURS 0x00010000 /* Purge units are in hours */ 214 #define SLURMDB_PURGE_DAYS 0x00020000 /* Purge units are in days */ 215 #define SLURMDB_PURGE_MONTHS 0x00040000 /* Purge units are in months, 216 * the default */ 217 #define SLURMDB_PURGE_ARCHIVE 0x00080000 /* Archive before purge */ 218 219 /* Parent account should be used when calculating FairShare */ 220 #define SLURMDB_FS_USE_PARENT 0x7FFFFFFF 221 222 #define SLURMDB_CLASSIFIED_FLAG 0x0100 223 #define SLURMDB_CLASS_BASE 0x00ff 224 225 /* Cluster flags */ 226 #define CLUSTER_FLAG_A1 0x00000001 /* UNUSED */ 227 #define CLUSTER_FLAG_A2 0x00000002 /* UNUSED */ 228 #define CLUSTER_FLAG_A3 0x00000004 /* UNUSED */ 229 #define CLUSTER_FLAG_A4 0x00000008 /* UNUSED */ 230 #define CLUSTER_FLAG_A5 0x00000010 /* UNUSED */ 231 #define CLUSTER_FLAG_A6 0x00000020 /* UNUSED */ 232 #define CLUSTER_FLAG_A7 0x00000040 /* UNUSED */ 233 #define CLUSTER_FLAG_MULTSD 0x00000080 /* This cluster is multiple slurmd */ 234 #define CLUSTER_FLAG_CRAYXT 0x00000100 /* This cluster is a ALPS cray 235 * Removed v19.05 */ 236 #define CLUSTER_FLAG_CRAY_A 0x00000100 /* This cluster is a ALPS cray 237 * Removed v19.05 */ 238 #define CLUSTER_FLAG_FE 0x00000200 /* This cluster is a front end system */ 239 #define CLUSTER_FLAG_CRAY_N 0x00000400 /* This cluster is a Native cray */ 240 #define CLUSTER_FLAG_FED 0x00000800 /* This cluster is in a federation. */ 241 #define CLUSTER_FLAG_EXT 0x00001000 /* This cluster is external */ 242 243 244 /* Cluster Combo flags */ 245 #define CLUSTER_FLAG_CRAY 0x00000500 /* This cluster is a cray. 246 Combo of CRAY_A | CRAY_N */ 247 248 /********************************************/ 249 250 /* Association conditions used for queries of the database */ 251 252 /* slurmdb_tres_rec_t is used in other structures below so this needs 253 * to be declared before hand. 254 */ 255 typedef struct { 256 uint64_t alloc_secs; /* total amount of secs allocated if used in an 257 accounting_list */ 258 uint32_t rec_count; /* number of records alloc_secs is, DON'T PACK */ 259 uint64_t count; /* Count of TRES on a given cluster, 0 if 260 * listed generically. */ 261 uint32_t id; /* Database ID for the TRES */ 262 char *name; /* Name of TRES if type is generic like GRES 263 * or License. Make include optional GRES type 264 * (e.g. "gpu" or "gpu:tesla") */ 265 char *type; /* Type of TRES (CPU, MEM, etc) */ 266 } slurmdb_tres_rec_t; 267 268 /* slurmdb_assoc_cond_t is used in other structures below so 269 * this needs to be declared first. 270 */ 271 typedef struct { 272 List acct_list; /* list of char * */ 273 List cluster_list; /* list of char * */ 274 275 List def_qos_id_list; /* list of char * */ 276 277 List format_list; /* list of char * */ 278 List id_list; /* list of char */ 279 280 uint16_t only_defs; /* only send back defaults */ 281 282 List parent_acct_list; /* name of parent account */ 283 List partition_list; /* list of char * */ 284 285 List qos_list; /* list of char * */ 286 287 time_t usage_end; 288 time_t usage_start; 289 290 List user_list; /* list of char * */ 291 292 uint16_t with_usage; /* fill in usage */ 293 uint16_t with_deleted; /* return deleted associations */ 294 uint16_t with_raw_qos; /* return a raw qos or delta_qos */ 295 uint16_t with_sub_accts; /* return sub acct information also */ 296 uint16_t without_parent_info; /* don't give me parent id/name */ 297 uint16_t without_parent_limits; /* don't give me limits from 298 * parents */ 299 } slurmdb_assoc_cond_t; 300 301 /* slurmdb_job_cond_t is used by slurmdb_archive_cond_t so it needs to 302 * be defined before hand. 303 */ 304 typedef struct { 305 List acct_list; /* list of char * */ 306 List associd_list; /* list of char */ 307 List cluster_list; /* list of char * */ 308 List constraint_list; /* list of char * */ 309 uint32_t cpus_max; /* number of cpus high range */ 310 uint32_t cpus_min; /* number of cpus low range */ 311 uint32_t db_flags; /* flags sent from the slurmctld on the job */ 312 int32_t exitcode; /* exit code of job */ 313 uint32_t flags; /* Reporting flags*/ 314 List format_list; /* list of char * */ 315 List groupid_list; /* list of char * */ 316 List jobname_list; /* list of char * */ 317 uint32_t nodes_max; /* number of nodes high range */ 318 uint32_t nodes_min; /* number of nodes low range */ 319 List partition_list; /* list of char * */ 320 List qos_list; /* list of char * */ 321 List reason_list; /* list of char * */ 322 List resv_list; /* list of char * */ 323 List resvid_list; /* list of char * */ 324 List state_list; /* list of char * */ 325 List step_list; /* list of slurmdb_selected_step_t */ 326 uint32_t timelimit_max; /* max timelimit */ 327 uint32_t timelimit_min; /* min timelimit */ 328 time_t usage_end; 329 time_t usage_start; 330 char *used_nodes; /* a ranged node string where jobs ran */ 331 List userid_list; /* list of char * */ 332 List wckey_list; /* list of char * */ 333 } slurmdb_job_cond_t; 334 335 /* slurmdb_stats_t needs to be defined before slurmdb_job_rec_t and 336 * slurmdb_step_rec_t. 337 */ 338 typedef struct { 339 double act_cpufreq; /* contains actual average cpu frequency */ 340 uint64_t consumed_energy; /* contains energy consumption in joules */ 341 char *tres_usage_in_ave; /* average amount of usage in data */ 342 char *tres_usage_in_max; /* contains max amount of usage in data */ 343 char *tres_usage_in_max_nodeid; /* contains node number max was on */ 344 char *tres_usage_in_max_taskid; /* contains task number max was on */ 345 char *tres_usage_in_min; /* contains min amount of usage in data */ 346 char *tres_usage_in_min_nodeid; /* contains node number min was on */ 347 char *tres_usage_in_min_taskid; /* contains task number min was on */ 348 char *tres_usage_in_tot; /* total amount of usage in data */ 349 char *tres_usage_out_ave; /* average amount of usage out data */ 350 char *tres_usage_out_max; /* contains amount of max usage out data */ 351 char *tres_usage_out_max_nodeid; /* contains node number max was on */ 352 char *tres_usage_out_max_taskid; /* contains task number max was on */ 353 char *tres_usage_out_min; /* contains amount of min usage out data */ 354 char *tres_usage_out_min_nodeid; /* contains node number min was on */ 355 char *tres_usage_out_min_taskid; /* contains task number min was on */ 356 char *tres_usage_out_tot; /* total amount of usage out data */ 357 } slurmdb_stats_t; 358 359 /************** alphabetical order of structures **************/ 360 361 typedef struct { 362 slurmdb_assoc_cond_t *assoc_cond;/* use acct_list here for 363 names */ 364 List description_list; /* list of char * */ 365 List organization_list; /* list of char * */ 366 uint16_t with_assocs; 367 uint16_t with_coords; 368 uint16_t with_deleted; 369 } slurmdb_account_cond_t; 370 371 typedef struct { 372 List assoc_list; /* list of slurmdb_assoc_rec_t *'s */ 373 List coordinators; /* list of slurmdb_coord_rec_t *'s */ 374 char *description; 375 char *name; 376 char *organization; 377 } slurmdb_account_rec_t; 378 379 typedef struct { 380 uint64_t alloc_secs; /* number of cpu seconds allocated */ 381 uint32_t id; /* association/wckey ID */ 382 time_t period_start; /* when this record was started */ 383 slurmdb_tres_rec_t tres_rec; 384 } slurmdb_accounting_rec_t; 385 386 typedef struct { 387 char *archive_dir; /* location to place archive file */ 388 char *archive_script; /* script to run instead of default 389 actions */ 390 slurmdb_job_cond_t *job_cond; /* conditions for the jobs to archive */ 391 uint32_t purge_event; /* purge events older than this in 392 * months by default set the 393 * SLURMDB_PURGE_ARCHIVE bit for 394 * archiving */ 395 uint32_t purge_job; /* purge jobs older than this in months 396 * by default set the 397 * SLURMDB_PURGE_ARCHIVE bit for 398 * archiving */ 399 uint32_t purge_resv; /* purge reservations older than this in months 400 * by default set the 401 * SLURMDB_PURGE_ARCHIVE bit for 402 * archiving */ 403 uint32_t purge_step; /* purge steps older than this in months 404 * by default set the 405 * SLURMDB_PURGE_ARCHIVE bit for 406 * archiving */ 407 uint32_t purge_suspend; /* purge suspend data older than this 408 * in months by default set the 409 * SLURMDB_PURGE_ARCHIVE bit for 410 * archiving */ 411 uint32_t purge_txn; /* purge transaction data older than this 412 * in months by default set the 413 * SLURMDB_PURGE_ARCHIVE bit for 414 * archiving */ 415 uint32_t purge_usage; /* purge usage data older than this 416 * in months by default set the 417 * SLURMDB_PURGE_ARCHIVE bit for 418 * archiving */ 419 } slurmdb_archive_cond_t; 420 421 typedef struct { 422 char *archive_file; /* archive file containing data that was 423 once flushed from the database */ 424 char *insert; /* an sql statement to be ran containing the 425 insert of jobs since past */ 426 } slurmdb_archive_rec_t; 427 428 typedef struct { 429 uint64_t count; /* Count of tres on a given cluster, 0 if 430 listed generically. */ 431 List format_list;/* list of char * */ 432 List id_list; /* Database ID */ 433 List name_list; /* Name of tres if type is generic like GRES 434 or License. */ 435 List type_list; /* Type of tres (CPU, MEM, etc) */ 436 uint16_t with_deleted; 437 } slurmdb_tres_cond_t; 438 439 /* slurmdb_tres_rec_t is defined above alphabetical */ 440 441 /* slurmdb_assoc_cond_t is defined above alphabetical */ 442 443 /* This has slurmdb_assoc_rec_t's in it so we define the struct afterwards. */ 444 typedef struct slurmdb_assoc_usage slurmdb_assoc_usage_t; 445 typedef struct slurmdb_bf_usage slurmdb_bf_usage_t; 446 typedef struct slurmdb_user_rec slurmdb_user_rec_t; 447 448 typedef struct slurmdb_assoc_rec { 449 List accounting_list; /* list of slurmdb_accounting_rec_t *'s */ 450 char *acct; /* account/project associated to 451 * assoc */ 452 struct slurmdb_assoc_rec *assoc_next; /* next assoc with 453 * same hash index 454 * based off the 455 * account/user 456 * DOESN'T GET PACKED */ 457 struct slurmdb_assoc_rec *assoc_next_id; /* next assoc with 458 * same hash index 459 * DOESN'T GET PACKED */ 460 slurmdb_bf_usage_t *bf_usage; /* data for backfill scheduler, 461 * (DON'T PACK) */ 462 char *cluster; /* cluster associated to association */ 463 464 uint32_t def_qos_id; /* Which QOS id is this 465 * associations default */ 466 467 uint32_t grp_jobs; /* max number of jobs the 468 * underlying group of associations can run 469 * at one time */ 470 uint32_t grp_jobs_accrue; /* max number of jobs the 471 * underlying group of associations can have 472 * accruing priority at one time */ 473 uint32_t grp_submit_jobs; /* max number of jobs the 474 * underlying group of 475 * associations can submit at 476 * one time */ 477 char *grp_tres; /* max number of cpus the 478 * underlying group of 479 * associations can allocate at one time */ 480 uint64_t *grp_tres_ctld; /* grp_tres broken out in an array 481 * based off the ordering of the total 482 * number of TRES in the system 483 * (DON'T PACK) */ 484 char *grp_tres_mins; /* max number of cpu minutes the 485 * underlying group of 486 * associations can run for */ 487 uint64_t *grp_tres_mins_ctld; /* grp_tres_mins broken out in an array 488 * based off the ordering of the total 489 * number of TRES in the system 490 * (DON'T PACK) */ 491 char *grp_tres_run_mins; /* max number of cpu minutes the 492 * underlying group of 493 * assoiciations can 494 * having running at one time */ 495 uint64_t *grp_tres_run_mins_ctld; /* grp_tres_run_mins 496 * broken out in an array 497 * based off the ordering 498 * of the total number of TRES in 499 * the system 500 * (DON'T PACK) */ 501 uint32_t grp_wall; /* total time in hours the 502 * underlying group of 503 * associations can run for */ 504 505 uint32_t id; /* id identifing a combination of 506 * user-account-cluster(-partition) */ 507 508 uint16_t is_def; /* Is this the users default assoc/acct */ 509 510 uint32_t lft; /* lft used for grouping sub 511 * associations and jobs as a left 512 * most container used with rgt */ 513 514 uint32_t max_jobs; /* max number of jobs this 515 * association can run at one time */ 516 uint32_t max_jobs_accrue; /* max number of jobs this association can 517 * have accruing priority time. 518 */ 519 uint32_t max_submit_jobs; /* max number of jobs that can be 520 submitted by association */ 521 char *max_tres_mins_pj; /* max number of cpu seconds this 522 * association can have per job */ 523 uint64_t *max_tres_mins_ctld; /* max_tres_mins broken out in an array 524 * based off the ordering of the 525 * total number of TRES in the system 526 * (DON'T PACK) */ 527 char *max_tres_run_mins; /* max number of cpu minutes this 528 * association can 529 * having running at one time */ 530 uint64_t *max_tres_run_mins_ctld; /* max_tres_run_mins 531 * broken out in an array 532 * based off the ordering 533 * of the total number of TRES in 534 * the system 535 * (DON'T PACK) */ 536 char *max_tres_pj; /* max number of cpus this 537 * association can allocate per job */ 538 uint64_t *max_tres_ctld; /* max_tres broken out in an array 539 * based off the ordering of the 540 * total number of TRES in the system 541 * (DON'T PACK) */ 542 char *max_tres_pn; /* max number of TRES this 543 * association can allocate per node */ 544 uint64_t *max_tres_pn_ctld; /* max_tres_pn broken out in an array 545 * based off the ordering of the 546 * total number of TRES in the system 547 * (DON'T PACK) */ 548 uint32_t max_wall_pj; /* longest time this 549 * association can run a job */ 550 551 uint32_t min_prio_thresh; /* Don't reserve resources for pending jobs 552 * unless they have a priority equal to or 553 * higher than this. */ 554 char *parent_acct; /* name of parent account */ 555 uint32_t parent_id; /* id of parent account */ 556 char *partition; /* optional partition in a cluster 557 * associated to association */ 558 uint32_t priority; /* association priority */ 559 List qos_list; /* list of char * */ 560 561 uint32_t rgt; /* rgt used for grouping sub 562 * associations and jobs as a right 563 * most container used with lft */ 564 565 uint32_t shares_raw; /* number of shares allocated to 566 * association */ 567 568 uint32_t uid; /* user ID */ 569 slurmdb_assoc_usage_t *usage; 570 char *user; /* user associated to assoc */ 571 slurmdb_user_rec_t *user_rec; /* Cache of user record 572 * soft ref - mem not managed here 573 * (DON'T PACK) 574 */ 575 } slurmdb_assoc_rec_t; 576 577 struct slurmdb_assoc_usage { 578 uint32_t accrue_cnt; /* Count of how many jobs I have accuring prio 579 * (DON'T PACK for state file) */ 580 List children_list; /* list of children associations 581 * (DON'T PACK) */ 582 bitstr_t *grp_node_bitmap; /* Bitmap of allocated nodes 583 * (DON'T PACK) */ 584 uint16_t *grp_node_job_cnt; /* Count of jobs allocated on each node 585 * (DON'T PACK) */ 586 uint64_t *grp_used_tres; /* array of active tres counts 587 * (DON'T PACK for state file) */ 588 uint64_t *grp_used_tres_run_secs; /* array of running tres secs 589 * (DON'T PACK for state file) */ 590 591 double grp_used_wall; /* group count of time used in running jobs */ 592 double fs_factor; /* Fairshare factor. Not used by all algorithms 593 * (DON'T PACK for state file) */ 594 uint32_t level_shares; /* number of shares on this level of 595 * the tree (DON'T PACK for state file) */ 596 597 slurmdb_assoc_rec_t *parent_assoc_ptr; /* ptr to direct 598 * parent assoc 599 * set in slurmctld 600 * (DON'T PACK) */ 601 602 double priority_norm; /* normalized priority (DON'T PACK for 603 * state file) */ 604 605 slurmdb_assoc_rec_t *fs_assoc_ptr; /* ptr to fairshare parent 606 * assoc if fairshare 607 * == SLURMDB_FS_USE_PARENT 608 * set in slurmctld 609 * (DON'T PACK) */ 610 611 double shares_norm; /* normalized shares 612 * (DON'T PACK for state file) */ 613 614 uint32_t tres_cnt; /* size of the tres arrays, 615 * (DON'T PACK for state file) */ 616 long double usage_efctv;/* effective, normalized usage 617 * (DON'T PACK for state file) */ 618 long double usage_norm; /* normalized usage 619 * (DON'T PACK for state file) */ 620 long double usage_raw; /* measure of TRESBillableUnits usage */ 621 622 long double *usage_tres_raw; /* measure of each TRES usage */ 623 uint32_t used_jobs; /* count of active jobs 624 * (DON'T PACK for state file) */ 625 uint32_t used_submit_jobs; /* count of jobs pending or running 626 * (DON'T PACK for state file) */ 627 628 /* Currently FAIR_TREE systems are defining data on 629 * this struct but instead we could keep a void pointer to system 630 * specific data. This would allow subsystems to define whatever data 631 * they need without having to modify this struct; it would also save 632 * space. 633 */ 634 long double level_fs; /* (FAIR_TREE) Result of fairshare equation 635 * compared to the association's siblings 636 * (DON'T PACK for state file) */ 637 638 bitstr_t *valid_qos; /* qos available for this association 639 * derived from the qos_list. 640 * (DON'T PACK for state file) */ 641 }; 642 643 struct slurmdb_bf_usage { 644 uint64_t count; 645 time_t last_sched; 646 }; 647 648 typedef struct { 649 uint16_t classification; /* how this machine is classified */ 650 List cluster_list; /* list of char * */ 651 List federation_list; /* list of char */ 652 uint32_t flags; 653 List format_list; /* list of char * */ 654 List plugin_id_select_list; /* list of char * */ 655 List rpc_version_list; /* list of char * */ 656 time_t usage_end; 657 time_t usage_start; 658 uint16_t with_deleted; 659 uint16_t with_usage; 660 } slurmdb_cluster_cond_t; 661 662 typedef struct { 663 List feature_list; /* list of cluster features */ 664 uint32_t id; /* id of cluster in federation */ 665 char *name; /* Federation name */ 666 void *recv; /* slurm_persist_conn_t we recv information about this 667 * sibling on. (We get this information) */ 668 void *send; /* slurm_persist_conn_t we send information to this 669 * cluster on. (We set this information) */ 670 uint32_t state; /* state of cluster in federation */ 671 bool sync_recvd; /* true sync jobs from sib has been processed. */ 672 bool sync_sent; /* true after sib sent sync jobs to sibling */ 673 } slurmdb_cluster_fed_t; 674 675 struct slurmdb_cluster_rec { 676 List accounting_list; /* list of slurmdb_cluster_accounting_rec_t *'s */ 677 uint16_t classification; /* how this machine is classified */ 678 time_t comm_fail_time; /* avoid constant error messages. For 679 * convenience only. DOESN'T GET PACKED */ 680 slurm_addr_t control_addr; /* For convenience only. 681 * DOESN'T GET PACKED */ 682 char *control_host; 683 uint32_t control_port; 684 uint16_t dimensions; /* number of dimensions this cluster is */ 685 int *dim_size; /* For convenience only. 686 * Size of each dimension For now only on 687 * a bluegene cluster. DOESN'T GET 688 * PACKED, is set up in slurmdb_get_info_cluster */ 689 slurmdb_cluster_fed_t fed; /* Federation information */ 690 uint32_t flags; /* set of CLUSTER_FLAG_* */ 691 pthread_mutex_t lock; /* For convenience only. DOESN"T GET PACKED */ 692 char *name; 693 char *nodes; 694 uint32_t plugin_id_select; /* id of the select plugin */ 695 slurmdb_assoc_rec_t *root_assoc; /* root assoc for 696 * cluster */ 697 uint16_t rpc_version; /* rpc version this cluster is running */ 698 List send_rpc; /* For convenience only. DOESN'T GET PACKED */ 699 char *tres_str; /* comma separated list of TRES */ 700 }; 701 702 #ifndef __slurmdb_cluster_rec_t_defined 703 # define __slurmdb_cluster_rec_t_defined 704 typedef struct slurmdb_cluster_rec slurmdb_cluster_rec_t; 705 #endif 706 707 typedef struct { 708 uint64_t alloc_secs; /* number of cpu seconds allocated */ 709 uint64_t down_secs; /* number of cpu seconds down */ 710 uint64_t idle_secs; /* number of cpu seconds idle */ 711 uint64_t over_secs; /* number of cpu seconds overcommitted */ 712 uint64_t pdown_secs; /* number of cpu seconds planned down */ 713 time_t period_start; /* when this record was started */ 714 uint64_t resv_secs; /* number of cpu seconds reserved */ 715 slurmdb_tres_rec_t tres_rec; 716 } slurmdb_cluster_accounting_rec_t; 717 718 typedef struct { 719 char *cluster; /* name of cluster */ 720 uint16_t percent_allowed; /* percentage of total resources 721 * allowed for this cluster */ 722 } slurmdb_clus_res_rec_t; 723 724 typedef struct { 725 char *name; 726 uint16_t direct; 727 } slurmdb_coord_rec_t; 728 729 typedef struct { 730 List cluster_list; /* list of char * */ 731 uint32_t cpus_max; /* number of cpus high range */ 732 uint32_t cpus_min; /* number of cpus low range */ 733 uint16_t event_type; /* type of events (slurmdb_event_type_t), 734 * default is all */ 735 List format_list; /* list of char * */ 736 char *node_list; /* node list string */ 737 time_t period_end; /* period end of events */ 738 time_t period_start; /* period start of events */ 739 List reason_list; /* list of char * */ 740 List reason_uid_list; /* list of char * */ 741 List state_list; /* list of char * */ 742 } slurmdb_event_cond_t; 743 744 typedef struct { 745 char *cluster; /* Name of associated cluster */ 746 char *cluster_nodes; /* node list in cluster during time 747 * period (only set in a cluster event) */ 748 uint16_t event_type; /* type of event (slurmdb_event_type_t) */ 749 char *node_name; /* Name of node (only set in a node event) */ 750 time_t period_end; /* End of period */ 751 time_t period_start; /* Start of period */ 752 char *reason; /* reason node is in state during time 753 period (only set in a node event) */ 754 uint32_t reason_uid; /* uid of that who set the reason */ 755 uint32_t state; /* State of node during time 756 period (only set in a node event) */ 757 char *tres_str; /* TRES touched by this event */ 758 } slurmdb_event_rec_t; 759 760 typedef struct { 761 List cluster_list; /* list of char * */ 762 List federation_list; /* list of char * */ 763 List format_list; /* list of char * */ 764 uint16_t with_deleted; 765 } slurmdb_federation_cond_t; 766 767 typedef struct { 768 char *name; /* Name of federation */ 769 uint32_t flags; /* flags to control scheduling on controller */ 770 List cluster_list; /* List of slurmdb_cluster_rec_t *'s */ 771 } slurmdb_federation_rec_t; 772 773 /* slurmdb_job_cond_t is defined above alphabetical */ 774 775 typedef struct { 776 char *account; 777 char *admin_comment; 778 char *alloc_gres; 779 uint32_t alloc_nodes; 780 uint32_t array_job_id; /* job_id of a job array or 0 if N/A */ 781 uint32_t array_max_tasks; /* How many tasks of the array can be 782 running at one time. 783 */ 784 uint32_t array_task_id; /* task_id of a job array of NO_VAL 785 * if N/A */ 786 char *array_task_str; /* If pending these are the array 787 tasks this record represents. 788 */ 789 uint32_t associd; 790 char *blockid; 791 char *cluster; 792 char *constraints; 793 uint64_t db_index; /* index in the table */ 794 uint32_t derived_ec; 795 char *derived_es; /* aka "comment" */ 796 uint32_t elapsed; 797 time_t eligible; 798 time_t end; 799 uint32_t exitcode; 800 uint32_t flags; 801 void *first_step_ptr; 802 uint32_t gid; 803 uint32_t het_job_id; 804 uint32_t het_job_offset; 805 uint32_t jobid; 806 char *jobname; 807 uint32_t lft; 808 char *mcs_label; 809 char *nodes; 810 char *partition; 811 uint32_t priority; 812 uint32_t qosid; 813 uint32_t req_cpus; 814 char *req_gres; 815 uint64_t req_mem; 816 uint32_t requid; 817 uint32_t resvid; 818 char *resv_name; 819 uint32_t show_full; 820 time_t start; 821 uint32_t state; 822 uint32_t state_reason_prev; 823 slurmdb_stats_t stats; 824 List steps; /* list of slurmdb_step_rec_t *'s */ 825 time_t submit; 826 uint32_t suspended; 827 char *system_comment; 828 uint32_t sys_cpu_sec; 829 uint32_t sys_cpu_usec; 830 uint32_t timelimit; 831 uint32_t tot_cpu_sec; 832 uint32_t tot_cpu_usec; 833 uint16_t track_steps; 834 char *tres_alloc_str; 835 char *tres_req_str; 836 uint32_t uid; 837 char *used_gres; 838 char *user; 839 uint32_t user_cpu_sec; 840 uint32_t user_cpu_usec; 841 char *wckey; 842 uint32_t wckeyid; 843 char *work_dir; 844 } slurmdb_job_rec_t; 845 846 typedef struct { 847 uint32_t accrue_cnt; /* Count of how many jobs I have accuring prio 848 * (DON'T PACK for state file) */ 849 List acct_limit_list; /* slurmdb_used_limits_t's (DON'T PACK 850 * for state file) */ 851 List job_list; /* list of job pointers to submitted/running 852 jobs (DON'T PACK) */ 853 bitstr_t *grp_node_bitmap; /* Bitmap of allocated nodes 854 * (DON'T PACK) */ 855 uint16_t *grp_node_job_cnt; /* Count of jobs allocated on each node 856 * (DON'T PACK) */ 857 uint32_t grp_used_jobs; /* count of active jobs (DON'T PACK 858 * for state file) */ 859 uint32_t grp_used_submit_jobs; /* count of jobs pending or running 860 * (DON'T PACK for state file) */ 861 uint64_t *grp_used_tres; /* count of tres in use in this qos 862 * (DON'T PACK for state file) */ 863 uint64_t *grp_used_tres_run_secs; /* count of running tres secs 864 * (DON'T PACK for state file) */ 865 double grp_used_wall; /* group count of time (minutes) used in 866 * running jobs */ 867 double norm_priority;/* normalized priority (DON'T PACK for 868 * state file) */ 869 uint32_t tres_cnt; /* size of the tres arrays, 870 * (DON'T PACK for state file) */ 871 long double usage_raw; /* measure of resource usage */ 872 873 long double *usage_tres_raw; /* measure of each TRES usage */ 874 List user_limit_list; /* slurmdb_used_limits_t's (DON'T PACK 875 * for state file) */ 876 } slurmdb_qos_usage_t; 877 878 typedef struct { 879 char *description; 880 uint32_t id; 881 uint32_t flags; /* flags for various things to enforce or 882 override other limits */ 883 uint32_t grace_time; /* preemption grace time */ 884 uint32_t grp_jobs_accrue; /* max number of jobs this qos can 885 * have accruing priority time 886 */ 887 uint32_t grp_jobs; /* max number of jobs this qos can run 888 * at one time */ 889 uint32_t grp_submit_jobs; /* max number of jobs this qos can submit at 890 * one time */ 891 char *grp_tres; /* max number of tres this qos can 892 * allocate at one time */ 893 uint64_t *grp_tres_ctld; /* grp_tres broken out in an array 894 * based off the ordering of the total 895 * number of TRES in the system 896 * (DON'T PACK) */ 897 char *grp_tres_mins; /* max number of tres minutes this 898 * qos can run for */ 899 uint64_t *grp_tres_mins_ctld; /* grp_tres_mins broken out in an array 900 * based off the ordering of the total 901 * number of TRES in the system 902 * (DON'T PACK) */ 903 char *grp_tres_run_mins; /* max number of tres minutes this 904 * qos can have running at one time */ 905 uint64_t *grp_tres_run_mins_ctld; /* grp_tres_run_mins 906 * broken out in an array 907 * based off the ordering 908 * of the total number of TRES in 909 * the system 910 * (DON'T PACK) */ 911 uint32_t grp_wall; /* total time in hours this qos can run for */ 912 913 uint32_t max_jobs_pa; /* max number of jobs an account can 914 * run with this qos at one time */ 915 uint32_t max_jobs_pu; /* max number of jobs a user can 916 * run with this qos at one time */ 917 uint32_t max_jobs_accrue_pa; /* max number of jobs an account can 918 * have accruing priority time 919 */ 920 uint32_t max_jobs_accrue_pu; /* max number of jobs a user can 921 * have accruing priority time 922 */ 923 uint32_t max_submit_jobs_pa; /* max number of jobs an account can 924 submit with this qos at once */ 925 uint32_t max_submit_jobs_pu; /* max number of jobs a user can 926 submit with this qos at once */ 927 char *max_tres_mins_pj; /* max number of tres seconds this 928 * qos can have per job */ 929 uint64_t *max_tres_mins_pj_ctld; /* max_tres_mins broken out in an array 930 * based off the ordering of the 931 * total number of TRES in the system 932 * (DON'T PACK) */ 933 char *max_tres_pa; /* max number of tres this 934 * QOS can allocate per account */ 935 uint64_t *max_tres_pa_ctld; /* max_tres_pa broken out in an array 936 * based off the ordering of the 937 * total number of TRES in the system 938 * (DON'T PACK) */ 939 char *max_tres_pj; /* max number of tres this 940 * qos can allocate per job */ 941 uint64_t *max_tres_pj_ctld; /* max_tres_pj broken out in an array 942 * based off the ordering of the 943 * total number of TRES in the system 944 * (DON'T PACK) */ 945 char *max_tres_pn; /* max number of tres this 946 * qos can allocate per job */ 947 uint64_t *max_tres_pn_ctld; /* max_tres_pj broken out in an array 948 * based off the ordering of the 949 * total number of TRES in the system 950 * (DON'T PACK) */ 951 char *max_tres_pu; /* max number of tres this 952 * QOS can allocate per user */ 953 uint64_t *max_tres_pu_ctld; /* max_tres broken out in an array 954 * based off the ordering of the 955 * total number of TRES in the system 956 * (DON'T PACK) */ 957 char *max_tres_run_mins_pa; /* max number of tres minutes this 958 * qos can having running at one 959 * time per account, currently 960 * this doesn't do anything. 961 */ 962 uint64_t *max_tres_run_mins_pa_ctld; /* max_tres_run_mins_pa 963 * broken out in an array 964 * based off the ordering 965 * of the total number of TRES in 966 * the system, currently 967 * this doesn't do anything. 968 * (DON'T PACK) */ 969 char *max_tres_run_mins_pu; /* max number of tres minutes this 970 * qos can having running at one 971 * time, currently this doesn't 972 * do anything. 973 */ 974 uint64_t *max_tres_run_mins_pu_ctld; /* max_tres_run_mins_pu 975 * broken out in an array 976 * based off the ordering 977 * of the total number of TRES in 978 * the system, currently 979 * this doesn't do anything. 980 * (DON'T PACK) */ 981 uint32_t max_wall_pj; /* longest time this 982 * qos can run a job */ 983 uint32_t min_prio_thresh; /* Don't reserve resources for pending jobs 984 * unless they have a priority equal to or 985 * higher than this. */ 986 char *min_tres_pj; /* min number of tres a job can 987 * allocate with this qos */ 988 uint64_t *min_tres_pj_ctld; /* min_tres_pj broken out in an array 989 * based off the ordering of the 990 * total number of TRES in the system 991 * (DON'T PACK) */ 992 993 char *name; 994 bitstr_t *preempt_bitstr; /* other qos' this qos can preempt */ 995 List preempt_list; /* list of char *'s only used to add or 996 * change the other qos' this can preempt, 997 * when doing a get use the preempt_bitstr */ 998 uint16_t preempt_mode; /* See PREEMPT_MODE_* in slurm/slurm.h */ 999 uint32_t preempt_exempt_time; /* Job run time before becoming 1000 eligible for preemption */ 1001 uint32_t priority; /* ranged int needs to be a unint for 1002 * heterogeneous systems */ 1003 slurmdb_qos_usage_t *usage; /* For internal use only, DON'T PACK */ 1004 double usage_factor; /* factor to apply to usage in this qos */ 1005 double usage_thres; /* percent of effective usage of an 1006 association when breached will deny 1007 pending and new jobs */ 1008 time_t blocked_until; /* internal use only, DON'T PACK */ 1009 } slurmdb_qos_rec_t; 1010 1011 typedef struct { 1012 List description_list; /* list of char * */ 1013 List id_list; /* list of char * */ 1014 List format_list;/* list of char * */ 1015 List name_list; /* list of char * */ 1016 uint16_t preempt_mode; /* See PREEMPT_MODE_* in slurm/slurm.h */ 1017 uint16_t with_deleted; 1018 } slurmdb_qos_cond_t; 1019 1020 typedef struct { 1021 List cluster_list; /* cluster reservations are on list of 1022 * char * */ 1023 uint64_t flags; /* flags for reservation. */ 1024 List format_list;/* list of char * */ 1025 List id_list; /* ids of reservations. list of char * */ 1026 List name_list; /* name of reservations. list of char * */ 1027 char *nodes; /* list of nodes in reservation */ 1028 time_t time_end; /* end time of reservation */ 1029 time_t time_start; /* start time of reservation */ 1030 uint16_t with_usage; /* send usage for reservation */ 1031 } slurmdb_reservation_cond_t; 1032 1033 typedef struct { 1034 char *assocs; /* comma separated list of associations */ 1035 char *cluster; /* cluster reservation is for */ 1036 uint64_t flags; /* flags for reservation. */ 1037 uint32_t id; /* id of reservation. */ 1038 char *name; /* name of reservation */ 1039 char *nodes; /* list of nodes in reservation */ 1040 char *node_inx; /* node index of nodes in reservation */ 1041 time_t time_end; /* end time of reservation */ 1042 time_t time_start; /* start time of reservation */ 1043 time_t time_start_prev; /* If start time was changed this is 1044 * the pervious start time. Needed 1045 * for accounting */ 1046 char *tres_str; 1047 double unused_wall; /* amount of seconds this reservation wasn't used */ 1048 List tres_list; /* list of slurmdb_tres_rec_t, only set when 1049 * job usage is requested. 1050 */ 1051 } slurmdb_reservation_rec_t; 1052 1053 typedef struct { 1054 uint32_t array_task_id; /* task_id of a job array or NO_VAL */ 1055 uint32_t het_job_offset; /* het_job_offset or NO_VAL */ 1056 uint32_t jobid; 1057 uint32_t stepid; 1058 } slurmdb_selected_step_t; 1059 1060 typedef struct { 1061 uint32_t elapsed; 1062 time_t end; 1063 int32_t exitcode; 1064 slurmdb_job_rec_t *job_ptr; 1065 uint32_t nnodes; 1066 char *nodes; 1067 uint32_t ntasks; 1068 char *pid_str; 1069 uint32_t req_cpufreq_min; 1070 uint32_t req_cpufreq_max; 1071 uint32_t req_cpufreq_gov; 1072 uint32_t requid; 1073 time_t start; 1074 uint32_t state; 1075 slurmdb_stats_t stats; 1076 uint32_t stepid; /* job's step number */ 1077 char *stepname; 1078 uint32_t suspended; 1079 uint32_t sys_cpu_sec; 1080 uint32_t sys_cpu_usec; 1081 uint32_t task_dist; 1082 uint32_t tot_cpu_sec; 1083 uint32_t tot_cpu_usec; 1084 char *tres_alloc_str; 1085 uint32_t user_cpu_sec; 1086 uint32_t user_cpu_usec; 1087 } slurmdb_step_rec_t; 1088 1089 /* slurmdb_stats_t defined above alphabetical */ 1090 1091 typedef struct { 1092 List cluster_list; /* list of char * */ 1093 List description_list; /* list of char * */ 1094 uint32_t flags; 1095 List format_list;/* list of char * */ 1096 List id_list; /* list of char * */ 1097 List manager_list; /* list of char * */ 1098 List name_list; /* list of char * */ 1099 List percent_list; /* list of char * */ 1100 List server_list; /* list of char * */ 1101 List type_list; /* list of char * */ 1102 uint16_t with_deleted; 1103 uint16_t with_clusters; 1104 } slurmdb_res_cond_t; 1105 1106 typedef struct { 1107 List clus_res_list; /* list of slurmdb_clus_res_rec_t *'s */ 1108 slurmdb_clus_res_rec_t *clus_res_rec; /* if only one cluster 1109 being represented */ 1110 uint32_t count; /* count of resources managed on the server */ 1111 char *description; 1112 uint32_t flags; /* resource attribute flags */ 1113 uint32_t id; 1114 char *manager; /* resource manager name */ 1115 char *name; 1116 uint16_t percent_used; 1117 char *server; /* resource server name */ 1118 uint32_t type; /* resource type */ 1119 } slurmdb_res_rec_t; 1120 1121 typedef struct { 1122 List acct_list; /* list of char * */ 1123 List action_list; /* list of char * */ 1124 List actor_list; /* list of char * */ 1125 List cluster_list; /* list of char * */ 1126 List format_list;/* list of char * */ 1127 List id_list; /* list of char * */ 1128 List info_list; /* list of char * */ 1129 List name_list; /* list of char * */ 1130 time_t time_end; 1131 time_t time_start; 1132 List user_list; /* list of char * */ 1133 uint16_t with_assoc_info; 1134 } slurmdb_txn_cond_t; 1135 1136 typedef struct { 1137 char *accts; 1138 uint16_t action; 1139 char *actor_name; 1140 char *clusters; 1141 uint32_t id; 1142 char *set_info; 1143 time_t timestamp; 1144 char *users; 1145 char *where_query; 1146 } slurmdb_txn_rec_t; 1147 1148 /* Right now this is used in the slurmdb_qos_rec_t structure. In the 1149 * user_limit_list and acct_limit_list. */ 1150 typedef struct { 1151 uint32_t accrue_cnt; /* count of jobs accruing prio */ 1152 char *acct; /* If limits for an account this is the accounts name */ 1153 uint32_t jobs; /* count of active jobs */ 1154 uint32_t submit_jobs; /* count of jobs pending or running */ 1155 uint64_t *tres; /* array of TRES allocated */ 1156 uint64_t *tres_run_mins; /* array of how many TRES mins are 1157 * allocated currently, currently this doesn't 1158 * do anything and isn't set up. */ 1159 bitstr_t *node_bitmap; /* Bitmap of allocated nodes */ 1160 uint16_t *node_job_cnt; /* Count of jobs allocated on each node */ 1161 uint32_t uid; /* If limits for a user this is the users uid */ 1162 } slurmdb_used_limits_t; 1163 1164 typedef struct { 1165 uint16_t admin_level; /* really slurmdb_admin_level_t but for 1166 packing purposes needs to be uint16_t */ 1167 slurmdb_assoc_cond_t *assoc_cond; /* use user_list here for 1168 names and acct_list for 1169 default accounts */ 1170 List def_acct_list; /* list of char * (We can't really use 1171 * the assoc_cond->acct_list for this 1172 * because then it is impossible for us 1173 * to tell which accounts are defaults 1174 * and which ones aren't, especially when 1175 * dealing with other versions.)*/ 1176 List def_wckey_list; /* list of char * */ 1177 uint16_t with_assocs; 1178 uint16_t with_coords; 1179 uint16_t with_deleted; 1180 uint16_t with_wckeys; 1181 uint16_t without_defaults; 1182 } slurmdb_user_cond_t; 1183 1184 struct slurmdb_user_rec { 1185 uint16_t admin_level; /* really slurmdb_admin_level_t but for 1186 packing purposes needs to be uint16_t */ 1187 List assoc_list; /* list of slurmdb_association_rec_t *'s */ 1188 slurmdb_bf_usage_t *bf_usage; /* data for backfill scheduler, 1189 * (DON'T PACK) */ 1190 List coord_accts; /* list of slurmdb_coord_rec_t *'s */ 1191 char *default_acct; 1192 char *default_wckey; 1193 char *name; 1194 char *old_name; 1195 uint32_t uid; 1196 List wckey_list; /* list of slurmdb_wckey_rec_t *'s */ 1197 }; 1198 1199 typedef struct { 1200 List objects; /* depending on type */ 1201 uint16_t type; /* really slurmdb_update_type_t but for 1202 * packing purposes needs to be a 1203 * uint16_t */ 1204 } slurmdb_update_object_t; 1205 1206 typedef struct { 1207 List cluster_list; /* list of char * */ 1208 List format_list; /* list of char * */ 1209 List id_list; /* list of char * */ 1210 1211 List name_list; /* list of char * */ 1212 1213 uint16_t only_defs; /* only give me the defaults */ 1214 1215 time_t usage_end; 1216 time_t usage_start; 1217 1218 List user_list; /* list of char * */ 1219 1220 uint16_t with_usage; /* fill in usage */ 1221 uint16_t with_deleted; /* return deleted associations */ 1222 } slurmdb_wckey_cond_t; 1223 1224 typedef struct { 1225 List accounting_list; /* list of slurmdb_accounting_rec_t *'s */ 1226 char *cluster; /* cluster associated */ 1227 1228 uint32_t id; /* id identifing a combination of 1229 * user-wckey-cluster */ 1230 uint16_t is_def; /* Is this the users default wckey */ 1231 1232 char *name; /* wckey name */ 1233 uint32_t uid; /* user ID */ 1234 1235 char *user; /* user associated */ 1236 } slurmdb_wckey_rec_t; 1237 1238 typedef struct { 1239 char *name; 1240 char *print_name; 1241 char *spaces; 1242 uint16_t user; /* set to 1 if it is a user i.e. if name[0] is 1243 * '|' */ 1244 } slurmdb_print_tree_t; 1245 1246 typedef struct { 1247 slurmdb_assoc_rec_t *assoc; 1248 char *sort_name; 1249 List children; 1250 } slurmdb_hierarchical_rec_t; 1251 1252 /************** report specific structures **************/ 1253 1254 typedef struct { 1255 char *acct; 1256 char *cluster; 1257 char *parent_acct; 1258 List tres_list; /* list of slurmdb_tres_rec_t *'s */ 1259 char *user; 1260 } slurmdb_report_assoc_rec_t; 1261 1262 typedef struct { 1263 char *acct; 1264 List acct_list; /* list of char *'s */ 1265 List assoc_list; /* list of slurmdb_report_assoc_rec_t's */ 1266 char *name; 1267 List tres_list; /* list of slurmdb_tres_rec_t *'s */ 1268 uid_t uid; 1269 } slurmdb_report_user_rec_t; 1270 1271 typedef struct { 1272 List accounting_list; /* list of slurmdb_accounting_rec_t *'s */ 1273 List assoc_list; /* list of slurmdb_report_assoc_rec_t *'s */ 1274 char *name; 1275 List tres_list; /* list of slurmdb_tres_rec_t *'s */ 1276 List user_list; /* list of slurmdb_report_user_rec_t *'s */ 1277 } slurmdb_report_cluster_rec_t; 1278 1279 typedef struct { 1280 uint32_t count; /* count of jobs */ 1281 List jobs; /* This should be a NULL destroy since we are just 1282 * putting a pointer to a slurmdb_job_rec_t here 1283 * not allocating any new memory */ 1284 uint32_t min_size; /* smallest size of job in cpus here 0 if first */ 1285 uint32_t max_size; /* largest size of job in cpus here INFINITE if 1286 * last */ 1287 List tres_list; /* list of slurmdb_tres_rec_t *'s */ 1288 } slurmdb_report_job_grouping_t; 1289 1290 typedef struct { 1291 char *acct; /* account name */ 1292 uint32_t count; /* total count of jobs taken up by this acct */ 1293 List groups; /* containing slurmdb_report_job_grouping_t's*/ 1294 uint32_t lft; 1295 uint32_t rgt; 1296 List tres_list; /* list of slurmdb_tres_rec_t *'s */ 1297 } slurmdb_report_acct_grouping_t; 1298 1299 typedef struct { 1300 List acct_list; /* containing slurmdb_report_acct_grouping_t's */ 1301 char *cluster; /* cluster name */ 1302 uint32_t count; /* total count of jobs taken up by this cluster */ 1303 List tres_list; /* list of slurmdb_tres_rec_t *'s */ 1304 } slurmdb_report_cluster_grouping_t; 1305 1306 enum { 1307 DBD_ROLLUP_HOUR, 1308 DBD_ROLLUP_DAY, 1309 DBD_ROLLUP_MONTH, 1310 DBD_ROLLUP_COUNT 1311 }; 1312 1313 typedef struct { 1314 char *cluster_name; /* Cluster name */ 1315 uint16_t count[DBD_ROLLUP_COUNT]; /* How many rollups have 1316 * happened in time period */ 1317 time_t timestamp[DBD_ROLLUP_COUNT]; /* Timestamps of last rollup. */ 1318 uint64_t time_last[DBD_ROLLUP_COUNT]; /* Last rollup time */ 1319 uint64_t time_max[DBD_ROLLUP_COUNT]; /* What was the longest time 1320 * for each rollup */ 1321 uint64_t time_total[DBD_ROLLUP_COUNT]; /* Time it took to do each 1322 * rollup */ 1323 } slurmdb_rollup_stats_t; 1324 1325 typedef struct { 1326 uint32_t cnt; /* count of object processed */ 1327 uint32_t id; /* ID of object */ 1328 uint64_t time; /* total usecs this object */ 1329 uint64_t time_ave; /* ave usecs this object (DON'T PACK) */ 1330 } slurmdb_rpc_obj_t; 1331 1332 typedef struct { 1333 slurmdb_rollup_stats_t *dbd_rollup_stats; 1334 List rollup_stats; /* List of Clusters rollup stats */ 1335 List rpc_list; /* list of RPCs sent to the dbd. */ 1336 time_t time_start; /* When we started collecting data */ 1337 List user_list; /* list of users issuing RPCs */ 1338 } slurmdb_stats_rec_t; 1339 1340 1341 /* global variable for cross cluster communication */ 1342 extern slurmdb_cluster_rec_t *working_cluster_rec; 1343 1344 1345 /************** account functions **************/ 1346 1347 /* 1348 * add accounts to accounting system 1349 * IN: account_list List of slurmdb_account_rec_t * 1350 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1351 */ 1352 extern int slurmdb_accounts_add(void *db_conn, List acct_list); 1353 1354 /* 1355 * get info from the storage 1356 * IN: slurmdb_account_cond_t * 1357 * IN: params void * 1358 * returns List of slurmdb_account_rec_t * 1359 * note List needs to be freed with slurm_list_destroy() when called 1360 */ 1361 extern List slurmdb_accounts_get(void *db_conn, 1362 slurmdb_account_cond_t *acct_cond); 1363 1364 /* 1365 * modify existing accounts in the accounting system 1366 * IN: slurmdb_acct_cond_t *acct_cond 1367 * IN: slurmdb_account_rec_t *acct 1368 * RET: List containing (char *'s) else NULL on error 1369 * note List needs to be freed with slurm_list_destroy() when called 1370 */ 1371 extern List slurmdb_accounts_modify(void *db_conn, 1372 slurmdb_account_cond_t *acct_cond, 1373 slurmdb_account_rec_t *acct); 1374 1375 /* 1376 * remove accounts from accounting system 1377 * IN: slurmdb_account_cond_t *acct_cond 1378 * RET: List containing (char *'s) else NULL on error 1379 * note List needs to be freed with slurm_list_destroy() when called 1380 */ 1381 extern List slurmdb_accounts_remove(void *db_conn, 1382 slurmdb_account_cond_t *acct_cond); 1383 1384 1385 /************** archive functions **************/ 1386 1387 /* 1388 * expire old info from the storage 1389 */ 1390 extern int slurmdb_archive(void *db_conn, slurmdb_archive_cond_t *arch_cond); 1391 1392 /* 1393 * expire old info from the storage 1394 */ 1395 extern int slurmdb_archive_load(void *db_conn, 1396 slurmdb_archive_rec_t *arch_rec); 1397 1398 1399 /************** association functions **************/ 1400 1401 /* 1402 * add associations to accounting system 1403 * IN: assoc_list List of slurmdb_assoc_rec_t * 1404 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1405 */ 1406 extern int slurmdb_associations_add(void *db_conn, List assoc_list); 1407 1408 /* 1409 * get info from the storage 1410 * IN: slurmdb_assoc_cond_t * 1411 * RET: List of slurmdb_assoc_rec_t * 1412 * note List needs to be freed with slurm_list_destroy() when called 1413 */ 1414 extern List slurmdb_associations_get(void *db_conn, 1415 slurmdb_assoc_cond_t *assoc_cond); 1416 1417 /* 1418 * modify existing associations in the accounting system 1419 * IN: slurmdb_assoc_cond_t *assoc_cond 1420 * IN: slurmdb_assoc_rec_t *assoc 1421 * RET: List containing (char *'s) else NULL on error 1422 * note List needs to be freed with slurm_list_destroy() when called 1423 */ 1424 extern List slurmdb_associations_modify(void *db_conn, 1425 slurmdb_assoc_cond_t *assoc_cond, 1426 slurmdb_assoc_rec_t *assoc); 1427 1428 /* 1429 * remove associations from accounting system 1430 * IN: slurmdb_assoc_cond_t *assoc_cond 1431 * RET: List containing (char *'s) else NULL on error 1432 * note List needs to be freed with slurm_list_destroy() when called 1433 */ 1434 extern List slurmdb_associations_remove(void *db_conn, 1435 slurmdb_assoc_cond_t *assoc_cond); 1436 1437 /************** cluster functions **************/ 1438 1439 /* 1440 * add clusters to accounting system 1441 * IN: cluster_list List of slurmdb_cluster_rec_t * 1442 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1443 */ 1444 extern int slurmdb_clusters_add(void *db_conn, List cluster_list); 1445 1446 /* 1447 * get info from the storage 1448 * IN: slurmdb_cluster_cond_t * 1449 * IN: params void * 1450 * returns List of slurmdb_cluster_rec_t * 1451 * note List needs to be freed with slurm_list_destroy() when called 1452 */ 1453 extern List slurmdb_clusters_get(void *db_conn, 1454 slurmdb_cluster_cond_t *cluster_cond); 1455 1456 /* 1457 * modify existing clusters in the accounting system 1458 * IN: slurmdb_cluster_cond_t *cluster_cond 1459 * IN: slurmdb_cluster_rec_t *cluster 1460 * RET: List containing (char *'s) else NULL on error 1461 * note List needs to be freed with slurm_list_destroy() when called 1462 */ 1463 extern List slurmdb_clusters_modify(void *db_conn, 1464 slurmdb_cluster_cond_t *cluster_cond, 1465 slurmdb_cluster_rec_t *cluster); 1466 1467 /* 1468 * remove clusters from accounting system 1469 * IN: slurmdb_cluster_cond_t *cluster_cond 1470 * RET: List containing (char *'s) else NULL on error 1471 * note List needs to be freed with slurm_list_destroy() when called 1472 */ 1473 extern List slurmdb_clusters_remove(void *db_conn, 1474 slurmdb_cluster_cond_t *cluster_cond); 1475 1476 /************** cluster report functions **************/ 1477 1478 /* report for clusters of account per user 1479 * IN: slurmdb_assoc_cond_t *assoc_cond 1480 * RET: List containing (slurmdb_report_cluster_rec_t *'s) else NULL on error 1481 * note List needs to be freed with slurm_list_destroy() when called 1482 */ 1483 extern List slurmdb_report_cluster_account_by_user(void *db_conn, 1484 slurmdb_assoc_cond_t *assoc_cond); 1485 1486 /* report for clusters of users per account 1487 * IN: slurmdb_assoc_cond_t *assoc_cond 1488 * RET: List containing (slurmdb_report_cluster_rec_t *'s) else NULL on error 1489 * note List needs to be freed with slurm_list_destroy() when called 1490 */ 1491 extern List slurmdb_report_cluster_user_by_account(void *db_conn, 1492 slurmdb_assoc_cond_t *assoc_cond); 1493 1494 /* report for clusters of wckey per user 1495 * IN: slurmdb_wckey_cond_t *wckey_cond 1496 * RET: List containing (slurmdb_report_cluster_rec_t *'s) else NULL on error 1497 * note List needs to be freed with slurm_list_destroy() when called 1498 */ 1499 extern List slurmdb_report_cluster_wckey_by_user(void *db_conn, 1500 slurmdb_wckey_cond_t *wckey_cond); 1501 1502 /* report for clusters of users per wckey 1503 * IN: slurmdb_wckey_cond_t *wckey_cond 1504 * RET: List containing (slurmdb_report_cluster_rec_t *'s) else NULL on error 1505 * note List needs to be freed with slurm_list_destroy() when called 1506 */ 1507 extern List slurmdb_report_cluster_user_by_wckey(void *db_conn, 1508 slurmdb_wckey_cond_t *wckey_cond); 1509 1510 1511 extern List slurmdb_report_job_sizes_grouped_by_account( 1512 void *db_conn, 1513 slurmdb_job_cond_t *job_cond, 1514 List grouping_list, 1515 bool flat_view, 1516 bool acct_as_parent); 1517 1518 extern List slurmdb_report_job_sizes_grouped_by_wckey(void *db_conn, 1519 slurmdb_job_cond_t *job_cond, 1520 List grouping_list); 1521 1522 extern List slurmdb_report_job_sizes_grouped_by_account_then_wckey( 1523 void *db_conn, 1524 slurmdb_job_cond_t *job_cond, 1525 List grouping_list, 1526 bool flat_view, 1527 bool acct_as_parent); 1528 1529 1530 /* report on users with top usage 1531 * IN: slurmdb_user_cond_t *user_cond 1532 * IN: group_accounts - Whether or not to group all accounts together 1533 * for each user. If 0 a separate entry for each 1534 * user and account reference is displayed. 1535 * RET: List containing (slurmdb_report_cluster_rec_t *'s) else NULL on error 1536 * note List needs to be freed with slurm_list_destroy() when called 1537 */ 1538 extern List slurmdb_report_user_top_usage(void *db_conn, 1539 slurmdb_user_cond_t *user_cond, 1540 bool group_accounts); 1541 1542 /************** connection functions **************/ 1543 1544 /* 1545 * get a new connection to the slurmdb 1546 * RET: pointer used to access db 1547 */ 1548 extern void *slurmdb_connection_get(); 1549 /* 1550 * get a new connection to the slurmdb 1551 * OUT: persist_conn_flags - Flags returned from connection if any see 1552 * slurm_persist_conn.h. 1553 * RET: pointer used to access db 1554 */ 1555 extern void *slurmdb_connection_get2(uint16_t *persist_conn_flags); 1556 /* 1557 * release connection to the storage unit 1558 * IN/OUT: void ** pointer returned from 1559 * slurmdb_connection_get() which will be freed. 1560 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1561 */ 1562 extern int slurmdb_connection_close(void **db_conn); 1563 1564 /* 1565 * commit or rollback changes made without closing connection 1566 * IN: void * pointer returned from slurmdb_connection_get() 1567 * IN: bool - true will commit changes false will rollback 1568 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1569 */ 1570 extern int slurmdb_connection_commit(void *db_conn, bool commit); 1571 1572 /************** coordinator functions **************/ 1573 1574 /* 1575 * add users as account coordinators 1576 * IN: acct_list list of char *'s of names of accounts 1577 * IN: slurmdb_user_cond_t *user_cond 1578 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1579 */ 1580 extern int slurmdb_coord_add(void *db_conn, 1581 List acct_list, 1582 slurmdb_user_cond_t *user_cond); 1583 1584 /* 1585 * remove users from being a coordinator of an account 1586 * IN: acct_list list of char *'s of names of accounts 1587 * IN: slurmdb_user_cond_t *user_cond 1588 * RET: List containing (char *'s) else NULL on error 1589 * note List needs to be freed with slurm_list_destroy() when called 1590 */ 1591 extern List slurmdb_coord_remove(void *db_conn, List acct_list, 1592 slurmdb_user_cond_t *user_cond); 1593 1594 /*************** Federation functions **************/ 1595 1596 /* 1597 * add federations to accounting system 1598 * IN: list List of slurmdb_federation_rec_t * 1599 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1600 */ 1601 extern int slurmdb_federations_add(void *db_conn, List federation_list); 1602 1603 /* 1604 * modify existing federations in the accounting system 1605 * IN: slurmdb_federation_cond_t *fed_cond 1606 * IN: slurmdb_federation_rec_t *fed 1607 * RET: List containing (char *'s) else NULL on error 1608 */ 1609 extern List slurmdb_federations_modify(void *db_conn, 1610 slurmdb_federation_cond_t *fed_cond, 1611 slurmdb_federation_rec_t *fed); 1612 1613 /* 1614 * remove federations from accounting system 1615 * IN: slurmdb_federation_cond_t *fed_cond 1616 * RET: List containing (char *'s) else NULL on error 1617 */ 1618 extern List slurmdb_federations_remove(void *db_conn, 1619 slurmdb_federation_cond_t *fed_cond); 1620 1621 /* 1622 * get info from the storage 1623 * IN: slurmdb_federation_cond_t * 1624 * RET: List of slurmdb_federation_rec_t * 1625 * note List needs to be freed when called 1626 */ 1627 extern List slurmdb_federations_get(void *db_conn, 1628 slurmdb_federation_cond_t *fed_cond); 1629 1630 /*************** Job functions **************/ 1631 1632 /* 1633 * modify existing job in the accounting system 1634 * IN: slurmdb_job_cond_t *job_cond 1635 * IN: slurmdb_job_rec_t *job 1636 * RET: List containing (char *'s) else NULL on error 1637 */ 1638 extern List slurmdb_job_modify(void *db_conn, 1639 slurmdb_job_cond_t *job_cond, 1640 slurmdb_job_rec_t *job); 1641 1642 /* 1643 * get info from the storage 1644 * returns List of slurmdb_job_rec_t * 1645 * note List needs to be freed with slurm_list_destroy() when called 1646 */ 1647 extern List slurmdb_jobs_get(void *db_conn, slurmdb_job_cond_t *job_cond); 1648 1649 /* 1650 * Fix runaway jobs 1651 * IN: jobs, a list of all the runaway jobs 1652 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1653 */ 1654 extern int slurmdb_jobs_fix_runaway(void *db_conn, List jobs); 1655 1656 /* initialization of job completion logging */ 1657 extern int slurmdb_jobcomp_init(char *jobcomp_loc); 1658 1659 /* terminate pthreads and free, general clean-up for termination */ 1660 extern int slurmdb_jobcomp_fini(void); 1661 1662 /* 1663 * get info from the storage 1664 * returns List of jobcomp_job_rec_t * 1665 * note List needs to be freed when called 1666 */ 1667 extern List slurmdb_jobcomp_jobs_get(slurmdb_job_cond_t *job_cond); 1668 1669 /************** extra get functions **************/ 1670 1671 /* 1672 * reconfigure the slurmdbd 1673 */ 1674 extern int slurmdb_reconfig(void *db_conn); 1675 1676 /* 1677 * shutdown the slurmdbd 1678 */ 1679 extern int slurmdb_shutdown(void *db_conn); 1680 1681 /* 1682 * clear the slurmdbd statistics 1683 */ 1684 extern int slurmdb_clear_stats(void *db_conn); 1685 1686 /* 1687 * get the slurmdbd statistics 1688 * Call slurmdb_destroy_stats_rec() to free stats_pptr 1689 */ 1690 extern int slurmdb_get_stats(void *db_conn, slurmdb_stats_rec_t **stats_pptr); 1691 1692 /* 1693 * get info from the storage 1694 * RET: List of config_key_pair_t * 1695 * note List needs to be freed with slurm_list_destroy() when called 1696 */ 1697 extern List slurmdb_config_get(void *db_conn); 1698 1699 /* 1700 * get info from the storage 1701 * IN: slurmdb_event_cond_t * 1702 * RET: List of slurmdb_event_rec_t * 1703 * note List needs to be freed with slurm_list_destroy() when called 1704 */ 1705 extern List slurmdb_events_get(void *db_conn, 1706 slurmdb_event_cond_t *event_cond); 1707 1708 /* 1709 * get info from the storage 1710 * IN: slurmdb_assoc_cond_t * 1711 * RET: List of slurmdb_assoc_rec_t * 1712 * note List needs to be freed with slurm_list_destroy() when called 1713 */ 1714 extern List slurmdb_problems_get(void *db_conn, 1715 slurmdb_assoc_cond_t *assoc_cond); 1716 1717 /* 1718 * get info from the storage 1719 * IN: slurmdb_reservation_cond_t * 1720 * RET: List of slurmdb_reservation_rec_t * 1721 * note List needs to be freed with slurm_list_destroy() when called 1722 */ 1723 extern List slurmdb_reservations_get(void *db_conn, 1724 slurmdb_reservation_cond_t *resv_cond); 1725 1726 /* 1727 * get info from the storage 1728 * IN: slurmdb_txn_cond_t * 1729 * RET: List of slurmdb_txn_rec_t * 1730 * note List needs to be freed with slurm_list_destroy() when called 1731 */ 1732 extern List slurmdb_txn_get(void *db_conn, slurmdb_txn_cond_t *txn_cond); 1733 1734 /* 1735 * Get information about requested cluster(s). Similar to 1736 * slurmdb_clusters_get, but should be used when setting up the 1737 * working_cluster_rec. It replaces the plugin_id_select with 1738 * the position of the id in the select plugin array, as well as sets up the 1739 * control_addr and dim_size parts of the structure. 1740 * 1741 * IN: cluster_names - comma separated string of cluster names 1742 * RET: List of slurmdb_cluster_rec_t * 1743 * note List needs to bbe freed with slurm_list_destroy() when called 1744 */ 1745 extern List slurmdb_get_info_cluster(char *cluster_names); 1746 1747 /* 1748 * get the first cluster that will run a job 1749 * IN: req - description of resource allocation request 1750 * IN: cluster_names - comma separated string of cluster names 1751 * OUT: cluster_rec - record of selected cluster or NULL if none found or 1752 * cluster_names is NULL 1753 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1754 * 1755 * Note: Cluster_rec needs to be freed with slurmdb_destroy_cluster_rec() when 1756 * called 1757 * Note: The will_runs are not threaded. Currently it relies on the 1758 * working_cluster_rec to pack the job_desc's jobinfo. See previous commit for 1759 * an example of how to thread this. 1760 */ 1761 extern int slurmdb_get_first_avail_cluster(job_desc_msg_t *req, 1762 char *cluster_names, 1763 slurmdb_cluster_rec_t **cluster_rec); 1764 1765 /* 1766 * get the first cluster that will run a heterogeneous job 1767 * IN: req - description of resource allocation request 1768 * IN: cluster_names - comma separated string of cluster names 1769 * OUT: cluster_rec - record of selected cluster or NULL if none found or 1770 * cluster_names is NULL 1771 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1772 * 1773 * Note: Cluster_rec needs to be freed with slurmdb_destroy_cluster_rec() when 1774 * called 1775 * Note: The will_runs are not threaded. Currently it relies on the 1776 * working_cluster_rec to pack the job_desc's jobinfo. See previous commit for 1777 * an example of how to thread this. 1778 */ 1779 extern int slurmdb_get_first_het_job_cluster(List job_req_list, 1780 char *cluster_names, slurmdb_cluster_rec_t **cluster_rec); 1781 1782 /************** helper functions **************/ 1783 extern void slurmdb_destroy_assoc_usage(void *object); 1784 extern void slurmdb_destroy_bf_usage(void *object); 1785 extern void slurmdb_destroy_bf_usage_members(void *object); 1786 extern void slurmdb_destroy_qos_usage(void *object); 1787 extern void slurmdb_destroy_user_rec(void *object); 1788 extern void slurmdb_destroy_account_rec(void *object); 1789 extern void slurmdb_destroy_coord_rec(void *object); 1790 extern void slurmdb_destroy_clus_res_rec(void *object); 1791 extern void slurmdb_destroy_cluster_accounting_rec(void *object); 1792 extern void slurmdb_destroy_cluster_rec(void *object); 1793 extern void slurmdb_destroy_federation_rec(void *object); 1794 extern void slurmdb_destroy_accounting_rec(void *object); 1795 extern void slurmdb_free_assoc_mgr_state_msg(void *object); 1796 extern void slurmdb_free_assoc_rec_members(slurmdb_assoc_rec_t *assoc); 1797 extern void slurmdb_destroy_assoc_rec(void *object); 1798 extern void slurmdb_destroy_event_rec(void *object); 1799 extern void slurmdb_destroy_job_rec(void *object); 1800 extern void slurmdb_free_qos_rec_members(slurmdb_qos_rec_t *qos); 1801 extern void slurmdb_destroy_qos_rec(void *object); 1802 extern void slurmdb_destroy_reservation_rec(void *object); 1803 extern void slurmdb_destroy_step_rec(void *object); 1804 extern void slurmdb_destroy_res_rec(void *object); 1805 extern void slurmdb_destroy_txn_rec(void *object); 1806 extern void slurmdb_destroy_wckey_rec(void *object); 1807 extern void slurmdb_destroy_archive_rec(void *object); 1808 extern void slurmdb_destroy_tres_rec_noalloc(void *object); 1809 extern void slurmdb_destroy_tres_rec(void *object); 1810 extern void slurmdb_destroy_report_assoc_rec(void *object); 1811 extern void slurmdb_destroy_report_user_rec(void *object); 1812 extern void slurmdb_destroy_report_cluster_rec(void *object); 1813 1814 extern void slurmdb_destroy_user_cond(void *object); 1815 extern void slurmdb_destroy_account_cond(void *object); 1816 extern void slurmdb_destroy_cluster_cond(void *object); 1817 extern void slurmdb_destroy_federation_cond(void *object); 1818 extern void slurmdb_destroy_tres_cond(void *object); 1819 extern void slurmdb_destroy_assoc_cond(void *object); 1820 extern void slurmdb_destroy_event_cond(void *object); 1821 extern void slurmdb_destroy_job_cond(void *object); 1822 extern void slurmdb_destroy_qos_cond(void *object); 1823 extern void slurmdb_destroy_reservation_cond(void *object); 1824 extern void slurmdb_destroy_res_cond(void *object); 1825 extern void slurmdb_destroy_txn_cond(void *object); 1826 extern void slurmdb_destroy_wckey_cond(void *object); 1827 extern void slurmdb_destroy_archive_cond(void *object); 1828 1829 extern void slurmdb_destroy_update_object(void *object); 1830 extern void slurmdb_destroy_used_limits(void *object); 1831 extern void slurmdb_destroy_print_tree(void *object); 1832 extern void slurmdb_destroy_hierarchical_rec(void *object); 1833 extern void slurmdb_destroy_selected_step(void *object); 1834 1835 extern void slurmdb_destroy_report_job_grouping(void *object); 1836 extern void slurmdb_destroy_report_acct_grouping(void *object); 1837 extern void slurmdb_destroy_report_cluster_grouping(void *object); 1838 extern void slurmdb_destroy_rpc_obj(void *object); 1839 extern void slurmdb_destroy_rollup_stats(void *object); 1840 extern void slurmdb_free_stats_rec_members(void *object); 1841 extern void slurmdb_destroy_stats_rec(void *object); 1842 1843 extern void slurmdb_free_slurmdb_stats_members(slurmdb_stats_t *stats); 1844 extern void slurmdb_destroy_slurmdb_stats(slurmdb_stats_t *stats); 1845 1846 extern void slurmdb_init_assoc_rec(slurmdb_assoc_rec_t *assoc, 1847 bool free_it); 1848 extern void slurmdb_init_clus_res_rec(slurmdb_clus_res_rec_t *clus_res, 1849 bool free_it); 1850 extern void slurmdb_init_cluster_rec(slurmdb_cluster_rec_t *cluster, 1851 bool free_it); 1852 extern void slurmdb_init_federation_rec(slurmdb_federation_rec_t *federation, 1853 bool free_it); 1854 extern void slurmdb_init_qos_rec(slurmdb_qos_rec_t *qos, 1855 bool free_it, 1856 uint32_t init_val); 1857 extern void slurmdb_init_res_rec(slurmdb_res_rec_t *res, 1858 bool free_it); 1859 extern void slurmdb_init_wckey_rec(slurmdb_wckey_rec_t *wckey, 1860 bool free_it); 1861 extern void slurmdb_init_tres_cond(slurmdb_tres_cond_t *tres, 1862 bool free_it); 1863 extern void slurmdb_init_cluster_cond(slurmdb_cluster_cond_t *cluster, 1864 bool free_it); 1865 extern void slurmdb_init_federation_cond(slurmdb_federation_cond_t *federation, 1866 bool free_it); 1867 extern void slurmdb_init_res_cond(slurmdb_res_cond_t *cluster, 1868 bool free_it); 1869 1870 /* The next two functions have pointers to assoc_list so do not 1871 * destroy assoc_list before using the list returned from this function. 1872 */ 1873 extern List slurmdb_get_hierarchical_sorted_assoc_list( 1874 List assoc_list, bool use_lft); 1875 extern List slurmdb_get_acct_hierarchical_rec_list(List assoc_list); 1876 1877 1878 /* IN/OUT: tree_list a list of slurmdb_print_tree_t's */ 1879 extern char *slurmdb_tree_name_get(char *name, char *parent, List tree_list); 1880 1881 /************** job report functions **************/ 1882 1883 /************** resource functions **************/ 1884 /* 1885 * add resource's to accounting system 1886 * IN: res_list List of char * 1887 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1888 */ 1889 extern int slurmdb_res_add(void *db_conn, List res_list); 1890 1891 /* 1892 * get info from the storage 1893 * IN: slurmdb_res_cond_t * 1894 * RET: List of slurmdb_res_rec_t * 1895 * note List needs to be freed with slurm_list_destroy() when called 1896 */ 1897 extern List slurmdb_res_get(void *db_conn, slurmdb_res_cond_t *res_cond); 1898 1899 /* 1900 * modify existing resource in the accounting system 1901 * IN: slurmdb_res_cond_t *res_cond 1902 * IN: slurmdb_res_rec_t *res 1903 * RET: List containing (char *'s) else NULL on error 1904 * note List needs to be freed with slurm_list_destroy() when called 1905 */ 1906 extern List slurmdb_res_modify(void *db_conn, 1907 slurmdb_res_cond_t *res_cond, 1908 slurmdb_res_rec_t *res); 1909 1910 /* 1911 * remove resource from accounting system 1912 * IN: slurmdb_res_cond_t *res 1913 * RET: List containing (char *'s) else NULL on error 1914 * note List needs to be freed with slurm_list_destroy() when called 1915 */ 1916 extern List slurmdb_res_remove(void *db_conn, slurmdb_res_cond_t *res_cond); 1917 1918 /************** qos functions **************/ 1919 1920 /* 1921 * add qos's to accounting system 1922 * IN: qos_list List of char * 1923 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1924 */ 1925 extern int slurmdb_qos_add(void *db_conn, List qos_list); 1926 1927 /* 1928 * get info from the storage 1929 * IN: slurmdb_qos_cond_t * 1930 * RET: List of slurmdb_qos_rec_t * 1931 * note List needs to be freed with slurm_list_destroy() when called 1932 */ 1933 extern List slurmdb_qos_get(void *db_conn, slurmdb_qos_cond_t *qos_cond); 1934 1935 /* 1936 * modify existing qos in the accounting system 1937 * IN: slurmdb_qos_cond_t *qos_cond 1938 * IN: slurmdb_qos_rec_t *qos 1939 * RET: List containing (char *'s) else NULL on error 1940 * note List needs to be freed with slurm_list_destroy() when called 1941 */ 1942 extern List slurmdb_qos_modify(void *db_conn, 1943 slurmdb_qos_cond_t *qos_cond, 1944 slurmdb_qos_rec_t *qos); 1945 1946 /* 1947 * remove qos from accounting system 1948 * IN: slurmdb_qos_cond_t *assoc_qos 1949 * RET: List containing (char *'s) else NULL on error 1950 * note List needs to be freed with slurm_list_destroy() when called 1951 */ 1952 extern List slurmdb_qos_remove(void *db_conn, slurmdb_qos_cond_t *qos_cond); 1953 1954 /************** tres functions **************/ 1955 1956 /* 1957 * add tres's to accounting system 1958 * IN: tres_list List of char * 1959 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1960 */ 1961 extern int slurmdb_tres_add(void *db_conn, List tres_list); 1962 1963 /* 1964 * get info from the storage 1965 * IN: slurmdb_tres_cond_t * 1966 * RET: List of slurmdb_tres_rec_t * 1967 * note List needs to be freed with slurm_list_destroy() when called 1968 */ 1969 extern List slurmdb_tres_get(void *db_conn, slurmdb_tres_cond_t *tres_cond); 1970 1971 1972 /************** usage functions **************/ 1973 1974 /* 1975 * get info from the storage 1976 * IN/OUT: in void * (slurmdb_assoc_rec_t *) or 1977 * (slurmdb_wckey_rec_t *) of (slurmdb_cluster_rec_t *) with 1978 * the id, and cluster set. 1979 * IN: type what type is 'in' 1980 * IN: start time stamp for records >= 1981 * IN: end time stamp for records <= 1982 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1983 */ 1984 extern int slurmdb_usage_get(void *db_conn, 1985 void *in, 1986 int type, 1987 time_t start, 1988 time_t end); 1989 1990 /* 1991 * roll up data in the storage 1992 * IN: sent_start (option time to do a re-roll or start from this point) 1993 * IN: sent_end (option time to do a re-roll or end at this point) 1994 * IN: archive_data (if 0 old data is not archived in a monthly rollup) 1995 * OUT: rollup_stats_list_in (list containing stats about each clusters rollup) 1996 * RET: SLURM_SUCCESS on success SLURM_ERROR else 1997 */ 1998 extern int slurmdb_usage_roll(void *db_conn, 1999 time_t sent_start, 2000 time_t sent_end, 2001 uint16_t archive_data, 2002 List *rollup_stats_list_in); 2003 2004 /************** user functions **************/ 2005 2006 /* 2007 * add users to accounting system 2008 * IN: user_list List of slurmdb_user_rec_t * 2009 * RET: SLURM_SUCCESS on success SLURM_ERROR else 2010 */ 2011 extern int slurmdb_users_add(void *db_conn, List user_list); 2012 2013 /* 2014 * get info from the storage 2015 * IN: slurmdb_user_cond_t * 2016 * IN: params void * 2017 * returns List of slurmdb_user_rec_t * 2018 * note List needs to be freed with slurm_list_destroy() when called 2019 */ 2020 extern List slurmdb_users_get(void *db_conn, slurmdb_user_cond_t *user_cond); 2021 2022 /* 2023 * modify existing users in the accounting system 2024 * IN: slurmdb_user_cond_t *user_cond 2025 * IN: slurmdb_user_rec_t *user 2026 * RET: List containing (char *'s) else NULL on error 2027 * note List needs to be freed with slurm_list_destroy() when called 2028 */ 2029 extern List slurmdb_users_modify(void *db_conn, 2030 slurmdb_user_cond_t *user_cond, 2031 slurmdb_user_rec_t *user); 2032 2033 /* 2034 * remove users from accounting system 2035 * IN: slurmdb_user_cond_t *user_cond 2036 * RET: List containing (char *'s) else NULL on error 2037 * note List needs to be freed with slurm_list_destroy() when called 2038 */ 2039 extern List slurmdb_users_remove(void *db_conn, 2040 slurmdb_user_cond_t *user_cond); 2041 2042 2043 /************** user report functions **************/ 2044 2045 2046 /************** wckey functions **************/ 2047 2048 /* 2049 * add wckey's to accounting system 2050 * IN: wckey_list List of slurmdb_wckey_rec_t * 2051 * RET: SLURM_SUCCESS on success SLURM_ERROR else 2052 */ 2053 extern int slurmdb_wckeys_add(void *db_conn, List wckey_list); 2054 2055 /* 2056 * get info from the storage 2057 * IN: slurmdb_wckey_cond_t * 2058 * RET: List of slurmdb_wckey_rec_t * 2059 * note List needs to be freed with slurm_list_destroy() when called 2060 */ 2061 extern List slurmdb_wckeys_get(void *db_conn, 2062 slurmdb_wckey_cond_t *wckey_cond); 2063 2064 /* 2065 * modify existing wckey in the accounting system 2066 * IN: slurmdb_wckey_cond_t *wckey_cond 2067 * IN: slurmdb_wckey_rec_t *wckey 2068 * RET: List containing (char *'s) else NULL on error 2069 * note List needs to be freed with slurm_list_destroy() when called 2070 */ 2071 extern List slurmdb_wckeys_modify(void *db_conn, 2072 slurmdb_wckey_cond_t *wckey_cond, 2073 slurmdb_wckey_rec_t *wckey); 2074 2075 /* 2076 * remove wckey from accounting system 2077 * IN: slurmdb_wckey_cond_t *assoc_wckey 2078 * RET: List containing (char *'s) else NULL on error 2079 * note List needs to be freed with slurm_list_destroy() when called 2080 */ 2081 extern List slurmdb_wckeys_remove(void *db_conn, 2082 slurmdb_wckey_cond_t *wckey_cond); 2083 2084 #ifdef __cplusplus 2085 } 2086 #endif 2087 2088 #endif /* !_SLURMDB_H */ 2089