1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "Launcher.hxx"
24 #include "Batch_Date.hxx"
25 #include "Batch_FactBatchManager_eLSF.hxx"
26 #include "Batch_FactBatchManager_ePBS.hxx"
27 #include "Batch_BatchManager_eClient.hxx"
28 #include "Batch_FactBatchManager_eSGE.hxx"
29 #include "SALOME_Launcher_Handler.hxx"
30 #include "Launcher.hxx"
38 //=============================================================================
42 * Define a CORBA single thread policy for the server, which avoid to deal
43 * with non thread-safe usage like Change_Directory in SALOME naming service
45 //=============================================================================
47 Launcher_cpp::Launcher_cpp()
49 #if defined(_DEBUG_) || defined(_DEBUG)
50 cerr << "Launcher_cpp constructor" << endl;
54 //=============================================================================
58 //=============================================================================
60 Launcher_cpp::~Launcher_cpp()
62 #if defined(_DEBUG_) || defined(_DEBUG)
63 cerr << "Launcher_cpp destructor" << endl;
65 std::map < string, Batch::BatchManager_eClient * >::const_iterator it1;
66 for(it1=_batchmap.begin();it1!=_batchmap.end();it1++)
68 std::map < std::pair<std::string,long> , Batch::Job* >::const_iterator it2;
69 for(it2=_jobmap.begin();it2!=_jobmap.end();it2++)
73 //=============================================================================
75 * Submit a batch job on a cluster and returns the JobId
76 * \param xmlExecuteFile : to define the execution on the batch cluster
77 * \param clusterName : name of the batch cluster
79 //=============================================================================
80 long Launcher_cpp::submitJob( const std::string xmlExecuteFile,
81 const std::string clusterName) throw(LauncherException)
83 #if defined(_DEBUG_) || defined(_DEBUG)
84 cout << "BEGIN OF Launcher_cpp::submitJob" << endl;
87 vector<string> aMachineList;
90 throw LauncherException("You must set Resources Manager to Launcher!!");
92 // verify if cluster is in resources catalog
94 params.hostname = clusterName;
96 aMachineList = _ResManager->GetFittingResources(params);
98 catch(const ResourcesException &ex){
99 throw LauncherException(ex.msg.c_str());
101 if (aMachineList.size() == 0)
102 throw LauncherException("This cluster is not in resources catalog");
105 ParseXmlFile(xmlExecuteFile);
107 // verify if clustername is in xml file
108 map<std::string,MachineParameters>::const_iterator it1 = _launch.MachinesList.find(clusterName);
109 if(it1 == _launch.MachinesList.end())
110 throw LauncherException("This cluster is not in xml file");
112 ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]);
113 string cname(p.Alias);
114 #if defined(_DEBUG_) || defined(_DEBUG)
115 cout << "Choose cluster: " << cname << endl;
118 // search batch manager for that cluster in map or instanciate one
119 map < string, Batch::BatchManager_eClient * >::const_iterator it2 = _batchmap.find(cname);
120 if(it2 == _batchmap.end())
122 _batchmap[cname] = FactoryBatchManager(p);
123 // TODO: Add a test for the cluster !
128 // directory on cluster to put files to execute
129 string remotedir = _launch.MachinesList[clusterName].WorkDirectory;
130 // local directory to get files to execute and to put results
131 string localdir = _launch.RefDirectory;
133 int idx1 = xmlExecuteFile.find_last_of("/");
134 if(idx1 == string::npos) idx1 = -1;
135 int idx2 = xmlExecuteFile.find(".xml");
136 string logfile = xmlExecuteFile.substr(idx1+1,idx2-idx1-1);
137 string ologfile = logfile + ".output.log";
138 string elogfile = logfile + ".error.log";
140 // create and submit job on cluster
141 Batch::Parametre param;
142 param[USER] = p.UserName;
143 param[EXECUTABLE] = "";
144 for(int i=0; i<_launch.InputFile.size();i++)
145 param[INFILE] += Batch::Couple( localdir + "/" + _launch.InputFile[i], remotedir + "/" + _launch.InputFile[i] );
146 for(int i=0; i<_launch.OutputFile.size();i++)
147 param[OUTFILE] += Batch::Couple( localdir + "/" + _launch.OutputFile[i], remotedir + "/" + _launch.OutputFile[i] );
148 param[OUTFILE] += Batch::Couple( localdir + "/" + ologfile, remotedir + "/" + ologfile );
149 param[OUTFILE] += Batch::Couple( localdir + "/" + elogfile, remotedir + "/" + elogfile );
150 param[NBPROC] = _launch.NbOfProcesses;
151 param[WORKDIR] = remotedir;
152 param[TMPDIR] = remotedir;
153 param[MAXWALLTIME] = getWallTime("");
154 param[MAXRAMSIZE] = getRamSize("");
157 Batch::Environnement env;
158 env["COMMAND"] = _launch.Command;
159 env["SOURCEFILE"] = _launch.MachinesList[clusterName].EnvFile;
160 env["LOGFILE"] = logfile;
162 Batch::Job* job = new Batch::Job(param,env);
164 // submit job on cluster
165 Batch::JobId jid = _batchmap[cname]->submitJob(*job);
167 // get job id in long
168 istringstream iss(jid.getReference());
171 _jobmap[ pair<string,long>(cname,jobId) ] = job;
173 catch(const Batch::EmulationException &ex){
174 throw LauncherException(ex.msg.c_str());
180 //=============================================================================
182 * Submit a batch job on a cluster and returns the JobId
183 * \param fileToExecute : .py/.exe/.sh/... to execute on the batch cluster
184 * \param filesToExport : to export on the batch cluster
185 * \param NumberOfProcessors : Number of processors needed on the batch cluster
186 * \param params : Constraints for the choice of the batch cluster
188 //=============================================================================
189 long Launcher_cpp::submitSalomeJob( const string fileToExecute ,
190 const vector<string>& filesToExport ,
191 const vector<string>& filesToImport ,
192 const batchParams& batch_params,
193 const machineParams& params) throw(LauncherException)
195 #if defined(_DEBUG_) || defined(_DEBUG)
196 cerr << "BEGIN OF Launcher_cpp::submitSalomeJob" << endl;
199 vector<string> aMachineList;
202 throw LauncherException("You must set Resources Manager to Launcher!!");
204 // check batch params
205 if ( !check(batch_params) )
206 throw LauncherException("Batch parameters are bad (see informations above)");
208 // find a cluster matching the structure params
210 aMachineList = _ResManager->GetFittingResources(params);
212 catch(const ResourcesException &ex){
213 throw LauncherException(ex.msg.c_str());
215 if (aMachineList.size() == 0)
216 throw LauncherException("No resources have been found with your parameters");
218 ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]);
219 string clustername(p.Alias);
220 #if defined(_DEBUG_) || defined(_DEBUG)
221 cerr << "Choose cluster: " << clustername << endl;
224 // search batch manager for that cluster in map or instanciate one
225 map < string, Batch::BatchManager_eClient * >::const_iterator it = _batchmap.find(clustername);
226 if(it == _batchmap.end())
228 _batchmap[clustername] = FactoryBatchManager(p);
229 // TODO: Add a test for the cluster !
233 // tmp directory on cluster to put files to execute
234 string tmpdir = getTmpDirForBatchFiles();
236 // create and submit job on cluster
237 Batch::Parametre param;
238 param[USER] = p.UserName;
239 param[EXECUTABLE] = buildSalomeCouplingScript(fileToExecute,tmpdir,p);
240 param[INFILE] = Batch::Couple( fileToExecute, getRemoteFile(tmpdir,fileToExecute) );
241 for(int i=0;i<filesToExport.size();i++)
242 param[INFILE] += Batch::Couple( filesToExport[i], getRemoteFile(tmpdir,filesToExport[i]) );
244 ostringstream file_name_output;
245 file_name_output << "~/" << tmpdir << "/" << "output.log*";
246 ostringstream file_name_error;
247 file_name_error << "~/" << tmpdir << "/" << "error.log*";
248 ostringstream file_container_log;
249 file_container_log << "~/" << tmpdir << "/" << "YACS_Server*";
250 param[OUTFILE] = Batch::Couple( "", file_name_output.str());
251 param[OUTFILE] += Batch::Couple( "", file_name_error.str());
252 param[OUTFILE] += Batch::Couple( "", file_container_log.str());
254 for(int i=0;i<filesToImport.size();i++)
255 param[OUTFILE] += Batch::Couple( "", filesToImport[i] );
257 param[NBPROC] = batch_params.nb_proc;
258 param[WORKDIR] = batch_params.batch_directory;
259 param[TMPDIR] = tmpdir;
260 param[MAXWALLTIME] = getWallTime(batch_params.expected_during_time);
261 param[MAXRAMSIZE] = getRamSize(batch_params.mem);
262 param[HOMEDIR] = getHomeDir(p, tmpdir);
263 param[QUEUE] = p.batchQueue;
265 Batch::Environnement env;
267 Batch::Job* job = new Batch::Job(param,env);
269 // submit job on cluster
270 Batch::JobId jid = _batchmap[clustername]->submitJob(*job);
272 // get job id in long
273 istringstream iss(jid.getReference());
276 _jobmap[ pair<string,long>(clustername,jobId) ] = job;
278 catch(const Batch::EmulationException &ex){
279 throw LauncherException(ex.msg.c_str());
285 //=============================================================================
287 * Query a batch job on a cluster and returns the status of job
288 * \param jobId : identification of Salome job
289 * \param params : Constraints for the choice of the batch cluster
291 //=============================================================================
292 string Launcher_cpp::queryJob( long id,
293 const machineParams& params) throw(LauncherException)
296 throw LauncherException("You must set Resources Manager to Launcher!!");
298 // find a cluster matching params structure
299 vector<string> aMachineList = _ResManager->GetFittingResources( params ) ;
300 ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]);
301 string clustername(p.Alias);
303 // search batch manager for that cluster in map
304 std::map < string, Batch::BatchManager_eClient * >::const_iterator it = _batchmap.find(clustername);
305 if(it == _batchmap.end())
306 throw LauncherException("no batchmanager for that cluster");
308 Batch::Parametre par;
312 Batch::JobId jobId( _batchmap[clustername], oss.str() );
314 Batch::JobInfo jinfo = jobId.queryJob();
315 par = jinfo.getParametre();
317 catch(const Batch::EmulationException &ex){
318 throw LauncherException(ex.msg.c_str());
324 string Launcher_cpp::queryJob( long id,
325 const std::string clusterName)
327 machineParams params;
328 params.hostname = clusterName;
329 return queryJob(id,params);
332 //=============================================================================
334 * Delete a batch job on a cluster
335 * \param jobId : identification of Salome job
336 * \param params : Constraints for the choice of the batch cluster
338 //=============================================================================
339 void Launcher_cpp::deleteJob( const long id,
340 const machineParams& params) throw(LauncherException)
343 throw LauncherException("You must set Resources Manager to Launcher!!");
345 // find a cluster matching params structure
346 vector<string> aMachineList = _ResManager->GetFittingResources( params ) ;
347 ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]);
348 string clustername(p.Alias);
350 // search batch manager for that cluster in map
351 map < string, Batch::BatchManager_eClient * >::const_iterator it = _batchmap.find(clustername);
352 if(it == _batchmap.end())
353 throw LauncherException("no batchmanager for that cluster");
357 Batch::JobId jobId( _batchmap[clustername], oss.str() );
362 void Launcher_cpp::deleteJob( long id,
363 const std::string clusterName)
365 machineParams params;
366 params.hostname = clusterName;
367 deleteJob(id,params);
370 //=============================================================================
372 * Get result files of job on a cluster
373 * \param jobId : identification of Salome job
374 * \param params : Constraints for the choice of the batch cluster
376 //=============================================================================
377 void Launcher_cpp::getResultsJob( const string directory,
379 const machineParams& params) throw(LauncherException)
382 throw LauncherException("You must set Resources Manager to Launcher!!");
384 vector<string> aMachineList = _ResManager->GetFittingResources( params ) ;
385 ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]);
386 string clustername(p.Alias);
388 // search batch manager for that cluster in map
389 map < string, Batch::BatchManager_eClient * >::const_iterator it = _batchmap.find(clustername);
390 if(it == _batchmap.end())
391 throw LauncherException("no batchmanager for that cluster");
393 Batch::Job* job = _jobmap[ pair<string,long>(clustername,id) ];
395 _batchmap[clustername]->importOutputFiles( *job, directory );
398 void Launcher_cpp::getResultsJob( const std::string directory,
400 const std::string clusterName)
402 machineParams params;
403 params.hostname = clusterName;
404 getResultsJob(directory,id,params);
407 //=============================================================================
409 * Factory to instanciate the good batch manager for choosen cluster.
411 //=============================================================================
413 Batch::BatchManager_eClient *Launcher_cpp::FactoryBatchManager( const ParserResourcesType& params ) throw(LauncherException)
416 std::string hostname, protocol, mpi;
417 Batch::FactBatchManager_eClient* fact;
419 hostname = params.Alias;
420 switch(params.Protocol){
428 throw LauncherException("unknown protocol");
451 throw LauncherException("you must specified an mpi implementation for batch manager");
454 throw LauncherException("unknown mpi implementation");
457 #if defined(_DEBUG_) || defined(_DEBUG)
458 cerr << "Instanciation of batch manager" << endl;
460 switch( params.Batch ){
462 #if defined(_DEBUG_) || defined(_DEBUG)
463 cerr << "Instantiation of PBS batch manager" << endl;
465 fact = new Batch::FactBatchManager_ePBS;
468 #if defined(_DEBUG_) || defined(_DEBUG)
469 cerr << "Instantiation of LSF batch manager" << endl;
471 fact = new Batch::FactBatchManager_eLSF;
474 #if defined(_DEBUG_) || defined(_DEBUG)
475 cout << "Instantiation of SGE batch manager" << endl;
477 fact = new Batch::FactBatchManager_eSGE;
480 #if defined(_DEBUG_) || defined(_DEBUG)
481 cerr << "BATCH = " << params.Batch << endl;
483 throw LauncherException("no batchmanager for that cluster");
485 return (*fact)(hostname.c_str(),protocol.c_str(),mpi.c_str());
488 string Launcher_cpp::buildSalomeCouplingScript(const string fileToExecute, const string dirForTmpFiles, const ParserResourcesType& params)
490 #ifndef WIN32 //TODO: need for porting on Windows
491 int idx = dirForTmpFiles.find("Batch/");
492 std::string filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length());
494 string::size_type p1 = fileToExecute.find_last_of("/");
495 string::size_type p2 = fileToExecute.find_last_of(".");
496 std::string fileNameToExecute = fileToExecute.substr(p1+1,p2-p1-1);
497 std::string TmpFileName = "/tmp/runSalome_" + fileNameToExecute + ".sh";
499 MpiImpl* mpiImpl = FactoryMpiImpl(params.mpi);
501 ofstream tempOutputFile;
502 tempOutputFile.open(TmpFileName.c_str(), ofstream::out );
505 tempOutputFile << "#! /bin/sh -f" << endl ;
506 tempOutputFile << "cd " ;
507 tempOutputFile << params.AppliPath << endl ;
508 tempOutputFile << "export SALOME_BATCH=1\n";
509 tempOutputFile << "export PYTHONPATH=~/" ;
510 tempOutputFile << dirForTmpFiles ;
511 tempOutputFile << ":$PYTHONPATH" << endl ;
513 // Adding user script
514 std::string script = params.userCommands;
516 tempOutputFile << script << endl;
518 tempOutputFile << "if test \"" ;
519 tempOutputFile << mpiImpl->rank() ;
520 tempOutputFile << "\" = \"0\"; then" << endl ;
522 // -----------------------------------------------
523 // Code for rank 0 : launch runAppli and a container
525 if(params.ModulesList.size()>0)
526 tempOutputFile << " ./runAppli --terminal --modules=" ;
528 tempOutputFile << " ./runAppli --terminal ";
529 for ( int i = 0 ; i < params.ModulesList.size() ; i++ ) {
530 tempOutputFile << params.ModulesList[i] ;
531 if ( i != params.ModulesList.size()-1 )
532 tempOutputFile << "," ;
534 tempOutputFile << " --standalone=registry,study,moduleCatalog --ns-port-log="
538 // Wait NamingService
539 tempOutputFile << " current=0\n"
541 << " while ! test -f " << filelogtemp << "\n"
544 << " let current=current+1\n"
545 << " if [ \"$current\" -eq \"$stop\" ] ; then\n"
546 << " echo Error Naming Service failed ! >&2"
550 << " port=`cat " << filelogtemp << "`\n";
552 // Wait other containers
553 tempOutputFile << " for ((ip=1; ip < ";
554 tempOutputFile << mpiImpl->size();
555 tempOutputFile << " ; ip++))" << endl;
556 tempOutputFile << " do" << endl ;
557 tempOutputFile << " arglist=\"$arglist YACS_Server_\"$ip" << endl ;
558 tempOutputFile << " done" << endl ;
559 tempOutputFile << " sleep 5" << endl ;
560 tempOutputFile << " ./runSession waitContainers.py $arglist" << endl ;
562 // Launch user script
563 tempOutputFile << " ./runSession python ~/" << dirForTmpFiles << "/" << fileNameToExecute << ".py" << endl;
566 tempOutputFile << " rm " << filelogtemp << "\n"
567 << " ./runSession shutdownSalome.py" << endl;
569 // -------------------------------------
570 // Other nodes launch a container
571 tempOutputFile << "else" << endl ;
573 // Wait NamingService
574 tempOutputFile << " current=0\n"
576 << " while ! test -f " << filelogtemp << "\n"
579 << " let current=current+1\n"
580 << " if [ \"$current\" -eq \"$stop\" ] ; then\n"
581 << " echo Error Naming Service failed ! >&2"
585 << " port=`cat " << filelogtemp << "`\n";
587 // Launching container
588 tempOutputFile << " ./runSession SALOME_Container YACS_Server_";
589 tempOutputFile << mpiImpl->rank()
590 << " > ~/" << dirForTmpFiles << "/YACS_Server_"
591 << mpiImpl->rank() << "_container_log." << filelogtemp
593 tempOutputFile << "fi" << endl ;
594 tempOutputFile.flush();
595 tempOutputFile.close();
596 chmod(TmpFileName.c_str(), 0x1ED);
597 #if defined(_DEBUG_) || defined(_DEBUG)
598 cerr << TmpFileName.c_str() << endl;
610 MpiImpl *Launcher_cpp::FactoryMpiImpl(MpiImplType mpi) throw(LauncherException)
614 return new MpiImpl_LAM();
616 return new MpiImpl_MPICH1();
618 return new MpiImpl_MPICH2();
620 return new MpiImpl_OPENMPI();
622 return new MpiImpl_SLURM();
624 return new MpiImpl_PRUN();
626 throw LauncherException("you must specify an mpi implementation for batch manager");
629 oss << mpi << " : not yet implemented";
630 throw LauncherException(oss.str().c_str());
635 string Launcher_cpp::getTmpDirForBatchFiles()
640 // Adding date to the directory name
641 Batch::Date date = Batch::Date(time(0));
642 thedate = date.str();
643 int lend = thedate.size() ;
646 if ( thedate[i] == '/' || thedate[i] == '-' || thedate[i] == ':' ) {
652 ret = string("Batch/");
657 string Launcher_cpp::getRemoteFile( std::string remoteDir, std::string localFile )
659 string::size_type pos = localFile.find_last_of("/") + 1;
660 int ln = localFile.length() - pos;
661 string remoteFile = remoteDir + "/" + localFile.substr(pos,ln);
665 bool Launcher_cpp::check(const batchParams& batch_params)
668 #if defined(_DEBUG_) || defined(_DEBUG)
669 cerr << "Job parameters are :" << endl;
670 cerr << "Directory : $HOME/Batch/$date" << endl;
673 // check expected_during_time (check the format)
674 std::string edt_info = batch_params.expected_during_time;
675 std::string edt_value = batch_params.expected_during_time;
676 if (edt_value != "") {
677 std::string begin_edt_value = edt_value.substr(0, 2);
678 std::string mid_edt_value = edt_value.substr(2, 1);
679 std::string end_edt_value = edt_value.substr(3);
682 std::istringstream iss(begin_edt_value);
683 if (!(iss >> value)) {
684 edt_info = "Error on definition ! : " + edt_value;
687 else if (value < 0) {
688 edt_info = "Error on definition time is negative ! : " + value;
691 std::istringstream iss_2(end_edt_value);
692 if (!(iss_2 >> value)) {
693 edt_info = "Error on definition ! : " + edt_value;
696 else if (value < 0) {
697 edt_info = "Error on definition time is negative ! : " + value;
700 if (mid_edt_value != ":") {
701 edt_info = "Error on definition ! :" + edt_value;
706 edt_info = "No value given";
708 #if defined(_DEBUG_) || defined(_DEBUG)
709 cerr << "Expected during time : " << edt_info << endl;;
712 // check memory (check the format)
713 std::string mem_info;
714 std::string mem_value = batch_params.mem;
715 if (mem_value != "") {
716 std::string begin_mem_value = mem_value.substr(0, mem_value.length()-2);
718 std::istringstream iss(begin_mem_value);
719 if (!(iss >> re_mem_value)) {
720 mem_info = "Error on definition ! : " + mem_value;
723 else if (re_mem_value <= 0) {
724 mem_info = "Error on definition memory is negative ! : " + mem_value;
727 std::string end_mem_value = mem_value.substr(mem_value.length()-2);
728 if (end_mem_value != "gb" && end_mem_value != "mb") {
729 mem_info = "Error on definition, type is bad ! " + mem_value;
734 mem_info = "No value given";
736 #if defined(_DEBUG_) || defined(_DEBUG)
737 cerr << "Memory : " << mem_info << endl;
741 std::string nb_proc_info;
742 ostringstream nb_proc_value;
743 nb_proc_value << batch_params.nb_proc;
744 if(batch_params.nb_proc <= 0) {
745 nb_proc_info = "Bad value ! nb_proc = ";
746 nb_proc_info += nb_proc_value.str();
750 nb_proc_info = nb_proc_value.str();
752 #if defined(_DEBUG_) || defined(_DEBUG)
753 cerr << "Nb of processors : " << nb_proc_info << endl;
759 long Launcher_cpp::getWallTime(std::string edt)
763 if( edt.size() == 0 )
766 string::size_type pos = edt.find(":");
767 string h = edt.substr(0,pos);
768 string m = edt.substr(pos+1,edt.size()-pos+1);
769 istringstream issh(h);
771 istringstream issm(m);
777 long Launcher_cpp::getRamSize(std::string mem)
781 if( mem.size() == 0 )
784 string ram = mem.substr(0,mem.size()-2);
785 istringstream iss(ram);
787 string unity = mem.substr(mem.size()-2,2);
788 if( (unity.find("gb") != string::npos) || (unity.find("GB") != string::npos) )
790 else if( (unity.find("mb") != string::npos) || (unity.find("MB") != string::npos) )
792 else if( (unity.find("kb") != string::npos) || (unity.find("KB") != string::npos) )
794 else if( (unity.find("b") != string::npos) || (unity.find("B") != string::npos) )
795 return mv/(1024*1024);
800 void Launcher_cpp::ParseXmlFile(string xmlExecuteFile)
802 SALOME_Launcher_Handler* handler = new SALOME_Launcher_Handler(_launch);
804 const char* aFilePath = xmlExecuteFile.c_str();
805 FILE* aFile = fopen(aFilePath, "r");
809 xmlDocPtr aDoc = xmlReadFile(aFilePath, NULL, 0);
812 handler->ProcessXmlDocument(aDoc);
814 #if defined(_DEBUG_) || defined(_DEBUG)
815 cout << "ResourcesManager_cpp: could not parse file "<< aFilePath << endl;
825 #if defined(_DEBUG_) || defined(_DEBUG)
826 cout << "Launcher_cpp: file "<<aFilePath<<" is not readable." << endl;
834 std::string Launcher_cpp::getHomeDir(const ParserResourcesType& p, const std::string& tmpdir)
838 int idx = tmpdir.find("Batch/");
839 std::string filelogtemp = tmpdir.substr(idx+6, tmpdir.length());
840 filelogtemp = "/tmp/logs" + filelogtemp + "_home";
842 if( p.Protocol == rsh )
844 else if( p.Protocol == ssh )
847 throw LauncherException("Unknown protocol");
848 if (p.UserName != ""){
849 command += p.UserName;
853 command += " 'echo $HOME' > ";
854 command += filelogtemp;
855 #if defined(_DEBUG_) || defined(_DEBUG)
856 std::cerr << command.c_str() << std::endl;
858 int status = system(command.c_str());
860 throw LauncherException("Error of launching home command on remote host");
862 std::ifstream file_home(filelogtemp.c_str());
863 std::getline(file_home, home);