Salome HOME
Merge remote branch 'origin/bsr/resmgr'
authorvsr <vsr@opencascade.com>
Tue, 7 May 2019 10:25:36 +0000 (13:25 +0300)
committervsr <vsr@opencascade.com>
Tue, 7 May 2019 10:25:36 +0000 (13:25 +0300)
19 files changed:
bin/CMakeLists.txt
bin/appliskel/salome_tester/salome_instance.py
bin/launchConfigureParser.py
bin/orbmodule.py
bin/runRemote.py [new file with mode: 0644]
bin/runSalome.py
bin/runSession.py
bin/salomeContext.py
bin/salomeContextUtils.py.in
bin/setenv.py
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_ContainerManager.hxx
src/DSC/DSC_Basic/ConnectionManager_i.cxx
src/DSC/DSC_Basic/ConnectionManager_i.hxx
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx
src/NamingService/SALOME_NamingServicePy.py
src/ResourcesManager/ResourcesManager.cxx
src/SALOMEDS/SALOMEDS_Server.cxx

index 311ae399aaba2113ab79aae3c9797d8be3c3f643..bba6cb6d84f01ec240971220830c4d28ea3914fe 100644 (file)
@@ -48,6 +48,7 @@ SET(SCRIPTS
   runSalome.py
   runSession.py
   runConsole.py
+  runRemote.py
   runTests.py
   ${CMAKE_CURRENT_BINARY_DIR}/salomeContextUtils.py
   salomeContext.py
index 36c5aee8da27482fc8aaf66fada17588907c4d96..867fe8ed9fd0ac663f2c435cd575407f0db633a3 100755 (executable)
@@ -49,10 +49,13 @@ class SalomeInstance(object):
     salome_instance = SalomeInstance()
     salome_instance.__run(args=instance_args, with_gui=with_gui)
 
-    with open(port_log) as f:
-      salome_instance.port = int(f.readline())
+    try:
+      with open(port_log) as f:
+        salome_instance.port = int(f.readline())
+      os.remove(port_log)
+    except:
+      pass
 
-    os.remove(port_log)
     return salome_instance
   #
 
index 30f4eb73afd64bf4200a0487116e140573370cb2..1a5984cd73b7e2f200edece1cd0e00d19db603cd 100644 (file)
@@ -70,6 +70,8 @@ valgrind_session_nam = "valgrind_session"
 shutdown_servers_nam = "shutdown_servers"
 foreground_nam = "foreground"
 wake_up_session_nam = "wake_up_session"
+launcher_only_nam = "launcher_only"
+launcher_nam = "launcher"
 
 # values in XML configuration file giving specific module parameters (<module_name> section)
 # which are stored in opts with key <module_name>_<parameter> (eg SMESH_plugins)
@@ -89,8 +91,9 @@ standalone_choices = [ "registry", "study", "moduleCatalog", "cppContainer"]
 
 # values of boolean type (must be '0' or '1').
 # xml_parser.boolValue() is used for correct setting
-boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam, shutdown_servers_nam )
+boolKeys = ( gui_nam, splash_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, except_nam, pinter_nam, shutdown_servers_nam, launcher_only_nam )
 intKeys = ( interp_nam, )
+strKeys = ( launcher_nam )
 
 # values of list type
 listKeys = ( embedded_nam, key_nam, modules_nam, standalone_nam, plugins_nam )
@@ -365,6 +368,8 @@ class xml_parser:
                 self.opts[key] = self.boolValue( val )  # assign boolean value: 0 or 1
             elif nam in intKeys:
                 self.opts[key] = self.intValue( val )   # assign integer value
+            elif nam in strKeys:
+                self.opts[key] = val                    # assign value
             elif nam in listKeys:
                 self.opts[key] = [ self.strValue( a ) for a in re.split( "[:;,]", val ) ] # assign list value: []
             else:
@@ -683,6 +688,22 @@ Python file arguments, if any, must be comma-separated (without blank characters
                       dest="print_port",
                       help=help_str)
 
+    # launch only omniNames and Launcher server
+    help_str = "launch only omniNames and Launcher server"
+    pars.add_argument("--launcher_only",
+                      action="store_true",
+                      dest="launcher_only",
+                      help=help_str)
+
+    # machine and port where is the Launcher
+    help_str  = "machine and port where is the Launcher. Usage: "
+    help_str += "--launcher=machine:port"
+    pars.add_argument("--launcher",
+                      metavar="<=machine:port>",
+                      type=str,
+                      dest="launcher",
+                      help=help_str)
+
     # Do not relink ${HOME}/.omniORB_last.cfg
     help_str = "Do not save current configuration ${HOME}/.omniORB_last.cfg"
     pars.add_argument("--nosave-config",
@@ -833,7 +854,6 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None):
     # - Command line options have the highest priority and replace options
     #   specified in configuration file(s)
     ###
-
     global args
     config_var = appname+'Config'
 
@@ -1087,6 +1107,14 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None):
         args[shutdown_servers_nam] = cmd_opts.shutdown_servers
         pass
 
+    # Launcher only
+    if cmd_opts.launcher_only is not None:
+        args[launcher_only_nam] = cmd_opts.launcher_only
+
+    # machine and port where is the Launcher
+    if cmd_opts.launcher is not None:
+        args[launcher_nam] = cmd_opts.launcher
+
     # Foreground
     if cmd_opts.foreground is None:
         args[foreground_nam] = 1
index 60e800b5e24b46117dfeec25394a97cfd93b63f1..ddb8762c7e42e417f4b17a5efe44aebb8d59a14d 100644 (file)
@@ -41,6 +41,15 @@ class client:
 
     def __init__(self,args=None):
       # Initialise the ORB
+
+      if args is not None and 'launcher' in args:
+        pos = args['launcher'].find(":")
+        if pos != -1:
+          machine = args['launcher'][0:pos]
+          port = args['launcher'][pos+1:]
+          sys.argv.append('-ORBInitRef')
+          sys.argv.append("NameService=corbaname::" + machine + ":" + port)
+          print("Connect to naming service on machine: "+machine+" port: "+port)
       self.orb=CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
 
       # Initialise the Naming Service
diff --git a/bin/runRemote.py b/bin/runRemote.py
new file mode 100644 (file)
index 0000000..ea7872d
--- /dev/null
@@ -0,0 +1,101 @@
+# Copyright (C) 2007-2018  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# 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
+#
+
+import os
+from optparse import OptionParser
+import subprocess
+from salome_utils import getUserName
+from salomeContextUtils import getShortAndExtraArgs
+
+# Use to display newlines (\n) in epilog
+class MyParser(OptionParser):
+    def format_epilog(self, formatter):
+        return self.epilog
+#
+#
+# --- set the OMNIORB_CONFIG file and environment relative to this run of SALOME
+def _writeConfigFile(port, host):
+    path = os.environ['OMNIORB_USER_PATH']
+    kwargs = {'with_username' : getUserName()}
+
+    from ORBConfigFile import writeORBConfigFile
+    [ filename, msgSize ] = writeORBConfigFile(path, host, port, kwargs)
+
+    os.environ['OMNIORB_CONFIG'] = filename
+#
+
+def runRemote(args):
+    if args is None:
+      args = []
+    usage = "Usage: salome runremote [options] -- command"
+    epilog  = """\n
+Execute command in SALOME environment from a remote call, ssh or rsh.
+salome runremote is used notably to launch containers from a distant salome session.
+
+For example:
+    salome remote -m xxx.cea.fr -p 2810 -- ls /tmp >/dev/null 2>&1  
+     -> execute the command ls /tmp >/dev/null 2>&1
+
+    salome remote -m xxx.cea.fr -p 2810 -- SALOME_Container Cont_S 
+                                        -ORBInitRef NameService=IOR:01...
+     -> starts a Salome container called Cont_S connected to port 2810 
+        of xxx.cea.fr
+"""
+    parser = MyParser(usage=usage, epilog=epilog)
+    parser.add_option("-p", "--port", metavar="<port>", default="2810",
+                      action="store", type="string", dest="port",
+                      help="The port to connect to."
+                     )
+    parser.add_option("-m", "--machine", metavar="<machine>",
+                      action="store", type="string", dest="host", 
+                      default="localhost",
+                      help="The machine where salome was launched."
+                     )
+    parser.add_option('-d', '--directory', dest="directory", 
+                      metavar="<directory>", default=None,
+                      help="The directory where to execute the command."
+                     )
+
+    # separate runRemote args from the command to run (given after --)
+    short_args, extra_args = getShortAndExtraArgs(args)
+    try:
+      (options, args) = parser.parse_args(short_args)
+    except Exception as e:
+      print(e)
+      print(usage)
+      print(epilog)
+      return
+
+    port = options.port
+    host = options.host
+    directory = options.directory
+    command=extra_args[1:]
+
+    _writeConfigFile(port, host)
+    os.environ['NSPORT'] = port
+    os.environ['NSHOST'] = host
+    print("[ Remote Command ] ", " ".join(command))
+    cmd = subprocess.Popen(command, cwd=directory)
+    cmd.wait()
+    return
+#
+
index b07a5eabe493d2308e239a1540c81a43ae7d184b..e51e08cb24bf837b1dae18eac4963099996b75eb 100755 (executable)
@@ -144,7 +144,15 @@ class CatalogServer(Server):
     def __init__(self,args):
         self.args=args
         self.initArgs()
-        self.SCMD1=['SALOME_ModuleCatalog_Server','-common']
+        self.SCMD1=['SALOME_ModuleCatalog_Server']
+        if 'launcher' in self.args:
+            pos = args['launcher'].find(":")
+            if pos != -1:
+              self.SCMD1+=['-ORBInitRef']
+              machine = args['launcher'][0:pos]
+              port = args['launcher'][pos+1:]
+              self.SCMD1+=["NameService=corbaname::" + machine + ":" + port]
+        self.SCMD1+=['-common']
         self.SCMD2=[]
         home_dir=os.getenv('HOME')
         if home_dir is not None:
@@ -169,6 +177,13 @@ class SalomeDSServer(Server):
         self.args=args
         self.initArgs()
         self.CMD=['SALOMEDS_Server']
+        if 'launcher' in self.args:
+            pos = args['launcher'].find(":")
+            if pos != -1:
+              self.CMD+=['-ORBInitRef']
+              machine = args['launcher'][0:pos]
+              port = args['launcher'][pos+1:]
+              self.CMD+=["NameService=corbaname::" + machine + ":" + port]
 
 # ---
 
@@ -177,6 +192,14 @@ class ConnectionManagerServer(Server):
         self.args=args
         self.initArgs()
         self.CMD=['SALOME_ConnectionManagerServer']
+        if 'launcher' in self.args:
+            pos = args['launcher'].find(":")
+            if pos != -1:
+              self.CMD+=['-ORBInitRef']
+              machine = args['launcher'][0:pos]
+              port = args['launcher'][pos+1:]
+              self.CMD+=["NameService=corbaname::" + machine + ":" + port]
+
 
 # ---
 
@@ -185,6 +208,13 @@ class RegistryServer(Server):
         self.args=args
         self.initArgs()
         self.CMD=['SALOME_Registry_Server', '--salome_session','theSession']
+        if 'launcher' in self.args:
+            pos = args['launcher'].find(":")
+            if pos != -1:
+              self.CMD+=['-ORBInitRef']
+              machine = args['launcher'][0:pos]
+              port = args['launcher'][pos+1:]
+              self.CMD+=["NameService=corbaname::" + machine + ":" + port]
 
 # ---
 
@@ -192,7 +222,15 @@ class ContainerCPPServer(Server):
     def __init__(self,args,with_gui=False):
         self.args=args
         self.initArgs()
-        self.CMD=['SALOME_Container','FactoryServer']
+        self.CMD=['SALOME_Container']
+        if 'launcher' in self.args:
+            pos = args['launcher'].find(":")
+            if pos != -1:
+              self.CMD+=['-ORBInitRef']
+              machine = args['launcher'][0:pos]
+              port = args['launcher'][pos+1:]
+              self.CMD+=["NameService=corbaname::" + machine + ":" + port]
+        self.CMD+=['FactoryServer']
         if not with_gui and self.args["valgrind_session"]:
             l = ["valgrind"]
             val = os.getenv("VALGRIND_OPTIONS")
@@ -234,6 +272,13 @@ class SessionServer(Server):
         self.initArgs()
         self.SCMD1=['SALOME_Session_Server']
         self.SCMD2=[]
+        if 'launcher' in self.args:
+            pos = args['launcher'].find(":")
+            if pos != -1:
+              self.SCMD1+=['-ORBInitRef']
+              machine = args['launcher'][0:pos]
+              port = args['launcher'][pos+1:]
+              self.SCMD1+=["NameService=corbaname::" + machine + ":" + port]
         if 'registry' in self.args['embedded']:
             self.SCMD1+=['--with','Registry',
                          '(','--salome_session','theSession',')']
@@ -471,7 +516,7 @@ def startSalome(args, modules_list, modules_root_dir):
     # Launch  Session Server (to show splash ASAP)
     #
 
-    if args["gui"]:
+    if args["gui"] and not args['launcher_only']:
         mySessionServ = SessionServer(args,args['modules'],modules_root_dir)
         mySessionServ.setpath(modules_list,modules_root_dir)
         mySessionServ.run()
@@ -523,17 +568,18 @@ def startSalome(args, modules_list, modules_root_dir):
     # Launch LauncherServer
     #
 
-    myCmServer = LauncherServer(args)
-    myCmServer.setpath(modules_list,modules_root_dir)
-    myCmServer.run()
+    if not 'launcher' in args:
+      myCmServer = LauncherServer(args)
+      myCmServer.setpath(modules_list,modules_root_dir)
+      myCmServer.run()
 
     #
     # Launch ConnectionManagerServer
     #
 
-    myConnectionServer = ConnectionManagerServer(args)
-    myConnectionServer.run()
-
+    if not args['launcher_only']:
+      myConnectionServer = ConnectionManagerServer(args)
+      myConnectionServer.run()
 
     from Utils_Identity import getShortHostName
 
@@ -565,7 +611,7 @@ def startSalome(args, modules_list, modules_root_dir):
     # Wait until Session Server is registered in naming service
     #
 
-    if args["gui"]:
+    if args["gui"] and not args['launcher_only']:
 ##----------------
         import Engines
         import SALOME
@@ -776,7 +822,7 @@ def main(exeName=None):
     if args['wake_up_session']:
         test = False
         pass
-    if test:
+    if test and not 'launcher' in args:
         from searchFreePort import searchFreePort
         searchFreePort(args, save_config, args.get('useport'))
         pass
index 305fda70feba7a21c82b82e8042b70172218d817..fde468001a926bcf7b8934023b0fe55f67104107 100644 (file)
@@ -118,6 +118,10 @@ User "myself" connects to remotemachine to run the script concatenate.py in
                     help="[Remote mode] The user on the computer to connect to."
                     )
 
+  parser.add_option('-l', '--launcher', dest="launcher", default=None,
+                    help="[Remote mode] The machine and the port to connect to."
+                    )
+
   short_args, extra_args = getShortAndExtraArgs(args)
   try:
     (options, args) = parser.parse_args(short_args)
@@ -127,6 +131,12 @@ User "myself" connects to remotemachine to run the script concatenate.py in
 
   port = options.port
   host = options.host
+  launcher = options.launcher
+  if launcher is not None:
+    pos = launcher.find(":")
+    if pos != -1:
+      host = launcher[0:pos]
+      port = launcher[pos+1:]
 
   # :GLITCH: this code defines specific environment variables (OMNIORB_CONFIG, NSPORT,
   # NSHOST) which are later used by other modules. Working, but not really "safe"...
@@ -162,7 +172,7 @@ User "myself" connects to remotemachine to run the script concatenate.py in
   # determine running mode, that is either 'local' or 'remote'
   here = getShortHostName()
   mode = "local"
-  if host != here and host != "localhost" and host != "no_host":
+  if host != here and host != "localhost" and host != "no_host" and launcher is None:
     mode="remote"
     pass
   params = SessionParameters(mode, port, host, options.user, options.directory)
index 85d132655b4552c9cb5ea0dd10e82f1ed5a00c6e..ae0267c9d78f6eb794f4d3a8f08f33a33fc24a22 100755 (executable)
@@ -45,6 +45,7 @@ Commands:
                     User works in a Shell terminal. SALOME environment is set but
                     application is not started.
     connect         Connect a Python console to the active SALOME instance.
+    remote          run command in SALOME environment from remote call, ssh or rsh.
     kill <port(s)>  Terminate SALOME instances running on given ports for current user.
                     Port numbers must be separated by blank characters.
     killall         Terminate *all* SALOME running instances for current user.
@@ -216,6 +217,7 @@ class SalomeContext:
       'start'   : '_runAppli',
       'context' : '_setContext',
       'shell'   : '_runSession',
+      'remote'  : '_runRemote',
       'connect' : '_runConsole',
       'kill'    : '_kill',
       'killall' : '_killAll',
@@ -362,6 +364,18 @@ class SalomeContext:
     return runSession.runSession(params, args)
   #
 
+  def _runRemote(self, args=None):
+    if args is None:
+      args = []
+#   complete salome environment 
+    sys.argv = ['runRemote']
+    import setenv
+    setenv.main(True)
+
+    import runRemote
+    return runRemote.runRemote(args)
+  #
+
   def _runConsole(self, args=None):
     if args is None:
       args = []
index 318c40c2bce17514f81f98d6612414f6678ead95..6971315d7da818150370e555a684526e0d9be525 100644 (file)
@@ -308,9 +308,9 @@ def formatScriptsAndArgs(scriptArgs=None):
 # If OMNIORB_USER_PATH is already set, only checks write access to associated directory ;
 # an exception is raised if check fails. It allows users for choosing a specific folder.
 # Else the function sets OMNIORB_USER_PATH this way:
-# - If APPLI environment variable is set, OMNIORB_USER_PATH is set to ${APPLI}/USERS.
-#   The function does not check USERS folder existence or write access. This folder
-#   must exist ; this is the case if SALOME virtual application has been created using
+# - If APPLI environment variable is set, and if ${APPLI}/USERS points at an existing 
+#   folder with write access, then OMNIORB_USER_PATH is set to ${APPLI}/USERS.
+#   This is the case if SALOME virtual application has been created using
 #   appli_gen.py script.
 # - Else OMNIORB_USER_PATH is set to user home directory.
 def setOmniOrbUserPath():
@@ -334,7 +334,9 @@ def setOmniOrbUserPath():
       #defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
       defaultOmniorbUserPath = homePath
       if os.getenv("APPLI"):
-        defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS")
+        appli_users_path=os.path.join(homePath, os.getenv("APPLI"), "USERS")
+        if os.access(appli_users_path, os.W_OK):
+          defaultOmniorbUserPath = appli_users_path
         pass
       os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
 #
index 21ad0a2a77ecd23d857f8e668e715c6de056a520..09ecdb1724961e89af8f4541a9fe0c4527610ee2 100755 (executable)
@@ -146,6 +146,13 @@ def set_env(args, modules_list, modules_root_dir, silent=False):
     import os
     from salome_utils import getLogDir, generateFileName, makeTmpDir, getPortNumber
 
+    if 'launcher' in args:
+      pos = args['launcher'].find(":")
+      if pos != -1:
+        machine = args['launcher'][0:pos]
+        port = args['launcher'][pos+1:]
+        os.environ["NSPORT"] = port
+
     # create temporary directory for environment files needed by modules from the list
     port = getPortNumber(False)
     if port:
index 0d21953b24aed1fdbb0fa9a3107d04adb5c7177e..1837cfc6dc787243f60b2437d26b951abd067151 100644 (file)
@@ -519,26 +519,13 @@ SALOME_ContainerManager::LaunchContainer(const Engines::ContainerParameters& par
     // Only if an application directory is set
     if(hostname != Kernel_Utils::GetHostname() && _isAppliSalomeDefined)
       {
-        // Preparing remote command
-        std::string command = "";
+
         const ParserResourcesType resInfo(_resManager->GetResourceDefinition(resource_selected));
-        command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName, resInfo.UserName);
-        if (resInfo.AppliPath != "")
-          command += resInfo.AppliPath;
-        else
-          {
-            ASSERT(GetenvThreadSafe("APPLI"));
-            command += GetenvThreadSafeAsString("APPLI");
-          }
-        command += "/runRemote.sh ";
-        ASSERT(GetenvThreadSafe("NSHOST"));
-        command += GetenvThreadSafeAsString("NSHOST"); // hostname of CORBA name server
-        command += " ";
-        ASSERT(GetenvThreadSafe("NSPORT"));
-        command += GetenvThreadSafeAsString("NSPORT"); // port of CORBA name server
-        command += " \"ls /tmp >/dev/null 2>&1\"";
+        std::string command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName, 
+                                                           resInfo.UserName, resInfo.AppliPath);
 
         // Launch remote command
+          command += " \"ls /tmp >/dev/null 2>&1\"";
         int status = SystemThreadSafe(command.c_str());
         if (status != 0)
           {
@@ -760,37 +747,16 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer(const std::string&
         nbproc = params.nb_proc;
     }
 
-    // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir
-    //  SALOME_Container containerName &"
-    command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName, resInfo.UserName);
-
-    if (resInfo.AppliPath != "")
-      command += resInfo.AppliPath; // path relative to user@machine $HOME
-    else
-    {
-      ASSERT(GetenvThreadSafe("APPLI"));
-      command += GetenvThreadSafeAsString("APPLI"); // path relative to user@machine $HOME
-    }
-
-    command += "/runRemote.sh ";
-
-    ASSERT(GetenvThreadSafe("NSHOST"));
-    command += GetenvThreadSafeAsString("NSHOST"); // hostname of CORBA name server
-
-    command += " ";
-    ASSERT(GetenvThreadSafe("NSPORT"));
-    command += GetenvThreadSafeAsString("NSPORT"); // port of CORBA name server
-
     std::string wdir = params.workingdir.in();
-    if(wdir != "")
-    {
-      command += " WORKINGDIR ";
-      command += " '";
-      if(wdir == "$TEMPDIR")
-        wdir="\\$TEMPDIR";
-      command += wdir; // requested working directory
-      command += "'";
-    }
+
+    // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
+    //  SALOME_Container containerName -ORBInitRef NameService=IOR:01000..."
+    //  or 
+    //  "ssh -l user machine distantLauncher remote -p hostNS -m portNS -d dir
+    //      --  SALOME_Container contName -ORBInitRef NameService=IOR:01000..."
+    command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName, 
+                                           resInfo.UserName, resInfo.AppliPath,
+                                           wdir);
 
     if(params.isMPI)
     {
@@ -1212,43 +1178,8 @@ std::string SALOME_ContainerManager::GetMPIZeroNode(const std::string machine, c
     {
       if (_isAppliSalomeDefined)
         {
-
-          if (resInfo.Protocol == rsh)
-            command = "rsh ";
-          else if (resInfo.Protocol == ssh)
-            command = "ssh ";
-          else if (resInfo.Protocol == srun)
-            command = "srun -n 1 -N 1 --share --mem-per-cpu=0 --nodelist=";
-          else
-            throw SALOME_Exception("Unknown protocol");
-
-          if (resInfo.UserName != "")
-            {
-              command += "-l ";
-              command += resInfo.UserName;
-              command += " ";
-            }
-
-          command += resInfo.HostName;
-          command += " ";
-
-          if (resInfo.AppliPath != "")
-            command += resInfo.AppliPath; // path relative to user@machine $HOME
-          else
-            {
-              ASSERT(GetenvThreadSafe("APPLI"));
-              command += GetenvThreadSafeAsString("APPLI"); // path relative to user@machine $HOME
-            }
-
-          command += "/runRemote.sh ";
-
-          ASSERT(GetenvThreadSafe("NSHOST"));
-          command += GetenvThreadSafeAsString("NSHOST"); // hostname of CORBA name server
-
-          command += " ";
-          ASSERT(GetenvThreadSafe("NSPORT"));
-          command += GetenvThreadSafeAsString("NSPORT"); // port of CORBA name server
-
+          command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName, 
+                                                 resInfo.UserName, resInfo.AppliPath);
           command += " mpirun -np 1 hostname -s > " + tmpFile;
         }
       else
@@ -1299,7 +1230,9 @@ std::string SALOME_ContainerManager::machinesFile(const int nbproc)
 
 std::string SALOME_ContainerManager::getCommandToRunRemoteProcess(AccessProtocolType protocol,
                                                                   const std::string & hostname,
-                                                                  const std::string & username)
+                                                                  const std::string & username,
+                                                                  const std::string & applipath,
+                                                                  const std::string & workdir)
 {
   std::ostringstream command;
   switch (protocol)
@@ -1335,6 +1268,52 @@ std::string SALOME_ContainerManager::getCommandToRunRemoteProcess(AccessProtocol
     throw SALOME_Exception("Unknown protocol");
   }
 
+  std::string remoteapplipath;
+  if (applipath=="")
+    remoteapplipath = GetenvThreadSafeAsString("APPLI");
+  else
+    remoteapplipath = applipath;
+
+  ASSERT(GetenvThreadSafe("NSHOST"));
+  ASSERT(GetenvThreadSafe("NSPORT"));
+
+  // $APPLI points either to an application directory, or to a salome launcher file
+  // we prepare the remote command according to the case
+  struct stat statbuf;
+  if (stat(GetenvThreadSafe("APPLI"), &statbuf) ==0 &&  S_ISREG(statbuf.st_mode))
+  {
+    // if $APPLI is a regular file, we asume it's a salome Launcher
+    // generate a command with a salome launcher
+    command << remoteapplipath 
+            << " remote"
+            << " -m "
+            <<  GetenvThreadSafeAsString("NSHOST") // hostname of CORBA name server
+            << " -p "
+            <<  GetenvThreadSafeAsString("NSPORT"); // port of CORBA name server
+    if (workdir != "")
+      command << "-d " << workdir;
+    command <<  " -- " ;
+  }
+  else  // we assume it's a salome application directory
+  {
+    // 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
+    if(workdir != "")
+    {
+      command << " WORKINGDIR ";
+      command << " '";
+      if(workdir == "$TEMPDIR")
+          command << "\\$TEMPDIR";
+      else
+        command << workdir; // requested working directory
+      command << "'";
+    }
+  }
+
   return command.str();
 }
 
index 4c9293e16c5d86da4254075e7b6c0f4c3f6e0e82..941603e936d88a7a4a939af654a6a1e0b39604d5 100644 (file)
@@ -89,7 +89,11 @@ protected:
 
   std::string machinesFile(const int nbproc);
 
- static std::string getCommandToRunRemoteProcess(AccessProtocolType protocol, const std::string & hostname, const std::string & username);
+ static std::string getCommandToRunRemoteProcess(AccessProtocolType protocol, 
+                                                 const std::string & hostname, 
+                                                 const std::string & username,
+                                                 const std::string & applipath,
+                                                 const std::string & workdir="");
 
   Engines::Container_ptr
   LaunchContainer(const Engines::ContainerParameters& params,
index 90a5943cfc406110e0e222541ee4c267afc2d3dc..eda264295df9600bbf3fbba9dc7348642cdb7373 100644 (file)
@@ -25,7 +25,6 @@
 //  Module : KERNEL
 //
 #include "ConnectionManager_i.hxx"
-#include "SALOME_NamingService.hxx"
 
 #ifdef WIN32
 # include <process.h>
 # include <unistd.h>
 #endif
 
+const char * ConnectionManager_i::_ConnectionManagerNameInNS = "/ConnectionManager";
+
 ConnectionManager_i::ConnectionManager_i(CORBA::ORB_ptr orb) {
   _orb = CORBA::ORB::_duplicate(orb) ;
-  SALOME_NamingService * ns = new SALOME_NamingService(orb);
-  const char * ConnectionManagerNameInNS = "/ConnectionManager";
+  _NS = new SALOME_NamingService(orb);
   CORBA::Object_var obref = _this();
   _remove_ref();
-  ns->Register(obref, ConnectionManagerNameInNS);
-  delete ns;
+  _NS->Register(obref, _ConnectionManagerNameInNS);
 
   current_id = 0;
   pthread_mutex_init(&mutex, NULL);
 }
 
-ConnectionManager_i::~ConnectionManager_i() {}
+ConnectionManager_i::~ConnectionManager_i()
+{
+  delete _NS;
+}
 
 Engines::ConnectionManager::connectionId
 ConnectionManager_i::connect(Engines::DSC_ptr uses_component, 
@@ -122,6 +124,7 @@ ConnectionManager_i::disconnect(Engines::ConnectionManager::connectionId id,
 void
 ConnectionManager_i::ShutdownWithExit()
 {
+  _NS->Destroy_Name(_ConnectionManagerNameInNS);
   ids_it = ids.begin();
   while(ids_it != ids.end())
     {
index e3f6f24ce88b80c57c3865bb4f00c54afee2a9c7..84c7c94f68cab5605fef2843cc275e68f740321d 100644 (file)
@@ -28,6 +28,7 @@
 #define _CONNECTION_MANAGER_I_HXX_
 
 #include "DSC_Basic.hxx"
+#include "SALOME_NamingService.hxx"
 
 #include <iostream>
 #include <map>
@@ -74,6 +75,8 @@ class ConnectionManager_i :
      */
     CORBA::Long getPID();
 
+    static const char *_ConnectionManagerNameInNS;
+
   private :
 
     struct connection_infos {
@@ -96,6 +99,7 @@ class ConnectionManager_i :
     pthread_mutex_t mutex;
   protected:
     CORBA::ORB_var _orb;
+    SALOME_NamingService * _NS;
 };
 
 #endif
index a6f1d9a5745c4b4224e4f815fae1ebe14bc4f089..1e3ce0cdacd718cee85886f4c1f84a3327db84e5 100644 (file)
@@ -420,7 +420,7 @@ Engines::ResourcesManager_ptr SALOME_LifeCycleCORBA::getResourcesManager()
  */
 //=============================================================================
 
-void SALOME_LifeCycleCORBA::shutdownServers()
+void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher)
 {
   // get each Container from NamingService => shutdown it
   // (the order is inverse to the order of servers initialization)
@@ -469,6 +469,7 @@ void SALOME_LifeCycleCORBA::shutdownServers()
       SALOMEDS::Study_var study = SALOMEDS::Study::_narrow(objSDS) ;
       if ( !CORBA::is_nil(study) && ( pid != study->getPID() ) )
         study->Shutdown();
+      _NS->Destroy_Name("/Study");
     }
   catch(const CORBA::Exception& e)
     {
@@ -487,6 +488,7 @@ void SALOME_LifeCycleCORBA::shutdownServers()
       SALOME_ModuleCatalog::ModuleCatalog_var catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objMC);
       if ( !CORBA::is_nil(catalog) && ( pid != catalog->getPID() ) )
         catalog->shutdown();
+      _NS->Destroy_Name("/Kernel/ModulCatalog");
     }
   catch(const CORBA::Exception& e)
     {
@@ -513,10 +515,12 @@ void SALOME_LifeCycleCORBA::shutdownServers()
   // 5) SalomeLauncher
   try
     {
-      CORBA::Object_var objSL = _NS->Resolve("/SalomeLauncher");
-      Engines::SalomeLauncher_var launcher = Engines::SalomeLauncher::_narrow(objSL);
-      if (!CORBA::is_nil(launcher) && (pid != launcher->getPID()))
-        launcher->Shutdown();
+      if(shutdownLauncher){
+        CORBA::Object_var objSL = _NS->Resolve("/SalomeLauncher");
+        Engines::SalomeLauncher_var launcher = Engines::SalomeLauncher::_narrow(objSL);
+        if (!CORBA::is_nil(launcher) && (pid != launcher->getPID()))
+          launcher->Shutdown();
+      }
     }
   catch(const CORBA::Exception& e)
     {
@@ -535,6 +539,7 @@ void SALOME_LifeCycleCORBA::shutdownServers()
       Registry::Components_var registry = Registry::Components::_narrow(objR);
       if ( !CORBA::is_nil(registry) && ( pid != registry->getPID() ) )
           registry->Shutdown();
+      _NS->Destroy_Name("/Registry");
     }
   catch(const CORBA::Exception& e)
     {
index 2a0ae9248175710b54c9bdb078be37871bb1bf22..ad6d7bb62022f9b2998f30f86656f562a8d9acd8 100644 (file)
@@ -99,7 +99,7 @@ public:
   CORBA::ORB_ptr orb();
   void copyFile(const char* hostSrc, const char* fileSrc, const char* hostDest, const char* fileDest);
 
-  void shutdownServers();
+  void shutdownServers(bool shutdownLauncher=true);
   static void killOmniNames();
 
 protected:
index 342c9371608bd26b354e29cf5f90af4207411b89..8fdde096bfece450976281493ec1efc1c8b89869 100644 (file)
@@ -190,6 +190,43 @@ class SALOME_NamingServicePy_i(object):
             self._obj = None
         return self._obj
 
+    #-------------------------------------------------------------------------
+
+    def Resolve_Dir(self, Path):
+        """ ns.Resolve_Dir(pathname) -> dir
+
+        find a CORBA object (ior) by its pathname
+        """
+        #MESSAGE ( "SALOME_NamingServicePy_i::Resolve" )
+        path_list = list(Path)
+        if path_list[0]=='/':
+            self._current_context = self._root_context
+            #delete first '/' before split
+            Path=Path[1:]
+
+        result_resolve_path = Path.split('/')
+        _context_name=[]
+        for i in range(len(result_resolve_path)-1):
+            _context_name.append(CosNaming.NameComponent(result_resolve_path[i],"dir"))
+        _context_name.append(CosNaming.NameComponent(result_resolve_path[len(result_resolve_path)-1],"dir"))
+        print(_context_name)
+        return None
+        try:
+            self._obj = self._current_context.resolve(_context_name)
+        except CosNaming.NamingContext.NotFound as ex:
+            MESSAGE ( "Resolve : CosNaming.NamingContext.NotFound" )
+            self._obj = None
+        except CosNaming.NamingContext.InvalidName as ex:
+            MESSAGE ( "Resolve : CosNaming.NamingContext.InvalidName" )
+            self._obj = None
+        except CosNaming.NamingContext.CannotProceed as ex:
+            MESSAGE ( "Resolve : CosNaming.NamingContext.CannotProceed" )
+            self._obj = None
+        except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
+            MESSAGE ( "Resolve : CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE" )
+            self._obj = None
+        return self._obj
+
 
     #-------------------------------------------------------------------------
 
index f53cce8ac73c0b33038aa14337b32cf8b511e042..650160d617f5df8e0f87addcd61ae89b47e03151 100644 (file)
@@ -148,17 +148,23 @@ ResourcesManager_cpp::ResourcesManager_cpp() throw(ResourcesException)
       default_file += "/";
       default_file += getenv("APPLI");
       default_file += "/CatalogResources.xml";
-      _path_resources.push_back(default_file);
-    }
-    else
-    {
-      if(!getenv("KERNEL_ROOT_DIR"))
-        throw ResourcesException("you must define KERNEL_ROOT_DIR environment variable!! -> cannot load a CatalogResources.xml");
-      default_file = getenv("KERNEL_ROOT_DIR");
-      default_file += "/share/salome/resources/kernel/CatalogResources.xml";
-      _path_resources.push_back(default_file);
+      std::ifstream ifile(default_file.c_str(), std::ifstream::in );
+      if (ifile) {
+        // The file exists, and is open for input
+        _path_resources.push_back(default_file);
+        default_catalog_resource=false;
+      }
     }
   }
+  if (default_catalog_resource)
+  {
+    std::string default_file("");
+    if(!getenv("KERNEL_ROOT_DIR"))
+      throw ResourcesException("you must define KERNEL_ROOT_DIR environment variable!! -> cannot load a CatalogResources.xml");
+    default_file = getenv("KERNEL_ROOT_DIR");
+    default_file += "/share/salome/resources/kernel/CatalogResources.xml";
+    _path_resources.push_back(default_file);
+  }
 
   ParseXmlFiles();
   RES_MESSAGE("ResourcesManager_cpp constructor end");
index 821806ec2ac9898791809b6865ada35058dbffa9..bb66e6e9dcf5ad13b7a744c4da3e53d138784e3b 100644 (file)
@@ -197,6 +197,7 @@ int main(int argc, char** argv)
 #endif
       orb->run();
       MESSAGE( "end of SALOME_DS server" );
+      NS->Destroy_Name("/Study");
       orb->destroy();
     }
   catch(CORBA::SystemException&)