Skip to content

Commit 8875a02

Browse files
committed
sbcast - Add --nodelist/-w option
Issue #2
1 parent 0055e1c commit 8875a02

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/bcast/file_bcast.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,22 @@ static int _get_cred_for_job(struct bcast_parameters *params)
151151
job_id_str, slurm_strerror(errno));
152152
return rc;
153153
}
154+
155+
if (params->node_list) {
156+
hostset_t *job_nodes = hostset_create(sbcast_cred->node_list);
157+
158+
if (!hostset_within(job_nodes, params->node_list)) {
159+
error("Not all nodes in --nodelist/-w '%s' are in job %s.",
160+
params->node_list, job_id_str);
161+
FREE_NULL_HOSTSET(job_nodes);
162+
return SLURM_ERROR;
163+
}
164+
FREE_NULL_HOSTSET(job_nodes);
165+
166+
xfree(sbcast_cred->node_list);
167+
sbcast_cred->node_list = xstrdup(params->node_list);
168+
}
169+
154170
verbose("jobid = %s", job_id_str);
155171
verbose("node_list = %s", sbcast_cred->node_list);
156172

src/bcast/file_bcast.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct bcast_parameters {
5252
char *dst_fname;
5353
char *exe_fname;
5454
uint16_t flags;
55+
char *node_list;
5556
slurm_selected_step_t *selected_step;
5657
char *src_fname;
5758
uint32_t step_id;

src/sbcast/opts.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ extern void parse_command_line(int argc, char **argv)
8787
{"treewidth", required_argument, 0, OPT_LONG_TREE_WIDTH},
8888
{"force", no_argument, 0, 'f'},
8989
{"jobid", required_argument, 0, 'j'},
90+
{"nodelist", optional_argument, 0, 'w'},
9091
{"send-libs", optional_argument, 0, OPT_LONG_SEND_LIBS},
9192
{"preserve", no_argument, 0, 'p'},
9293
{"size", required_argument, 0, 's'},
@@ -148,7 +149,7 @@ extern void parse_command_line(int argc, char **argv)
148149
params.timeout = (atoi(env_val) * 1000);
149150

150151
optind = 0;
151-
while ((opt_char = getopt_long(argc, argv, "C::fF:j:ps:t:vV",
152+
while ((opt_char = getopt_long(argc, argv, "C::fF:j:ps:t:vVw:",
152153
long_options, &option_index)) != -1) {
153154
switch (opt_char) {
154155
case (int)'?':
@@ -201,6 +202,9 @@ extern void parse_command_line(int argc, char **argv)
201202
case (int) 'V':
202203
print_slurm_version();
203204
exit(0);
205+
case (int) 'w':
206+
params.node_list = xstrdup(optarg);
207+
break;
204208
case (int) OPT_LONG_HELP:
205209
_help();
206210
exit(0);

0 commit comments

Comments
 (0)