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"
34 #include "Batch_Date.hxx"
37 #ifdef WITH_PACO_PARALLEL
41 #define TIME_OUT_TO_LAUNCH_CONT 61
45 vector<Engines::Container_ptr> SALOME_ContainerManager::_batchLaunchedContainers;
47 vector<Engines::Container_ptr>::iterator SALOME_ContainerManager::_batchLaunchedContainersIter;
49 const char *SALOME_ContainerManager::_ContainerManagerNameInNS =
52 //=============================================================================
56 * Define a CORBA single thread policy for the server, which avoid to deal
57 * with non thread-safe usage like Change_Directory in SALOME naming service
59 //=============================================================================
61 SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns)
63 MESSAGE("constructor");
67 PortableServer::POAManager_var pman = poa->the_POAManager();
68 _orb = CORBA::ORB::_duplicate(orb) ;
69 CORBA::PolicyList policies;
71 PortableServer::ThreadPolicy_var threadPol =
72 poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
73 policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol);
75 _poa = poa->create_POA("SThreadPOA",pman,policies);
77 PortableServer::ObjectId_var id = _poa->activate_object(this);
78 CORBA::Object_var obj = _poa->id_to_reference(id);
79 Engines::ContainerManager_var refContMan =
80 Engines::ContainerManager::_narrow(obj);
82 _NS->Register(refContMan,_ContainerManagerNameInNS);
83 _isAppliSalomeDefined = (getenv("APPLI") != 0);
87 if( getenv("OMPI_URI_FILE") != NULL ){
88 system("killall ompi-server");
90 command = "ompi-server -r ";
91 command += getenv("OMPI_URI_FILE");
92 int status=system(command.c_str());
94 throw SALOME_Exception("Error when launching ompi-server");
99 MESSAGE("constructor end");
102 //=============================================================================
106 //=============================================================================
108 SALOME_ContainerManager::~SALOME_ContainerManager()
110 MESSAGE("destructor");
113 if( getenv("OMPI_URI_FILE") != NULL )
114 system("killall ompi-server");
119 //=============================================================================
120 //! shutdown all the containers, then the ContainerManager servant
123 //=============================================================================
125 void SALOME_ContainerManager::Shutdown()
128 ShutdownContainers();
129 _NS->Destroy_Name(_ContainerManagerNameInNS);
130 PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
131 _poa->deactivate_object(oid);
134 //=============================================================================
135 //! Loop on all the containers listed in naming service, ask shutdown on each
138 //=============================================================================
140 void SALOME_ContainerManager::ShutdownContainers()
142 MESSAGE("ShutdownContainers");
144 isOK = _NS->Change_Directory("/Containers");
146 vector<string> vec = _NS->list_directory_recurs();
147 list<string> lstCont;
148 for(vector<string>::iterator iter = vec.begin();iter!=vec.end();iter++)
151 CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
154 Engines::Container_var cont=Engines::Container::_narrow(obj);
155 if(!CORBA::is_nil(cont))
156 lstCont.push_back((*iter));
158 catch(const CORBA::Exception& e)
160 // ignore this entry and continue
163 MESSAGE("Container list: ");
164 for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++){
167 for(list<string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++)
172 CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
173 Engines::Container_var cont=Engines::Container::_narrow(obj);
174 if(!CORBA::is_nil(cont))
176 MESSAGE("ShutdownContainers: " << (*iter));
180 MESSAGE("ShutdownContainers: no container ref for " << (*iter));
182 catch(CORBA::SystemException& e)
184 INFOS("CORBA::SystemException ignored : " << e);
186 catch(CORBA::Exception&)
188 INFOS("CORBA::Exception ignored.");
192 INFOS("Unknown exception ignored.");
198 //=============================================================================
199 //! Give a suitable Container given constraints
201 * \param params Machine Parameters required for the container
202 * \return the container or nil
204 //=============================================================================
206 Engines::Container_ptr
207 SALOME_ContainerManager::GiveContainer(const Engines::MachineParameters& params)
209 char *valenv=getenv("SALOME_BATCH");
211 if (strcmp(valenv,"1")==0)
213 if(_batchLaunchedContainers.empty())
214 fillBatchLaunchedContainers();
216 if (_batchLaunchedContainersIter == _batchLaunchedContainers.end())
217 _batchLaunchedContainersIter = _batchLaunchedContainers.begin();
219 Engines::Container_ptr rtn = Engines::Container::_duplicate(*_batchLaunchedContainersIter);
220 _batchLaunchedContainersIter++;
223 return StartContainer(params);
226 //=============================================================================
227 //! Start a suitable Container in a list of machines with constraints
229 * Constraints are given by a machine parameters struct
230 * \param params Machine Parameters required for the container
231 * \param possibleComputers list of machines usable for start
232 * \param container_exe specific container executable (default=SALOME_Container)
234 //=============================================================================
236 Engines::Container_ptr
237 SALOME_ContainerManager::StartContainer(const Engines::MachineParameters& params,
238 const Engines::MachineList& possibleComputers,
239 const std::string& container_exe)
241 #ifdef WITH_PACO_PARALLEL
242 std::string parallelLib(params.parallelLib);
243 if (parallelLib != "")
245 Engines::MachineParameters myparams(params);
246 myparams.computerList=possibleComputers;
247 return StartParallelContainer(myparams);
250 string containerNameInNS;
251 Engines::Container_ptr ret = Engines::Container::_nil();
253 MESSAGE("SALOME_ContainerManager::StartContainer " << possibleComputers.length());
256 // if mode is "get" keep only machines with existing containers
257 if(std::string(params.mode.in())=="get")
259 for(unsigned int i=0;i<possibleComputers.length();i++)
261 Engines::Container_ptr cont = FindContainer(params,possibleComputers[i]);
264 if(!cont->_non_existent())
265 lm.push_back(string(possibleComputers[i]));
267 catch(CORBA::Exception&)
269 // CORBA::Exception ignored.
275 for(unsigned int i=0;i<possibleComputers.length();i++)
276 lm.push_back(string(possibleComputers[i]));
282 theMachine=_ResManager->GetImpl()->Find(params.policy.in(),lm);
284 catch( const SALOME_Exception &ex )
287 return Engines::Container::_nil();
290 //If the machine name is localhost use the real name
291 if(theMachine == "localhost")
292 theMachine=Kernel_Utils::GetHostname();
294 //check if an entry exists in Naming service
295 //if params.mode == "start" or "" shutdown the existing container before launching a new one with that name
296 //if params.mode == "getorstart" or "get" use the existing container
298 // A parallel container register on zero node in NS
299 containerNameInNS = _NS->BuildContainerNameForNS(params,GetMPIZeroNode(theMachine).c_str());
301 containerNameInNS = _NS->BuildContainerNameForNS(params,theMachine.c_str());
303 SCRUTE(containerNameInNS);
304 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
305 if ( !CORBA::is_nil(obj) )
309 Engines::Container_var cont=Engines::Container::_narrow(obj);
310 if(!cont->_non_existent())
312 if(std::string(params.mode.in())=="getorstart"||std::string(params.mode.in())=="get")
313 return cont._retn(); /* the container exists and params.mode is getorstart or get use it*/
316 INFOS("A container is already registered with the name: " << containerNameInNS << ", shutdown the existing container");
317 cont->Shutdown(); // shutdown the registered container if it exists
321 catch(CORBA::Exception&)
323 INFOS("CORBA::Exception ignored.");
327 //try to launch a new container
328 MESSAGE("try to launch it on " << theMachine);
332 MESSAGE("SALOME_ContainerManager::StartContainer : no possible computer");
333 return Engines::Container::_nil();
335 else if(theMachine==Kernel_Utils::GetHostname())
336 command = BuildCommandToLaunchLocalContainer(params,container_exe);
338 command = BuildCommandToLaunchRemoteContainer(theMachine,params,container_exe);
340 //redirect stdout and stderr in a file
342 string logFilename=getenv("TEMP");
345 string logFilename="/tmp";
346 char* val = getenv("SALOME_TMP_DIR");
349 struct stat file_info;
350 stat(val, &file_info);
351 bool is_dir = S_ISDIR(file_info.st_mode);
352 if (is_dir)logFilename=val;
353 else std::cerr << "SALOME_TMP_DIR environment variable is not a directory use /tmp instead" << std::endl;
357 logFilename += _NS->ContainerName(params)+"_"+ theMachine +"_"+getenv( "USER" )+".log" ;
358 command += " > " + logFilename + " 2>&1";
360 command = "%PYTHONBIN% -c \"import win32pm ; win32pm.spawnpid(r'" + command + "', '')\"";
365 // launch container with a system call
366 int status=system(command.c_str());
369 MESSAGE("SALOME_ContainerManager::StartContainer rsh failed (system command status -1)");
370 RmTmpFile(_TmpFileName); // command file can be removed here
371 return Engines::Container::_nil();
373 else if (status == 217){
374 MESSAGE("SALOME_ContainerManager::StartContainer rsh failed (system command status 217)");
375 RmTmpFile(_TmpFileName); // command file can be removed here
376 return Engines::Container::_nil();
379 int count=TIME_OUT_TO_LAUNCH_CONT;
380 MESSAGE("count = "<<count);
381 while ( CORBA::is_nil(ret) && count ){
389 MESSAGE( count << ". Waiting for container on " << theMachine);
391 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
392 ret=Engines::Container::_narrow(obj);
395 if ( CORBA::is_nil(ret) )
397 MESSAGE("SALOME_ContainerManager::StartContainer rsh failed");
401 logFilename=":"+logFilename;
402 logFilename="@"+Kernel_Utils::GetHostname()+logFilename;
403 logFilename=getenv( "USER" )+logFilename;
404 ret->logfilename(logFilename.c_str());
407 RmTmpFile(_TmpFileName); // command file can be removed here
412 //=============================================================================
413 //! Start a suitable Container given constraints
415 * \param params Machine Parameters required for the container
417 //=============================================================================
419 Engines::Container_ptr
420 SALOME_ContainerManager::StartContainer(const Engines::MachineParameters& params)
422 Engines::MachineList_var possibleComputers = _ResManager->GetFittingResources(params);
424 // Look into ModulCatalog if a specific container must be launched
425 CORBA::String_var container_exe;
429 CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog");
430 SALOME_ModuleCatalog::ModuleCatalog_var Catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ;
431 if (CORBA::is_nil (Catalog))
432 return Engines::Container::_nil();
433 // Loop through component list
434 for(unsigned int i=0;i<params.componentList.length();i++)
436 const char* compoi = params.componentList[i];
437 SALOME_ModuleCatalog::Acomponent_var compoInfo = Catalog->GetComponent(compoi);
438 if (CORBA::is_nil (compoInfo))
442 SALOME_ModuleCatalog::ImplType impl=compoInfo->implementation_type();
443 container_exe=compoInfo->implementation_name();
444 if(impl==SALOME_ModuleCatalog::CEXE)
448 INFOS("ContainerManager Error: you can't have 2 CEXE component in the same container" );
449 return Engines::Container::_nil();
455 catch (ServiceUnreachable&)
457 INFOS("Caught exception: Naming Service Unreachable");
458 return Engines::Container::_nil();
462 INFOS("Caught unknown exception.");
463 return Engines::Container::_nil();
467 return StartContainer(params,possibleComputers,container_exe.in());
469 return StartContainer(params,possibleComputers);
472 //=============================================================================
473 //! Find or start a suitable Container given some constraints
475 * \param params Machine Parameters required for the container
476 * \return the container or nil
478 //=============================================================================
480 Engines::Container_ptr
481 SALOME_ContainerManager::FindOrStartContainer(const Engines::MachineParameters& params)
483 Engines::Container_ptr ret = FindContainer(params,params.computerList);
484 if(!CORBA::is_nil(ret))
486 MESSAGE("Container doesn't exist try to launch it ...");
488 return StartContainer(params);
491 //=============================================================================
492 //! Find a container given constraints (params) on a list of machines (possibleComputers)
496 //=============================================================================
498 Engines::Container_ptr
499 SALOME_ContainerManager::FindContainer(const Engines::MachineParameters& params,
500 const Engines::MachineList& possibleComputers)
502 MESSAGE("FindContainer "<<possibleComputers.length());
503 for(unsigned int i=0;i<possibleComputers.length();i++)
505 MESSAGE("FindContainer possible " << possibleComputers[i]);
506 Engines::Container_ptr cont = FindContainer(params,possibleComputers[i]);
507 if( !CORBA::is_nil(cont) )
510 MESSAGE("FindContainer: not found");
511 return Engines::Container::_nil();
514 //=============================================================================
515 //! Find a container given constraints (params) on a machine (theMachine)
519 //=============================================================================
521 Engines::Container_ptr
522 SALOME_ContainerManager::FindContainer(const Engines::MachineParameters& params,
523 const char *theMachine)
525 string containerNameInNS(_NS->BuildContainerNameForNS(params,theMachine));
526 CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
529 if(obj->_non_existent())
530 return Engines::Container::_nil();
532 return Engines::Container::_narrow(obj);
534 catch(const CORBA::Exception& e)
536 return Engines::Container::_nil();
540 #ifdef WITH_PACO_PARALLEL
541 //=============================================================================
543 * Find or Start a suitable PaCO++ Parallel Container in a list of machines.
544 * \param params Machine Parameters required for the container
545 * \return CORBA container reference.
547 //=============================================================================
548 Engines::Container_ptr
549 SALOME_ContainerManager::StartParallelContainer(const Engines::MachineParameters& params_const)
551 CORBA::Object_var obj;
552 PaCO::InterfaceManager_var container_proxy;
553 Engines::Container_ptr ret = Engines::Container::_nil();
554 Engines::MachineParameters params(params_const);
556 // Step 1 : Try to find a suitable container
557 // Currently not as good as could be since
558 // we have to verified the number of nodes of the container
559 // if a user tell that.
560 ret = FindContainer(params, params.computerList);
561 if(CORBA::is_nil(ret)) {
562 // Step 2 : Starting a new parallel container !
563 INFOS("[StartParallelContainer] Starting a PaCO++ parallel container");
565 // Step 3 : Choose a computer
566 std::string theMachine = _ResManager->FindFirst(params.computerList);
567 //If the machine name is localhost use the real name
568 if(theMachine == "localhost")
569 theMachine=Kernel_Utils::GetHostname();
571 if(theMachine == "") {
572 INFOS("[StartParallelContainer] !!!!!!!!!!!!!!!!!!!!!!!!!!");
573 INFOS("[StartParallelContainer] No possible computer found");
574 INFOS("[StartParallelContainer] !!!!!!!!!!!!!!!!!!!!!!!!!!");
577 INFOS("[StartParallelContainer] on machine : " << theMachine);
578 params.hostname = CORBA::string_dup(theMachine.c_str());
580 // Step 4 : starting parallel container proxy
581 Engines::MachineParameters params_proxy(params);
582 std::string command_proxy;
583 SALOME_ContainerManager::actual_launch_machine_t proxy_machine;
586 command_proxy = BuildCommandToLaunchParallelContainer("SALOME_ParallelContainerProxy", params_proxy, proxy_machine);
588 catch(const SALOME_Exception & ex)
590 INFOS("[StartParallelContainer] Exception in BuildCommandToLaunchParallelContainer");
594 params_proxy.nb_component_nodes = 0; // LaunchParallelContainer uses this value to know if it launches the proxy or the nodes
595 obj = LaunchParallelContainer(command_proxy, params_proxy, _NS->ContainerName(params_proxy), proxy_machine);
596 if (CORBA::is_nil(obj))
598 INFOS("[StartParallelContainer] LaunchParallelContainer for proxy returns NIL !");
603 container_proxy = PaCO::InterfaceManager::_narrow(obj);
605 catch(CORBA::SystemException& e)
607 INFOS("[StartParallelContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
608 INFOS("CORBA::SystemException : " << e);
611 catch(CORBA::Exception& e)
613 INFOS("[StartParallelContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
614 INFOS("CORBA::Exception" << e);
619 INFOS("[StartParallelContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
620 INFOS("Unknown exception !");
623 if (CORBA::is_nil(container_proxy))
625 INFOS("[StartParallelContainer] PaCO::InterfaceManager::_narrow returns NIL !");
629 // Step 5 : starting parallel container nodes
630 std::string command_nodes;
631 Engines::MachineParameters params_nodes(params);
632 SALOME_ContainerManager::actual_launch_machine_t nodes_machines;
635 command_nodes = BuildCommandToLaunchParallelContainer("SALOME_ParallelContainerNode", params_nodes, nodes_machines, proxy_machine[0]);
637 catch(const SALOME_Exception & ex)
639 INFOS("[StartParallelContainer] Exception in BuildCommandToLaunchParallelContainer");
643 std::string container_generic_node_name = _NS->ContainerName(params) + "Node";
644 obj = LaunchParallelContainer(command_nodes, params_nodes, container_generic_node_name, nodes_machines);
645 if (CORBA::is_nil(obj))
647 INFOS("[StartParallelContainer] LaunchParallelContainer for nodes returns NIL !");
648 // Il faut tuer le proxy
651 Engines::Container_var proxy = Engines::Container::_narrow(container_proxy);
656 INFOS("[StartParallelContainer] Exception catched from proxy Shutdown...");
661 // Step 6 : connecting nodes and the proxy to actually create a parallel container
662 for (int i = 0; i < params.nb_component_nodes; i++)
664 std::ostringstream tmp;
666 std::string proc_number = tmp.str();
667 std::string container_node_name = container_generic_node_name + proc_number;
669 std::string theNodeMachine(nodes_machines[i]);
670 std::string containerNameInNS = _NS->BuildContainerNameForNS(container_node_name.c_str(), theNodeMachine.c_str());
671 obj = _NS->Resolve(containerNameInNS.c_str());
672 if (CORBA::is_nil(obj))
674 INFOS("[StartParallelContainer] CONNECTION FAILED From Naming Service !");
675 INFOS("[StartParallelContainer] Container name is " << containerNameInNS);
680 MESSAGE("[StartParallelContainer] Deploying node : " << container_node_name);
681 PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
683 MESSAGE("[StartParallelContainer] node " << container_node_name << " is deployed");
685 catch(CORBA::SystemException& e)
687 INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS);
688 INFOS("CORBA::SystemException : " << e);
691 catch(CORBA::Exception& e)
693 INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS);
694 INFOS("CORBA::Exception" << e);
699 INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS);
700 INFOS("Unknown exception !");
705 // Step 7 : starting parallel container
708 MESSAGE ("[StartParallelContainer] Starting parallel object");
709 container_proxy->start();
710 MESSAGE ("[StartParallelContainer] Parallel object is started");
711 ret = Engines::Container::_narrow(container_proxy);
713 catch(CORBA::SystemException& e)
715 INFOS("Caught CORBA::SystemException. : " << e);
717 catch(PortableServer::POA::ServantAlreadyActive&)
719 INFOS("Caught CORBA::ServantAlreadyActiveException");
721 catch(CORBA::Exception&)
723 INFOS("Caught CORBA::Exception.");
725 catch(std::exception& exc)
727 INFOS("Caught std::exception - "<<exc.what());
731 INFOS("Caught unknown exception.");
737 //=============================================================================
739 * Find or Start a suitable PaCO++ Parallel Container in a list of machines.
740 * \param params Machine Parameters required for the container
741 * \return CORBA container reference.
743 //=============================================================================
744 Engines::Container_ptr
745 SALOME_ContainerManager::StartParallelContainer(const Engines::MachineParameters& params)
747 Engines::Container_ptr ret = Engines::Container::_nil();
748 INFOS("[StartParallelContainer] is disabled !");
749 INFOS("[StartParallelContainer] recompile SALOME Kernel to enable parallel extension");
754 //=============================================================================
755 /*! This method launches the parallel container.
756 * It will may be placed on the ressources manager.
758 * \param command to launch
759 * \param container's parameters
760 * \param name of the container
762 * \return CORBA container reference
764 //=============================================================================
766 SALOME_ContainerManager::LaunchParallelContainer(const std::string& command,
767 const Engines::MachineParameters& params,
768 const std::string& name,
769 SALOME_ContainerManager::actual_launch_machine_t & vect_machine)
771 CORBA::Object_ptr obj = CORBA::Object::_nil();
772 std::string containerNameInNS;
773 int count = TIME_OUT_TO_LAUNCH_CONT;
775 INFOS("[LaunchParallelContainer] Begin");
776 int status = system(command.c_str());
778 INFOS("[LaunchParallelContainer] failed : system command status -1");
781 else if (status == 217) {
782 INFOS("[LaunchParallelContainer] failed : system command status 217");
786 if (params.nb_component_nodes == 0)
788 std::string theMachine(vect_machine[0]);
789 // Proxy We have launch a proxy
790 containerNameInNS = _NS->BuildContainerNameForNS((char*) name.c_str(), theMachine.c_str());
791 INFOS("[LaunchParallelContainer] Waiting for Parallel Container proxy " << containerNameInNS << " on " << theMachine);
792 while (CORBA::is_nil(obj) && count)
800 obj = _NS->Resolve(containerNameInNS.c_str());
805 INFOS("[LaunchParallelContainer] launching the nodes of the parallel container");
806 // We are waiting all the nodes
807 for (int i = 0; i < params.nb_component_nodes; i++)
809 obj = CORBA::Object::_nil();
810 std::string theMachine(vect_machine[i]);
812 std::ostringstream tmp;
814 std::string proc_number = tmp.str();
815 std::string container_node_name = name + proc_number;
816 containerNameInNS = _NS->BuildContainerNameForNS((char*) container_node_name.c_str(), theMachine.c_str());
817 INFOS("[LaunchParallelContainer] Waiting for Parallel Container node " << containerNameInNS << " on " << theMachine);
818 while (CORBA::is_nil(obj) && count) {
825 obj = _NS->Resolve(containerNameInNS.c_str());
827 if (CORBA::is_nil(obj))
829 INFOS("[LaunchParallelContainer] Launch of node failed (or not found) !");
834 if (CORBA::is_nil(obj))
835 INFOS("[LaunchParallelContainer] failed");
840 void SALOME_ContainerManager::fillBatchLaunchedContainers()
842 _batchLaunchedContainers.clear();
843 _NS->Change_Directory("/Containers");
844 vector<string> vec = _NS->list_directory_recurs();
845 for(vector<string>::iterator iter = vec.begin();iter!=vec.end();iter++){
846 CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
847 Engines::Container_ptr cont=Engines::Container::_narrow(obj);
848 if(!CORBA::is_nil(cont)){
849 _batchLaunchedContainers.push_back(cont);
852 _batchLaunchedContainersIter=_batchLaunchedContainers.begin();
855 //=============================================================================
857 * This is no longer valid (C++ container are also python containers)
859 //=============================================================================
861 bool isPythonContainer(const char* ContainerName)
864 int len = strlen(ContainerName);
867 if (strcmp(ContainerName + len - 2, "Py") == 0)
873 //=============================================================================
875 * Builds the script to be launched
877 * If SALOME Application not defined ($APPLI),
878 * see BuildTempFileToLaunchRemoteContainer()
880 * Else rely on distant configuration. Command is under the form (example):
881 * ssh user@machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
882 * SALOME_Container containerName &"
884 * - where user is ommited if not specified in CatalogResources,
885 * - where distant path is always relative to user@machine $HOME, and
886 * equal to $APPLI if not specified in CatalogResources,
887 * - where hostNS is the hostname of CORBA naming server (set by scripts to
888 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
889 * - where portNS is the port used by CORBA naming server (set by scripts to
890 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
891 * - where workingdir is the requested working directory for the container.
892 * If WORKINGDIR (and workingdir) is not present the working dir will be $HOME
894 //=============================================================================
897 SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
898 (const string& machine,
899 const Engines::MachineParameters& params, const std::string& container_exe)
904 if ( ! _isAppliSalomeDefined )
905 command = BuildTempFileToLaunchRemoteContainer(machine, params);
909 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine);
913 if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
915 else if ( params.nb_node == 0 )
916 nbproc = params.nb_proc_per_node;
917 else if ( params.nb_proc_per_node == 0 )
918 nbproc = params.nb_node;
920 nbproc = params.nb_node * params.nb_proc_per_node;
923 // "ssh user@machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
924 // SALOME_Container containerName &"
926 if (resInfo.Protocol == rsh)
928 else if (resInfo.Protocol == ssh)
931 throw SALOME_Exception("Unknown protocol");
933 if (resInfo.UserName != "")
935 command += resInfo.UserName;
942 if (resInfo.AppliPath != "")
943 command += resInfo.AppliPath; // path relative to user@machine $HOME
946 ASSERT(getenv("APPLI"));
947 command += getenv("APPLI"); // path relative to user@machine $HOME
950 command += "/runRemote.sh ";
952 ASSERT(getenv("NSHOST"));
953 command += getenv("NSHOST"); // hostname of CORBA name server
956 ASSERT(getenv("NSPORT"));
957 command += getenv("NSPORT"); // port of CORBA name server
959 std::string wdir=params.workingdir.in();
962 command += " WORKINGDIR ";
964 if(wdir == "$TEMPDIR")
966 command += wdir; // requested working directory
972 command += " mpirun -np ";
973 std::ostringstream o;
977 command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
978 #elif defined(WITHOPENMPI)
979 if( getenv("OMPI_URI_FILE") == NULL )
980 command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
982 command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
983 command += getenv("OMPI_URI_FILE");
986 command += " SALOME_MPIContainer ";
989 command += " " +container_exe+ " ";
991 command += _NS->ContainerName(params);
993 AddOmninamesParams(command);
995 MESSAGE("command =" << command);
1001 //=============================================================================
1003 * builds the command to be launched.
1005 //=============================================================================
1008 SALOME_ContainerManager::BuildCommandToLaunchLocalContainer
1009 (const Engines::MachineParameters& params, const std::string& container_exe)
1011 _TmpFileName = BuildTemporaryFileName();
1015 ofstream command_file( _TmpFileName.c_str() );
1019 //command = "mpirun -np ";
1020 command_file << "mpirun -np ";
1022 if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
1024 else if ( params.nb_node == 0 )
1025 nbproc = params.nb_proc_per_node;
1026 else if ( params.nb_proc_per_node == 0 )
1027 nbproc = params.nb_node;
1029 nbproc = params.nb_node * params.nb_proc_per_node;
1031 //std::ostringstream o;
1033 //o << nbproc << " ";
1034 command_file << nbproc << " ";
1036 //command += o.str();
1038 //command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
1039 command_file << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
1040 #elif defined(WITHOPENMPI)
1041 //command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace ";
1042 if( getenv("OMPI_URI_FILE") == NULL )
1043 command_file << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
1046 command_file << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
1047 command_file << getenv("OMPI_URI_FILE");
1051 if (isPythonContainer(params.container_name))
1052 //command += "pyMPI SALOME_ContainerPy.py ";
1053 command_file << " pyMPI SALOME_ContainerPy.py ";
1055 //command += "SALOME_MPIContainer ";
1056 command_file << " SALOME_MPIContainer ";
1062 std::string wdir=params.workingdir.in();
1065 // a working directory is requested
1066 if(wdir == "$TEMPDIR")
1068 // a new temporary directory is requested
1069 string dir = Kernel_Utils::GetTmpDir();
1071 //command += "cd /d "+ dir +";";
1072 command_file << "cd /d " << dir << endl;
1074 //command = "cd "+ dir +";";
1075 command_file << "cd " << dir << ";";
1081 // a permanent directory is requested use it or create it
1083 //command="mkdir " + wdir;
1084 command_file << "mkdir " + wdir << endl;
1085 command_file << "cd /D " + wdir << endl;
1087 //command="mkdir -p " + wdir + " && cd " + wdir + ";";
1088 command_file << "mkdir -p " << wdir << " && cd " << wdir + ";";
1092 if (isPythonContainer(params.container_name))
1093 //command += "SALOME_ContainerPy.py ";
1094 command_file << "SALOME_ContainerPy.py ";
1096 //command += container_exe + " ";
1097 command_file << container_exe + " ";
1101 command_file << _NS->ContainerName(params);
1102 command_file << " -";
1103 AddOmninamesParams(command_file);
1104 command_file.close();
1107 chmod(_TmpFileName.c_str(), 0x1ED);
1109 command = _TmpFileName;
1111 MESSAGE("Command is file ... " << command);
1116 //=============================================================================
1118 * removes the generated temporary file in case of a remote launch.
1120 //=============================================================================
1122 void SALOME_ContainerManager::RmTmpFile(std::string& tmpFileName)
1124 int lenght = tmpFileName.size();
1128 string command = "del /F ";
1130 string command = "rm ";
1133 command += tmpFileName.substr(0, lenght - 3 );
1135 command += tmpFileName;
1137 system(command.c_str());
1138 //if dir is empty - remove it
1139 string tmp_dir = Kernel_Utils::GetDirByPath( tmpFileName );
1140 if ( Kernel_Utils::IsEmptyDir( tmp_dir ) )
1143 command = "del /F " + tmp_dir;
1145 command = "rmdir " + tmp_dir;
1147 system(command.c_str());
1152 //=============================================================================
1154 * add to command all options relative to naming service.
1156 //=============================================================================
1158 void SALOME_ContainerManager::AddOmninamesParams(string& command) const
1160 CORBA::String_var iorstr = _NS->getIORaddr();
1161 command += "ORBInitRef NameService=";
1166 //=============================================================================
1168 * add to command all options relative to naming service.
1170 //=============================================================================
1172 void SALOME_ContainerManager::AddOmninamesParams(ofstream& fileStream) const
1174 CORBA::String_var iorstr = _NS->getIORaddr();
1175 fileStream << "ORBInitRef NameService=";
1176 fileStream << iorstr;
1179 //=============================================================================
1181 * generate a file name in /tmp directory
1183 //=============================================================================
1185 string SALOME_ContainerManager::BuildTemporaryFileName() const
1187 //build more complex file name to support multiple salome session
1188 string aFileName = Kernel_Utils::GetTmpFileName();
1192 aFileName += ".bat";
1198 //=============================================================================
1200 * Builds in a temporary file the script to be launched.
1202 * Used if SALOME Application ($APPLI) is not defined.
1203 * The command is build with data from CatalogResources, in which every path
1204 * used on remote computer must be defined.
1206 //=============================================================================
1209 SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer
1210 (const string& machine,
1211 const Engines::MachineParameters& params) throw(SALOME_Exception)
1215 _TmpFileName = BuildTemporaryFileName();
1216 ofstream tempOutputFile;
1217 tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
1218 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine);
1219 tempOutputFile << "#! /bin/sh" << endl;
1223 tempOutputFile << "export SALOME_trace=local" << endl; // mkr : 27.11.2006 : PAL13967 - Distributed supervision graphs - Problem with "SALOME_trace"
1224 //tempOutputFile << "source " << resInfo.PreReqFilePath << endl;
1230 tempOutputFile << "mpirun -np ";
1233 if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
1235 else if ( params.nb_node == 0 )
1236 nbproc = params.nb_proc_per_node;
1237 else if ( params.nb_proc_per_node == 0 )
1238 nbproc = params.nb_node;
1240 nbproc = params.nb_node * params.nb_proc_per_node;
1242 std::ostringstream o;
1244 tempOutputFile << nbproc << " ";
1246 tempOutputFile << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
1247 #elif defined(WITHOPENMPI)
1248 if( getenv("OMPI_URI_FILE") == NULL )
1249 tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
1251 tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
1252 tempOutputFile << getenv("OMPI_URI_FILE");
1257 tempOutputFile << getenv("KERNEL_ROOT_DIR") << "/bin/salome/";
1261 if (isPythonContainer(params.container_name))
1262 tempOutputFile << " pyMPI SALOME_ContainerPy.py ";
1264 tempOutputFile << " SALOME_MPIContainer ";
1269 if (isPythonContainer(params.container_name))
1270 tempOutputFile << "SALOME_ContainerPy.py ";
1272 tempOutputFile << "SALOME_Container ";
1275 tempOutputFile << _NS->ContainerName(params) << " -";
1276 AddOmninamesParams(tempOutputFile);
1277 tempOutputFile << " &" << endl;
1278 tempOutputFile.flush();
1279 tempOutputFile.close();
1281 chmod(_TmpFileName.c_str(), 0x1ED);
1284 // --- Build command
1288 if (resInfo.Protocol == rsh)
1291 string commandRcp = "rcp ";
1292 commandRcp += _TmpFileName;
1294 commandRcp += machine;
1296 commandRcp += _TmpFileName;
1297 status = system(commandRcp.c_str());
1300 else if (resInfo.Protocol == ssh)
1303 string commandRcp = "scp ";
1304 commandRcp += _TmpFileName;
1306 commandRcp += machine;
1308 commandRcp += _TmpFileName;
1309 status = system(commandRcp.c_str());
1312 throw SALOME_Exception("Unknown protocol");
1315 throw SALOME_Exception("Error of connection on remote host");
1318 _CommandForRemAccess = command;
1320 command += _TmpFileName;
1328 //=============================================================================
1329 /*! Creates a command line that the container manager uses to launch
1330 * a parallel container.
1332 //=============================================================================
1334 SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string& exe_name,
1335 const Engines::MachineParameters& params,
1336 SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
1337 const std::string proxy_hostname)
1339 // This method knows the differences between the proxy and the nodes.
1340 // nb_component_nodes is not used in the same way if it is a proxy or
1343 //command = "gdb --args ";
1344 //command = "valgrind --tool=memcheck --log-file=val_log ";
1345 //command += real_exe_name;
1347 // Step 0 : init some variables...
1348 std::string parallelLib(CORBA::string_dup(params.parallelLib));
1349 std::string real_exe_name = exe_name + parallelLib;
1350 std::string machine_file_name("");
1351 bool remote = false;
1352 bool is_a_proxy = false;
1353 std::string hostname(CORBA::string_dup(params.hostname));
1355 std::ostringstream tmp_string;
1356 CORBA::Long nb_nodes = params.nb_component_nodes;
1357 tmp_string << nb_nodes;
1358 std::string nbproc = tmp_string.str();
1360 Engines::MachineParameters_var rtn = new Engines::MachineParameters();
1361 rtn->container_name = params.container_name;
1362 rtn->hostname = params.hostname;
1363 rtn->OS = params.OS;
1364 rtn->mem_mb = params.mem_mb;
1365 rtn->cpu_clock = params.cpu_clock;
1366 rtn->nb_proc_per_node = params.nb_proc_per_node;
1367 rtn->nb_node = params.nb_node;
1368 rtn->isMPI = params.isMPI;
1370 // Step 1 : local or remote launch ?
1371 if (hostname != std::string(Kernel_Utils::GetHostname()) )
1373 MESSAGE("[BuildCommandToLaunchParallelContainer] remote machine case detected !");
1377 // Step 2 : proxy or nodes launch ?
1378 std::string::size_type loc_proxy = exe_name.find("Proxy");
1379 if( loc_proxy != string::npos ) {
1383 // Step 3 : Depending of the parallelLib, getting the machine file
1384 // ParallelLib Dummy has is own machine for this method
1389 machine_file_name = _ResManager->getMachineFile(hostname,
1395 machine_file_name = _ResManager->getMachineFile(hostname,
1396 params.nb_component_nodes,
1399 if (machine_file_name == "")
1401 INFOS("[BuildCommandToLaunchParallelContainer] Error machine_file was not generated for machine " << hostname);
1402 throw SALOME_Exception("Error machine_file was not generated");
1404 MESSAGE("[BuildCommandToLaunchParallelContainer] machine_file_name is : " << machine_file_name);
1407 // Step 4 : Log type choosen by the user
1408 std::string log_env("");
1409 char * get_val = getenv("PARALLEL_LOG");
1412 std::string command_begin("");
1413 std::string command_end("");
1414 if(log_env == "xterm")
1416 command_begin = "/usr/X11R6/bin/xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1417 command_end = "\"&";
1419 else if(log_env == "xterm_debug")
1421 command_begin = "/usr/X11R6/bin/xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1422 command_end = "; cat \" &";
1426 // default into a file...
1427 std::string logFilename = "/tmp/" + _NS->ContainerName(params) + "_" + hostname;
1429 logFilename += "_Proxy_";
1431 logFilename += "_Node_";
1432 logFilename += std::string(getenv("USER")) + ".log";
1433 command_end = " > " + logFilename + " 2>&1 & ";
1436 // Step 5 : Building the command
1437 std::string command("");
1438 if (parallelLib == "Dummy")
1442 std::string command_remote("");
1445 std::string machine_name;
1446 std::ifstream machine_file(machine_file_name.c_str());
1447 std::getline(machine_file, machine_name);
1448 MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << machine_name)
1450 // We want to launch a command like :
1451 // ssh user@machine distantPath/runRemote.sh hostNS portNS
1452 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine_name);
1453 if (resInfo.Protocol == rsh)
1454 command_remote = "rsh ";
1456 command_remote = "ssh ";
1457 command_remote += resInfo.UserName;
1458 command_remote += "@";
1459 command_remote += machine_name;
1460 command_remote += " ";
1461 command_remote += resInfo.AppliPath; // path relative to user@machine $HOME
1462 command_remote += "/runRemote.sh ";
1463 ASSERT(getenv("NSHOST"));
1464 command_remote += getenv("NSHOST"); // hostname of CORBA name server
1465 command_remote += " ";
1466 ASSERT(getenv("NSPORT"));
1467 command_remote += getenv("NSPORT"); // port of CORBA name server
1468 command_remote += " ";
1470 hostname = machine_name;
1473 command = real_exe_name;
1474 command += " " + _NS->ContainerName(rtn);
1475 command += " " + parallelLib;
1476 command += " " + hostname;
1477 command += " " + nbproc;
1479 AddOmninamesParams(command);
1481 command = command_begin + command_remote + command + command_end;
1482 vect_machine.push_back(hostname);
1486 std::ifstream * machine_file = NULL;
1488 machine_file = new std::ifstream(machine_file_name.c_str());
1489 for (int i= 0; i < nb_nodes; i++)
1491 std::string command_remote("");
1494 std::string machine_name;
1495 std::getline(*machine_file, machine_name);
1496 MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << machine_name)
1498 // We want to launch a command like :
1499 // ssh user@machine distantPath/runRemote.sh hostNS portNS
1500 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine_name);
1501 if (resInfo.Protocol == rsh)
1502 command_remote = "rsh ";
1504 command_remote = "ssh ";
1505 command_remote += resInfo.UserName;
1506 command_remote += "@";
1507 command_remote += machine_name;
1508 command_remote += " ";
1509 command_remote += resInfo.AppliPath; // path relative to user@machine $HOME
1510 command_remote += "/runRemote.sh ";
1511 ASSERT(getenv("NSHOST"));
1512 command_remote += getenv("NSHOST"); // hostname of CORBA name server
1513 command_remote += " ";
1514 ASSERT(getenv("NSPORT"));
1515 command_remote += getenv("NSPORT"); // port of CORBA name server
1516 command_remote += " ";
1518 hostname = machine_name;
1521 std::ostringstream tmp;
1523 std::string proc_number = tmp.str();
1525 std::string command_tmp("");
1526 command_tmp += real_exe_name;
1527 command_tmp += " " + _NS->ContainerName(rtn);
1528 command_tmp += " " + parallelLib;
1529 command_tmp += " " + proxy_hostname;
1530 command_tmp += " " + proc_number;
1531 command_tmp += " -";
1532 AddOmninamesParams(command_tmp);
1534 // On change _Node_ par _Nodex_ pour avoir chaque noeud
1536 std::string command_end_tmp = command_end;
1537 std::string::size_type loc_node = command_end_tmp.find("_Node_");
1538 if (loc_node != std::string::npos)
1539 command_end_tmp.insert(loc_node+5, proc_number);
1540 command += command_begin + command_remote + command_tmp + command_end_tmp;
1541 vect_machine.push_back(hostname);
1544 delete machine_file;
1547 else if (parallelLib == "Mpi")
1549 // Step 0: if remote we have to copy the file
1550 // to the first machine of the file
1551 std::string remote_machine("");
1554 std::ifstream * machine_file = NULL;
1555 machine_file = new std::ifstream(machine_file_name.c_str());
1556 // Get first word of the line
1557 // For MPI implementation the first word is the
1559 std::getline(*machine_file, remote_machine, ' ');
1560 machine_file->close();
1561 MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << remote_machine)
1563 // We want to launch a command like :
1564 // scp mpi_machine_file user@machine:Path
1565 std::string command_remote("");
1566 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine);
1567 if (resInfo.Protocol == rsh)
1568 command_remote = "rcp ";
1570 command_remote = "scp ";
1572 command_remote += machine_file_name;
1573 command_remote += " ";
1574 command_remote += resInfo.UserName;
1575 command_remote += "@";
1576 command_remote += remote_machine;
1577 command_remote += ":";
1578 command_remote += machine_file_name;
1580 int status = system(command_remote.c_str());
1583 INFOS("copy of the mpi machine file failed !");
1590 std::string command_remote("");
1593 // We want to launch a command like :
1594 // ssh user@machine distantPath/runRemote.sh hostNS portNS
1595 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine);
1596 if (resInfo.Protocol == rsh)
1597 command_remote = "rsh ";
1599 command_remote = "ssh ";
1600 command_remote += resInfo.UserName;
1601 command_remote += "@";
1602 command_remote += remote_machine;
1603 command_remote += " ";
1604 command_remote += resInfo.AppliPath; // path relative to user@machine $HOME
1605 command_remote += "/runRemote.sh ";
1606 ASSERT(getenv("NSHOST"));
1607 command_remote += getenv("NSHOST"); // hostname of CORBA name server
1608 command_remote += " ";
1609 ASSERT(getenv("NSPORT"));
1610 command_remote += getenv("NSPORT"); // port of CORBA name server
1611 command_remote += " ";
1613 hostname = remote_machine;
1616 // We use Dummy proxy for MPI parallel containers
1617 real_exe_name = exe_name + "Dummy";
1618 command = real_exe_name;
1619 command += " " + _NS->ContainerName(rtn);
1620 command += " Dummy";
1621 command += " " + hostname;
1622 command += " " + nbproc;
1624 AddOmninamesParams(command);
1626 command = command_begin + command_remote + command + command_end;
1627 vect_machine.push_back(hostname);
1631 std::string command_remote("");
1634 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine);
1635 if (resInfo.Protocol == rsh)
1636 command_remote = "rsh ";
1638 command_remote = "ssh ";
1639 command_remote += resInfo.UserName;
1640 command_remote += "@";
1641 command_remote += remote_machine;
1642 command_remote += " ";
1644 std::string new_real_exe_name("");
1645 new_real_exe_name += resInfo.AppliPath; // path relative to user@machine $HOME
1646 new_real_exe_name += "/runRemote.sh ";
1647 ASSERT(getenv("NSHOST"));
1648 new_real_exe_name += getenv("NSHOST"); // hostname of CORBA name server
1649 new_real_exe_name += " ";
1650 ASSERT(getenv("NSPORT"));
1651 new_real_exe_name += getenv("NSPORT"); // port of CORBA name server
1652 new_real_exe_name += " ";
1654 real_exe_name = new_real_exe_name + real_exe_name;
1655 hostname = remote_machine;
1658 const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(hostname);
1659 if (resInfo.mpi == lam)
1661 command = "mpiexec -ssi boot ";
1662 if (resInfo.Protocol == rsh)
1666 command += "-machinefile " + machine_file_name + " ";
1667 command += "-n " + nbproc + " ";
1668 command += real_exe_name;
1669 command += " " + _NS->ContainerName(rtn);
1670 command += " " + parallelLib;
1671 command += " " + proxy_hostname;
1673 AddOmninamesParams(command);
1677 command = "mpirun -np " + nbproc + " ";
1678 command += real_exe_name;
1679 command += " " + _NS->ContainerName(rtn);
1680 command += " " + parallelLib;
1681 command += " " + proxy_hostname;
1683 AddOmninamesParams(command);
1686 command = command_begin + command_remote + command + command_end;
1687 for (int i= 0; i < nb_nodes; i++)
1688 vect_machine.push_back(proxy_hostname);
1693 std::string message("Unknown parallelLib : " + parallelLib);
1694 throw SALOME_Exception(message.c_str());
1697 MESSAGE("Parallel launch is: " << command);
1701 string SALOME_ContainerManager::GetMPIZeroNode(string machine)
1706 string tmpFile = BuildTemporaryFileName();
1708 cmd = "ssh " + machine + " mpirun -np 1 hostname > " + tmpFile;
1710 status = system(cmd.c_str());
1712 ifstream fp(tmpFile.c_str(),ios::in);