]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
KERNEL ContainerManager is able to launch SALOME_Container_No_NS_Serv on remote nodes
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 11 Jun 2021 13:08:07 +0000 (15:08 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 11 Jun 2021 13:08:07 +0000 (15:08 +0200)
bin/appli_gen.py
bin/appliskel/CMakeLists.txt
bin/appliskel/runRemoteSSL.sh [new file with mode: 0755]
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_ContainerManager.hxx

index 89650dffa1a405395a2358d498a7832d1c49b94a..63ef704368b98086317e147f5dc0b4225c41b517 100755 (executable)
@@ -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',
index 5cfc22427e8d5d046373cebb375363548f00a1e8..aa88b5be53d80b685481bef96f17f6e72177e87f 100644 (file)
@@ -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 (executable)
index 0000000..ff81b9e
--- /dev/null
@@ -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"
index f709319f22cb268909d9a7ea7b2b1e8894c400f9..ff7d9518c2eaaf2cb3fbb8752e538dc716fc53a3 100644 (file)
@@ -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 ";
index bc8587ce36454af41a1b65deca30f6f4326d0dbe..35be333e2819d7775bde0a20f20d224ff4ea5979 100644 (file)
@@ -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,