Salome HOME
Make ContainerManager::GiveContainer threadsafe to allow // launch of containers.
[modules/kernel.git] / src / Container / SALOME_ContainerManager.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "SALOME_ContainerManager.hxx"
24 #include "SALOME_NamingService.hxx"
25 #include "SALOME_ModuleCatalog.hh"
26 #include "Basics_Utils.hxx"
27 #include "Basics_DirUtils.hxx"
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <signal.h>
31 #ifndef WIN32
32 #include <unistd.h>
33 #endif
34 #include <vector>
35 #include "Utils_CorbaException.hxx"
36 #include <sstream>
37 #include <string>
38
39 #include <SALOMEconfig.h>
40 #include CORBA_CLIENT_HEADER(SALOME_Session)
41
42 #ifdef WIN32
43 #include <process.h>
44 #define getpid _getpid
45 #endif
46
47 #ifdef WITH_PACO_PARALLEL
48 #include "PaCOPP.hxx"
49 #endif
50
51 #define TIME_OUT_TO_LAUNCH_CONT 60
52
53 const char *SALOME_ContainerManager::_ContainerManagerNameInNS = 
54   "/ContainerManager";
55
56 omni_mutex SALOME_ContainerManager::_numInstanceMutex;
57
58 Utils_Mutex SALOME_ContainerManager::_getenvMutex;
59
60 Utils_Mutex SALOME_ContainerManager::_systemMutex;
61
62 //=============================================================================
63 /*! 
64  *  Constructor
65  *  \param orb
66  *  Define a CORBA single thread policy for the server, which avoid to deal
67  *  with non thread-safe usage like Change_Directory in SALOME naming service
68  */
69 //=============================================================================
70
71 SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns):_nbprocUsed(1)
72 {
73   MESSAGE("constructor");
74   _NS = ns;
75   _ResManager = rm;
76
77   PortableServer::POAManager_var pman = poa->the_POAManager();
78   _orb = CORBA::ORB::_duplicate(orb) ;
79   CORBA::PolicyList policies;
80   policies.length(1);
81   PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL));
82   policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol);
83
84   _poa = poa->create_POA("MThreadPOA",pman,policies);
85   threadPol->destroy();
86   PortableServer::ObjectId_var id = _poa->activate_object(this);
87   CORBA::Object_var obj = _poa->id_to_reference(id);
88   Engines::ContainerManager_var refContMan =
89     Engines::ContainerManager::_narrow(obj);
90
91   _NS->Register(refContMan,_ContainerManagerNameInNS);
92   _isAppliSalomeDefined = (GetenvThreadSafe("APPLI") != 0);
93
94 #ifdef HAVE_MPI2
95 #ifdef WITHOPENMPI
96   _pid_mpiServer = -1;
97   // the urifile name depends on pid of the process
98   std::stringstream urifile;
99   urifile << GetenvThreadSafe("HOME") << "/.urifile_" << getpid();
100   setenv("OMPI_URI_FILE",urifile.str().c_str(),1);
101   if( GetenvThreadSafe("OMPI_URI_FILE") != NULL ){
102     // get the pid of all ompi-server
103     std::set<pid_t> thepids1 = getpidofprogram("ompi-server");
104     // launch a new ompi-server
105     std::string command;
106     command = "ompi-server -r ";
107     command += GetenvThreadSafe("OMPI_URI_FILE");
108     int status=SystemThreadSafe(command.c_str());
109     if(status!=0)
110       throw SALOME_Exception("Error when launching ompi-server");
111     // get the pid of all ompi-server
112     std::set<pid_t> thepids2 = getpidofprogram("ompi-server");
113     // my ompi-server is the new one
114     std::set<pid_t>::const_iterator it;
115     for(it=thepids2.begin();it!=thepids2.end();it++)
116       if(thepids1.find(*it) == thepids1.end())
117         _pid_mpiServer = *it;
118     if(_pid_mpiServer < 0)
119       throw SALOME_Exception("Error when getting ompi-server id");
120   }
121 #elif defined(WITHMPICH)
122   _pid_mpiServer = -1;
123   // get the pid of all hydra_nameserver
124   std::set<pid_t> thepids1 = getpidofprogram("hydra_nameserver");
125   // launch a new hydra_nameserver
126   std::string command;
127   command = "hydra_nameserver &";
128   SystemThreadSafe(command.c_str());
129   // get the pid of all hydra_nameserver
130   std::set<pid_t> thepids2 = getpidofprogram("hydra_nameserver");
131   // my hydra_nameserver is the new one
132   std::set<pid_t>::const_iterator it;
133   for(it=thepids2.begin();it!=thepids2.end();it++)
134     if(thepids1.find(*it) == thepids1.end())
135       _pid_mpiServer = *it;
136 #endif
137 #endif
138
139   MESSAGE("constructor end");
140 }
141
142 //=============================================================================
143 /*! 
144  * destructor
145  */
146 //=============================================================================
147
148 SALOME_ContainerManager::~SALOME_ContainerManager()
149 {
150   MESSAGE("destructor");
151 #ifdef HAVE_MPI2
152 #ifdef WITHOPENMPI
153   if( GetenvThreadSafe("OMPI_URI_FILE") != NULL ){
154     // kill my ompi-server
155     if( kill(_pid_mpiServer,SIGTERM) != 0 )
156       throw SALOME_Exception("Error when killing ompi-server");
157     // delete my urifile
158     int status=SystemThreadSafe("rm -f ${OMPI_URI_FILE}");
159     if(status!=0)
160       throw SALOME_Exception("Error when removing urifile");
161   }
162 #elif defined(WITHMPICH)
163   // kill my hydra_nameserver
164   if(_pid_mpiServer > -1)
165     if( kill(_pid_mpiServer,SIGTERM) != 0 )
166       throw SALOME_Exception("Error when killing hydra_nameserver");
167 #endif
168 #endif
169 }
170
171 //=============================================================================
172 //! shutdown all the containers, then the ContainerManager servant
173 /*! CORBA method:
174  */
175 //=============================================================================
176
177 void SALOME_ContainerManager::Shutdown()
178 {
179   MESSAGE("Shutdown");
180   ShutdownContainers();
181   _NS->Destroy_Name(_ContainerManagerNameInNS);
182   PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
183   _poa->deactivate_object(oid);
184 }
185
186 //=============================================================================
187 //! Loop on all the containers listed in naming service, ask shutdown on each
188 /*! CORBA Method:
189  */
190 //=============================================================================
191
192 void SALOME_ContainerManager::ShutdownContainers()
193 {
194   MESSAGE("ShutdownContainers");
195
196   SALOME::Session_var session = SALOME::Session::_nil();
197   CORBA::Long pid = 0;
198   CORBA::Object_var objS = _NS->Resolve("/Kernel/Session");
199   if (!CORBA::is_nil(objS))
200   {
201     session = SALOME::Session::_narrow(objS);
202     if (!CORBA::is_nil(session))
203       pid = session->getPID();
204   }
205
206   bool isOK;
207   isOK = _NS->Change_Directory("/Containers");
208   if( isOK ){
209     std::vector<std::string> vec = _NS->list_directory_recurs();
210     std::list<std::string> lstCont;
211     for(std::vector<std::string>::iterator iter = vec.begin();iter!=vec.end();iter++)
212       {
213         SCRUTE((*iter));
214         CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
215         try
216           {
217             Engines::Container_var cont=Engines::Container::_narrow(obj);
218             if(!CORBA::is_nil(cont) && pid != cont->getPID())
219               lstCont.push_back((*iter));
220           }
221         catch(const CORBA::Exception& e)
222           {
223             // ignore this entry and continue
224           }
225       }
226     MESSAGE("Container list: ");
227     for(std::list<std::string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++){
228       SCRUTE((*iter));
229     }
230     for(std::list<std::string>::iterator iter=lstCont.begin();iter!=lstCont.end();iter++)
231     {
232       try
233       {
234         SCRUTE((*iter));
235         CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
236         Engines::Container_var cont=Engines::Container::_narrow(obj);
237         if(!CORBA::is_nil(cont))
238         {
239           MESSAGE("ShutdownContainers: " << (*iter));
240           cont->Shutdown();
241         }
242         else 
243           MESSAGE("ShutdownContainers: no container ref for " << (*iter));
244       }
245       catch(CORBA::SystemException& e)
246       {
247         INFOS("CORBA::SystemException ignored : " << e);
248       }
249       catch(CORBA::Exception&)
250       {
251         INFOS("CORBA::Exception ignored.");
252       }
253       catch(...)
254       {
255         INFOS("Unknown exception ignored.");
256       }
257     }
258   }
259 }
260
261 //=============================================================================
262 //! Give a suitable Container given constraints
263 /*! CORBA Method:
264  *  \param params Container Parameters required for the container
265  *  \return the container or nil
266  */
267 //=============================================================================
268 Engines::Container_ptr SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& params)
269 {
270   std::string machFile;
271   Engines::Container_ptr ret(Engines::Container::_nil());
272
273   // Step 0: Default mode is start
274   Engines::ContainerParameters local_params(params);
275   if (std::string(local_params.mode.in()) == "")
276     local_params.mode = CORBA::string_dup("start");
277   std::string mode = local_params.mode.in();
278   MESSAGE("[GiveContainer] starting with mode: " << mode);
279
280   // Step 1: Find Container for find and findorstart mode
281   if (mode == "find" || mode == "findorstart")
282   {
283     ret = FindContainer(params, params.resource_params.resList);
284     if(!CORBA::is_nil(ret))
285       return ret;
286     else
287     {
288       if (mode == "find")
289       {
290         MESSAGE("[GiveContainer] no container found");
291         return ret;
292       }
293       else
294       {
295         mode = "start";
296       }
297     }
298   }
299
300   // Step 2: Get all possibleResources from the parameters
301   // Consider only resources that can run containers
302   local_params.resource_params.can_run_containers = true;
303   Engines::ResourceList_var possibleResources = _ResManager->GetFittingResources(local_params.resource_params);
304   MESSAGE("[GiveContainer] - length of possible resources " << possibleResources->length());
305   std::vector<std::string> local_resources;
306
307   // Step 3: if mode is "get" keep only machines with existing containers 
308   if(mode == "get")
309   {
310     for(unsigned int i=0; i < possibleResources->length(); i++)
311     {
312       Engines::Container_ptr cont = FindContainer(params, possibleResources[i].in());
313       try
314       {
315         if(!cont->_non_existent())
316           local_resources.push_back(std::string(possibleResources[i]));
317       }
318       catch(CORBA::Exception&) {}
319     }
320
321     // if local_resources is empty, we cannot give a container
322     if (local_resources.size() == 0)
323     {
324       MESSAGE("[GiveContainer] cannot find a container for mode get");
325       return ret;
326     }
327   }
328   else
329     for(unsigned int i=0; i < possibleResources->length(); i++)
330       local_resources.push_back(std::string(possibleResources[i]));
331
332   // Step 4: select the resource where to get/start the container
333   bool resource_available = true;
334   std::string resource_selected;
335   std::vector<std::string> resources = local_resources;
336   while (resource_available)
337   {
338     if (resources.size() == 0)
339       resource_available = false;
340     else
341     {
342       try
343       {
344         resource_selected = _ResManager->GetImpl()->Find(params.resource_params.policy.in(), resources);
345         // Remove resource_selected from vector
346         std::vector<std::string>::iterator it;
347         for (it=resources.begin() ; it < resources.end(); it++ )
348           if (*it == resource_selected)
349           {
350             resources.erase(it);
351             break;
352           }
353       }
354       catch(const SALOME_Exception &ex)
355       {
356         MESSAGE("[GiveContainer] Exception in ResourceManager find !: " << ex.what());
357         return ret;
358       }
359       MESSAGE("[GiveContainer] Resource selected is: " << resource_selected);
360
361       // Step 5: Create container name
362       Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_selected.c_str());
363       std::string hostname(resource_definition->hostname.in());
364       std::string containerNameInNS;
365       if(params.isMPI){
366         int nbproc;
367         if ( params.nb_proc <= 0 )
368           nbproc = 1;
369         else
370           nbproc = params.nb_proc;
371         try
372         {
373           if( GetenvThreadSafe("LIBBATCH_NODEFILE") != NULL )
374             machFile = machinesFile(nbproc);
375         }
376         catch(const SALOME_Exception & ex)
377         {
378           std::string err_msg = ex.what();
379           err_msg += params.container_name;
380           INFOS(err_msg.c_str());
381           return ret;
382         }
383         // A mpi parallel container register on zero node in NS
384         containerNameInNS = _NS->BuildContainerNameForNS(params, GetMPIZeroNode(hostname,machFile).c_str());
385       }
386       else
387         containerNameInNS = _NS->BuildContainerNameForNS(params, hostname.c_str());
388       MESSAGE("[GiveContainer] Container name in the naming service: " << containerNameInNS);
389
390       // Step 6: check if the name exists in naming service
391       //if params.mode == "getorstart" or "get" use the existing container
392       //if params.mode == "start" shutdown the existing container before launching a new one with that name
393
394       { // critical section
395         Utils_Locker lock (&_giveContainerMutex1);
396         CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
397         if (!CORBA::is_nil(obj))
398           {
399             try
400             {
401                 Engines::Container_var cont=Engines::Container::_narrow(obj);
402                 if(!cont->_non_existent())
403                   {
404                     if(std::string(params.mode.in())=="getorstart" || std::string(params.mode.in())=="get"){
405                         return cont._retn(); /* the container exists and params.mode is getorstart or get use it*/
406                     }
407                     else
408                       {
409                         INFOS("[GiveContainer] A container is already registered with the name: " << containerNameInNS << ", shutdown the existing container");
410                         cont->Shutdown(); // shutdown the registered container if it exists
411                       }
412                   }
413             }
414             catch(CORBA::Exception&)
415             {
416                 INFOS("[GiveContainer] CORBA::Exception ignored when trying to get the container - we start a new one");
417             }
418           }
419       } // end critical section
420       Engines::Container_var cont = LaunchContainer(params, resource_selected, hostname, machFile, containerNameInNS);
421       if (!CORBA::is_nil(cont))
422       {
423         INFOS("[GiveContainer] container " << containerNameInNS << " launched");
424         return cont._retn();
425       }
426       else
427       {
428         INFOS("[GiveContainer] Failed to launch container on resource " << resource_selected);
429       }
430     }
431   }
432
433   // We were not able to launch the container
434   INFOS("[GiveContainer] Cannot launch the container on the following selected resources:")
435   std::vector<std::string>::iterator it;
436   for (it=local_resources.begin() ; it < local_resources.end(); it++ )
437     INFOS("[GiveContainer] " << *it)
438   return ret;
439 }
440
441 Engines::Container_ptr
442 SALOME_ContainerManager::LaunchContainer(const Engines::ContainerParameters& params,
443                                          const std::string & resource_selected,
444                                          const std::string & hostname,
445                                          const std::string & machFile,
446                                          const std::string & containerNameInNS)
447 {
448   std::string user,command,logFilename,tmpFileName;
449   int status;
450   Engines::Container_ptr ret(Engines::Container::_nil());
451   {//start of critical section
452     Utils_Locker lock (&_giveContainerMutex1);
453     // Step 1: type of container: PaCO, Exe, Mpi or Classic
454     // Mpi already tested in step 5, specific code on BuildCommandToLaunch Local/Remote Container methods
455     // TODO -> separates Mpi from Classic/Exe
456     // Classic or Exe ?
457     std::string container_exe = "SALOME_Container"; // Classic container
458     Engines::ContainerParameters local_params(params);
459     int found=0;
460     try
461     {
462         CORBA::String_var container_exe_tmp;
463         CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog");
464         SALOME_ModuleCatalog::ModuleCatalog_var Catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ;
465         if (CORBA::is_nil (Catalog))
466           {
467             INFOS("[GiveContainer] Module Catalog is not found -> cannot launch a container");
468             return ret;
469           }
470         // Loop through component list
471         for(unsigned int i=0; i < local_params.resource_params.componentList.length(); i++)
472           {
473             const char* compoi = local_params.resource_params.componentList[i];
474             SALOME_ModuleCatalog::Acomponent_var compoInfo = Catalog->GetComponent(compoi);
475             if (CORBA::is_nil (compoInfo))
476               {
477                 continue;
478               }
479             SALOME_ModuleCatalog::ImplType impl=compoInfo->implementation_type();
480             container_exe_tmp=compoInfo->implementation_name();
481             if(impl==SALOME_ModuleCatalog::CEXE)
482               {
483                 if(found)
484                   {
485                     INFOS("ContainerManager Error: you can't have 2 CEXE component in the same container" );
486                     return Engines::Container::_nil();
487                   }
488                 MESSAGE("[GiveContainer] Exe container found !: " << container_exe_tmp);
489                 container_exe = container_exe_tmp.in();
490                 found=1;
491               }
492           }
493     }
494     catch (ServiceUnreachable&)
495     {
496         INFOS("Caught exception: Naming Service Unreachable");
497         return ret;
498     }
499     catch (...)
500     {
501         INFOS("Caught unknown exception.");
502         return ret;
503     }
504
505     // Step 2: test resource
506     // Only if an application directory is set
507     if(hostname != Kernel_Utils::GetHostname() && _isAppliSalomeDefined)
508       {
509         // Preparing remote command
510         std::string command = "";
511         const ParserResourcesType resInfo(_ResManager->GetImpl()->GetResourcesDescr(resource_selected));
512         command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName, resInfo.UserName);
513         if (resInfo.AppliPath != "")
514           command += resInfo.AppliPath;
515         else
516           {
517             ASSERT(GetenvThreadSafe("APPLI"));
518             command += GetenvThreadSafe("APPLI");
519           }
520         command += "/runRemote.sh ";
521         ASSERT(GetenvThreadSafe("NSHOST"));
522         command += GetenvThreadSafe("NSHOST"); // hostname of CORBA name server
523         command += " ";
524         ASSERT(GetenvThreadSafe("NSPORT"));
525         command += GetenvThreadSafe("NSPORT"); // port of CORBA name server
526         command += " \"ls /tmp >/dev/null 2>&1\"";
527
528         // Launch remote command
529         int status = SystemThreadSafe(command.c_str());
530         if (status != 0)
531           {
532             // Error on resource - cannot launch commands
533             INFOS("[LaunchContainer] Cannot launch commands on machine " << hostname);
534             INFOS("[LaunchContainer] Command was " << command);
535 #ifndef WIN32
536             INFOS("[LaunchContainer] Command status is " << WEXITSTATUS(status));
537 #endif
538             return Engines::Container::_nil();
539           }
540       }
541
542     // Step 3: start a new container
543     // Check if a PaCO container
544     // PaCO++
545     if (std::string(local_params.parallelLib.in()) != "")
546       {
547         ret = StartPaCOPPContainer(params, resource_selected);
548         return ret;
549       }
550     // Other type of containers...
551     MESSAGE("[GiveContainer] Try to launch a new container on " << resource_selected);
552     // if a parallel container is launched in batch job, command is: "mpirun -np nbproc -machinefile nodesfile SALOME_MPIContainer"
553     if( GetenvThreadSafe("LIBBATCH_NODEFILE") != NULL && params.isMPI )
554       command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe, tmpFileName);
555     // if a container is launched on localhost, command is "SALOME_Container" or "mpirun -np nbproc SALOME_MPIContainer"
556     else if(hostname == Kernel_Utils::GetHostname())
557       command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe, tmpFileName);
558     // if a container is launched in remote mode, command is "ssh resource_selected SALOME_Container" or "ssh resource_selected mpirun -np nbproc SALOME_MPIContainer"
559     else
560       command = BuildCommandToLaunchRemoteContainer(resource_selected, params, container_exe);
561
562     //redirect stdout and stderr in a file
563 #ifdef WIN32
564     logFilename=GetenvThreadSafe("TEMP");
565     logFilename += "\\";
566     user = GetenvThreadSafe( "USERNAME" );
567 #else
568     user = GetenvThreadSafe( "USER" );
569     logFilename="/tmp";
570     char* val = GetenvThreadSafe("SALOME_TMP_DIR");
571     if(val)
572       {
573         struct stat file_info;
574         stat(val, &file_info);
575         bool is_dir = S_ISDIR(file_info.st_mode);
576         if (is_dir)logFilename=val;
577         else std::cerr << "SALOME_TMP_DIR environment variable is not a directory use /tmp instead" << std::endl;
578       }
579     logFilename += "/";
580 #endif
581     logFilename += _NS->ContainerName(params)+"_"+ resource_selected +"_"+user;
582     std::ostringstream tmp;
583     tmp << "_" << getpid();
584     logFilename += tmp.str();
585     logFilename += ".log" ;
586     command += " > " + logFilename + " 2>&1";
587 #ifdef WIN32
588     command = "%PYTHONBIN% -c \"import win32pm ; win32pm.spawnpid(r'" + command + "', '')\"";
589 #else
590     command += " &";
591 #endif
592
593     // launch container with a system call
594     status=SystemThreadSafe(command.c_str());
595   }//end of critical of section
596
597   if (status == -1)
598     {
599       INFOS("[LaunchContainer] command failed (system command status -1): " << command);
600       RmTmpFile(tmpFileName); // command file can be removed here
601       return Engines::Container::_nil();
602     }
603   else if (status == 217)
604     {
605       INFOS("[LaunchContainer] command failed (system command status 217): " << command);
606       RmTmpFile(tmpFileName); // command file can be removed here
607       return Engines::Container::_nil();
608     }
609   else
610     {
611       // Step 4: Wait for the container
612       int count = TIME_OUT_TO_LAUNCH_CONT;
613       if (GetenvThreadSafe("TIMEOUT_TO_LAUNCH_CONTAINER") != 0)
614         {
615           std::string new_count_str = GetenvThreadSafe("TIMEOUT_TO_LAUNCH_CONTAINER");
616           int new_count;
617           std::istringstream ss(new_count_str);
618           if (!(ss >> new_count))
619             {
620               INFOS("[LaunchContainer] TIMEOUT_TO_LAUNCH_CONTAINER should be an int");
621             }
622           else
623             count = new_count;
624         }
625       INFOS("[GiveContainer] waiting " << count << " second steps container " << containerNameInNS);
626       while (CORBA::is_nil(ret) && count)
627         {
628 #ifndef WIN32
629           sleep( 1 ) ;
630 #else
631           Sleep(1000);
632 #endif
633           count--;
634           MESSAGE("[GiveContainer] step " << count << " Waiting for container on " << resource_selected);
635           CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
636           ret=Engines::Container::_narrow(obj);
637         }
638       if (CORBA::is_nil(ret))
639         {
640           INFOS("[GiveContainer] was not able to launch container " << containerNameInNS);
641         }
642       else
643         {
644           // Setting log file name
645           logFilename=":"+logFilename;
646           logFilename="@"+Kernel_Utils::GetHostname()+logFilename;//threadsafe
647           logFilename=user+logFilename;
648           ret->logfilename(logFilename.c_str());
649           RmTmpFile(tmpFileName); // command file can be removed here
650         }
651     }
652   return ret;
653 }
654
655 //=============================================================================
656 //! Find a container given constraints (params) on a list of machines (possibleComputers)
657 //! agy : this method is ThreadSafe
658 /*!
659  *
660  */
661 //=============================================================================
662
663 Engines::Container_ptr SALOME_ContainerManager::FindContainer(const Engines::ContainerParameters& params, const Engines::ResourceList& possibleResources)
664 {
665   MESSAGE("[FindContainer] FindContainer on " << possibleResources.length() << " resources");
666   for(unsigned int i=0; i < possibleResources.length();i++)
667     {
668       Engines::Container_ptr cont = FindContainer(params, possibleResources[i].in());
669       if(!CORBA::is_nil(cont))
670         return cont;
671     }
672   MESSAGE("[FindContainer] no container found");
673   return Engines::Container::_nil();
674 }
675
676 //=============================================================================
677 //! Find a container given constraints (params) on a machine (theMachine)
678 //! agy : this method is ThreadSafe
679 /*!
680  *
681  */
682 //=============================================================================
683
684 Engines::Container_ptr
685 SALOME_ContainerManager::FindContainer(const Engines::ContainerParameters& params, const std::string& resource)
686 {
687   Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource.c_str());
688   std::string hostname(resource_definition->hostname.in());
689   std::string containerNameInNS(_NS->BuildContainerNameForNS(params, hostname.c_str()));
690   MESSAGE("[FindContainer] Try to find a container  " << containerNameInNS << " on resource " << resource);
691   CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
692   try
693   {
694     if(obj->_non_existent())
695       return Engines::Container::_nil();
696     else
697       return Engines::Container::_narrow(obj);
698   }
699   catch(const CORBA::Exception& e)
700   {
701     return Engines::Container::_nil();
702   }
703 }
704
705
706 bool isPythonContainer(const char* ContainerName);
707
708 //=============================================================================
709 /*!
710  *  This is no longer valid (C++ container are also python containers)
711  */ 
712 //=============================================================================
713 bool isPythonContainer(const char* ContainerName)
714 {
715   return false; // VSR 02/08/2013: Python containers are no more supported
716   bool ret = false;
717   int len = strlen(ContainerName);
718
719   if (len >= 2)
720     if (strcmp(ContainerName + len - 2, "Py") == 0)
721       ret = true;
722
723   return ret;
724 }
725
726 //=============================================================================
727 /*!
728  *  Builds the script to be launched
729  *
730  *  If SALOME Application not defined ($APPLI),
731  *  see BuildTempFileToLaunchRemoteContainer()
732  *
733  *  Else rely on distant configuration. Command is under the form (example):
734  *  ssh user@machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
735  *                   SALOME_Container containerName &"
736
737  *  - where user is ommited if not specified in CatalogResources,
738  *  - where distant path is always relative to user@machine $HOME, and
739  *    equal to $APPLI if not specified in CatalogResources,
740  *  - where hostNS is the hostname of CORBA naming server (set by scripts to
741  *    use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
742  *  - where portNS is the port used by CORBA naming server (set by scripts to
743  *    use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
744  *  - where workingdir is the requested working directory for the container.
745  *    If WORKINGDIR (and workingdir) is not present the working dir will be $HOME
746  */ 
747 //=============================================================================
748
749 std::string
750 SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer(const std::string& resource_name, const Engines::ContainerParameters& params, const std::string& container_exe) const
751 {
752   std::string command,tmpFileName;
753   if (!_isAppliSalomeDefined)
754     command = BuildTempFileToLaunchRemoteContainer(resource_name, params, tmpFileName);
755   else
756   {
757     int nbproc;
758     Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_name.c_str());
759     std::string hostname(resource_definition->hostname.in());
760     const ParserResourcesType resInfo(_ResManager->GetImpl()->GetResourcesDescr(resource_name));
761
762     if (params.isMPI)
763     {
764       if ( params.nb_proc <= 0 )
765         nbproc = 1;
766       else
767         nbproc = params.nb_proc;
768     }
769
770     // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
771     //  SALOME_Container containerName &"
772     command = getCommandToRunRemoteProcess(resInfo.Protocol, resInfo.HostName, resInfo.UserName);
773
774     if (resInfo.AppliPath != "")
775       command += resInfo.AppliPath; // path relative to user@machine $HOME
776     else
777     {
778       ASSERT(GetenvThreadSafe("APPLI"));
779       command += GetenvThreadSafe("APPLI"); // path relative to user@machine $HOME
780     }
781
782     command += "/runRemote.sh ";
783
784     ASSERT(GetenvThreadSafe("NSHOST"));
785     command += GetenvThreadSafe("NSHOST"); // hostname of CORBA name server
786
787     command += " ";
788     ASSERT(GetenvThreadSafe("NSPORT"));
789     command += GetenvThreadSafe("NSPORT"); // port of CORBA name server
790
791     std::string wdir = params.workingdir.in();
792     if(wdir != "")
793     {
794       command += " WORKINGDIR ";
795       command += " '";
796       if(wdir == "$TEMPDIR")
797         wdir="\\$TEMPDIR";
798       command += wdir; // requested working directory
799       command += "'"; 
800     }
801
802     if(params.isMPI)
803     {
804       command += " mpirun -np ";
805       std::ostringstream o;
806       o << nbproc << " ";
807       command += o.str();
808 #ifdef WITHLAM
809       command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
810 #elif defined(WITHOPENMPI)
811       if( GetenvThreadSafe("OMPI_URI_FILE") == NULL )
812         command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
813       else{
814         command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
815         command += GetenvThreadSafe("OMPI_URI_FILE");
816       }
817 #elif defined(WITHMPICH)
818       command += "-nameserver " + Kernel_Utils::GetHostname();
819 #endif        
820       command += " SALOME_MPIContainer ";
821     }
822     else
823       command += " " +container_exe+ " ";
824
825     command += _NS->ContainerName(params);
826     command += " -";
827     AddOmninamesParams(command);
828
829     MESSAGE("command =" << command);
830   }
831
832   return command;
833 }
834
835 //=============================================================================
836 /*!
837  *  builds the command to be launched.
838  */ 
839 //=============================================================================
840 std::string SALOME_ContainerManager::BuildCommandToLaunchLocalContainer(const Engines::ContainerParameters& params, const std::string& machinesFile, const std::string& container_exe, std::string& tmpFileName) const
841 {
842   tmpFileName = BuildTemporaryFileName();
843   std::string command;
844   int nbproc = 0;
845
846   std::ostringstream o;
847
848   if (params.isMPI)
849     {
850       o << "mpirun -np ";
851
852       if ( params.nb_proc <= 0 )
853         nbproc = 1;
854       else
855         nbproc = params.nb_proc;
856
857       o << nbproc << " ";
858
859       if( GetenvThreadSafe("LIBBATCH_NODEFILE") != NULL )
860         o << "-machinefile " << machinesFile << " ";
861
862 #ifdef WITHLAM
863       o << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
864 #elif defined(WITHOPENMPI)
865       if( GetenvThreadSafe("OMPI_URI_FILE") == NULL )
866         o << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
867       else
868         {
869           o << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
870           o << GetenvThreadSafe("OMPI_URI_FILE");
871         }
872 #elif defined(WITHMPICH)
873       o << "-nameserver " + Kernel_Utils::GetHostname();
874 #endif
875
876       if (isPythonContainer(params.container_name))
877         o << " pyMPI SALOME_ContainerPy.py ";
878       else
879         o << " SALOME_MPIContainer ";
880     }
881
882   else
883     {
884       std::string wdir=params.workingdir.in();
885       if(wdir != "")
886         {
887           // a working directory is requested
888           if(wdir == "$TEMPDIR")
889             {
890               // a new temporary directory is requested
891               std::string dir = Kernel_Utils::GetTmpDir();
892 #ifdef WIN32
893               o << "cd /d " << dir << std::endl;
894 #else
895               o << "cd " << dir << ";";
896 #endif
897
898             }
899           else
900             {
901               // a permanent directory is requested use it or create it
902 #ifdef WIN32
903               o << "mkdir " + wdir << std::endl;
904               o << "cd /D " + wdir << std::endl;
905 #else
906               o << "mkdir -p " << wdir << " && cd " << wdir + ";";
907 #endif
908             }
909         }
910
911       if (isPythonContainer(params.container_name))
912         o << "SALOME_ContainerPy.py ";
913       else
914         o << container_exe + " ";
915
916     }
917
918   o << _NS->ContainerName(params);
919   o << " -";
920   AddOmninamesParams(o);
921
922   std::ofstream command_file( tmpFileName.c_str() );
923   command_file << o.str();
924   command_file.close();
925
926 #ifndef WIN32
927   chmod(tmpFileName.c_str(), 0x1ED);
928 #endif
929   command = tmpFileName;
930
931   MESSAGE("Command is file ... " << command);
932   MESSAGE("Command is ... " << o.str());
933   return command;
934 }
935
936
937 //=============================================================================
938 /*!
939  *  removes the generated temporary file in case of a remote launch.
940  *  This method is thread safe
941  */ 
942 //=============================================================================
943
944 void SALOME_ContainerManager::RmTmpFile(std::string& tmpFileName)
945 {
946   int lenght = tmpFileName.size();
947   if ( lenght  > 0)
948     {
949 #ifdef WIN32
950       std::string command = "del /F ";
951 #else
952       std::string command = "rm ";      
953 #endif
954       if ( lenght > 4 )
955         command += tmpFileName.substr(0, lenght - 3 );
956       else
957         command += tmpFileName;
958       command += '*';
959       SystemThreadSafe(command.c_str());
960       //if dir is empty - remove it
961       std::string tmp_dir = Kernel_Utils::GetDirByPath( tmpFileName );
962       if ( Kernel_Utils::IsEmptyDir( tmp_dir ) )
963         {
964 #ifdef WIN32
965           command = "del /F " + tmp_dir;
966 #else
967           command = "rmdir " + tmp_dir;
968 #endif
969           SystemThreadSafe(command.c_str());
970         }
971     }
972 }
973
974 //=============================================================================
975 /*!
976  *   add to command all options relative to naming service.
977  */ 
978 //=============================================================================
979
980 void SALOME_ContainerManager::AddOmninamesParams(std::string& command) const
981 {
982   CORBA::String_var iorstr = _NS->getIORaddr();
983   command += "ORBInitRef NameService=";
984   command += iorstr;
985 }
986
987 //=============================================================================
988 /*!
989  *  add to command all options relative to naming service.
990  */ 
991 //=============================================================================
992
993 void SALOME_ContainerManager::AddOmninamesParams(std::ofstream& fileStream) const
994 {
995   CORBA::String_var iorstr = _NS->getIORaddr();
996   fileStream << "ORBInitRef NameService=";
997   fileStream << iorstr;
998 }
999
1000 //=============================================================================
1001 /*!
1002  *  add to command all options relative to naming service.
1003  */ 
1004 //=============================================================================
1005
1006 void SALOME_ContainerManager::AddOmninamesParams(std::ostringstream& oss) const
1007 {
1008   CORBA::String_var iorstr = _NS->getIORaddr();
1009   oss << "ORBInitRef NameService=";
1010   oss << iorstr;
1011 }
1012
1013 //=============================================================================
1014 /*!
1015  *  generate a file name in /tmp directory
1016  */ 
1017 //=============================================================================
1018
1019 std::string SALOME_ContainerManager::BuildTemporaryFileName()
1020 {
1021   //build more complex file name to support multiple salome session
1022   std::string aFileName = Kernel_Utils::GetTmpFileName();
1023 #ifndef WIN32
1024   aFileName += ".sh";
1025 #else
1026   aFileName += ".bat";
1027 #endif
1028   return aFileName;
1029 }
1030
1031 //=============================================================================
1032 /*!
1033  *  Builds in a temporary file the script to be launched.
1034  *  
1035  *  Used if SALOME Application ($APPLI) is not defined.
1036  *  The command is build with data from CatalogResources, in which every path
1037  *  used on remote computer must be defined.
1038  */ 
1039 //=============================================================================
1040
1041 std::string SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer (const std::string& resource_name, const Engines::ContainerParameters& params, std::string& tmpFileName) const throw(SALOME_Exception)
1042 {
1043   int status;
1044
1045   tmpFileName = BuildTemporaryFileName();
1046   std::ofstream tempOutputFile;
1047   tempOutputFile.open(tmpFileName.c_str(), std::ofstream::out );
1048   const ParserResourcesType resInfo(_ResManager->GetImpl()->GetResourcesDescr(resource_name));
1049   tempOutputFile << "#! /bin/sh" << std::endl;
1050
1051   // --- set env vars
1052
1053   tempOutputFile << "export SALOME_trace=local" << std::endl; // mkr : 27.11.2006 : PAL13967 - Distributed supervision graphs - Problem with "SALOME_trace"
1054   //tempOutputFile << "source " << resInfo.PreReqFilePath << endl;
1055
1056   // ! env vars
1057
1058   if (params.isMPI)
1059     {
1060       tempOutputFile << "mpirun -np ";
1061       int nbproc;
1062
1063       if ( params.nb_proc <= 0 )
1064         nbproc = 1;
1065       else
1066         nbproc = params.nb_proc;
1067
1068       std::ostringstream o;
1069
1070       tempOutputFile << nbproc << " ";
1071 #ifdef WITHLAM
1072       tempOutputFile << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
1073 #elif defined(WITHOPENMPI)
1074       if( GetenvThreadSafe("OMPI_URI_FILE") == NULL )
1075         tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
1076       else{
1077         tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
1078         tempOutputFile << GetenvThreadSafe("OMPI_URI_FILE");
1079       }
1080 #elif defined(WITHMPICH)
1081       tempOutputFile << "-nameserver " + Kernel_Utils::GetHostname();
1082 #endif
1083     }
1084
1085   tempOutputFile << GetenvThreadSafe("KERNEL_ROOT_DIR") << "/bin/salome/";
1086
1087   if (params.isMPI)
1088     {
1089       if (isPythonContainer(params.container_name))
1090         tempOutputFile << " pyMPI SALOME_ContainerPy.py ";
1091       else
1092         tempOutputFile << " SALOME_MPIContainer ";
1093     }
1094
1095   else
1096     {
1097       if (isPythonContainer(params.container_name))
1098         tempOutputFile << "SALOME_ContainerPy.py ";
1099       else
1100         tempOutputFile << "SALOME_Container ";
1101     }
1102
1103   tempOutputFile << _NS->ContainerName(params) << " -";
1104   AddOmninamesParams(tempOutputFile);
1105   tempOutputFile << " &" << std::endl;
1106   tempOutputFile.flush();
1107   tempOutputFile.close();
1108 #ifndef WIN32
1109   chmod(tmpFileName.c_str(), 0x1ED);
1110 #endif
1111
1112   // --- Build command
1113
1114   std::string command;
1115
1116   if (resInfo.Protocol == rsh)
1117     {
1118       command = "rsh ";
1119       std::string commandRcp = "rcp ";
1120       commandRcp += tmpFileName;
1121       commandRcp += " ";
1122       commandRcp += resInfo.HostName;
1123       commandRcp += ":";
1124       commandRcp += tmpFileName;
1125       status = SystemThreadSafe(commandRcp.c_str());
1126     }
1127
1128   else if (resInfo.Protocol == ssh)
1129     {
1130       command = "ssh ";
1131       std::string commandRcp = "scp ";
1132       commandRcp += tmpFileName;
1133       commandRcp += " ";
1134       commandRcp += resInfo.HostName;
1135       commandRcp += ":";
1136       commandRcp += tmpFileName;
1137       status = SystemThreadSafe(commandRcp.c_str());
1138     }
1139
1140   else if (resInfo.Protocol == srun)
1141     {
1142       command = "srun -n 1 -N 1 --share --nodelist=";
1143       std::string commandRcp = "rcp ";
1144       commandRcp += tmpFileName;
1145       commandRcp += " ";
1146       commandRcp += resInfo.HostName;
1147       commandRcp += ":";
1148       commandRcp += tmpFileName;
1149       status = SystemThreadSafe(commandRcp.c_str());
1150     }
1151   else
1152     throw SALOME_Exception("Unknown protocol");
1153
1154   if(status)
1155     throw SALOME_Exception("Error of connection on remote host");    
1156
1157   command += resInfo.HostName;
1158   command += " ";
1159   command += tmpFileName;
1160
1161   SCRUTE(command);
1162
1163   return command;
1164
1165 }
1166
1167 std::string SALOME_ContainerManager::GetMPIZeroNode(const std::string machine, const std::string machinesFile) const
1168 {
1169   int status;
1170   std::string zeronode;
1171   std::string command;
1172   std::string tmpFile = BuildTemporaryFileName();
1173
1174   if( GetenvThreadSafe("LIBBATCH_NODEFILE") == NULL )
1175     {
1176       if (_isAppliSalomeDefined)
1177         {
1178           const ParserResourcesType resInfo(_ResManager->GetImpl()->GetResourcesDescr(machine));
1179
1180           if (resInfo.Protocol == rsh)
1181             command = "rsh ";
1182           else if (resInfo.Protocol == ssh)
1183             command = "ssh ";
1184           else if (resInfo.Protocol == srun)
1185             command = "srun -n 1 -N 1 --share --nodelist=";
1186           else
1187             throw SALOME_Exception("Unknown protocol");
1188
1189           if (resInfo.UserName != "")
1190             {
1191               command += "-l ";
1192               command += resInfo.UserName;
1193               command += " ";
1194             }
1195
1196           command += resInfo.HostName;
1197           command += " ";
1198
1199           if (resInfo.AppliPath != "")
1200             command += resInfo.AppliPath; // path relative to user@machine $HOME
1201           else
1202             {
1203               ASSERT(GetenvThreadSafe("APPLI"));
1204               command += GetenvThreadSafe("APPLI"); // path relative to user@machine $HOME
1205             }
1206
1207           command += "/runRemote.sh ";
1208
1209           ASSERT(GetenvThreadSafe("NSHOST"));
1210           command += GetenvThreadSafe("NSHOST"); // hostname of CORBA name server
1211
1212           command += " ";
1213           ASSERT(GetenvThreadSafe("NSPORT"));
1214           command += GetenvThreadSafe("NSPORT"); // port of CORBA name server
1215
1216           command += " mpirun -np 1 hostname -s > " + tmpFile;
1217         }
1218       else
1219         command = "mpirun -np 1 hostname -s > " + tmpFile;
1220     }
1221   else
1222     command = "mpirun -np 1 -machinefile " + machinesFile + " hostname -s > " + tmpFile;
1223
1224   status = SystemThreadSafe(command.c_str());
1225   if( status == 0 ){
1226     std::ifstream fp(tmpFile.c_str(),std::ios::in);
1227     while(fp >> zeronode);
1228   }
1229
1230   RmTmpFile(tmpFile);
1231
1232   return zeronode;
1233 }
1234
1235 std::string SALOME_ContainerManager::machinesFile(const int nbproc)
1236 {
1237   std::string tmp;
1238   std::string nodesFile = GetenvThreadSafe("LIBBATCH_NODEFILE");
1239   std::string machinesFile = Kernel_Utils::GetTmpFileName();
1240   std::ifstream fpi(nodesFile.c_str(),std::ios::in);
1241   std::ofstream fpo(machinesFile.c_str(),std::ios::out);
1242
1243   _numInstanceMutex.lock();
1244
1245   for(int i=0;i<_nbprocUsed;i++)
1246     fpi >> tmp;
1247
1248   for(int i=0;i<nbproc;i++)
1249     if( fpi >> tmp )
1250       fpo << tmp << std::endl;
1251     else
1252       throw SALOME_Exception("You need more processors than batch session have allocated for you! Unable to launch the mpi container: ");
1253
1254   _nbprocUsed += nbproc;
1255   fpi.close();
1256   fpo.close();
1257
1258   _numInstanceMutex.unlock();
1259
1260   return machinesFile;
1261
1262 }
1263
1264 std::set<pid_t> SALOME_ContainerManager::getpidofprogram(const std::string program)
1265 {
1266   std::set<pid_t> thepids;
1267   std::string tmpFile = Kernel_Utils::GetTmpFileName();
1268   std::string cmd;
1269   std::string thepid;
1270   cmd = "pidof " + program + " > " + tmpFile;
1271   SystemThreadSafe(cmd.c_str());
1272   std::ifstream fpi(tmpFile.c_str(),std::ios::in);
1273   while(fpi >> thepid){
1274     thepids.insert(atoi(thepid.c_str()));
1275   }
1276   return thepids;
1277 }
1278
1279 std::string SALOME_ContainerManager::getCommandToRunRemoteProcess(AccessProtocolType protocol,
1280                                                                   const std::string & hostname,
1281                                                                   const std::string & username)
1282 {
1283   std::ostringstream command;
1284   switch (protocol)
1285   {
1286   case rsh:
1287     command << "rsh ";
1288     if (username != "")
1289     {
1290       command << "-l " << username << " ";
1291     }
1292     command << hostname << " ";
1293     break;
1294   case ssh:
1295     command << "ssh ";
1296     if (username != "")
1297     {
1298       command << "-l " << username << " ";
1299     }
1300     command << hostname << " ";
1301     break;
1302   case srun:
1303     // no need to redefine the user with srun, the job user is taken by default
1304     // (note: for srun, user id can be specified with " --uid=<user>")
1305     command << "srun -n 1 -N 1 --share --nodelist=" << hostname << " ";
1306     break;
1307   case pbsdsh:
1308     command << "pbsdsh -o -h " << hostname << " ";
1309     break;
1310   case blaunch:
1311     command << "blaunch -no-shell " << hostname << " ";
1312     break;
1313   default:
1314     throw SALOME_Exception("Unknown protocol");
1315   }
1316
1317   return command.str();
1318 }
1319
1320 bool 
1321 SALOME_ContainerManager::checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected)
1322 {
1323   bool result = true;
1324  
1325   // Step 1 : check ContainerParameters
1326   // Check container_name, has to be defined
1327   if (std::string(params.container_name.in()) == "")
1328   {
1329     INFOS("[checkPaCOParameters] You must define a container_name to launch a PaCO++ container");
1330     result = false;
1331   }
1332   // Check parallelLib
1333   std::string parallelLib = params.parallelLib.in();
1334   if (parallelLib != "Mpi" && parallelLib != "Dummy")
1335   {
1336     INFOS("[checkPaCOParameters] parallelLib is not correctly defined");
1337     INFOS("[checkPaCOParameters] you can chosse between: Mpi and Dummy");
1338     INFOS("[checkPaCOParameters] you entered: " << parallelLib);
1339     result = false;
1340   }
1341   // Check nb_proc
1342   if (params.nb_proc <= 0)
1343   {
1344     INFOS("[checkPaCOParameters] You must define a nb_proc > 0");
1345     result = false;
1346   }
1347
1348   // Step 2 : check resource_selected
1349   Engines::ResourceDefinition_var resource_definition = _ResManager->GetResourceDefinition(resource_selected.c_str());
1350   std::string protocol = resource_definition->protocol.in();
1351   std::string username = resource_definition->username.in();
1352   std::string applipath = resource_definition->applipath.in();
1353
1354   if (protocol == "" || username == "" || applipath == "")
1355   {
1356     INFOS("[checkPaCOParameters] resource selected is not well defined");
1357     INFOS("[checkPaCOParameters] resource name: " << resource_definition->name.in());
1358     INFOS("[checkPaCOParameters] resource hostname: " << resource_definition->hostname.in());
1359     INFOS("[checkPaCOParameters] resource protocol: " << protocol);
1360     INFOS("[checkPaCOParameters] resource username: " << username);
1361     INFOS("[checkPaCOParameters] resource applipath: " << applipath);
1362     result = false;
1363   }
1364
1365   return result;
1366 }
1367
1368 char *SALOME_ContainerManager::GetenvThreadSafe(const char *name)
1369 {// getenv is not thread safe. See man 7 pthread.
1370   Utils_Locker lock (&_getenvMutex);
1371   return getenv(name);
1372 }
1373
1374 int SALOME_ContainerManager::SystemThreadSafe(const char *command)
1375 {
1376   Utils_Locker lock (&_systemMutex);
1377   return system(command);
1378 }
1379
1380 #ifdef WITH_PACO_PARALLEL
1381
1382 //=============================================================================
1383 /*! CORBA Method:
1384  *  Start a suitable PaCO++ Parallel Container in a list of machines.
1385  *  \param params           Container Parameters required for the container
1386  *  \return CORBA container reference.
1387  */
1388 //=============================================================================
1389 Engines::Container_ptr
1390 SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters& params_const,
1391                                               std::string resource_selected)
1392 {
1393   CORBA::Object_var obj;
1394   PaCO::InterfaceManager_var container_proxy;
1395   Engines::Container_ptr ret = Engines::Container::_nil();
1396   Engines::ContainerParameters params(params_const);
1397   params.resource_params.name = CORBA::string_dup(resource_selected.c_str());
1398
1399   // Step 0 : Check parameters
1400   if (!checkPaCOParameters(params, resource_selected))
1401   {
1402     INFOS("[StartPaCOPPContainer] check parameters failed ! see logs...");
1403     return ret;
1404   }
1405
1406   // Step 1 : Starting a new parallel container !
1407   INFOS("[StartPaCOPPContainer] Starting a PaCO++ parallel container");
1408   INFOS("[StartPaCOPPContainer] on resource : " << resource_selected);
1409
1410   // Step 2 : Get a MachineFile for the parallel container
1411   std::string machine_file_name = _ResManager->getMachineFile(resource_selected, 
1412                                                               params.nb_proc,
1413                                                               params.parallelLib.in());
1414
1415   if (machine_file_name == "")
1416   {
1417     INFOS("[StartPaCOPPContainer] Machine file generation failed");
1418     return ret;
1419   }
1420
1421   // Step 3 : starting parallel container proxy
1422   std::string command_proxy("");
1423   std::string proxy_machine;
1424   try 
1425   {
1426     command_proxy = BuildCommandToLaunchPaCOProxyContainer(params, machine_file_name, proxy_machine);
1427   }
1428   catch(const SALOME_Exception & ex)
1429   {
1430     INFOS("[StartPaCOPPContainer] Exception in BuildCommandToLaunchPaCOContainer");
1431     INFOS(ex.what());
1432     return ret;
1433   }
1434   obj = LaunchPaCOProxyContainer(command_proxy, params, proxy_machine);
1435   if (CORBA::is_nil(obj))
1436   {
1437     INFOS("[StartPaCOPPContainer] LaunchPaCOContainer for proxy returns NIL !");
1438     return ret;
1439   }
1440   container_proxy = PaCO::InterfaceManager::_narrow(obj);
1441   MESSAGE("[StartPaCOPPContainer] PaCO container proxy is launched");
1442
1443   // Step 4 : starting parallel container nodes
1444   std::string command_nodes("");
1445   SALOME_ContainerManager::actual_launch_machine_t nodes_machines;
1446   try 
1447   {
1448     command_nodes = BuildCommandToLaunchPaCONodeContainer(params, machine_file_name, nodes_machines, proxy_machine);
1449   }
1450   catch(const SALOME_Exception & ex)
1451   {
1452     INFOS("[StarPaCOPPContainer] Exception in BuildCommandToLaunchPaCONodeContainer");
1453     INFOS(ex.what());
1454     return ret;
1455   }
1456
1457   std::string container_generic_node_name = std::string(params.container_name.in()) + std::string("Node");
1458   bool result = LaunchPaCONodeContainer(command_nodes, params, container_generic_node_name, nodes_machines);
1459   if (!result)
1460   {
1461     INFOS("[StarPaCOPPContainer] LaunchPaCONodeContainer failed !");
1462     // Il faut tuer le proxy
1463     try 
1464     {
1465       Engines::Container_var proxy = Engines::Container::_narrow(container_proxy);
1466       proxy->Shutdown();
1467     }
1468     catch (...)
1469     {
1470       INFOS("[StarPaCOPPContainer] Exception catched from proxy Shutdown...");
1471     }
1472     return ret;
1473   }
1474
1475   // Step 4 : connecting nodes and the proxy to actually create a parallel container
1476   for (int i = 0; i < params.nb_proc; i++) 
1477   {
1478     std::ostringstream tmp;
1479     tmp << i;
1480     std::string proc_number = tmp.str();
1481     std::string container_node_name = container_generic_node_name + proc_number;
1482
1483     std::string theNodeMachine(nodes_machines[i]);
1484     std::string containerNameInNS = _NS->BuildContainerNameForNS(container_node_name.c_str(), theNodeMachine.c_str());
1485     obj = _NS->Resolve(containerNameInNS.c_str());
1486     if (CORBA::is_nil(obj)) 
1487     {
1488       INFOS("[StarPaCOPPContainer] CONNECTION FAILED From Naming Service !");
1489       INFOS("[StarPaCOPPContainer] Container name is " << containerNameInNS);
1490       return ret;
1491     }
1492     try
1493     {
1494       MESSAGE("[StarPaCOPPContainer] Deploying node : " << container_node_name);
1495       PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
1496       node->deploy();
1497       MESSAGE("[StarPaCOPPContainer] node " << container_node_name << " is deployed");
1498     }
1499     catch(CORBA::SystemException& e)
1500     {
1501       INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1502       INFOS("CORBA::SystemException : " << e);
1503       return ret;
1504     }
1505     catch(CORBA::Exception& e)
1506     {
1507       INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1508       INFOS("CORBA::Exception" << e);
1509       return ret;
1510     }
1511     catch(...)
1512     {
1513       INFOS("[StarPaCOPPContainer] Exception in deploying node : " << containerNameInNS);
1514       INFOS("Unknown exception !");
1515       return ret;
1516     }
1517   }
1518
1519   // Step 5 : starting parallel container
1520   try 
1521   {
1522     MESSAGE ("[StarPaCOPPContainer] Starting parallel object");
1523     container_proxy->start();
1524     MESSAGE ("[StarPaCOPPContainer] Parallel object is started");
1525     ret = Engines::Container::_narrow(container_proxy);
1526   }
1527   catch(CORBA::SystemException& e)
1528   {
1529     INFOS("Caught CORBA::SystemException. : " << e);
1530   }
1531   catch(PortableServer::POA::ServantAlreadyActive&)
1532   {
1533     INFOS("Caught CORBA::ServantAlreadyActiveException");
1534   }
1535   catch(CORBA::Exception&)
1536   {
1537     INFOS("Caught CORBA::Exception.");
1538   }
1539   catch(std::exception& exc)
1540   {
1541     INFOS("Caught std::exception - "<<exc.what()); 
1542   }
1543   catch(...)
1544   {
1545     INFOS("Caught unknown exception.");
1546   }
1547   return ret;
1548 }
1549
1550 std::string 
1551 SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
1552                                                                 std::string machine_file_name,
1553                                                                 std::string & proxy_hostname)
1554 {
1555   // In the proxy case, we always launch a Dummy Proxy
1556   std::string exe_name = "SALOME_ParallelContainerProxyDummy";
1557   std::string container_name = params.container_name.in();
1558
1559   // Convert nb_proc in string
1560   std::ostringstream tmp_string;
1561   tmp_string << params.nb_proc;
1562   std::string nb_proc_str = tmp_string.str();
1563
1564   // Get resource definition
1565   Engines::ResourceDefinition_var resource_definition = 
1566     _ResManager->GetResourceDefinition(params.resource_params.name);
1567
1568   // Choose hostname
1569   std::string hostname;
1570   std::ifstream machine_file(machine_file_name.c_str());
1571   std::getline(machine_file, hostname, ' ');
1572   size_t found = hostname.find('\n');
1573   if (found!=std::string::npos)
1574     hostname.erase(found, 1); // Remove \n
1575   proxy_hostname = hostname;
1576   MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] machine file name extracted is " << hostname);
1577
1578   // Remote execution
1579   bool remote_execution = false;
1580   if (hostname != std::string(Kernel_Utils::GetHostname()))
1581   {
1582     MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] remote machine case detected !");
1583     remote_execution = true;
1584   }
1585   
1586   // Log environnement
1587   std::string log_type("");
1588   char * get_val = GetenvThreadSafe("PARALLEL_LOG");
1589   if (get_val)
1590     log_type = get_val;
1591
1592   // Generating the command
1593   std::string command_begin("");
1594   std::string command_end("");
1595   std::ostringstream command;
1596
1597   LogConfiguration(log_type, "proxy", container_name, hostname, command_begin, command_end);
1598   command << command_begin;
1599
1600   // Adding connection command
1601   // We can only have a remote execution with
1602   // a SALOME application
1603   if (remote_execution)
1604   {
1605     ASSERT(GetenvThreadSafe("NSHOST"));
1606     ASSERT(GetenvThreadSafe("NSPORT"));
1607
1608     command << resource_definition->protocol.in();
1609     command << " -l ";
1610     command << resource_definition->username.in();
1611     command << " " << hostname;
1612     command << " " << resource_definition->applipath.in();
1613     command << "/runRemote.sh ";
1614     command << GetenvThreadSafe("NSHOST") << " "; // hostname of CORBA name server
1615     command << GetenvThreadSafe("NSPORT") << " "; // port of CORBA name server
1616   }
1617
1618   command << exe_name;
1619   command << " " << container_name;
1620   command << " Dummy";
1621   command << " " << hostname;
1622   command << " " << nb_proc_str;
1623   command << " -";
1624   AddOmninamesParams(command);
1625
1626   // Final command
1627   command << command_end;
1628   MESSAGE("[BuildCommandToLaunchPaCOProxyContainer] Command is: " << command.str());
1629
1630   return command.str();
1631 }
1632
1633 std::string 
1634 SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
1635                                                                const std::string & machine_file_name,
1636                                                                SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
1637                                                                const std::string & proxy_hostname)
1638 {
1639   // Name of exe
1640   std::string exe_name = "SALOME_ParallelContainerNode";
1641   exe_name += params.parallelLib.in();
1642   std::string container_name = params.container_name.in();
1643
1644   // Convert nb_proc in string
1645   std::ostringstream nb_proc_stream;
1646   nb_proc_stream << params.nb_proc;
1647
1648   // Get resource definition
1649   Engines::ResourceDefinition_var resource_definition = 
1650     _ResManager->GetResourceDefinition(params.resource_params.name);
1651   
1652   // Log environnement
1653   std::string log_type("");
1654   char * get_val = GetenvThreadSafe("PARALLEL_LOG");
1655   if (get_val)
1656     log_type = get_val;
1657
1658   // Now the command is different according to paralleLib
1659   std::ostringstream command_nodes;
1660   std::ifstream machine_file(machine_file_name.c_str());
1661   if (std::string(params.parallelLib.in()) == "Dummy")
1662   {
1663     for (int i= 0; i < params.nb_proc; i++)
1664     {
1665       // Choose hostname
1666       std::string hostname;
1667       std::getline(machine_file, hostname);
1668       MESSAGE("[BuildCommandToLaunchPaCONodeContainer] machine file name extracted is " << hostname);
1669
1670       // Remote execution
1671       bool remote_execution = false;
1672       if (hostname != std::string(Kernel_Utils::GetHostname()))
1673       {
1674         MESSAGE("[BuildCommandToLaunchPaCONodeContainer] remote machine case detected !");
1675         remote_execution = true;
1676       }
1677
1678       // For each node we have a new command
1679       // Generating the command
1680       std::ostringstream command_node_stream;
1681       std::string command_node_begin("");
1682       std::string command_node_end("");
1683       std::ostringstream node_number;
1684       node_number << i;
1685       std::string container_node_name = container_name + node_number.str();
1686       LogConfiguration(log_type, "node", container_node_name, hostname, command_node_begin, command_node_end);
1687
1688       // Adding connection command
1689       // We can only have a remote execution with
1690       // a SALOME application
1691       if (remote_execution)
1692       {
1693         ASSERT(GetenvThreadSafe("NSHOST"));
1694         ASSERT(GetenvThreadSafe("NSPORT"));
1695
1696         command_node_stream << resource_definition->protocol.in();
1697         command_node_stream << " -l ";
1698         command_node_stream << resource_definition->username.in();
1699         command_node_stream << " " << hostname;
1700         command_node_stream << " " << resource_definition->applipath.in();
1701         command_node_stream << "/runRemote.sh ";
1702         command_node_stream << GetenvThreadSafe("NSHOST") << " "; // hostname of CORBA name server
1703         command_node_stream << GetenvThreadSafe("NSPORT") << " "; // port of CORBA name server
1704       }
1705
1706       command_node_stream << exe_name;
1707       command_node_stream << " " << container_name;
1708       command_node_stream << " " << params.parallelLib.in();
1709       command_node_stream << " " << proxy_hostname;
1710       command_node_stream << " " << node_number.str();
1711       command_node_stream << " -";
1712       AddOmninamesParams(command_node_stream);
1713
1714       command_nodes << command_node_begin << command_node_stream.str() << command_node_end;
1715       vect_machine.push_back(hostname);
1716     }
1717   }
1718
1719   else if (std::string(params.parallelLib.in()) == "Mpi")
1720   {
1721     // Choose hostname
1722     std::string hostname;
1723     std::getline(machine_file, hostname, ' ');
1724     MESSAGE("[BuildCommandToLaunchPaCONodeContainer] machine file name extracted is " << hostname);
1725
1726     // Remote execution
1727     bool remote_execution = false;
1728     if (hostname != std::string(Kernel_Utils::GetHostname()))
1729     {
1730       MESSAGE("[BuildCommandToLaunchPaCONodeContainer] remote machine case detected !");
1731       remote_execution = true;
1732     }
1733
1734     // In case of Mpi and Remote, we copy machine_file in the applipath
1735     // scp mpi_machine_file user@machine:Path
1736     std::ostringstream command_remote_stream;
1737     std::string::size_type last = machine_file_name.find_last_of("/");
1738     if (last == std::string::npos)
1739       last = -1;
1740
1741     std::string protocol = resource_definition->protocol.in();
1742     if (protocol == "rsh")
1743       command_remote_stream << "rcp ";
1744     else 
1745       command_remote_stream << "scp ";
1746     command_remote_stream << machine_file_name << " ";
1747     command_remote_stream << resource_definition->username.in() << "@";
1748     command_remote_stream << hostname << ":" << resource_definition->applipath.in();
1749     command_remote_stream <<  "/" << machine_file_name.substr(last+1);
1750
1751     int status = SystemThreadSafe(command_remote_stream.str().c_str());
1752     if (status == -1)
1753     {
1754       INFOS("copy of the MPI machine file failed ! - sorry !");
1755       return "";
1756     }
1757
1758     // Generating the command
1759     std::string command_begin("");
1760     std::string command_end("");
1761
1762     LogConfiguration(log_type, "nodes", container_name, hostname, command_begin, command_end);
1763     command_nodes << command_begin;
1764
1765     // Adding connection command
1766     // We can only have a remote execution with
1767     // a SALOME application
1768     if (remote_execution)
1769     {
1770       ASSERT(GetenvThreadSafe("NSHOST"));
1771       ASSERT(GetenvThreadSafe("NSPORT"));
1772
1773       command_nodes << resource_definition->protocol.in();
1774       command_nodes << " -l ";
1775       command_nodes << resource_definition->username.in();
1776       command_nodes << " " << hostname;
1777       command_nodes << " " << resource_definition->applipath.in();
1778       command_nodes << "/runRemote.sh ";
1779       command_nodes << GetenvThreadSafe("NSHOST") << " "; // hostname of CORBA name server
1780       command_nodes << GetenvThreadSafe("NSPORT") << " "; // port of CORBA name server
1781     }
1782
1783     if (std::string(resource_definition->mpiImpl.in()) == "lam")
1784     {
1785       command_nodes << "mpiexec -ssi boot ";
1786       command_nodes << "-machinefile "  << machine_file_name << " "; 
1787       command_nodes <<  "-n " << params.nb_proc;
1788     }
1789     else
1790     {
1791       command_nodes << "mpirun -np " << params.nb_proc;
1792     }
1793     command_nodes << " " << exe_name;
1794     command_nodes << " " << container_name;
1795     command_nodes << " " << params.parallelLib.in();
1796     command_nodes << " " << proxy_hostname;
1797     command_nodes << " -";
1798     AddOmninamesParams(command_nodes);
1799
1800     // We don't put hostname, because nodes are registered in the resource of the proxy
1801     for (int i= 0; i < params.nb_proc; i++)
1802       vect_machine.push_back(proxy_hostname); 
1803
1804     command_nodes << command_end;
1805   }
1806   return command_nodes.str();
1807 }
1808
1809 void
1810 SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
1811                                           const std::string & exe_type,
1812                                           const std::string & container_name,
1813                                           const std::string & hostname,
1814                                           std::string & begin, 
1815                                           std::string & end)
1816 {
1817   if(log_type == "xterm")
1818   {
1819     begin = "xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1820     end   = "\"&";
1821   }
1822   else if(log_type == "xterm_debug")
1823   {
1824     begin = "xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH;";
1825     end   = "; cat \" &";
1826   }
1827   else
1828   {
1829     // default into a file...
1830     std::string logFilename = "/tmp/" + container_name + "_" + hostname + "_" + exe_type + "_";
1831     logFilename += std::string(GetenvThreadSafe("USER")) + ".log";
1832     end = " > " + logFilename + " 2>&1 & ";
1833   }
1834 }
1835
1836 CORBA::Object_ptr 
1837 SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command, 
1838                                                   const Engines::ContainerParameters& params,
1839                                                   const std::string & hostname)
1840 {
1841   PaCO::InterfaceManager_ptr container_proxy = PaCO::InterfaceManager::_nil();
1842
1843   MESSAGE("[LaunchPaCOProxyContainer] Launch command");
1844   int status = SystemThreadSafe(command.c_str());
1845   if (status == -1) {
1846     INFOS("[LaunchPaCOProxyContainer] failed : system command status -1");
1847     return container_proxy;
1848   }
1849   else if (status == 217) {
1850     INFOS("[LaunchPaCOProxyContainer] failed : system command status 217");
1851     return container_proxy;
1852   }
1853
1854   int count = TIME_OUT_TO_LAUNCH_CONT;
1855   CORBA::Object_var obj = CORBA::Object::_nil();
1856   std::string containerNameInNS = _NS->BuildContainerNameForNS(params.container_name.in(), 
1857                                                                hostname.c_str());
1858   MESSAGE("[LaunchParallelContainer]  Waiting for Parallel Container proxy : " << containerNameInNS);
1859
1860   while (CORBA::is_nil(obj) && count) 
1861   {
1862     sleep(1);
1863     count--;
1864     obj = _NS->Resolve(containerNameInNS.c_str());
1865   }
1866
1867   try 
1868   {
1869     container_proxy = PaCO::InterfaceManager::_narrow(obj);
1870   }
1871   catch(CORBA::SystemException& e)
1872   {
1873     INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1874     INFOS("CORBA::SystemException : " << e);
1875     return container_proxy;
1876   }
1877   catch(CORBA::Exception& e)
1878   {
1879     INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1880     INFOS("CORBA::Exception" << e);
1881     return container_proxy;
1882   }
1883   catch(...)
1884   {
1885     INFOS("[StarPaCOPPContainer] Exception in _narrow after LaunchParallelContainer for proxy !");
1886     INFOS("Unknown exception !");
1887     return container_proxy;
1888   }
1889   if (CORBA::is_nil(container_proxy))
1890   {
1891     INFOS("[StarPaCOPPContainer] PaCO::InterfaceManager::_narrow returns NIL !");
1892     return container_proxy;
1893   }
1894   return obj._retn();
1895 }
1896
1897 //=============================================================================
1898 /*! This method launches the parallel container.
1899  *  It will may be placed on the ressources manager.
1900  *
1901  * \param command to launch
1902  * \param container's parameters
1903  * \param name of the container
1904  *
1905  * \return CORBA container reference
1906  */
1907 //=============================================================================
1908 bool
1909 SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command, 
1910                                                  const Engines::ContainerParameters& params,
1911                                                  const std::string& name,
1912                                                  SALOME_ContainerManager::actual_launch_machine_t & vect_machine)
1913 {
1914   INFOS("[LaunchPaCONodeContainer] Launch command");
1915   int status = SystemThreadSafe(command.c_str());
1916   if (status == -1) {
1917     INFOS("[LaunchPaCONodeContainer] failed : system command status -1");
1918     return false;
1919   }
1920   else if (status == 217) {
1921     INFOS("[LaunchPaCONodeContainer] failed : system command status 217");
1922     return false;
1923   }
1924
1925   INFOS("[LaunchPaCONodeContainer] Waiting for the nodes of the parallel container");
1926   // We are waiting all the nodes
1927   for (int i = 0; i < params.nb_proc; i++) 
1928   {
1929     CORBA::Object_var obj = CORBA::Object::_nil();
1930     std::string theMachine(vect_machine[i]);
1931     // Name of the node
1932     std::ostringstream tmp;
1933     tmp << i;
1934     std::string proc_number = tmp.str();
1935     std::string container_node_name = name + proc_number;
1936     std::string containerNameInNS = _NS->BuildContainerNameForNS((char*) container_node_name.c_str(), theMachine.c_str());
1937     INFOS("[LaunchPaCONodeContainer]  Waiting for Parallel Container node " << containerNameInNS << " on " << theMachine);
1938     int count = TIME_OUT_TO_LAUNCH_CONT;
1939     while (CORBA::is_nil(obj) && count) {
1940       sleep(1) ;
1941       count-- ;
1942       obj = _NS->Resolve(containerNameInNS.c_str());
1943     }
1944     if (CORBA::is_nil(obj))
1945     {
1946       INFOS("[LaunchPaCONodeContainer] Launch of node failed (or not found) !");
1947       return false;
1948     }
1949   }
1950   return true;
1951 }
1952
1953 #else
1954
1955 Engines::Container_ptr
1956 SALOME_ContainerManager::StartPaCOPPContainer(const Engines::ContainerParameters& params,
1957                                               std::string resource_selected)
1958 {
1959   Engines::Container_ptr ret = Engines::Container::_nil();
1960   INFOS("[StarPaCOPPContainer] is disabled !");
1961   INFOS("[StarPaCOPPContainer] recompile SALOME Kernel to enable PaCO++ parallel extension");
1962   return ret;
1963 }
1964
1965 std::string 
1966 SALOME_ContainerManager::BuildCommandToLaunchPaCOProxyContainer(const Engines::ContainerParameters& params,
1967                                                                 std::string machine_file_name,
1968                                                                 std::string & proxy_hostname)
1969 {
1970   return "";
1971 }
1972
1973 std::string 
1974 SALOME_ContainerManager::BuildCommandToLaunchPaCONodeContainer(const Engines::ContainerParameters& params,
1975                                                                const std::string & machine_file_name,
1976                                                                SALOME_ContainerManager::actual_launch_machine_t & vect_machine, 
1977                                                                const std::string & proxy_hostname) 
1978 {
1979   return "";
1980 }
1981 void 
1982 SALOME_ContainerManager::LogConfiguration(const std::string & log_type,
1983                                           const std::string & exe_type,
1984                                           const std::string & container_name,
1985                                           const std::string & hostname,
1986                                           std::string & begin, 
1987                                           std::string & end)
1988 {
1989 }
1990
1991 CORBA::Object_ptr 
1992 SALOME_ContainerManager::LaunchPaCOProxyContainer(const std::string& command, 
1993                                                   const Engines::ContainerParameters& params,
1994                                                   const std::string& hostname)
1995 {
1996   CORBA::Object_ptr ret = CORBA::Object::_nil();
1997   return ret;
1998 }
1999
2000 bool 
2001 SALOME_ContainerManager::LaunchPaCONodeContainer(const std::string& command, 
2002                         const Engines::ContainerParameters& params,
2003                         const std::string& name,
2004                         SALOME_ContainerManager::actual_launch_machine_t & vect_machine)
2005 {
2006   return false;
2007 }
2008 #endif
2009