Slurm API(3) | Slurm partition information functions | Slurm API(3) |
slurm_free_partition_info_msg, slurm_load_partitions, slurm_print_partition_info, slurm_print_partition_info_msg - Slurm partition information reporting functions
#include <stdio.h>
#include <slurm/slurm.h>
void slurm_free_partition_info_msg (
partition_info_msg_t *partition_info_msg_ptr
);
int slurm_load_partitions (
time_t update_time,
partition_info_msg_t **partition_info_msg_pptr,
uint16_t show_flags
);
void slurm_print_partition_info (
FILE *out_file,
partition_info_t *partition_ptr,
int one_liner
);
void slurm_print_partition_info_msg (
FILE *out_file,
partition_info_msg_t *partition_info_msg_ptr,
int one_liner
);
slurm_free_partition_info_msg Release the storage generated by the slurm_load_partitions function.
slurm_load_partitions Returns a partition_info_msg_t that contains an update time, record count, and array of partition_table records for all partitions.
slurm_print_partition_info Prints the contents of the data structure describing a single partition records from the data loaded by the slurm_load_partitions function.
slurm_print_partition_info_msg Prints the contents of the data structure describing all partition records loaded by the slurm_load_partitions function.
On success, zero is returned. On error, -1 is returned, and Slurm error code is set appropriately.
SLURM_NO_CHANGE_IN_DATA Data has not changed since update_time.
SLURM_PROTOCOL_VERSION_ERROR Protocol version has changed, re-link your code.
SLURM_PROTOCOL_SOCKET_IMPL_TIMEOUT Timeout in communicating with Slurm controller.
#include <stdio.h>
#include <stdlib.h>
#include <slurm/slurm.h>
#include <slurm/slurm_errno.h>
int main (int argc, char *argv[])
{
int i;
partition_info_msg_t *part_info_ptr = NULL;
partition_info_t *part_ptr;
/* get and dump some partition information */
if (slurm_load_partitions((time_t)NULL,
&part_info_ptr, SHOW_ALL)) {
slurm_perror ("slurm_load_partitions error");
exit (1);
}
/* The easy way to print... */
slurm_print_partition_info_msg (stdout,
part_info_ptr, 0);
/* A harder way.. */
for (i = 0; i < part_info_ptr->record_count; i++) {
part_ptr = &part_info_ptr->partition_array[i];
slurm_print_partition_info(stdout, part_ptr, 0);
}
/* The hardest way. */
printf("Partitions updated at %lx, records=%d\n",
part_info_ptr->last_update,
part_info_ptr->record_count);
for (i = 0; i < part_info_ptr->record_count; i++) {
printf ("PartitionName=%s Nodes=%s\n",
part_info_ptr->partition_array[i].name,
part_info_ptr->partition_array[i].nodes );
}
slurm_free_partition_info_msg (part_info_ptr);
exit (0);
}
These functions are included in the libslurm library, which must be linked to your process for use (e.g. "cc -lslurm myprog.c").
Some data structures contain index values to cross-reference each other. If the show_flags argument is not set to SHOW_ALL when getting this data, these index values will be invalid.
The slurm_hostlist_ functions can be used to convert Slurm node list expressions into a collection of individual node names.
Copyright (C) 2002-2006 The Regents of the University of California. Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). CODE-OCEC-09-009. All rights reserved.
This file is part of Slurm, a resource management program. For details, see <https://slurm.schedmd.com/>.
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.
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.
scontrol(1), sinfo(1), squeue(1), slurm_hostlist_create(3), slurm_hostlist_shift(3), slurm_hostlist_destroy(3), slurm_get_errno(3), slurm_load_node(3), slurm_perror(3), slurm_strerror(3)
Slurm partition information functions | May 2017 |