1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "SALOME_ContainerManager.hxx"
23 #include "SALOME_NamingService.hxx"
24 #include "SALOME_ModuleCatalog.hh"
25 #include "Basics_Utils.hxx"
26 #include "Basics_DirUtils.hxx"
27 #include <sys/types.h>
33 #include "Utils_CorbaException.hxx"
36 #ifdef WITH_PACO_PARALLEL
40 #define TIME_OUT_TO_LAUNCH_CONT 61
44 vector<Engines::Container_ptr> SALOME_ContainerManager::_batchLaunchedContainers;
46 vector<Engines::Container_ptr>::iterator SALOME_ContainerManager::_batchLaunchedContainersIter;
48 const char *SALOME_ContainerManager::_ContainerManagerNameInNS =
51 //=============================================================================
55 * Define a CORBA single thread policy for the server, which avoid to deal
56 * with non thread-safe usage like Change_Directory in SALOME naming service
58 //=============================================================================
60 SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns)
62 MESSAGE("constructor");
66 PortableServer::POAManager_var pman = poa->the_POAManager();
67 _orb = CORBA::ORB::_duplicate(orb) ;
68 CORBA::PolicyList policies;
70 PortableServer::ThreadPolicy_var threadPol =
71 poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
72 policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol);
74 _poa = poa->create_POA("SThreadPOA",pman,policies);
76 PortableServer::ObjectId_var id = _poa->activate_object(this);
77 CORBA::Object_var obj = _poa->id_to_reference(id);
78 Engines::ContainerManager_var refContMan =
79 Engines::ContainerManager::_narrow(obj);
81 _NS->Register(refContMan,_ContainerManagerNameInNS);
82 _isAppliSalomeDefined = (getenv("APPLI") != 0);
86 if( getenv("OMPI_URI_FILE") != NULL ){
87 system("killall ompi-server");
89 command = "ompi-server -r ";
90 command += getenv("OMPI_URI_FILE");
91 int status=system(command.c_str());
93 throw SALOME_Exception("Error when launching ompi-server");
98 MESSAGE("constructor end");
101 //=============================================================================
105 //=============================================================================
107 SALOME_ContainerManager::~SALOME_ContainerManager()
109 MESSAGE("destructor");
112 if( getenv("OMPI_URI_FILE") != NULL )
113 system("killall ompi-server");
118 //=============================================================================
119 //! shutdown all the containers, then the ContainerManager servant
122 //=============================================================================
124 void SALOME_ContainerManager::Shutdown()
127 ShutdownContainers();
128 _NS->Destroy_Name(_ContainerManagerNameInNS);
129 PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
130 _poa->deactivate_object(oid);
133 //=============================================================================
134 //! Loop on all the containers listed in naming service, ask shutdown on each
137 //=============================================================================
139 void SALOME_ContainerManager::ShutdownContainers()
141 MESSAGE("ShutdownContainers");
143 isOK = _NS->Change_Directory("/Containers");
145 vector<string> vec = _NS->list_directory_recurs();
146 list<string> lstCont;
147 for(vector<string>::iterator iter = vec.begin();iter!=vec.end();iter++)
150 CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
153 Engines::Container_var cont=Engines::Container::_narrow(obj);
154 if(!CORBA::is_nil(cont))
155 lstCont.push_back((*iter));
157 catch(const CORBA::Exception& e)
159 // ignore this entry and continue
162 MESSAGE("Container list: ");
163 for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++){
166 for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++)
171 CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
172 Engines::Container_var cont=Engines::Container::_narrow(obj);
173 if(!CORBA::is_nil(cont))
175 MESSAGE("ShutdownContainers: " << (*iter));
179 MESSAGE("ShutdownContainers: no container ref for " << (*iter));
181 catch(CORBA::SystemException& e)
183 INFOS("CORBA::SystemException ignored : " << e);
185 catch(CORBA::Exception&)
187 INFOS("CORBA::Exception ignored.");
191 INFOS("Unknown exception ignored.");
197 //=============================================================================
198 //! Give a suitable Container given constraints
200 * \param params Machine Parameters required for the container
201 * \return the container or nil
203 //=============================================================================
205 Engines::Container_ptr
206 SALOME_ContainerManager::GiveContainer(const Engines::MachineParameters& params)
208 char *valenv=getenv("SALOME_BATCH");
210 if (strcmp(valenv,"1")==0)
212 if(_batchLaunchedContainers.empty())
213 fillBatchLaunchedContainers();
215 if (_batchLaunchedContainersIter == _batchLaunchedContainers.end())
216 _batchLaunchedContainersIter = _batchLaunchedContainers.begin();
218 Engines::Container_ptr rtn = Engines::Container::_duplicate(*_batchLaunchedContainersIter);
219 _batchLaunchedContainersIter++;
222 return StartContainer(params);
225 //=============================================================================
226 //! Start a suitable Container in a list of machines with constraints
228 * Constraints are given by a machine parameters struct
229 * \param params Machine Parameters required for the container
230 * \param possibleComputers list of machines usable for start
231 * \param container_exe specific container executable (default=SALOME_Container)
233 //=============================================================================
235 Engines::Container_ptr
236 SALOME_ContainerManager::StartContainer(const Engines::MachineParameters& params,
237 const Engines::MachineList& possibleComputers,
238 const std::string& container_exe)
240 #ifdef WITH_PACO_PARALLEL
241 std::string parallelLib(params.parallelLib);
242 if (parallelLib != "")
244 Engines::MachineParameters myparams(params);
245 myparams.computerList=possibleComputers;
246 return StartParallelContainer(myparams);
249 string containerNameInNS;
250 Engines::Container_ptr ret = Engines::Container::_nil();
252 MESSAGE("SALOME_ContainerManager::StartContainer " << possibleComputers.length());
255 // if mode is "get" keep only machines with existing containers
256 if(std::string(params.mode.in())=="get")
258 for(unsigned int i=0;i<possibleComputers.length();i++)
260 Engines::Container_ptr cont = FindContainer(params,possibleComputers[i]);
263 if(!cont->_non_existent())
264 lm.push_back(string(possibleComputers[i]));
266 catch(CORBA::Exception&)
268 // CORBA::Exception ignored.
274 for(unsigned int i=0;i<possibleComputers.length();i++)
275 lm.push_back(string(possibleComputers[i]));
281 theMachine=_ResManager->GetImpl()->Find(params.policy.in(),lm);
283 catch( const SALOME_Exception &ex )
286 return Engines::Container::_nil();
289 //If the machine name is localhost use the real name
290 if(theMachine == "localhost")
291 theMachine=Kernel_Utils::GetHostname();
293 //check if an entry exists in Naming service
294 //if params.mode == "start" or "" shutdown the existing container before launching a new one with that name
295 //if params.mode == "getorstart" or "get" use the existing container
297 // A parallel container register on zero node in NS
298 containerNameInNS = _NS->BuildContainerNameForNS(params,GetMPIZeroNode(theMachine).c_str());
300 containerNameInNS = _NS->BuildContainerNameForNS(params,theMachine.c_str());
302 SCRUTE(containerNameInNS);
303 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
304 if ( !CORBA::is_nil(obj) )
308 Engines::Container_var cont=Engines::Container::_narrow(obj);
309 if(!cont->_non_existent())
311 if(std::string(params.mode.in())=="getorstart"||std::string(params.mode.in())=="get")
312 return cont._retn(); /* the container exists and params.mode is getorstart or get use it*/
315 INFOS("A container is already registered with the name: " << containerNameInNS << ", shutdown the existing container");
316 cont->Shutdown(); // shutdown the registered container if it exists
320 catch(CORBA::Exception&)
322 INFOS("CORBA::Exception ignored.");
326 //try to launch a new container
327 MESSAGE("try to launch it on " << theMachine);
331 MESSAGE("SALOME_ContainerManager::StartContainer : no possible computer");
332 return Engines::Container::_nil();
334 else if(theMachine==Kernel_Utils::GetHostname())
335 command = BuildCommandToLaunchLocalContainer(params,container_exe);
337 command = BuildCommandToLaunchRemoteContainer(theMachine,params,container_exe);
339 //redirect stdout and stderr in a file
341 string logFilename=getenv("TEMP");
344 string logFilename="/tmp";
345 char* val = getenv("SALOME_TMP_DIR");
348 struct stat file_info;
349 stat(val, &file_info);
350 bool is_dir = S_ISDIR(file_info.st_mode);
351 if (is_dir)logFilename=val;
352 else std::cerr << "SALOME_TMP_DIR environment variable is not a directory use /tmp instead" << std::endl;
356 logFilename += _NS->ContainerName(params)+"_"+ theMachine +"_"+getenv( "USER" )+".log" ;
357 command += " > " + logFilename + " 2>&1";
359 command = "%PYTHONBIN% -c \"import win32pm ; win32pm.spawnpid(r'" + command + "', '')\"";
364 // launch container with a system call
365 int status=system(command.c_str());
368 MESSAGE("SALOME_ContainerManager::StartContainer rsh failed (system command status -1)");
369 RmTmpFile(_TmpFileName); // command file can be removed here
370 return Engines::Container::_nil();
372 else if (status == 217){
373 MESSAGE("SALOME_ContainerManager::StartContainer rsh failed (system command status 217)");
374 RmTmpFile(_TmpFileName); // command file can be removed here
375 return Engines::Container::_nil();
378 int count=TIME_OUT_TO_LAUNCH_CONT;
379 MESSAGE("count = "<<count);
380 while ( CORBA::is_nil(ret) && count ){
388 MESSAGE( count << ". Waiting for container on " << theMachine);
390 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
391 ret=Engines::Container::_narrow(obj);
394 if ( CORBA::is_nil(ret) )
396 MESSAGE("SALOME_ContainerManager::StartContainer rsh failed");
400 logFilename=":"+logFilename;
401 logFilename="@"+Kernel_Utils::GetHostname()+logFilename;
402 logFilename=getenv( "USER" )+logFilename;
403 ret->logfilename(logFilename.c_str());
406 RmTmpFile(_TmpFileName); // command file can be removed here
411 //=============================================================================
412 //! Start a suitable Container given constraints
414 * \param params Machine Parameters required for the container
416 //=============================================================================
418 Engines::Container_ptr
419 SALOME_ContainerManager::StartContainer(const Engines::MachineParameters& params)
421 Engines::MachineList_var possibleComputers = _ResManager->GetFittingResources(params);
423 // Look into ModulCatalog if a specific container must be launched
424 CORBA::String_var container_exe;
428 CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog");
429 SALOME_ModuleCatalog::ModuleCatalog_var Catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ;
430 if (CORBA::is_nil (Catalog))
431 return Engines::Container::_nil();
432 // Loop through component list
433 for(unsigned int i=0;i<params.componentList.length();i++)
435 const char* compoi = params.componentList[i];
436 SALOME_ModuleCatalog::Acomponent_var compoInfo = Catalog->GetComponent(compoi);
437 if (CORBA::is_nil (compoInfo))
441 SALOME_ModuleCatalog::ImplType impl=compoInfo->implementation_type();
442 container_exe=compoInfo->implementation_name();
443 if(impl==SALOME_ModuleCatalog::CEXE)
447 INFOS("ContainerManager Error: you can't have 2 CEXE component in the same container" );
448 return Engines::Container::_nil();
454 catch (ServiceUnreachable&)
456 INFOS("Caught exception: Naming Service Unreachable");
457 return Engines::Container::_nil();
461 INFOS("Caught unknown exception.");
462 return Engines::Container::_nil();
466 return StartContainer(params,possibleComputers,container_exe.in());
468 return StartContainer(params,possibleComputers);
471 //=============================================================================
472 //! Find or start a suitable Container given some constraints
474 * \param params Machine Parameters required for the container
475 * \return the container or nil
477 //=============================================================================
479 Engines::Container_ptr
480 SALOME_ContainerManager::FindOrStartContainer(const Engines::MachineParameters& params)
482 Engines::Container_ptr ret = FindContainer(params,params.computerList);
483 if(!CORBA::is_nil(ret))
485 MESSAGE("Container doesn't exist try to launch it ...");
487 return StartContainer(params);
490 //=============================================================================
491 //! Find a container given constraints (params) on a list of machines (possibleComputers)
495 //=============================================================================
497 Engines::Container_ptr
498 SALOME_ContainerManager::FindContainer(const Engines::MachineParameters& params,
499 const Engines::MachineList& possibleComputers)
501 MESSAGE("FindContainer "<<possibleComputers.length());
502 for(unsigned int i=0;i<possibleComputers.length();i++)
504 MESSAGE("FindContainer possible " << possibleComputers[i]);
505 Engines::Container_ptr cont = FindContainer(params,possibleComputers[i]);
506 if( !CORBA::is_nil(cont) )
509 MESSAGE("FindContainer: not found");
510 return Engines::Container::_nil();
513 //=============================================================================
514 //! Find a container given constraints (params) on a machine (theMachine)
518 //=============================================================================
520 Engines::Container_ptr
521 SALOME_ContainerManager::FindContainer(const Engines::MachineParameters& params,
522 const char *theMachine)
524 string containerNameInNS(_NS->BuildContainerNameForNS(params,theMachine));
525 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
528 if(obj->_non_existent())
529 return Engines::Container::_nil();
531 return Engines::Container::_narrow(obj);
533 catch(const CORBA::Exception& e)
535 return Engines::Container::_nil();
539 #ifdef WITH_PACO_PARALLEL
540 //=============================================================================
542 * Find or Start a suitable PaCO++ Parallel Container in a list of machines.
543 * \param params Machine Parameters required for the container
544 * \return CORBA container reference.
546 //=============================================================================
547 Engines::Container_ptr
548 SALOME_ContainerManager::StartParallelContainer(const Engines::MachineParameters& params_const)
550 CORBA::Object_var obj;
551 PaCO::InterfaceManager_var container_proxy;
552 Engines::Container_ptr ret = Engines::Container::_nil();
553 Engines::MachineParameters params(params_const);
555 // Step 1 : Try to find a suitable container
556 // Currently not as good as could be since
557 // we have to verified the number of nodes of the container
558 // if a user tell that.
559 ret = FindContainer(params, params.computerList);
560 if(CORBA::is_nil(ret)) {
561 // Step 2 : Starting a new parallel container !
562 INFOS("[StartParallelContainer] Starting a PaCO++ parallel container");
564 // Step 3 : Choose a computer
565 std::string theMachine = _ResManager->FindFirst(params.computerList);
566 //If the machine name is localhost use the real name
567 if(theMachine == "localhost")
568 theMachine=Kernel_Utils::GetHostname();
570 if(theMachine == "") {
571 INFOS("[StartParallelContainer] !!!!!!!!!!!!!!!!!!!!!!!!!!");
572 INFOS("[StartParallelContainer] No possible computer found");
573 INFOS("[StartParallelContainer] !!!!!!!!!!!!!!!!!!!!!!!!!!");
576 INFOS("[StartParallelContainer] on machine : " << theMachine);
577 params.hostname = CORBA::string_dup(theMachine.c_str());
579 // Step 4 : starting parallel container proxy
580 Engines::MachineParameters params_proxy(params);
581 std::string command_proxy;
582 SALOME_ContainerManager::actual_launch_machine_t proxy_machine;
585 command_proxy = BuildCommandToLaunchParallelContainer("SALOME_ParallelContainerProxy", params_proxy, proxy_machine);
587 catch(const SALOME_Exception & ex)
589 INFOS("[StartParallelContainer] Exception in BuildCommandToLaunchParallelContainer");
593 params_proxy.nb_component_nodes = 0; // LaunchParallelContainer uses this value to know if it launches the proxy or the nodes
594 obj = LaunchParallelContainer(command_proxy, params_proxy, _NS->ContainerName(params_proxy), proxy_machine);
595 if (CORBA::is_nil(obj))
597 INFOS("[StartParallelContainer] LaunchParallelContainer for proxy returns NIL !");
602 container_proxy = PaCO::InterfaceManager::_narrow(obj);
604 catch(CORBA::SystemException& e)
606 INFOS("[StartParallelContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
607 INFOS("CORBA::SystemException : " << e);
610 catch(CORBA::Exception& e)
612 INFOS("[StartParallelContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
613 INFOS("CORBA::Exception" << e);
618 INFOS("[StartParallelContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
619 INFOS("Unknown exception !");
622 if (CORBA::is_nil(container_proxy))
624 INFOS("[StartParallelContainer] PaCO::InterfaceManager::_narrow returns NIL !");
628 // Step 5 : starting parallel container nodes
629 std::string command_nodes;
630 Engines::MachineParameters params_nodes(params);
631 SALOME_ContainerManager::actual_launch_machine_t nodes_machines;
634 command_nodes = BuildCommandToLaunchParallelContainer("SALOME_ParallelContainerNode", params_nodes, nodes_machines, proxy_machine[0]);
636 catch(const SALOME_Exception & ex)
638 INFOS("[StartParallelContainer] Exception in BuildCommandToLaunchParallelContainer");
642 std::string container_generic_node_name = _NS->ContainerName(params) + "Node";
643 obj = LaunchParallelContainer(command_nodes, params_nodes, container_generic_node_name, nodes_machines);
644 if (CORBA::is_nil(obj))
646 INFOS("[StartParallelContainer] LaunchParallelContainer for nodes returns NIL !");
647 // Il faut tuer le proxy
650 Engines::Container_var proxy = Engines::Container::_narrow(container_proxy);
655 INFOS("[StartParallelContainer] Exception catched from proxy Shutdown...");
660 // Step 6 : connecting nodes and the proxy to actually create a parallel container
661 for (int i = 0; i < params.nb_component_nodes; i++)
663 std::ostringstream tmp;
665 std::string proc_number = tmp.str();
666 std::string container_node_name = container_generic_node_name + proc_number;
668 std::string theNodeMachine(nodes_machines[i]);
669 std::string containerNameInNS = _NS->BuildContainerNameForNS(container_node_name.c_str(), theNodeMachine.c_str());
670 obj = _NS->Resolve(containerNameInNS.c_str());
671 if (CORBA::is_nil(obj))
673 INFOS("[StartParallelContainer] CONNECTION FAILED From Naming Service !");
674 INFOS("[StartParallelContainer] Container name is " << containerNameInNS);
679 MESSAGE("[StartParallelContainer] Deploying node : " << container_node_name);
680 PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
682 MESSAGE("[StartParallelContainer] node " << container_node_name << " is deployed");
684 catch(CORBA::SystemException& e)
686 INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS);
687 INFOS("CORBA::SystemException : " << e);
690 catch(CORBA::Exception& e)
692 INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS);
693 INFOS("CORBA::Exception" << e);
698 INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS);
699 INFOS("Unknown exception !");
704 // Step 7 : starting parallel container
707 MESSAGE ("[StartParallelContainer] Starting parallel object");
708 container_proxy->start();
709 MESSAGE ("[StartParallelContainer] Parallel object is started");
710 ret = Engines::Container::_narrow(container_proxy);
712 catch(CORBA::SystemException& e)
714 INFOS("Caught CORBA::SystemException. : " << e);
716 catch(PortableServer::POA::ServantAlreadyActive&)
718 INFOS("Caught CORBA::ServantAlreadyActiveException");
720 catch(CORBA::Exception&)
722 INFOS("Caught CORBA::Exception.");
724 catch(std::exception& exc)
726 INFOS("Caught std::exception - "<<exc.what());
730 INFOS("Caught unknown exception.");
736 //=============================================================================
738 * Find or Start a suitable PaCO++ Parallel Container in a list of machines.
739 * \param params Machine Parameters required for the container
740 * \return CORBA container reference.
742 //=============================================================================
743 Engines::Container_ptr
744 SALOME_ContainerManager::StartParallelContainer(const Engines::MachineParameters& params)
746 Engines::Container_ptr ret = Engines::Container::_nil();
747 INFOS("[StartParallelContainer] is disabled !");
748 INFOS("[StartParallelContainer] recompile SALOME Kernel to enable parallel extension");
753 //=============================================================================
754 /*! This method launches the parallel container.
755 * It will may be placed on the ressources manager.
757 * \param command to launch
758 * \param container's parameters
759 * \param name of the container
761 * \return CORBA container reference
763 //=============================================================================
765 SALOME_ContainerManager::LaunchParallelContainer(const std::string& command,
766 const Engines::MachineParameters& params,
767 const std::string& name,
768 SALOME_ContainerManager::actual_launch_machine_t & vect_machine)
770 CORBA::Object_ptr obj = CORBA::Object::_nil();
771 std::string containerNameInNS;
772 int count = TIME_OUT_TO_LAUNCH_CONT;
774 INFOS("[LaunchParallelContainer] Begin");
775 int status = system(command.c_str());
777 INFOS("[LaunchParallelContainer] failed : system command status -1");
780 else if (status == 217) {
781 INFOS("[LaunchParallelContainer] failed : system command status 217");
785 if (params.nb_component_nodes == 0)
787 std::string theMachine(vect_machine[0]);
788 // Proxy We have launch a proxy
789 containerNameInNS = _NS->BuildContainerNameForNS((char*) name.c_str(), theMachine.c_str());
790 INFOS("[LaunchParallelContainer] Waiting for Parallel Container proxy " << containerNameInNS << " on " << theMachine);
791 while (CORBA::is_nil(obj) && count)
799 obj = _NS->Resolve(containerNameInNS.c_str());
804 INFOS("[LaunchParallelContainer] launching the nodes of the parallel container");
805 // We are waiting all the nodes
806 for (int i = 0; i < params.nb_component_nodes; i++)
808 obj = CORBA::Object::_nil();
809 std::string theMachine(vect_machine[i]);
811 std::ostringstream tmp;
813 std::string proc_number = tmp.str();
814 std::string container_node_name = name + proc_number;
815 containerNameInNS = _NS->BuildContainerNameForNS((char*) container_node_name.c_str(), theMachine.c_str());
816 INFOS("[LaunchParallelContainer] Waiting for Parallel Container node " << containerNameInNS << " on " << theMachine);
817 while (CORBA::is_nil(obj) && count) {
824 obj = _NS->Resolve(containerNameInNS.c_str());
826 if (CORBA::is_nil(obj))
828 INFOS("[LaunchParallelContainer] Launch of node failed (or not found) !");
833 if (CORBA::is_nil(obj))
834 INFOS("[LaunchParallelContainer] failed");
839 void SALOME_ContainerManager::fillBatchLaunchedContainers()
841 _batchLaunchedContainers.clear();
842 _NS->Change_Directory("/Containers");
843 vector<string> vec = _NS->list_directory_recurs();
844 for(vector<string>::iterator iter = vec.begin();iter!=vec.end();iter++){
845 CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
846 Engines::Container_ptr cont=Engines::Container::_narrow(obj);
847 if(!CORBA::is_nil(cont)){
848 _batchLaunchedContainers.push_back(cont);
851 _batchLaunchedContainersIter=_batchLaunchedContainers.begin();
854 //=============================================================================
856 * This is no longer valid (C++ container are also python containers)
858 //=============================================================================
860 bool isPythonContainer(const char* ContainerName)
863 int len = strlen(ContainerName);
866 if (strcmp(ContainerName + len - 2, "Py") == 0)
872 //=============================================================================
874 * Builds the script to be launched
876 * If SALOME Application not defined ($APPLI),
877 * see BuildTempFileToLaunchRemoteContainer()
879 * Else rely on distant configuration. Command is under the form (example):
880 * ssh user@machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
881 * SALOME_Container containerName &"
883 * - where user is ommited if not specified in CatalogResources,
884 * - where distant path is always relative to user@machine $HOME, and
885 * equal to $APPLI if not specified in CatalogResources,
886 * - where hostNS is the hostname of CORBA naming server (set by scripts to
887 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
888 * - where portNS is the port used by CORBA naming server (set by scripts to
889 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
890 * - where workingdir is the requested working directory for the container.
891 * If WORKINGDIR (and workingdir) is not present the working dir will be $HOME
893 //=============================================================================
896 SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
897 (const string& machine,
898 const Engines::MachineParameters& params, const std::string& container_exe)
903 if ( ! _isAppliSalomeDefined )
904 command = BuildTempFileToLaunchRemoteContainer(machine, params);
908 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine);
912 if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
914 else if ( params.nb_node == 0 )
915 nbproc = params.nb_proc_per_node;
916 else if ( params.nb_proc_per_node == 0 )
917 nbproc = params.nb_node;
919 nbproc = params.nb_node * params.nb_proc_per_node;
922 // "ssh user@machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
923 // SALOME_Container containerName &"
925 if (resInfo.Protocol == rsh)
927 else if (resInfo.Protocol == ssh)
930 throw SALOME_Exception("Unknown protocol");
932 if (resInfo.UserName != "")
934 command += resInfo.UserName;
941 if (resInfo.AppliPath != "")
942 command += resInfo.AppliPath; // path relative to user@machine $HOME
945 ASSERT(getenv("APPLI"));
946 command += getenv("APPLI"); // path relative to user@machine $HOME
949 command += "/runRemote.sh ";
951 ASSERT(getenv("NSHOST"));
952 command += getenv("NSHOST"); // hostname of CORBA name server
955 ASSERT(getenv("NSPORT"));
956 command += getenv("NSPORT"); // port of CORBA name server
958 std::string wdir=params.workingdir.in();
961 command += " WORKINGDIR ";
963 if(wdir == "$TEMPDIR")
965 command += wdir; // requested working directory
971 command += " mpirun -np ";
972 std::ostringstream o;
976 command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
977 #elif defined(WITHOPENMPI)
978 if( getenv("OMPI_URI_FILE") == NULL )
979 command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
981 command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
982 command += getenv("OMPI_URI_FILE");
985 command += " SALOME_MPIContainer ";
988 command += " " +container_exe+ " ";
990 command += _NS->ContainerName(params);
992 AddOmninamesParams(command);
994 MESSAGE("command =" << command);
1000 //=============================================================================
1002 * builds the command to be launched.
1004 //=============================================================================
1007 SALOME_ContainerManager::BuildCommandToLaunchLocalContainer
1008 (const Engines::MachineParameters& params, const std::string& container_exe)
1010 _TmpFileName = BuildTemporaryFileName();
1014 ofstream command_file( _TmpFileName.c_str() );
1018 //command = "mpirun -np ";
1019 command_file << "mpirun -np ";
1021 if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
1023 else if ( params.nb_node == 0 )
1024 nbproc = params.nb_proc_per_node;
1025 else if ( params.nb_proc_per_node == 0 )
1026 nbproc = params.nb_node;
1028 nbproc = params.nb_node * params.nb_proc_per_node;
1030 //std::ostringstream o;
1032 //o << nbproc << " ";
1033 command_file << nbproc << " ";
1035 //command += o.str();
1037 //command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
1038 command_file << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
1039 #elif defined(WITHOPENMPI)
1040 //command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace ";
1041 if( getenv("OMPI_URI_FILE") == NULL )
1042 command_file << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
1045 command_file << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
1046 command_file << getenv("OMPI_URI_FILE");
1050 if (isPythonContainer(params.container_name))
1051 //command += "pyMPI SALOME_ContainerPy.py ";
1052 command_file << " pyMPI SALOME_ContainerPy.py ";
1054 //command += "SALOME_MPIContainer ";
1055 command_file << " SALOME_MPIContainer ";
1061 std::string wdir=params.workingdir.in();
1064 // a working directory is requested
1065 if(wdir == "$TEMPDIR")
1067 // a new temporary directory is requested
1068 string dir = Kernel_Utils::GetTmpDir();
1070 //command += "cd /d "+ dir +";";
1071 command_file << "cd /d " << dir << endl;
1073 //command = "cd "+ dir +";";
1074 command_file << "cd " << dir << ";";
1080 // a permanent directory is requested use it or create it
1082 //command="mkdir " + wdir;
1083 command_file << "mkdir " + wdir << endl;
1084 command_file << "cd /D " + wdir << endl;
1086 //command="mkdir -p " + wdir + " && cd " + wdir + ";";
1087 command_file << "mkdir -p " << wdir << " && cd " << wdir + ";";
1091 if (isPythonContainer(params.container_name))
1092 //command += "SALOME_ContainerPy.py ";
1093 command_file << "SALOME_ContainerPy.py ";
1095 //command += container_exe + " ";
1096 command_file << container_exe + " ";
1100 command_file << _NS->ContainerName(params);
1101 command_file << " -";
1102 AddOmninamesParams(command_file);
1103 command_file.close();
1106 chmod(_TmpFileName.c_str(), 0x1ED);
1108 command = _TmpFileName;
1110 MESSAGE("Command is file ... " << command);
1115 //=============================================================================
1117 * removes the generated temporary file in case of a remote launch.
1119 //=============================================================================
1121 void SALOME_ContainerManager::RmTmpFile(std::string& tmpFileName)
1123 int lenght = tmpFileName.size();
1127 string command = "del /F ";
1129 string command = "rm ";
1132 command += tmpFileName.substr(0, lenght - 3 );
1134 command += tmpFileName;
1136 system(command.c_str());
1137 //if dir is empty - remove it
1138 string tmp_dir = Kernel_Utils::GetDirByPath( tmpFileName );
1139 if ( Kernel_Utils::IsEmptyDir( tmp_dir ) )
1142 command = "del /F " + tmp_dir;
1144 command = "rmdir " + tmp_dir;
1146 system(command.c_str());
1151 //=============================================================================
1153 * add to command all options relative to naming service.
1155 //=============================================================================
1157 void SALOME_ContainerManager::AddOmninamesParams(string& command) const
1159 CORBA::String_var iorstr = _NS->getIORaddr();
1160 command += "ORBInitRef NameService=";
1165 //=============================================================================
1167 * add to command all options relative to naming service.
1169 //=============================================================================
1171 void SALOME_ContainerManager::AddOmninamesParams(ofstream& fileStream) const
1173 CORBA::String_var iorstr = _NS->getIORaddr();
1174 fileStream << "ORBInitRef NameService=";
1175 fileStream << iorstr;
1178 //=============================================================================
1180 * generate a file name in /tmp directory
1182 //=============================================================================
1184 string SALOME_ContainerManager::BuildTemporaryFileName() const
1186 //build more complex file name to support multiple salome session
1187 string aFileName = Kernel_Utils::GetTmpFileName();
1191 aFileName += ".bat";
1197 //=============================================================================
1199 * Builds in a temporary file the script to be launched.
1201 * Used if SALOME Application ($APPLI) is not defined.
1202 * The command is build with data from CatalogResources, in which every path
1203 * used on remote computer must be defined.
1205 //=============================================================================
1208 SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer
1209 (const string& machine,
1210 const Engines::MachineParameters& params) throw(SALOME_Exception)
1214 _TmpFileName = BuildTemporaryFileName();
1215 ofstream tempOutputFile;
1216 tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
1217 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine);
1218 tempOutputFile << "#! /bin/sh" << endl;
1222 tempOutputFile << "export SALOME_trace=local" << endl; // mkr : 27.11.2006 : PAL13967 - Distributed supervision graphs - Problem with "SALOME_trace"
1223 //tempOutputFile << "source " << resInfo.PreReqFilePath << endl;
1229 tempOutputFile << "mpirun -np ";
1232 if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
1234 else if ( params.nb_node == 0 )
1235 nbproc = params.nb_proc_per_node;
1236 else if ( params.nb_proc_per_node == 0 )
1237 nbproc = params.nb_node;
1239 nbproc = params.nb_node * params.nb_proc_per_node;
1241 std::ostringstream o;
1243 tempOutputFile << nbproc << " ";
1245 tempOutputFile << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
1246 #elif defined(WITHOPENMPI)
1247 if( getenv("OMPI_URI_FILE") == NULL )
1248 tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
1250 tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
1251 tempOutputFile << getenv("OMPI_URI_FILE");
1256 tempOutputFile << getenv("KERNEL_ROOT_DIR") << "/bin/salome/";
1260 if (isPythonContainer(params.container_name))
1261 tempOutputFile << " pyMPI SALOME_ContainerPy.py ";
1263 tempOutputFile << " SALOME_MPIContainer ";
1268 if (isPythonContainer(params.container_name))
1269 tempOutputFile << "SALOME_ContainerPy.py ";
1271 tempOutputFile << "SALOME_Container ";
1274 tempOutputFile << _NS->ContainerName(params) << " -";
1275 AddOmninamesParams(tempOutputFile);
1276 tempOutputFile << " &" << endl;
1277 tempOutputFile.flush();
1278 tempOutputFile.close();
1280 chmod(_TmpFileName.c_str(), 0x1ED);
1283 // --- Build command
1287 if (resInfo.Protocol == rsh)
1290 string commandRcp = "rcp ";
1291 commandRcp += _TmpFileName;
1293 commandRcp += machine;
1295 commandRcp += _TmpFileName;
1296 status = system(commandRcp.c_str());
1299 else if (resInfo.Protocol == ssh)
1302 string commandRcp = "scp ";
1303 commandRcp += _TmpFileName;
1305 commandRcp += machine;
1307 commandRcp += _TmpFileName;
1308 status = system(commandRcp.c_str());
1311 throw SALOME_Exception("Unknown protocol");
1314 throw SALOME_Exception("Error of connection on remote host");
1317 _CommandForRemAccess = command;
1319 command += _TmpFileName;
1327 //=============================================================================
1328 /*! Creates a command line that the container manager uses to launch
1329 * a parallel container.
1331 //=============================================================================
1333 SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string& exe_name,
1334 const Engines::MachineParameters& params,
1335 SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
1336 const std::string proxy_hostname)
1338 // This method knows the differences between the proxy and the nodes.
1339 // nb_component_nodes is not used in the same way if it is a proxy or
1342 //command = "gdb --args ";
1343 //command = "valgrind --tool=memcheck --log-file=val_log ";
1344 //command += real_exe_name;
1346 // Step 0 : init some variables...
1347 std::string parallelLib(CORBA::string_dup(params.parallelLib));
1348 std::string real_exe_name = exe_name + parallelLib;
1349 std::string machine_file_name("");
1350 bool remote = false;
1351 bool is_a_proxy = false;
1352 std::string hostname(CORBA::string_dup(params.hostname));
1354 std::ostringstream tmp_string;
1355 CORBA::Long nb_nodes = params.nb_component_nodes;
1356 tmp_string << nb_nodes;
1357 std::string nbproc = tmp_string.str();
1359 Engines::MachineParameters_var rtn = new Engines::MachineParameters();
1360 rtn->container_name = params.container_name;
1361 rtn->hostname = params.hostname;
1362 rtn->OS = params.OS;
1363 rtn->mem_mb = params.mem_mb;
1364 rtn->cpu_clock = params.cpu_clock;
1365 rtn->nb_proc_per_node = params.nb_proc_per_node;
1366 rtn->nb_node = params.nb_node;
1367 rtn->isMPI = params.isMPI;
1369 // Step 1 : local or remote launch ?
1370 if (hostname != std::string(Kernel_Utils::GetHostname()) )
1372 MESSAGE("[BuildCommandToLaunchParallelContainer] remote machine case detected !");
1376 // Step 2 : proxy or nodes launch ?
1377 std::string::size_type loc_proxy = exe_name.find("Proxy");
1378 if( loc_proxy != string::npos ) {
1382 // Step 3 : Depending of the parallelLib, getting the machine file
1383 // ParallelLib Dummy has is own machine for this method
1388 machine_file_name = _ResManager->getMachineFile(hostname,
1394 machine_file_name = _ResManager->getMachineFile(hostname,
1395 params.nb_component_nodes,
1398 if (machine_file_name == "")
1400 INFOS("[BuildCommandToLaunchParallelContainer] Error machine_file was not generated for machine " << hostname);
1401 throw SALOME_Exception("Error machine_file was not generated");
1403 MESSAGE("[BuildCommandToLaunchParallelContainer] machine_file_name is : " << machine_file_name);
1406 // Step 4 : Log type choosen by the user
1407 std::string log_env("");
1408 char * get_val = getenv("PARALLEL_LOG");
1411 std::string command_begin("");
1412 std::string command_end("");
1413 if(log_env == "xterm")
1415 command_begin = "/usr/X11R6/bin/xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1416 command_end = "\"&";
1418 else if(log_env == "xterm_debug")
1420 command_begin = "/usr/X11R6/bin/xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1421 command_end = "; cat \" &";
1425 // default into a file...
1426 std::string logFilename = "/tmp/" + _NS->ContainerName(params) + "_" + hostname;
1428 logFilename += "_Proxy_";
1430 logFilename += "_Node_";
1431 logFilename += std::string(getenv("USER")) + ".log";
1432 command_end = " > " + logFilename + " 2>&1 & ";
1435 // Step 5 : Building the command
1436 std::string command("");
1437 if (parallelLib == "Dummy")
1441 std::string command_remote("");
1444 std::string machine_name;
1445 std::ifstream machine_file(machine_file_name.c_str());
1446 std::getline(machine_file, machine_name);
1447 MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << machine_name)
1449 // We want to launch a command like :
1450 // ssh user@machine distantPath/runRemote.sh hostNS portNS
1451 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine_name);
1452 if (resInfo.Protocol == rsh)
1453 command_remote = "rsh ";
1455 command_remote = "ssh ";
1456 command_remote += resInfo.UserName;
1457 command_remote += "@";
1458 command_remote += machine_name;
1459 command_remote += " ";
1460 command_remote += resInfo.AppliPath; // path relative to user@machine $HOME
1461 command_remote += "/runRemote.sh ";
1462 ASSERT(getenv("NSHOST"));
1463 command_remote += getenv("NSHOST"); // hostname of CORBA name server
1464 command_remote += " ";
1465 ASSERT(getenv("NSPORT"));
1466 command_remote += getenv("NSPORT"); // port of CORBA name server
1467 command_remote += " ";
1469 hostname = machine_name;
1472 command = real_exe_name;
1473 command += " " + _NS->ContainerName(rtn);
1474 command += " " + parallelLib;
1475 command += " " + hostname;
1476 command += " " + nbproc;
1478 AddOmninamesParams(command);
1480 command = command_begin + command_remote + command + command_end;
1481 vect_machine.push_back(hostname);
1485 std::ifstream * machine_file = NULL;
1487 machine_file = new std::ifstream(machine_file_name.c_str());
1488 for (int i= 0; i < nb_nodes; i++)
1490 std::string command_remote("");
1493 std::string machine_name;
1494 std::getline(*machine_file, machine_name);
1495 MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << machine_name)
1497 // We want to launch a command like :
1498 // ssh user@machine distantPath/runRemote.sh hostNS portNS
1499 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine_name);
1500 if (resInfo.Protocol == rsh)
1501 command_remote = "rsh ";
1503 command_remote = "ssh ";
1504 command_remote += resInfo.UserName;
1505 command_remote += "@";
1506 command_remote += machine_name;
1507 command_remote += " ";
1508 command_remote += resInfo.AppliPath; // path relative to user@machine $HOME
1509 command_remote += "/runRemote.sh ";
1510 ASSERT(getenv("NSHOST"));
1511 command_remote += getenv("NSHOST"); // hostname of CORBA name server
1512 command_remote += " ";
1513 ASSERT(getenv("NSPORT"));
1514 command_remote += getenv("NSPORT"); // port of CORBA name server
1515 command_remote += " ";
1517 hostname = machine_name;
1520 std::ostringstream tmp;
1522 std::string proc_number = tmp.str();
1524 std::string command_tmp("");
1525 command_tmp += real_exe_name;
1526 command_tmp += " " + _NS->ContainerName(rtn);
1527 command_tmp += " " + parallelLib;
1528 command_tmp += " " + proxy_hostname;
1529 command_tmp += " " + proc_number;
1530 command_tmp += " -";
1531 AddOmninamesParams(command_tmp);
1533 // On change _Node_ par _Nodex_ pour avoir chaque noeud
1535 std::string command_end_tmp = command_end;
1536 std::string::size_type loc_node = command_end_tmp.find("_Node_");
1537 if (loc_node != std::string::npos)
1538 command_end_tmp.insert(loc_node+5, proc_number);
1539 command += command_begin + command_remote + command_tmp + command_end_tmp;
1540 vect_machine.push_back(hostname);
1543 delete machine_file;
1546 else if (parallelLib == "Mpi")
1548 // Step 0: if remote we have to copy the file
1549 // to the first machine of the file
1550 std::string remote_machine("");
1553 std::ifstream * machine_file = NULL;
1554 machine_file = new std::ifstream(machine_file_name.c_str());
1555 // Get first word of the line
1556 // For MPI implementation the first word is the
1558 std::getline(*machine_file, remote_machine, ' ');
1559 machine_file->close();
1560 MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << remote_machine)
1562 // We want to launch a command like :
1563 // scp mpi_machine_file user@machine:Path
1564 std::string command_remote("");
1565 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine);
1566 if (resInfo.Protocol == rsh)
1567 command_remote = "rcp ";
1569 command_remote = "scp ";
1571 command_remote += machine_file_name;
1572 command_remote += " ";
1573 command_remote += resInfo.UserName;
1574 command_remote += "@";
1575 command_remote += remote_machine;
1576 command_remote += ":";
1577 command_remote += machine_file_name;
1579 int status = system(command_remote.c_str());
1582 INFOS("copy of the mpi machine file failed !");
1589 std::string command_remote("");
1592 // We want to launch a command like :
1593 // ssh user@machine distantPath/runRemote.sh hostNS portNS
1594 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine);
1595 if (resInfo.Protocol == rsh)
1596 command_remote = "rsh ";
1598 command_remote = "ssh ";
1599 command_remote += resInfo.UserName;
1600 command_remote += "@";
1601 command_remote += remote_machine;
1602 command_remote += " ";
1603 command_remote += resInfo.AppliPath; // path relative to user@machine $HOME
1604 command_remote += "/runRemote.sh ";
1605 ASSERT(getenv("NSHOST"));
1606 command_remote += getenv("NSHOST"); // hostname of CORBA name server
1607 command_remote += " ";
1608 ASSERT(getenv("NSPORT"));
1609 command_remote += getenv("NSPORT"); // port of CORBA name server
1610 command_remote += " ";
1612 hostname = remote_machine;
1615 // We use Dummy proxy for MPI parallel containers
1616 real_exe_name = exe_name + "Dummy";
1617 command = real_exe_name;
1618 command += " " + _NS->ContainerName(rtn);
1619 command += " Dummy";
1620 command += " " + hostname;
1621 command += " " + nbproc;
1623 AddOmninamesParams(command);
1625 command = command_begin + command_remote + command + command_end;
1626 vect_machine.push_back(hostname);
1630 std::string command_remote("");
1633 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine);
1634 if (resInfo.Protocol == rsh)
1635 command_remote = "rsh ";
1637 command_remote = "ssh ";
1638 command_remote += resInfo.UserName;
1639 command_remote += "@";
1640 command_remote += remote_machine;
1641 command_remote += " ";
1643 std::string new_real_exe_name("");
1644 new_real_exe_name += resInfo.AppliPath; // path relative to user@machine $HOME
1645 new_real_exe_name += "/runRemote.sh ";
1646 ASSERT(getenv("NSHOST"));
1647 new_real_exe_name += getenv("NSHOST"); // hostname of CORBA name server
1648 new_real_exe_name += " ";
1649 ASSERT(getenv("NSPORT"));
1650 new_real_exe_name += getenv("NSPORT"); // port of CORBA name server
1651 new_real_exe_name += " ";
1653 real_exe_name = new_real_exe_name + real_exe_name;
1654 hostname = remote_machine;
1657 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(hostname);
1658 if (resInfo.mpi == lam)
1660 command = "mpiexec -ssi boot ";
1661 if (resInfo.Protocol == rsh)
1665 command += "-machinefile " + machine_file_name + " ";
1666 command += "-n " + nbproc + " ";
1667 command += real_exe_name;
1668 command += " " + _NS->ContainerName(rtn);
1669 command += " " + parallelLib;
1670 command += " " + proxy_hostname;
1672 AddOmninamesParams(command);
1676 command = "mpirun -np " + nbproc + " ";
1677 command += real_exe_name;
1678 command += " " + _NS->ContainerName(rtn);
1679 command += " " + parallelLib;
1680 command += " " + proxy_hostname;
1682 AddOmninamesParams(command);
1685 command = command_begin + command_remote + command + command_end;
1686 for (int i= 0; i < nb_nodes; i++)
1687 vect_machine.push_back(proxy_hostname);
1692 std::string message("Unknown parallelLib : " + parallelLib);
1693 throw SALOME_Exception(message.c_str());
1696 MESSAGE("Parallel launch is: " << command);
1700 string SALOME_ContainerManager::GetMPIZeroNode(string machine)
1705 string tmpFile = BuildTemporaryFileName();
1707 cmd = "ssh " + machine + " mpirun -np 1 hostname > " + tmpFile;
1709 status = system(cmd.c_str());
1711 ifstream fp(tmpFile.c_str(),ios::in);