Salome HOME
Copyright update 2021
[modules/kernel.git] / src / Launcher / SALOME_Launcher.cxx
1 // Copyright (C) 2007-2021  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_Launcher.hxx"
24 #include "BatchTest.hxx"
25 #include "OpUtil.hxx"
26 #include "SALOME_ContainerManager.hxx"
27 #include "SALOME_NamingService.hxx"
28 #include "SALOME_ResourcesManager.hxx"
29 #include "Utils_CorbaException.hxx"
30
31
32 #include "Launcher_Job_Command.hxx"
33 #include "Launcher_Job_YACSFile.hxx"
34 #include "Launcher_Job_PythonSALOME.hxx"
35 #include "Launcher_Job_CommandSALOME.hxx"
36
37 #include "utilities.h"
38
39 #ifdef WIN32
40 # include <process.h>
41 #else
42 # include <unistd.h>
43 #endif
44 #include <sys/types.h>
45 #include <vector>
46 #include <list>
47
48 #include <stdio.h>
49 #include <sstream>
50
51 using namespace std;
52
53 const char *SALOME_Launcher::_LauncherNameInNS = "/SalomeLauncher";
54
55 //=============================================================================
56 /*!
57  *  Constructor
58  *  \param orb
59  */
60 //=============================================================================
61 SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa)
62 {
63   MESSAGE("SALOME_Launcher constructor");
64   _NS = new SALOME_NamingService(orb);
65   init(orb,poa);
66   MESSAGE("SALOME_Launcher constructor end");
67 }
68
69 SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *externalNS):_NS(externalNS)
70 {
71   init(orb,poa);
72 }
73
74 void SALOME_Launcher::init(CORBA::ORB_ptr orb, PortableServer::POA_var poa)
75 {
76   _ResManager = new SALOME_ResourcesManager(orb,poa,tradNS());
77   _l.SetResourcesManager(_ResManager->GetImpl());
78   _ContManager = new SALOME_ContainerManager(orb,poa,tradNS());
79   _ResManager->_remove_ref();
80   _ContManager->_remove_ref();
81
82   _orb = CORBA::ORB::_duplicate(orb) ;
83   _poa = PortableServer::POA::_duplicate(poa) ;
84   PortableServer::ObjectId_var id = _poa->activate_object(this);
85   CORBA::Object_var obj = _poa->id_to_reference(id);
86   Engines::SalomeLauncher_var refContMan = Engines::SalomeLauncher::_narrow(obj);
87   _NS->Register(refContMan,_LauncherNameInNS);
88 }
89
90 //=============================================================================
91 /*!
92  * destructor
93  */
94 //=============================================================================
95 SALOME_Launcher::~SALOME_Launcher()
96 {
97   MESSAGE("SALOME_Launcher destructor");
98   delete _NS;
99   MESSAGE("SALOME_Launcher destructor end");
100 }
101
102
103 CORBA::Long
104 SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters)
105 {
106   JobParameters_cpp cpp_parameters = JobParameters_CORBA2CPP(job_parameters);
107   CORBA::Long jobNumber = -1;
108   try
109   {
110     jobNumber = _l.createJob(cpp_parameters);
111     std::ostringstream job_id;
112     job_id << jobNumber;
113     notifyObservers("NEW_JOB", job_id.str());
114   }
115   catch(const LauncherException &ex)
116   {
117     INFOS(ex.msg.c_str());
118     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
119   }
120   return jobNumber;
121 }
122
123 void
124 SALOME_Launcher::launchJob(CORBA::Long job_id)
125 {
126   try
127   {
128     _l.launchJob(job_id);
129   }
130   catch(const LauncherException &ex)
131   {
132     INFOS(ex.msg.c_str());
133     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
134   }
135 }
136
137 char *
138 SALOME_Launcher::getJobState(CORBA::Long job_id)
139 {
140   std::string result;
141   try
142   {
143     result = _l.getJobState(job_id);
144   }
145   catch(const LauncherException &ex)
146   {
147     INFOS(ex.msg.c_str());
148     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
149   }
150   return CORBA::string_dup(result.c_str());
151 }
152
153 // Get names or ids of hosts assigned to the job
154 char *
155 SALOME_Launcher::getAssignedHostnames(CORBA::Long job_id)
156 {
157   std::string result;
158   try
159   {
160     result = _l.getAssignedHostnames(job_id);
161   }
162   catch(const LauncherException &ex)
163   {
164     INFOS(ex.msg.c_str());
165     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
166   }
167   return CORBA::string_dup(result.c_str());
168 }
169
170 void
171 SALOME_Launcher::exportInputFiles(CORBA::Long job_id)
172 {
173   try
174   {
175     _l.exportInputFiles(job_id);
176   }
177   catch(const LauncherException &ex)
178   {
179     INFOS(ex.msg.c_str());
180     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
181   }
182 }
183
184 void
185 SALOME_Launcher::getJobResults(CORBA::Long job_id, const char * directory)
186 {
187   try
188   {
189     _l.getJobResults(job_id, directory);
190   }
191   catch(const LauncherException &ex)
192   {
193     INFOS(ex.msg.c_str());
194     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
195   }
196 }
197
198 void
199 SALOME_Launcher::clearJobWorkingDir(CORBA::Long job_id)
200 {
201   try
202   {
203     _l.clearJobWorkingDir(job_id);
204   }
205   catch(const LauncherException &ex)
206   {
207     INFOS(ex.msg.c_str());
208     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
209   }
210 }
211
212 CORBA::Boolean
213 SALOME_Launcher::getJobDumpState(CORBA::Long job_id, const char * directory)
214 {
215   CORBA::Boolean rtn = false;
216   try
217   {
218     rtn = _l.getJobDumpState(job_id, directory);
219   }
220   catch(const LauncherException &ex)
221   {
222     INFOS(ex.msg.c_str());
223     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
224   }
225   return rtn;
226 }
227
228 CORBA::Boolean
229 SALOME_Launcher::getJobWorkFile(CORBA::Long job_id, const char * work_file, const char * directory)
230 {
231   CORBA::Boolean rtn = false;
232   try
233   {
234     rtn = _l.getJobWorkFile(job_id, work_file, directory);
235   }
236   catch(const LauncherException &ex)
237   {
238     INFOS(ex.msg.c_str());
239     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
240   }
241   return rtn;
242 }
243
244 void
245 SALOME_Launcher::removeJob(CORBA::Long job_id)
246 {
247   try
248   {
249     _l.removeJob(job_id);
250     std::ostringstream job_id_str;
251     job_id_str << job_id;
252     notifyObservers("REMOVE_JOB", job_id_str.str());
253   }
254   catch(const LauncherException &ex)
255   {
256     INFOS(ex.msg.c_str());
257     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
258   }
259 }
260
261 void
262 SALOME_Launcher::stopJob(CORBA::Long job_id)
263 {
264   try
265   {
266     _l.stopJob(job_id);
267     std::ostringstream job_id_str;
268     job_id_str << job_id;
269     notifyObservers("UPDATE_JOB_STATE", job_id_str.str());
270   }
271   catch(const LauncherException &ex)
272   {
273     INFOS(ex.msg.c_str());
274     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
275   }
276 }
277
278 char *
279 SALOME_Launcher::dumpJob(CORBA::Long job_id)
280 {
281   std::string result;
282   try
283   {
284     result = _l.dumpJob(job_id);
285   }
286   catch(const LauncherException &ex)
287   {
288     INFOS(ex.msg.c_str());
289     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
290   }
291   return CORBA::string_dup(result.c_str());
292 }
293
294 CORBA::Long
295 SALOME_Launcher::restoreJob(const char * dumpedJob)
296 {
297   CORBA::Long jobId;
298   try{
299     jobId = _l.restoreJob(dumpedJob);
300     if(jobId >= 0)
301     {
302       std::ostringstream job_str;
303       job_str << jobId;
304       notifyObservers("NEW_JOB", job_str.str());
305     }
306   }
307   catch(const LauncherException &ex){
308     INFOS(ex.msg.c_str());
309     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
310   }
311
312   return jobId;
313 }
314
315 //=============================================================================
316 /*! CORBA Method:
317  *  Create a job in the launcher with a file
318  *  \param xmlExecuteFile     : .xml to parse that contains job description
319  *  \param clusterName        : machine chosen
320  */
321 //=============================================================================
322 CORBA::Long
323 SALOME_Launcher::createJobWithFile(const char * xmlExecuteFile,
324                                    const char * clusterName)
325 {
326   CORBA::Long jobId;
327   try{
328     jobId = _l.createJobWithFile(xmlExecuteFile, clusterName);
329   }
330   catch(const LauncherException &ex){
331     INFOS(ex.msg.c_str());
332     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
333   }
334
335   return jobId;
336 }
337
338 //=============================================================================
339 /*! CORBA Method:
340  *  the test batch configuration
341  *  \param params             : The batch cluster
342  */
343 //=============================================================================
344 CORBA::Boolean
345 SALOME_Launcher::testBatch(const Engines::ResourceParameters& params)
346 {
347   MESSAGE("BEGIN OF SALOME_Launcher::testBatch");
348   CORBA::Boolean rtn = false;
349   try
350   {
351     // Consider only resources that can run batch jobs
352     Engines::ResourceParameters new_params(params);
353     new_params.can_launch_batch_jobs = true;
354
355     // find a resource matching the required parameters
356     Engines::ResourceList *aMachineList = _ResManager->GetFittingResources(new_params);
357     if (aMachineList->length() == 0)
358       throw SALOME_Exception("No resources have been found with your parameters");
359
360     const Engines::ResourceDefinition* p = _ResManager->GetResourceDefinition((*aMachineList)[0]);
361         std::string resource_name(p->name);
362     INFOS("Choose resource for test: " <<  resource_name);
363
364     BatchTest t(*p);
365     if (t.test())
366     {
367       rtn = true;
368     }
369   }
370   catch(const LauncherException &ex){
371     INFOS(ex.msg.c_str());
372     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
373   }
374   return rtn;
375 }
376
377 //=============================================================================
378 /*! CORBA method:
379  *  shutdown all the containers, then the ContainerManager servant
380  */
381 //=============================================================================
382 void SALOME_Launcher::Shutdown()
383 {
384   MESSAGE("Shutdown");
385   if(!_NS)
386     return;
387   _NS->Destroy_Name(_LauncherNameInNS);
388   _ContManager->Shutdown();
389   _ResManager->Shutdown();
390   PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
391   _poa->deactivate_object(oid);
392   if(!CORBA::is_nil(_orb))
393     _orb->shutdown(0);
394 }
395
396 //=============================================================================
397 /*! CORBA Method:
398  *  Returns the PID of the process
399  */
400 //=============================================================================
401 CORBA::Long SALOME_Launcher::getPID()
402 {
403   return
404 #ifndef WIN32
405     (CORBA::Long)getpid();
406 #else
407     (CORBA::Long)_getpid();
408 #endif
409 }
410
411 //=============================================================================
412 /*! CORBA Method:
413  *  Returns current launcher jobs list
414  */
415 //=============================================================================
416 Engines::JobsList *
417 SALOME_Launcher::getJobsList()
418 {
419   Engines::JobsList_var jobs_list = new Engines::JobsList();
420   std::map<int, Launcher::Job *> cpp_jobs = _l.getJobs();
421   std::map<int, Launcher::Job *>::const_iterator it_job;
422   int list_id = 0;
423   for(it_job = cpp_jobs.begin(); it_job != cpp_jobs.end(); it_job++)
424   {
425     int number          = it_job->first;
426     try
427     {
428       // Prepare CORBA job description
429       Engines::JobDescription_var job_descr = new Engines::JobDescription();
430       Engines::JobParameters_var job_parameters = getJobParameters(number);
431       job_descr->job_id = number;
432       job_descr->job_parameters = job_parameters;
433
434       // Add job description to the sequence
435       jobs_list->length(list_id + 1);
436       jobs_list[list_id] = job_descr;
437       list_id++;
438     }
439     catch (...) {}
440   }
441   return jobs_list._retn();
442 }
443
444 //=============================================================================
445 /*! CORBA Method:
446  * Returns the job description
447  */
448 //=============================================================================
449 Engines::JobParameters *
450 SALOME_Launcher::getJobParameters(CORBA::Long job_id)
451 {
452   Engines::JobParameters_var job_parameters;
453   try
454   {
455     JobParameters_cpp cpp_parameters = _l.getJobParameters(job_id);
456     job_parameters = JobParameters_CPP2CORBA(cpp_parameters);
457   }
458   catch(const LauncherException &ex)
459   {
460     INFOS(ex.msg.c_str());
461     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
462   }
463
464   return job_parameters._retn();
465 }
466
467 //=============================================================================
468 /*! CORBA Method:
469  *  Loads jobs saved in jobs_file
470  */
471 //=============================================================================
472 void
473 SALOME_Launcher::loadJobs(const char* jobs_file)
474 {
475   list<int> new_jobs_id_list;
476   try
477   {
478     // Load the jobs in Launcher
479     new_jobs_id_list = _l.loadJobs(jobs_file);
480   }
481   catch (const LauncherException & ex)
482   {
483     INFOS(ex.msg.c_str());
484     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(), SALOME::INTERNAL_ERROR);
485   }
486
487   // Notify observers of the new jobs
488   list<int>::const_iterator it_jobs_id;
489   for (it_jobs_id = new_jobs_id_list.begin(); it_jobs_id != new_jobs_id_list.end(); it_jobs_id++)
490   {
491     ostringstream job_id_sstr;
492     job_id_sstr << *it_jobs_id;
493     notifyObservers("NEW_JOB", job_id_sstr.str());
494   }
495   notifyObservers("LOAD_JOBS", jobs_file);
496 }
497
498 //=============================================================================
499 /*! CORBA Method:
500  *  Save jobs of Launcher (in any steps) in file jobs_file
501  */
502 //=============================================================================
503 void
504 SALOME_Launcher::saveJobs(const char* jobs_file)
505 {
506   _l.saveJobs(jobs_file);
507   notifyObservers("SAVE_JOBS", jobs_file);
508 }
509
510 //=============================================================================
511 /*! CORBA Method:
512  *  Add a new observer to the launcher
513  */
514 //=============================================================================
515 void
516 SALOME_Launcher::addObserver(Engines::SalomeLauncherObserver_ptr observer)
517 {
518   bool new_observer = true;
519   std::list<Engines::SalomeLauncherObserver_var>::iterator iter = _observers.begin();
520   while(iter != _observers.end())
521   {
522     if (std::string(_orb->object_to_string(*iter)) ==
523         std::string(_orb->object_to_string(observer)))
524     {
525       new_observer = false;
526       break;
527     }
528     iter++;
529   }
530   if (new_observer)
531     _observers.push_back(Engines::SalomeLauncherObserver::_duplicate(observer));
532
533   // We notify the new observer with all jobs that are currently in the Launcher
534   std::map<int, Launcher::Job *> cpp_jobs = _l.getJobs();
535   std::map<int, Launcher::Job *>::const_iterator it_job;
536   for(it_job = cpp_jobs.begin(); it_job != cpp_jobs.end(); it_job++)
537   {
538     int number = it_job->first;
539     std::ostringstream job_id;
540     job_id << number;
541     try
542     {
543       observer->notify("NEW_JOB", job_id.str().c_str());
544     }
545     catch (...)
546     {
547        MESSAGE("Notify Observer, exception catch");
548     }
549
550   }
551 }
552
553 //=============================================================================
554 /*! CORBA Method:
555  *  Add a new observer to the launcher
556  */
557 //=============================================================================
558 void
559 SALOME_Launcher::removeObserver(Engines::SalomeLauncherObserver_ptr observer)
560 {
561   std::list<Engines::SalomeLauncherObserver_var>::iterator iter = _observers.begin();
562   while(iter != _observers.end())
563   {
564     if (std::string(_orb->object_to_string(*iter)) ==
565         std::string(_orb->object_to_string(observer)))
566     {
567       // Observer found
568       iter =_observers.erase(iter++);
569     }
570     else
571     {
572       iter++;
573     }
574   }
575 }
576
577 //=============================================================================
578 /*! Internal Method:
579  *  Notify observers on a new event
580  */
581 //=============================================================================
582 void
583 SALOME_Launcher::notifyObservers(const std::string & event_name,
584                                  const std::string & event_data)
585 {
586   std::list<Engines::SalomeLauncherObserver_var>::iterator iter = _observers.begin();
587   while(iter != _observers.end())
588   {
589     try
590     {
591       (*iter)->notify(CORBA::string_dup(event_name.c_str()),
592                       CORBA::string_dup(event_data.c_str()));
593     }
594     catch (...)
595     {
596        MESSAGE("Notify Observer, exception catch");
597     }
598     iter++;
599   }
600
601 }
602
603 JobParameters_cpp
604 SALOME_Launcher::JobParameters_CORBA2CPP(
605                                    const Engines::JobParameters& job_parameters)
606 {
607   JobParameters_cpp result;
608
609   result.job_name = job_parameters.job_name.in();
610   result.job_type = job_parameters.job_type.in();
611   result.job_file = job_parameters.job_file.in();
612   result.pre_command = job_parameters.pre_command.in();
613   result.env_file = job_parameters.env_file.in();
614
615   result.in_files.clear();
616   for (CORBA::ULong i = 0; i < job_parameters.in_files.length(); i++)
617     result.in_files.push_back(job_parameters.in_files[i].in());
618   result.out_files.clear();
619   for (CORBA::ULong i = 0; i < job_parameters.out_files.length(); i++)
620     result.out_files.push_back(job_parameters.out_files[i].in());
621
622   result.work_directory = job_parameters.work_directory.in();
623   result.local_directory = job_parameters.local_directory.in();
624   result.result_directory = job_parameters.result_directory.in();
625   result.maximum_duration = job_parameters.maximum_duration.in();
626
627   result.resource_required = resourceParameters_CORBAtoCPP(job_parameters.resource_required);
628
629   result.queue = job_parameters.queue.in();
630   result.partition = job_parameters.partition.in();
631   result.exclusive = job_parameters.exclusive;
632   result.mem_per_cpu = job_parameters.mem_per_cpu;
633   result.wckey = job_parameters.wckey.in();
634   result.extra_params = job_parameters.extra_params.in();
635
636   result.specific_parameters.clear();
637   for (CORBA::ULong i = 0; i < job_parameters.specific_parameters.length(); i++)
638     result.specific_parameters[job_parameters.specific_parameters[i].name.in()]
639                              = job_parameters.specific_parameters[i].value.in();
640
641   result.launcher_file = job_parameters.launcher_file.in();
642   result.launcher_args = job_parameters.launcher_args.in();
643   return result;
644 }
645
646 Engines::JobParameters_var
647 SALOME_Launcher::JobParameters_CPP2CORBA(const JobParameters_cpp& job_parameters)
648 {
649   Engines::JobParameters_var result = new Engines::JobParameters;
650   result->job_name = CORBA::string_dup(job_parameters.job_name.c_str());
651   result->job_type = CORBA::string_dup(job_parameters.job_type.c_str());
652   result->job_file = CORBA::string_dup(job_parameters.job_file.c_str());
653   result->pre_command = CORBA::string_dup(job_parameters.pre_command.c_str());
654   result->env_file = CORBA::string_dup(job_parameters.env_file.c_str());
655   result->in_files.length((CORBA::ULong)job_parameters.in_files.size()); //!< TODO: conversion from size_t to CORBA::ULong
656
657   int i = 0;
658   for(const std::string& it : job_parameters.in_files)
659   {
660     result->in_files[i] = CORBA::string_dup(it.c_str());
661     i++;
662   }
663   result->out_files.length((CORBA::ULong)job_parameters.out_files.size()); //!< TODO: conversion from size_t to CORBA::ULong
664   i = 0;
665   for(const std::string& it : job_parameters.out_files)
666   {
667     result->out_files[i] = CORBA::string_dup(it.c_str());
668     i++;
669   }
670
671   result->work_directory = CORBA::string_dup(job_parameters.work_directory.c_str());
672   result->local_directory = CORBA::string_dup(job_parameters.local_directory.c_str());
673   result->result_directory = CORBA::string_dup(job_parameters.result_directory.c_str());
674   result->maximum_duration = CORBA::string_dup(job_parameters.maximum_duration.c_str());
675
676   result->resource_required = resourceParameters_CPPtoCORBA(job_parameters.resource_required);
677
678   result->queue = CORBA::string_dup(job_parameters.queue.c_str());
679   result->partition = CORBA::string_dup(job_parameters.partition.c_str());
680   result->exclusive = job_parameters.exclusive;
681   result->mem_per_cpu = job_parameters.mem_per_cpu;
682   result->wckey = CORBA::string_dup(job_parameters.wckey.c_str());
683   result->extra_params = CORBA::string_dup(job_parameters.extra_params.c_str());
684
685   const std::map<std::string, std::string>& specific_parameters
686                                        = job_parameters.specific_parameters;
687   if (!specific_parameters.empty())
688   {
689     result->specific_parameters.length((CORBA::ULong)specific_parameters.size()); //!< TODO: conversion from size_t to CORBA::ULong
690     CORBA::ULong i = 0;
691     for (const auto& it_specific : specific_parameters)
692     {
693       Engines::Parameter_var new_param = new Engines::Parameter;
694       new_param->name  = CORBA::string_dup(it_specific.first.c_str());
695       new_param->value = CORBA::string_dup(it_specific.second.c_str());
696       result->specific_parameters[i] = new_param;
697       i++;
698     }
699   }
700
701   result->launcher_file = CORBA::string_dup(job_parameters.launcher_file.c_str());
702   result->launcher_args = CORBA::string_dup(job_parameters.launcher_args.c_str());
703   return result;
704 }
705
706 static SALOME_Launcher *_launcher_singleton_ssl = nullptr;
707
708 #include "SALOME_Fake_NamingService.hxx"
709
710 SALOME_Launcher *KERNEL::getLauncherSA()
711 {
712   if(!_launcher_singleton_ssl)
713   {
714     int argc(0);
715     CORBA::ORB_var orb = CORBA::ORB_init(argc,nullptr);
716     PortableServer::POA_var root_poa=PortableServer::POA::_the_root_poa();
717     SALOME_Fake_NamingService *ns=new SALOME_Fake_NamingService(orb);
718     _launcher_singleton_ssl = new SALOME_Launcher(orb,root_poa,ns);//3rd arg is important to skip NS !
719   }
720   return _launcher_singleton_ssl;
721 }