Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom local file transfer commands via PBS_CP variable #1515

Merged
merged 13 commits into from Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion doc/man8/pbs.conf.8B
Expand Up @@ -157,7 +157,10 @@ name. Cannot contain a colon (":").
Hostname of primary server. Used only for failover configuration.
Overrides PBS_SERVER_HOST_NAME.

.IP PBS_RCP
.IP PBS_CP
Location of local copy command. Default is cp on Linux systems and xcopy on Windows.

.IP PBS_RCP
Location of rcp command if rcp is used.

.IP PBS_SCHEDULER_SERVICE_PORT
Expand Down
12 changes: 7 additions & 5 deletions doc/man8/pbs_mom.8B
Expand Up @@ -1228,10 +1228,10 @@ Default on Windows: value of the
environment variable

.IP "$usecp <hostname:source prefix> <destination prefix>" 5
MoM uses /bin/cp to deliver output files when
the destination is a network mounted file system, or when
the source and destination are both on the local host, or when
the
MoM uses /bin/cp or the program specified by PBS_CP to deliver
output files when the destination is a network mounted file system,
or when the source and destination are both on the local host, or
when the
.I source prefix
can be replaced with the
.I destination prefix
Expand All @@ -1243,7 +1243,9 @@ and
.I destination prefix
are absolute pathnames of directories, not files.

Overrides
Overrides
.I PBS_CP
and
.I PBS_RCP
and
.I PBS_SCP.
Expand Down
2 changes: 2 additions & 0 deletions src/include/pbs_internal.h
Expand Up @@ -218,6 +218,7 @@ struct pbs_config
char *pbs_exec_path; /* path to the pbs exec dir */
char *pbs_server_name; /* name of PBS Server, usually hostname of host on which PBS server is executing */
char *pbs_server_id; /* name of the database PBS server id associated with the server hostname, pbs_server_name */
char *cp_path; /* path to local copy function */
char *scp_path; /* path to ssh */
char *rcp_path; /* path to pbs_rsh */
char *pbs_demux_path; /* path to pbs demux */
Expand Down Expand Up @@ -291,6 +292,7 @@ extern struct pbs_config pbs_conf;
#define PBS_CONF_SERVER_NAME "PBS_SERVER" /* name of the pbs server */
#define PBS_CONF_INSTALL_MODE "PBS_INSTALL_MODE" /* PBS installation mode */
#define PBS_CONF_RCP "PBS_RCP"
#define PBS_CONF_CP "PBS_CP"
#define PBS_CONF_SCP "PBS_SCP" /* path to ssh */
#define PBS_CONF_ENVIRONMENT "PBS_ENVIRONMENT" /* path to pbs_environment */
#define PBS_CONF_PRIMARY "PBS_PRIMARY" /* Primary Server in failover */
Expand Down
24 changes: 24 additions & 0 deletions src/lib/Libifl/pbs_loadconf.c
Expand Up @@ -97,6 +97,7 @@ struct pbs_config pbs_conf = {
NULL, /* pbs_exec_path */
NULL, /* pbs_server_name */
NULL, /* PBS server id */
NULL, /* cp_path */
NULL, /* scp_path */
NULL, /* rcp_path */
NULL, /* pbs_demux_path */
Expand Down Expand Up @@ -507,6 +508,10 @@ __pbs_loadconf(int reload)
free(pbs_conf.scp_path);
pbs_conf.scp_path = shorten_and_cleanup_path(conf_value);
}
else if (!strcmp(conf_name, PBS_CONF_CP)) {
free(pbs_conf.cp_path);
pbs_conf.cp_path = shorten_and_cleanup_path(conf_value);
}
/* rcp_path can be inferred from pbs_conf.pbs_exec_path - see below */
/* pbs_demux_path is inferred from pbs_conf.pbs_exec_path - see below */
else if (!strcmp(conf_name, PBS_CONF_ENVIRONMENT)) {
Expand Down Expand Up @@ -698,6 +703,10 @@ __pbs_loadconf(int reload)
free(pbs_conf.scp_path);
pbs_conf.scp_path = shorten_and_cleanup_path(gvalue);
}
if ((gvalue = getenv(PBS_CONF_CP)) != NULL) {
free(pbs_conf.cp_path);
pbs_conf.cp_path = shorten_and_cleanup_path(gvalue);
}
if ((gvalue = getenv(PBS_CONF_PRIMARY)) != NULL) {
free(pbs_conf.pbs_primary);
if ((pbs_conf.pbs_primary = strdup(gvalue)) == NULL) {
Expand Down Expand Up @@ -919,6 +928,17 @@ __pbs_loadconf(int reload)
goto err;
}
}
if (pbs_conf.cp_path == NULL) {
jdburton marked this conversation as resolved.
Show resolved Hide resolved
#ifdef WIN32
char *cmd = "xcopy";
#else
char *cmd = "/bin/cp";
#endif
pbs_conf.cp_path = strdup(cmd);
if (pbs_conf.cp_path == NULL) {
goto err;
}
}

free(pbs_conf.pbs_demux_path);
/* strlen("/sbin/pbs_demux") + '\0' == 15 + 1 == 16 */
Expand Down Expand Up @@ -1040,6 +1060,10 @@ __pbs_loadconf(int reload)
free(pbs_conf.scp_path);
pbs_conf.scp_path = NULL;
}
if (pbs_conf.cp_path) {
free(pbs_conf.cp_path);
pbs_conf.cp_path = NULL;
}
if (pbs_conf.pbs_environment) {
free(pbs_conf.pbs_environment);
pbs_conf.pbs_environment = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/lib/Libpython/pbs_python_svr_internal.c
Expand Up @@ -11996,6 +11996,7 @@ pbsv1mod_meth_get_pbs_conf(void)
"PBS_EXEC", pbs_conf.pbs_exec_path?pbs_conf.pbs_exec_path:"",
"PBS_ENVIRONMENT", pbs_conf.pbs_environment?pbs_conf.pbs_environment:"",
"PBS_RCP", pbs_conf.rcp_path?pbs_conf.rcp_path:"",
"PBS_CP", pbs_conf.cp_path?pbs_conf.cp_path:"",
"PBS_SCP", pbs_conf.scp_path?pbs_conf.scp_path:"",
"PBS_MOM_HOME", pbs_conf.pbs_mom_home?pbs_conf.pbs_mom_home:"",
"PBS_TMPDIR", pbs_conf.pbs_tmpdir?pbs_conf.pbs_tmpdir:"",
Expand Down
4 changes: 2 additions & 2 deletions src/resmom/stage_func.c
Expand Up @@ -1629,7 +1629,7 @@ sys_copy(int dir, int rmtflg, char *owner, char *src, struct rqfpair *pair, int
for (loop = 1; loop < 5; ++loop) {
original = 0;
if (rmtflg == 0) { /* local copy */
ag0 = "/bin/cp";
ag0 = pbs_conf.cp_path;
if (strcmp(ag3, "/dev/null") == 0)
return (0); /* don't need to copy, just return zero */
else
Expand Down Expand Up @@ -1779,7 +1779,7 @@ sys_copy(int dir, int rmtflg, char *owner, char *src, struct rqfpair *pair, int
for (loop = 1; loop < 5; ++loop) {
original = 0;
if (rmtflg == 0) { /* local copy */
ag0 = "xcopy";
ag0 = pbs_conf.cp_path;
ag1 = "/e/i/q/y";
/* remote, try scp */
} else if (pbs_conf.scp_path != NULL && (loop % 2) == 1) {
Expand Down