From 9023d66e09c4f4d847dbdc890f47e9c504099291 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 11 Sep 2023 14:55:26 +0200 Subject: [PATCH] [EDF27562] : Fix clustertest --- src/Basics/KernelBasis.cxx | 22 +++++++++++++++++-- src/Basics/KernelBasis.hxx | 3 +++ src/Basics/KernelBasis.i | 4 ++++ src/Container/SALOME_ContainerManager.cxx | 12 ++++++++++ .../ScriptsTemplate/SALOME_CM_REMOTE.py | 13 +++++------ .../ScriptsTemplate/SALOME_CM_REMOTE_OLD.py | 13 +++++------ .../ScriptsTemplate/script_parameters.py | 7 ++---- 7 files changed, 53 insertions(+), 21 deletions(-) diff --git a/src/Basics/KernelBasis.cxx b/src/Basics/KernelBasis.cxx index 921ac72c3..f86b0026f 100644 --- a/src/Basics/KernelBasis.cxx +++ b/src/Basics/KernelBasis.cxx @@ -45,12 +45,30 @@ void setGUIMode(bool guiMode) GUI_MODE = guiMode; } -std::string BASICS_EXPORT getIOROfEmbeddedNS() +std::string getIOROfEmbeddedNS() { return IOR_OF_EMBEDDED_NS; } -void BASICS_EXPORT setIOROfEmbeddedNS(const std::string& ior) +void setIOROfEmbeddedNS(const std::string& ior) { IOR_OF_EMBEDDED_NS = ior; } + +#include + +/*! + * Callable from Python in case if sys.stdout is not connected to tty + */ +void WriteInStdout(const std::string& msg) +{ + std::cout << msg << std::endl << std::flush; +} + +/*! + * Callable from Python in case if sys.stdout is not connected to tty + */ +void WriteInStderr(const std::string& msg) +{ + std::cerr << msg << std::endl << std::flush; +} diff --git a/src/Basics/KernelBasis.hxx b/src/Basics/KernelBasis.hxx index 6e96c84e6..2aa0499e5 100644 --- a/src/Basics/KernelBasis.hxx +++ b/src/Basics/KernelBasis.hxx @@ -30,3 +30,6 @@ void BASICS_EXPORT setGUIMode(bool guiMode); std::string BASICS_EXPORT getIOROfEmbeddedNS(); void BASICS_EXPORT setIOROfEmbeddedNS(const std::string& ior); + +void BASICS_EXPORT WriteInStdout(const std::string& msg); +void BASICS_EXPORT WriteInStderr(const std::string& msg); diff --git a/src/Basics/KernelBasis.i b/src/Basics/KernelBasis.i index b159904c2..45908234b 100644 --- a/src/Basics/KernelBasis.i +++ b/src/Basics/KernelBasis.i @@ -45,6 +45,10 @@ bool VerbosityActivated(); void SetVerbosityActivated(bool flag); +void WriteInStdout(const std::string& msg); + +void WriteInStderr(const std::string& msg); + %inline { diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 013d25d5c..ca7efa7db 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -604,13 +604,22 @@ SALOME_ContainerManager::LaunchContainer(const Engines::ContainerParameters& par MESSAGE("[GiveContainer] Try to launch a new container on " << resource_selected); // if a parallel container is launched in batch job, command is: "mpirun -np nbproc -machinefile nodesfile SALOME_MPIContainer" if( GetenvThreadSafe("LIBBATCH_NODEFILE") != NULL && params.isMPI ) + { command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe, tmpFileName); + MESSAGE("[LaunchContainer] LIBBATCH_NODEFILE : \"" << command << "\""); + } // if a container is launched on localhost, command is "SALOME_Container" or "mpirun -np nbproc SALOME_MPIContainer" else if(hostname == Kernel_Utils::GetHostname()) + { command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe, tmpFileName); + MESSAGE("[LaunchContainer] hostname local : \"" << command << "\""); + } // if a container is launched in remote mode, command is "ssh resource_selected SALOME_Container" or "ssh resource_selected mpirun -np nbproc SALOME_MPIContainer" else + { command = BuildCommandToLaunchRemoteContainer(resource_selected, params, container_exe); + MESSAGE("[LaunchContainer] remote : \"" << command << "\""); + } //redirect stdout and stderr in a file #ifdef WIN32 @@ -641,6 +650,7 @@ SALOME_ContainerManager::LaunchContainer(const Engines::ContainerParameters& par command += " > " + logFilename + " 2>&1"; MakeTheCommandToBeLaunchedASync(command); + MESSAGE("[LaunchContainer] SYSTEM COMMAND that will be launched : \"" << command << "\""); // launch container with a system call status=SystemThreadSafe(command.c_str()); }//end of critical of section @@ -789,12 +799,14 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer(const std::string& std::string wdir = params.workingdir.in(); if (!_isAppliSalomeDefined) { + MESSAGE("[BuildCommandToLaunchRemoteContainer] NO APPLI MODE : " << " Protocol :" << resInfo.Protocol << " hostname :" << resInfo.HostName << " username : " << resInfo.UserName << " appli : " << resInfo.AppliPath << " wdir : \"" << wdir << "\""); command = getCommandToRunRemoteProcessNoAppli(resInfo.Protocol, resInfo.HostName, resInfo.UserName, resInfo.AppliPath, wdir); } else { + MESSAGE("[BuildCommandToLaunchRemoteContainer] WITH APPLI MODE : " << " Protocol :" << resInfo.Protocol << " hostname :" << resInfo.HostName << " username : " << resInfo.UserName << " appli : " << resInfo.AppliPath << " wdir : \"" << wdir << "\""); // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir // SALOME_Container containerName -ORBInitRef NameService=IOR:01000..." // or diff --git a/src/Container/ScriptsTemplate/SALOME_CM_REMOTE.py b/src/Container/ScriptsTemplate/SALOME_CM_REMOTE.py index c4a33b196..f439a541d 100644 --- a/src/Container/ScriptsTemplate/SALOME_CM_REMOTE.py +++ b/src/Container/ScriptsTemplate/SALOME_CM_REMOTE.py @@ -2,11 +2,8 @@ import sys class ScriptRemoteParameters: def __init__(self, args): - self.debug = False - if args[0] == "-d": - self.debug = True - args = args[1:] - + import KernelBasis + self.debug = KernelBasis.VerbosityActivated() self.protocol = args[0] self.user = self._read_arg(args[1], "NULL") self.host = self._read_arg(args[2], "NULL") @@ -45,8 +42,10 @@ class ScriptRemoteParameters: # ---------------------------------------------- def command(args): + import KernelBasis options = ScriptRemoteParameters(args) - if options.debug: print(options) + if options.debug: + KernelBasis.WriteInStdout( str(options) ) # build command depending on protocol cmd = [] @@ -102,7 +101,7 @@ def command(args): if options.workdir: cmd.append("-d " + options.workdir) - cmd.append("--") + cmd.append("--") # elif ignore other appli_mode value diff --git a/src/Container/ScriptsTemplate/SALOME_CM_REMOTE_OLD.py b/src/Container/ScriptsTemplate/SALOME_CM_REMOTE_OLD.py index 9be7bd72e..a9808c17a 100644 --- a/src/Container/ScriptsTemplate/SALOME_CM_REMOTE_OLD.py +++ b/src/Container/ScriptsTemplate/SALOME_CM_REMOTE_OLD.py @@ -2,11 +2,8 @@ import sys class ScriptRemoteParameters: def __init__(self, args): - self.debug = False - if args[0] == "-d": - self.debug = True - args = args[1:] - + import KernelBasis + self.debug = KernelBasis.VerbosityActivated() self.protocol = args[0] self.user = self._read_arg(args[1], "NULL") self.host = self._read_arg(args[2], "NULL") @@ -45,8 +42,10 @@ class ScriptRemoteParameters: # ---------------------------------------------- def command(args): + import KernelBasis options = ScriptRemoteParameters(args) - if options.debug: print(options) + if options.debug: + KernelBasis.WriteInStdout( str(options) ) # build command depending on protocol cmd = [] @@ -109,7 +108,7 @@ def command(args): if options.workdir: cmd.append("-d " + options.workdir) - cmd.append("--") + cmd.append("--") # elif ignore other appli_mode value diff --git a/src/Container/ScriptsTemplate/script_parameters.py b/src/Container/ScriptsTemplate/script_parameters.py index 407f24a3e..ee1c6d3e7 100644 --- a/src/Container/ScriptsTemplate/script_parameters.py +++ b/src/Container/ScriptsTemplate/script_parameters.py @@ -1,10 +1,7 @@ class ScriptLocalParameters: def __init__(self, args): - self.debug = False - if args[0] == "-d": - self.debug = True - args = args[1:] - + import KernelBasis + self.debug = KernelBasis.VerbosityActivated() self.nb_proc = self._read_arg(args[0], "NULL") self.workdir = self._read_arg(args[1], "NULL") self.isTmpDir = True if args[2] == "1" else False -- 2.39.2