diff --git a/rqd/rqd/rqconstants.py b/rqd/rqd/rqconstants.py index fe793970e..bb0a074e2 100644 --- a/rqd/rqd/rqconstants.py +++ b/rqd/rqd/rqconstants.py @@ -70,6 +70,9 @@ # Use the PATH environment variable from the RQD host. RQD_USE_PATH_ENV_VAR = False +# Use the environment variables from the RQD host. +RQD_USE_HOST_ENV_VARS = False + RQD_BECOME_JOB_USER = True RQD_CREATE_USER_IF_NOT_EXISTS = True RQD_TAGS = '' @@ -184,6 +187,8 @@ RQD_USE_IPV6_AS_HOSTNAME = config.getboolean(__section, "RQD_USE_IPV6_AS_HOSTNAME") if config.has_option(__section, "RQD_USE_PATH_ENV_VAR"): RQD_USE_PATH_ENV_VAR = config.getboolean(__section, "RQD_USE_PATH_ENV_VAR") + if config.has_option(__section, "RQD_USE_HOST_ENV_VARS"): + RQD_USE_HOST_ENV_VARS = config.getboolean(__section, "RQD_USE_HOST_ENV_VARS") if config.has_option(__section, "RQD_BECOME_JOB_USER"): RQD_BECOME_JOB_USER = config.getboolean(__section, "RQD_BECOME_JOB_USER") if config.has_option(__section, "RQD_TAGS"): diff --git a/rqd/rqd/rqcore.py b/rqd/rqd/rqcore.py index 842028732..1dbd0fc3e 100644 --- a/rqd/rqd/rqcore.py +++ b/rqd/rqd/rqcore.py @@ -122,13 +122,22 @@ def __createEnvVariables(self): if 'GPU_LIST' in self.runFrame.attributes: self.frameEnv['CUE_GPU_CORES'] = self.runFrame.attributes['GPU_LIST'] + # Add host environment variables + if rqd.rqconstants.RQD_USE_HOST_ENV_VARS: + for key, value in os.environ.items(): + if "PATH" in key and key in self.frameEnv: + self.frameEnv[key] += os.pathsep + value + + self.frameEnv[key] = value + + def _createCommandFile(self, command): """Creates a file that subprocess. Popen then executes. @type command: string @param command: The command specified in the runFrame request @rtype: string @return: Command file location""" - # TODO: this should use tempfile to create the files and clean them up afterwards + # TODO: this should use tempfile to create the files and clean them up afterwards try: if platform.system() == "Windows": rqd_tmp_dir = os.path.join(tempfile.gettempdir(), 'rqd')