slurm_hostlist_create - Man Page

Slurm host list support functions

Syntax

#include <slurm/slurm.h>

hostlist_t slurm_hostlist_create (
char *node_list
);

char * slurm_hostlist_shift (
hostlist_t host_list
);

void slurm_hostlist_destroy (
hostlist_t host_list
);

Arguments

node_list

A list of nodes as returned by the slurm_job_step_create functions. The returned value may include a simple range format to describe numeric ranges of values and/or multiple numeric values (e.g. "linux[1-3,6]" represents "linux1", "linux2", "linux3", and "linux6").

host_list

A hostlist created by the slurm_hostlist_create function.

Description

slurm_hostlist_create creates a database of node names from a range format describing node names. Use slurm_hostlist_destroy to release storage associated with the database when no longer required.

slurm_hostlist_shift extracts the first entry from the host list database created by the slurm_hostlist_create function.

slurm_hostlist_destroy releases storage associated with a database created by slurm_hostlist_create when no longer required.

Return Value

slurm_hostlist_create returns the host list database or NULL if memory can not be allocated for the database.

slurm_hostlist_shift returns a character string or NULL if no entries remain in the database.

Example

#include <stdio.h>
#include <hostlist.h>
#include <slurm.h>

int main (int argc, char *argv[])
{
hostlist_t my_hostlist;
char *hostnames, *host;

/* generate a list of hostnames, possibly using a */
/*    slurm job step creation function */

my_hostlist = slurm_hostlist_create (hostnames);
if (my_hostlist == NULL) {
fprintf (stderr, "No memory\n");
exit (1);
}

while ( (host = slurm_hostlist_shift(my_hostlist)) ) {
printf ("host = %s\n", host);
free(host);
}

slurm_hostlist_destroy (my_hostlist) ;
exit (0);
}

Note

These functions are included in the libslurm library, which must be linked to your process for use (e.g. "cc -lslurm myprog.c").

Copying

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.

See Also

slurm_get_job_steps(3), slurm_load_jobs(3), slurm_load_partitions(3)

Referenced By

slurm_free_job_info_msg(3), slurm_free_job_step_info_response_msg(3), slurm_free_partition_info(3), slurm_load_reservations(3).

The man pages slurm_hostlist_destroy(3) and slurm_hostlist_shift(3) are aliases of slurm_hostlist_create(3).

April 2015 Slurm host list functions