# 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():
#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
#
// 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)
{
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)
{
{
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
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)
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();
}
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");