From 6a6c2104dd33deedf1ac900df21e0c05f5a27496 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 11 Jun 2021 15:08:07 +0200 Subject: [PATCH] KERNEL ContainerManager is able to launch SALOME_Container_No_NS_Serv on remote nodes --- bin/appli_gen.py | 1 + bin/appliskel/CMakeLists.txt | 1 + bin/appliskel/runRemoteSSL.sh | 83 +++++++++++++++++++++++ src/Container/SALOME_ContainerManager.cxx | 43 +++++++++--- src/Container/SALOME_ContainerManager.hxx | 14 ++-- 5 files changed, 128 insertions(+), 14 deletions(-) create mode 100755 bin/appliskel/runRemoteSSL.sh diff --git a/bin/appli_gen.py b/bin/appli_gen.py index 89650dffa..63ef70436 100755 --- a/bin/appli_gen.py +++ b/bin/appli_gen.py @@ -274,6 +274,7 @@ def install(prefix, config_file, verbose=0): 'getAppliPath.py', 'kill_remote_containers.py', 'runRemote.sh', + 'runRemoteSSL.sh', '.salome_run', 'update_catalogs.py', '.bashrc', diff --git a/bin/appliskel/CMakeLists.txt b/bin/appliskel/CMakeLists.txt index 5cfc22427..aa88b5be5 100644 --- a/bin/appliskel/CMakeLists.txt +++ b/bin/appliskel/CMakeLists.txt @@ -28,6 +28,7 @@ ADD_SUBDIRECTORY(tests) SET(SCRIPTS envd runRemote.sh + runRemoteSSL.sh .bashrc getAppliPath.py update_catalogs.py diff --git a/bin/appliskel/runRemoteSSL.sh b/bin/appliskel/runRemoteSSL.sh new file mode 100755 index 000000000..ff81b9e66 --- /dev/null +++ b/bin/appliskel/runRemoteSSL.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# Copyright (C) 2021 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# --- run command in SALOME environment from remote call, ssh or rsh +# - SALOME configuration is defined by : +# - list of MODULE_ROOT_DIR +# - prerequisite environment +# - specific configuration for a particular SALOME application +# - These elements of configuration are defined locally on each computer +# in the directory APPLI: +# - A SALOME application distributed on several computers needs APPLI +# directories on the same path ($APPLI) relative to $HOME directory +# of the user, on each computer. +# --- call example (from cli76cd to cli76ce): +# ssh cli76ce ${APPLI}/runRemoteSSL.sh IOR_OF_CURSTOM_NS SALOME_Container myContainerName +# --- local arguments +# $0 : ${APPLI}/runRemote.sh: from arg name, rebuild and export $APPLI variable +# $1 : IOR_OF_CURSTOM_NS of reference to Engines::EmbeddedNamingService servant +# $2 : WORKINGDIR (if $2 == WORKINDIR a working dir is given in $3. If not the working dir is $HOME) +# $3 : if $2 == WORKINGDIR, the path to the workingdir +# $4 (or $2 if no workingdir given) and following : local command to execute, with args +# --- retrieve APPLI path, relative to $HOME, set ${APPLI} + +APPLI_HOME=$(dirname "$0") +export APPLI=$("${APPLI_HOME}/getAppliPath.py") + +# --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...) +# Sourcing files with parameters works with bash, not with dash. This is why +# we must use bash for this script. + +. "${HOME}/${APPLI}/envd" "${HOME}/${APPLI}" + +# --- set the OMNIORB_CONFIG file and environment relative to this run of SALOME +export CUSTOM_NS_IOR=$1 + +#go to the requested working directory if any +if test "x$2" == "xWORKINGDIR"; then + if test "x$3" = "x\$TEMPDIR"; then + #create a temp working dir and change to it + WDIR=$(mktemp -d) && { + cd "$WDIR" + } + else + if test -d "$3"; then + #the dir exists, go to it + cd "$3" + else + if test -a "$3"; then + # It's a file do nothing + echo "$3 is an existing file. Can't use it as a working directory" + else + #It does not exists, create it + mkdir -p "$3" && { + cd "$3" + } + fi + fi + fi + shift 3 +else + shift 1 +fi + +# --- execute the command in the SALOME environment + +"${KERNEL_ROOT_DIR}/bin/salome/envSalome.py" /bin/sh -c "$* $CUSTOM_NS_IOR" diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index f709319f2..ff7d9518c 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -454,6 +454,18 @@ Engines::Container_ptr SALOME_ContainerManager::GiveContainer(const Engines::Con return ret; } +std::string SALOME_ContainerManager::GetCppBinaryOfKernelContainer() const +{ + std::string ret = this->_isSSL ? "SALOME_Container_No_NS_Serv" : "SALOME_Container"; + return ret; +} + +std::string SALOME_ContainerManager::GetRunRemoteExecutableScript() const +{ + std::string ret = this->_isSSL ? "runRemoteSSL.sh" : "runRemote.sh"; + return ret; +} + Engines::Container_ptr SALOME_ContainerManager::LaunchContainer(const Engines::ContainerParameters& params, const std::string & resource_selected, @@ -470,7 +482,7 @@ SALOME_ContainerManager::LaunchContainer(const Engines::ContainerParameters& par // Mpi already tested in step 5, specific code on BuildCommandToLaunch Local/Remote Container methods // TODO -> separates Mpi from Classic/Exe // Classic or Exe ? - std::string container_exe = this->_isSSL ? "SALOME_Container_No_NS_Serv" : "SALOME_Container"; // Classic container + std::string container_exe = this->GetCppBinaryOfKernelContainer(); Engines::ContainerParameters local_params(params); int found=0; try @@ -778,9 +790,11 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer(const std::string& command += " " +container_exe+ " "; command += _NS->ContainerName(params); - command += " -"; - AddOmninamesParams(command); - + if(!this->_isSSL) + { + command += " -"; + AddOmninamesParams(command); + } MESSAGE("command =" << command); } @@ -1232,7 +1246,7 @@ std::string SALOME_ContainerManager::getCommandToRunRemoteProcess(AccessProtocol const std::string & hostname, const std::string & username, const std::string & applipath, - const std::string & workdir) + const std::string & workdir) const { std::ostringstream command; switch (protocol) @@ -1298,10 +1312,21 @@ std::string SALOME_ContainerManager::getCommandToRunRemoteProcess(AccessProtocol { // generate a command with runRemote.sh command << remoteapplipath; - command << "/runRemote.sh "; - command << GetenvThreadSafeAsString("NSHOST"); // hostname of CORBA name server - command << " "; - command << GetenvThreadSafeAsString("NSPORT"); // port of CORBA name server + command << "/" << this->GetRunRemoteExecutableScript() << " "; + + if(this->_isSSL) + { + Engines::EmbeddedNamingService_var ns = GetEmbeddedNamingService(); + CORBA::String_var iorNS = _orb->object_to_string(ns); + command << iorNS; + } + else + { + command << GetenvThreadSafeAsString("NSHOST"); // hostname of CORBA name server + command << " "; + command << GetenvThreadSafeAsString("NSPORT"); // port of CORBA name server + } + if(workdir != "") { command << " WORKINGDIR "; diff --git a/src/Container/SALOME_ContainerManager.hxx b/src/Container/SALOME_ContainerManager.hxx index bc8587ce3..35be333e2 100644 --- a/src/Container/SALOME_ContainerManager.hxx +++ b/src/Container/SALOME_ContainerManager.hxx @@ -67,6 +67,10 @@ protected: FindContainer(const Engines::ContainerParameters& params, const std::string& resource); + std::string GetCppBinaryOfKernelContainer() const; + + std::string GetRunRemoteExecutableScript() const; + std::string BuildCommandToLaunchRemoteContainer(const std::string & resource_name, const Engines::ContainerParameters& params, const std::string& container_exe="SALOME_Container") const; @@ -91,11 +95,11 @@ protected: std::string machinesFile(const int nbproc); - static std::string getCommandToRunRemoteProcess(AccessProtocolType protocol, - const std::string & hostname, - const std::string & username, - const std::string & applipath, - const std::string & workdir=""); + std::string getCommandToRunRemoteProcess(AccessProtocolType protocol, + const std::string & hostname, + const std::string & username, + const std::string & applipath, + const std::string & workdir="") const; Engines::Container_ptr LaunchContainer(const Engines::ContainerParameters& params, -- 2.39.2