From: vsr Date: Tue, 7 May 2019 10:25:36 +0000 (+0300) Subject: Merge remote branch 'origin/bsr/resmgr' X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d2eba6b9e0622cef37027558edeef4f070bbb549;hp=f8c9e0b384d0698e6c1529f6e52b2d14957cfcd6;p=modules%2Fyacs.git Merge remote branch 'origin/bsr/resmgr' --- diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index 311ae399a..bba6cb6d8 100644 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -48,6 +48,7 @@ SET(SCRIPTS runSalome.py runSession.py runConsole.py + runRemote.py runTests.py ${CMAKE_CURRENT_BINARY_DIR}/salomeContextUtils.py salomeContext.py diff --git a/bin/appliskel/salome_tester/salome_instance.py b/bin/appliskel/salome_tester/salome_instance.py index 36c5aee8d..867fe8ed9 100755 --- a/bin/appliskel/salome_tester/salome_instance.py +++ b/bin/appliskel/salome_tester/salome_instance.py @@ -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 # diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 30f4eb73a..1a5984cd7 100644 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -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 ( section) # which are stored in opts with key _ (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 diff --git a/bin/orbmodule.py b/bin/orbmodule.py index 60e800b5e..ddb8762c7 100644 --- a/bin/orbmodule.py +++ b/bin/orbmodule.py @@ -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 index 000000000..ea7872dde --- /dev/null +++ b/bin/runRemote.py @@ -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="", default="2810", + action="store", type="string", dest="port", + help="The port to connect to." + ) + parser.add_option("-m", "--machine", metavar="", + action="store", type="string", dest="host", + default="localhost", + help="The machine where salome was launched." + ) + parser.add_option('-d', '--directory', dest="directory", + metavar="", 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 +# + diff --git a/bin/runSalome.py b/bin/runSalome.py index b07a5eabe..e51e08cb2 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -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 diff --git a/bin/runSession.py b/bin/runSession.py index 305fda70f..fde468001 100644 --- a/bin/runSession.py +++ b/bin/runSession.py @@ -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) diff --git a/bin/salomeContext.py b/bin/salomeContext.py index 85d132655..ae0267c9d 100755 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -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 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 = [] diff --git a/bin/salomeContextUtils.py.in b/bin/salomeContextUtils.py.in index 318c40c2b..6971315d7 100644 --- a/bin/salomeContextUtils.py.in +++ b/bin/salomeContextUtils.py.in @@ -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 # diff --git a/bin/setenv.py b/bin/setenv.py index 21ad0a2a7..09ecdb172 100755 --- a/bin/setenv.py +++ b/bin/setenv.py @@ -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: diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 0d21953b2..1837cfc6d 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -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(); } diff --git a/src/Container/SALOME_ContainerManager.hxx b/src/Container/SALOME_ContainerManager.hxx index 4c9293e16..941603e93 100644 --- a/src/Container/SALOME_ContainerManager.hxx +++ b/src/Container/SALOME_ContainerManager.hxx @@ -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, diff --git a/src/DSC/DSC_Basic/ConnectionManager_i.cxx b/src/DSC/DSC_Basic/ConnectionManager_i.cxx index 90a5943cf..eda264295 100644 --- a/src/DSC/DSC_Basic/ConnectionManager_i.cxx +++ b/src/DSC/DSC_Basic/ConnectionManager_i.cxx @@ -25,7 +25,6 @@ // Module : KERNEL // #include "ConnectionManager_i.hxx" -#include "SALOME_NamingService.hxx" #ifdef WIN32 # include @@ -33,20 +32,23 @@ # include #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()) { diff --git a/src/DSC/DSC_Basic/ConnectionManager_i.hxx b/src/DSC/DSC_Basic/ConnectionManager_i.hxx index e3f6f24ce..84c7c94f6 100644 --- a/src/DSC/DSC_Basic/ConnectionManager_i.hxx +++ b/src/DSC/DSC_Basic/ConnectionManager_i.hxx @@ -28,6 +28,7 @@ #define _CONNECTION_MANAGER_I_HXX_ #include "DSC_Basic.hxx" +#include "SALOME_NamingService.hxx" #include #include @@ -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 diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index a6f1d9a57..1e3ce0cda 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -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) { diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index 2a0ae9248..ad6d7bb62 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -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: diff --git a/src/NamingService/SALOME_NamingServicePy.py b/src/NamingService/SALOME_NamingServicePy.py index 342c93716..8fdde096b 100644 --- a/src/NamingService/SALOME_NamingServicePy.py +++ b/src/NamingService/SALOME_NamingServicePy.py @@ -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 + #------------------------------------------------------------------------- diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index f53cce8ac..650160d61 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -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"); diff --git a/src/SALOMEDS/SALOMEDS_Server.cxx b/src/SALOMEDS/SALOMEDS_Server.cxx index 821806ec2..bb66e6e9d 100644 --- a/src/SALOMEDS/SALOMEDS_Server.cxx +++ b/src/SALOMEDS/SALOMEDS_Server.cxx @@ -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&)