Closed bdepardo closed 11 years ago
On 2012-11-21 14:52:11 +0100, 'Samuel Kortas (samuel.kortas@edf.fr) wrote: bonjour
pour l'utilisateur vishnu aunay, il n'est pas possible de rappatrier le fichier de sortie du job J_231 execute sur ivanoe.
le fichier existe pourtant bien et un scp direct passe
cela se produit sur la machinee claui2s0 mais également sur 2q1
SK
vishnu_connect -u root -s aunay password: sessionId: root-2012-Nov-21-14:20:03.359169:51986 aunay@claui2s0:~$ vishnu_get_job_info ivanoe J_231
Job : J_231 (Batch ID : 3191263) Work : UNDEFINED User : aunay Session : aunay-2012-Oct-24-16:23:41.585185:95716 Machine : ivanoe (Host: ivanoe2.noe.edf.fr) Job name : job_scriptzTMDbP Job path : /local00/home/aunay/job_Ivanoe Output path (remote) : /gpfs/home/SA06273S/slurm-3191263.out Error path (remote) : /gpfs/home/SA06273S/myJob-3191263.err Output dir (remote) : Priority : 1 (VERY_LOW) CPU per Node : 1 Working dir (remote) : /gpfs/home/SA06273S Status : TERMINATED Submit date : 2012-Oct-24 17:16:53 End date : 2012-Oct-24 17:22:23 Owner : SA06273S Queue : compute Wall clock limit : 00:05:00 Group name : rdusers Description : my first slurm job Max memory : UNDEFINED Nodes : 1 NbNodesAndCpuPerNode : 1:1
aunay@claui2s0:~$ vishnu_get_job_output ivanoe J_231 terminate called after throwing an instance of 'CORBA::UNKNOWN' aunay@claui2s0:~$
On 2012-11-26 15:01:16 +0100, 'R. Chakode (rodrigue.chakode@sysfera.com) wrote: Created attachment 144 patch fixing th bug 447 on get_job_output
On 2012-11-26 15:02:46 +0100, 'R. Chakode (rodrigue.chakode@sysfera.com) wrote: Le problème provient d'un problème de droit d'accès au fichier distant par le SeD. Le patch ci-dessus corrige le problème est se faisant passer par le local account sur la machine distante.
On 2012-11-26 15:49:27 +0100, 'R. Chakode (rodrigue.chakode@sysfera.com) wrote: Created attachment 145 MAJ patch bug 447
Désolé, le patch précédent a été généré à partir d'une mauvaise version de VISHNU. Ci-jointe la bonne version de patch
Attachment 145:
diff --git a/TMS/src/sed/internalApi.cpp b/TMS/src/sed/internalApi.cpp
index 4a42108..e638072 100644
--- a/TMS/src/sed/internalApi.cpp
+++ b/TMS/src/sed/internalApi.cpp
@@ -1,39 +1,3 @@
-/* This file is a part of VISHNU.
-
-* Copyright SysFera SA (2011)
-
-* contact@sysfera.com
-
-* This software is a computer program whose purpose is to provide
-* access to distributed computing resources.
-*
-* This software is governed by the CeCILL license under French law and
-* abiding by the rules of distribution of free software. You can use,
-* modify and/ or redistribute the software under the terms of the CeCILL
-* license as circulated by CEA, CNRS and INRIA at the following URL
-* "http://www.cecill.info".
-
-* As a counterpart to the access to the source code and rights to copy,
-* modify and redistribute granted by the license, users are provided only
-* with a limited warranty and the software's author, the holder of the
-* economic rights, and the successive licensors have only limited
-* liability.
-*
-* In this respect, the user's attention is drawn to the risks associated
-* with loading, using, modifying and/or developing or reproducing the
-* software by the user in light of its specific status of free software,
-* that may mean that it is complicated to manipulate, and that also
-* therefore means that it is reserved for developers and experienced
-* professionals having in-depth computer knowledge. Users are therefore
-* encouraged to load and test the software's suitability as regards their
-* requirements in conditions enabling the security of their systems and/or
-* data to be ensured and, more generally, to use and operate it in the
-* same conditions as regards security.
-*
-* The fact that you are presently reading this means that you have had
-* knowledge of the CeCILL license and that you accept its terms.
-*/
-
/**
* \file TMS/src/sed/internalApi.cpp
* \brief This file contains the VISHNU internal TMS API function.
@@ -203,7 +167,7 @@ solveSubmitJob(diet_profile_t* pb) {
std::string slaveDirectory = ServerTMS::getInstance()->getSlaveDirectory();
// Now submit the job
- jobServer.submitJob(script_content, *submitOptions, vishnuId, slaveDirectory);
+ jobServer.submitJob(script_content, *submitOptions, vishnuId, slaveDirectory, ServerTMS::getInstance()->getDefaultBatchOption());
*job = jobServer.getData();
::ecorecpp::serializer::serializer _ser;
@@ -555,20 +519,21 @@ solveJobOutPutGetResult(diet_profile_t* pb) {
ListStrings filePaths;
std::ostringstream ossFileName("");
+
ossFileName << result.getJobId(); /* each line starts with the associated job id */
- if( bfs::exists(result.getOutputPath())) {
- filePaths.push_back(result.getOutputPath());
- ossFileName << " " << result.getJobId() << ".stdout";
- } else {
- throw SystemException(ERRCODE_INVDATA, "The output file does not longer exist "+result.getErrorPath());
- }
- if( bfs::exists(result.getErrorPath())) {
- filePaths.push_back(result.getErrorPath());
- ossFileName << " " << result.getJobId() << ".stderr";
- } else {
- throw SystemException(ERRCODE_INVDATA, "The error file does not longer exist "+result.getErrorPath());
+
+ filePaths.push_back(result.getOutputPath());
+ ossFileName << " " << result.getJobId() << ".stdout";
+
+ filePaths.push_back(result.getErrorPath());
+ ossFileName << " " << result.getJobId() << ".stderr";
+
+ try {
+ vishnu::appendFilesFromDir(filePaths, ossFileName, result.getOutputDir());
+ } catch (...) {
+ throw UserException(ERRCODE_RUNTIME_ERROR, "Unable to read the output directory " + result.getOutputDir());
}
- vishnu::appendFilesFromDir(filePaths, ossFileName, result.getOutputDir());
+
ossFileName << std::endl;
char* fileNamesDescr = strdup("/tmp/vishnu-fdescXXXXXX");
@@ -584,7 +549,7 @@ solveJobOutPutGetResult(diet_profile_t* pb) {
for(int i = 0; i < nbFiles; i++) {
bfs::path dest = bfs::unique_path("/tmp/vishnu-f2dld%%%%%%") ;
if(sshJobExec.copyFile(filePaths[i], dest.string()) != 0) {
- throw UserException(ERRCODE_SYSTEM, "Cannot copy the file: " + filePaths[i]);
+ throw UserException(ERRCODE_RUNTIME_ERROR, "Cannot copy the file " + filePaths[i]);
}
dagda_put_file(const_cast<char*>(dest.string().c_str()), DIET_PERSISTENT_RETURN, &fileIds[i]);
dagda_add_container_element((*diet_parameter(pb,5)).desc.id, fileIds[i], i+1);
@@ -673,15 +638,17 @@ solveJobOutPutGetCompletedJobs(diet_profile_t* pb) {
TMS_Data::JobResult_ptr result = completedJobsOutput->getResults().get(i);
ossFileName << result->getJobId(); /* each line starts with the associated job id */
- if( bfs::exists( result->getOutputPath() ) ) {
- filePaths.push_back( result->getOutputPath() );
- ossFileName << " " << result->getJobId() << ".stdout";
- }
- if( bfs::exists( result->getErrorPath() ) ) {
- filePaths.push_back( result->getErrorPath() );
- ossFileName << " " << result->getJobId() << ".stderr";
+
+ filePaths.push_back( result->getOutputPath() );
+ ossFileName << " " << result->getJobId() << ".stdout";
+
+ filePaths.push_back( result->getErrorPath() );
+ ossFileName << " " << result->getJobId() << ".stderr";
+ try {
+ vishnu::appendFilesFromDir(filePaths, ossFileName, result->getOutputDir());
+ } catch (...) {
+ throw UserException(ERRCODE_RUNTIME_ERROR, "Unable to read the output directory " + result->getOutputDir());
}
- vishnu::appendFilesFromDir(filePaths, ossFileName, result->getOutputDir());
ossFileName << std::endl;
}
@@ -698,14 +665,14 @@ solveJobOutPutGetCompletedJobs(diet_profile_t* pb) {
for(int i = 0; i < nbFiles; i++) {
bfs::path dest = bfs::unique_path("/tmp/vishnu-f2dld%%%%%%") ;
if(sshJobExec.copyFile(filePaths[i], dest.string()) != 0) {
- throw UserException(ERRCODE_SYSTEM, "Cannot copy the file: " + filePaths[i]);
+ throw UserException(ERRCODE_RUNTIME_ERROR, "Cannot copy the file: " + filePaths[i]);
}
dagda_put_file(const_cast<char*>(dest.string().c_str()), DIET_PERSISTENT_RETURN, &fileIds[i]);
dagda_add_container_element((*diet_parameter(pb,5)).desc.id, fileIds[i], i+1);
}
sessionServer.finish(cmd, TMS, vishnu::CMDSUCCESS);
- } catch (VishnuException& e) {
+ } catch (VishnuException & e) {
try {
sessionServer.finish(cmd, TMS, vishnu::CMDFAILED);
} catch (VishnuException& fe) {
@@ -725,6 +692,8 @@ solveJobOutPutGetCompletedJobs(diet_profile_t* pb) {
dagda_put_file(strdup(outputPath.c_str()), DIET_PERSISTENT_RETURN, &ID);
dagda_add_container_element((*diet_parameter(pb,5)).desc.id, ID, 0);
+ } catch(...) {
+ throw;
}
return 0;
}
diff --git a/core/src/utils/utilVishnu.cpp b/core/src/utils/utilVishnu.cpp
index ee6f09d..633a4e7 100644
--- a/core/src/utils/utilVishnu.cpp
+++ b/core/src/utils/utilVishnu.cpp
@@ -1,39 +1,3 @@
-/* This file is a part of VISHNU.
-
-* Copyright SysFera SA (2011)
-
-* contact@sysfera.com
-
-* This software is a computer program whose purpose is to provide
-* access to distributed computing resources.
-*
-* This software is governed by the CeCILL license under French law and
-* abiding by the rules of distribution of free software. You can use,
-* modify and/ or redistribute the software under the terms of the CeCILL
-* license as circulated by CEA, CNRS and INRIA at the following URL
-* "http://www.cecill.info".
-
-* As a counterpart to the access to the source code and rights to copy,
-* modify and redistribute granted by the license, users are provided only
-* with a limited warranty and the software's author, the holder of the
-* economic rights, and the successive licensors have only limited
-* liability.
-*
-* In this respect, the user's attention is drawn to the risks associated
-* with loading, using, modifying and/or developing or reproducing the
-* software by the user in light of its specific status of free software,
-* that may mean that it is complicated to manipulate, and that also
-* therefore means that it is reserved for developers and experienced
-* professionals having in-depth computer knowledge. Users are therefore
-* encouraged to load and test the software's suitability as regards their
-* requirements in conditions enabling the security of their systems and/or
-* data to be ensured and, more generally, to use and operate it in the
-* same conditions as regards security.
-*
-* The fact that you are presently reading this means that you have had
-* knowledge of the CeCILL license and that you accept its terms.
-*/
-
/**
* \file utilVishnu.cpp
* \brief This file implements the utils functions of the vishnu system
@@ -93,17 +57,17 @@ namespace bs=boost::system;
*/
long long
vishnu::convertToTimeType(std::string date) {
- if(date.size()==0 ||
- // For mysql, the empty date is 0000-00-00, not empty, need this test to avoid problem in ptime
- date.find("0000-00-00")!=std::string::npos) {
- return 0;
- }
+ if(date.size()==0 ||
+ // For mysql, the empty date is 0000-00-00, not empty, need this test to avoid problem in ptime
+ date.find("0000-00-00")!=std::string::npos) {
+ return 0;
+ }
- boost::posix_time::ptime pt(time_from_string(date));
- boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
- time_duration::sec_type time = (pt - epoch).total_seconds();
+ boost::posix_time::ptime pt(time_from_string(date));
+ boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
+ time_duration::sec_type time = (pt - epoch).total_seconds();
- return (long long) time_t(time);
+ return (long long) time_t(time);
}
/**
@@ -114,18 +78,18 @@ vishnu::convertToTimeType(std::string date) {
int
vishnu::convertToInt(std::string val) {
#if 0
- int intValue;
- std::istringstream str(val);
- str >> intValue;
- return intValue;
+ int intValue;
+ std::istringstream str(val);
+ str >> intValue;
+ return intValue;
#endif
- int value = -1 ;
- if(! val.empty()) {
- value = vishnu::lexical_convertor<int>(val);
- } else {
- value = -1 ;
- }
- return value ;
+ int value = -1 ;
+ if(! val.empty()) {
+ value = vishnu::lexical_convertor<int>(val);
+ } else {
+ value = -1 ;
+ }
+ return value ;
}
@@ -137,18 +101,18 @@ vishnu::convertToInt(std::string val) {
long
vishnu::convertToLong(std::string val) {
#if 0
- int intValue;
- std::istringstream str(val);
- str >> intValue;
- return intValue;
+ int intValue;
+ std::istringstream str(val);
+ str >> intValue;
+ return intValue;
#endif
- int value = -1 ;
- if(! val.empty()) {
- value = vishnu::lexical_convertor<long>(val);
- } else {
- value = -1 ;
- }
- return value ;
+ int value = -1 ;
+ if(! val.empty()) {
+ value = vishnu::lexical_convertor<long>(val);
+ } else {
+ value = -1 ;
+ }
+ return value ;
}
/**
@@ -163,14 +127,14 @@ vishnu::convertToLong(std::string val) {
std::string
vishnu::cryptPassword(const std::string& salt, const std::string& password, bool encrypted) {
- if (!encrypted) {
- return password;
- }
- else {
- std::string saltTmp="$6$"+salt+"$";
- std::string encryptedPassword=crypt(password.c_str(),saltTmp.c_str());
- return encryptedPassword.substr(saltTmp.size());
- }
+ if (!encrypted) {
+ return password;
+ }
+ else {
+ std::string saltTmp="$6$"+salt+"$";
+ std::string encryptedPassword=crypt(password.c_str(),saltTmp.c_str());
+ return encryptedPassword.substr(saltTmp.size());
+ }
}
/**
@@ -181,11 +145,11 @@ vishnu::cryptPassword(const std::string& salt, const std::string& password, bool
int
vishnu::generateNumbers() {
- boost::mt19937 gen;
- gen.seed(static_cast<boost::uint32_t>(std::time(0)));
- boost::uniform_int<> dist(1, 100000);
- boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist);
- return die();
+ boost::mt19937 gen;
+ gen.seed(static_cast<boost::uint32_t>(std::time(0)));
+ boost::uniform_int<> dist(1, 100000);
+ boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist);
+ return die();
}
/**
@@ -195,8 +159,8 @@ vishnu::generateNumbers() {
*/
std::string
vishnu::takePassword(const std::string& prompt){
- std::string password=getpass(prompt.c_str());
- return password;
+ std::string password=getpass(prompt.c_str());
+ return password;
}
@@ -210,27 +174,27 @@ vishnu::takePassword(const std::string& prompt){
std::time_t
vishnu::string_to_time_t(const std::string& ts){
- // two aliases for convenience
+ // two aliases for convenience
- namespace bps= boost::posix_time;
- namespace bg=boost::gregorian;
+ namespace bps= boost::posix_time;
+ namespace bg=boost::gregorian;
- bps::ptime t;
+ bps::ptime t;
- if (std::string::npos==ts.find(":")){
- t=bps::ptime(bg::from_string(ts));
+ if (std::string::npos==ts.find(":")){
+ t=bps::ptime(bg::from_string(ts));
- }
- else{
- t= bps::ptime (bps::time_from_string(ts));
- }
+ }
+ else{
+ t= bps::ptime (bps::time_from_string(ts));
+ }
- bps::ptime epoch(bg::date(1970,1,1));
+ bps::ptime epoch(bg::date(1970,1,1));
- bps::time_duration::sec_type x = (t - epoch).total_seconds();
+ bps::time_duration::sec_type x = (t - epoch).total_seconds();
- return std::time_t(x);
+ return std::time_t(x);
}
@@ -248,32 +212,32 @@ vishnu::string_to_time_t(const std::string& ts){
std::time_t
vishnu::string_lc_to_utc_time_t(const std::string& ts,const std::string& utcOffset) {
- // two aliases for convenience
- namespace bps= boost::posix_time;
- namespace bg=boost::gregorian;
- namespace blt=boost::local_time;
+ // two aliases for convenience
+ namespace bps= boost::posix_time;
+ namespace bg=boost::gregorian;
+ namespace blt=boost::local_time;
- std::cout << " convert " << ts << " " << utcOffset << " in utc time\n";
+ std::cout << " convert " << ts << " " << utcOffset << " in utc time\n";
- boost::local_time::time_zone_ptr tz(new boost::local_time::posix_time_zone(utcOffset));
+ boost::local_time::time_zone_ptr tz(new boost::local_time::posix_time_zone(utcOffset));
- bps::ptime t;
+ bps::ptime t;
- if (std::string::npos==ts.find(":")){
- t=bps::ptime(bg::from_string(ts));
+ if (std::string::npos==ts.find(":")){
+ t=bps::ptime(bg::from_string(ts));
- }
- else{
- t= bps::ptime (bps::time_from_string(ts));
- }
+ }
+ else{
+ t= bps::ptime (bps::time_from_string(ts));
+ }
- bps::ptime epoch(bg::date(1970,1,1));
+ bps::ptime epoch(bg::date(1970,1,1));
- blt::local_date_time ldt(t.date(), t.time_of_day(),tz,blt::local_date_time::NOT_DATE_TIME_ON_ERROR);
+ blt::local_date_time ldt(t.date(), t.time_of_day(),tz,blt::local_date_time::NOT_DATE_TIME_ON_ERROR);
- bps::time_duration::sec_type x = (ldt.utc_time() - epoch).total_seconds();
+ bps::time_duration::sec_type x = (ldt.utc_time() - epoch).total_seconds();
- return std::time_t(x);
+ return std::time_t(x);
}
@@ -295,23 +259,23 @@ vishnu::string_lc_to_utc_time_t(const std::string& ts,const std::string& utcOffs
std::string
vishnu::get_file_content(const std::string& filePath, const bool& rejectEmptyFile){
- bfs::path file (filePath);
+ bfs::path file (filePath);
- // Check the existence of file
- if ( ! bfs::exists(file) ||
- ! bfs::is_regular_file(file) ||
- ( bfs::is_empty(file) && rejectEmptyFile) ) {
- throw UserException(ERRCODE_INVALID_PARAM, "can not read the file: " + filePath);
- }
+ // Check the existence of file
+ if ( ! bfs::exists(file) ||
+ ! bfs::is_regular_file(file) ||
+ ( bfs::is_empty(file) && rejectEmptyFile) ) {
+ throw UserException(ERRCODE_INVALID_PARAM, "can not read the file: " + filePath);
+ }
- bfs::ifstream ifs (file);
+ bfs::ifstream ifs (file);
- // Read the whole file into string
+ // Read the whole file into string
- std::stringstream ss;
- ss << ifs.rdbuf();
+ std::stringstream ss;
+ ss << ifs.rdbuf();
- return ss.str();
+ return ss.str();
}
@@ -362,14 +326,14 @@ vishnu::boostMoveFile(const std::string& src, const std::string& dest, const std
* \return raises an exception on error
*/
bool vishnu::isNumericalValue(const std::string& value) {
- if(value.size()==0) {
- throw UserException(ERRCODE_INVALID_PARAM, ("Invalid numerical value: The given value is empty"));
- }
- bool ret = (value.find_first_not_of("0123456789")==std::string::npos);
- if(! ret) {
- throw UserException(ERRCODE_INVALID_PARAM, ("Invalid numerical value: "+value));
- }
- return ret;
+ if(value.size()==0) {
+ throw UserException(ERRCODE_INVALID_PARAM, ("Invalid numerical value: The given value is empty"));
+ }
+ bool ret = (value.find_first_not_of("0123456789")==std::string::npos);
+ if(! ret) {
+ throw UserException(ERRCODE_INVALID_PARAM, ("Invalid numerical value: "+value));
+ }
+ return ret;
}
@@ -380,42 +344,42 @@ bool vishnu::isNumericalValue(const std::string& value) {
*/
std::string vishnu::convertWallTimeToString(const long& walltime) {
- long totalTime = walltime;
- long j = totalTime/86400;
- totalTime = walltime-j*86400;
- long h = totalTime/3600;
- totalTime = totalTime-h*3600;
- long m = totalTime/60;
- long s = totalTime-m*60;
-
- std::ostringstream StrWallTime;
- if(j > 0) {
- if(j < 10) {
- StrWallTime << "0" << j << ":";
- } else {
- StrWallTime << j << ":";
- }
- }
-
- if(h < 10) {
- StrWallTime << "0" << h << ":";
- } else {
- StrWallTime << h << ":";
- }
-
- if(m < 10) {
- StrWallTime << "0" << m << ":";
- } else {
- StrWallTime << m << ":";
- }
-
- if(s < 10) {
- StrWallTime << "0" << s;
- } else {
- StrWallTime << s ;
- }
-
- return StrWallTime.str();
+ long totalTime = walltime;
+ long j = totalTime/86400;
+ totalTime = walltime-j*86400;
+ long h = totalTime/3600;
+ totalTime = totalTime-h*3600;
+ long m = totalTime/60;
+ long s = totalTime-m*60;
+
+ std::ostringstream StrWallTime;
+ if(j > 0) {
+ if(j < 10) {
+ StrWallTime << "0" << j << ":";
+ } else {
+ StrWallTime << j << ":";
+ }
+ }
+
+ if(h < 10) {
+ StrWallTime << "0" << h << ":";
+ } else {
+ StrWallTime << h << ":";
+ }
+
+ if(m < 10) {
+ StrWallTime << "0" << m << ":";
+ } else {
+ StrWallTime << m << ":";
+ }
+
+ if(s < 10) {
+ StrWallTime << "0" << s;
+ } else {
+ StrWallTime << s ;
+ }
+
+ return StrWallTime.str();
}
/**
@@ -425,100 +389,100 @@ std::string vishnu::convertWallTimeToString(const long& walltime) {
*/
long vishnu::convertStringToWallTime(const std::string& walltime_) {
- std::string walltime(walltime_);
-
- if(!walltime.empty()){
- if(*(walltime.begin())=='\"'){
- walltime.replace(walltime.begin(), walltime.begin()+1, "");
- }
- if(*(walltime.end()-1)=='\"'){
- walltime.replace(walltime.end()-1, walltime.end(), "");
- }
- }
-
- if(walltime.size()!=0) {
- int seconds = 0;
- int minute = 0;
- int heure = 0;
- int jour = 0;
- std::string value;
-
- size_t size = walltime.size();
- size_t pos = walltime.rfind(":");
- if(pos!=std::string::npos) {
- if((size-pos > 1)) {
- value = walltime.substr(pos+1, size-1-pos);
- if(isNumericalValue(value)) {
- seconds = convertToInt(value);
- }
- }
- } else {
- if(walltime.size() > 0) {
- value = walltime;
- if(isNumericalValue(value)) {
- seconds = convertToInt(value);
- }
- }
- }
-
- if((pos!=std::string::npos) && (pos > 0)) {
- size = pos;
- pos = walltime.rfind(":", size-1);
- if(pos!=std::string::npos) {
- if((size-pos > 1)) {
- value = walltime.substr(pos+1, size-pos-1);
- if(isNumericalValue(value)) {
- minute = convertToInt(value);
- }
- }
- } else {
- value = walltime.substr(0, size);
- if(isNumericalValue(value)) {
- minute = convertToInt(value);
- }
- }
- }
-
- if((pos!=std::string::npos) && (pos > 0)) {
- size = pos;
- pos = walltime.rfind(":", size-1);
- if(pos!=std::string::npos) {
- if((size-pos > 1)) {
- value = walltime.substr(pos+1, size-pos-1);
- if(isNumericalValue(value)) {
- heure = convertToInt(value);
- }
- }
- } else {
- value = walltime.substr(0, size);
- if(isNumericalValue(value)) {
- heure = convertToInt(value);
- }
- }
- }
-
- if((pos!=std::string::npos) && (pos > 0)) {
- size = pos;
- pos = walltime.rfind(":", size-1);
- if(pos!=std::string::npos) {
- if((size-pos > 1)) {
- throw std::runtime_error("Invalid wallltime value: "+walltime);
- }
- } else {
- value = walltime.substr(0, size);
- if(isNumericalValue(value)) {
- jour = convertToInt(value);
- }
- }
- }
-
- long walltimeInSeconds = (jour*86400+heure*3600+minute*60+seconds);
-
- return walltimeInSeconds;
-
- } else {
- throw UserException(ERRCODE_INVALID_PARAM, ("Invalid walltime value: The given value is empty"));
- }
+ std::string walltime(walltime_);
+
+ if(!walltime.empty()){
+ if(*(walltime.begin())=='\"'){
+ walltime.replace(walltime.begin(), walltime.begin()+1, "");
+ }
+ if(*(walltime.end()-1)=='\"'){
+ walltime.replace(walltime.end()-1, walltime.end(), "");
+ }
+ }
+
+ if(walltime.size()!=0) {
+ int seconds = 0;
+ int minute = 0;
+ int heure = 0;
+ int jour = 0;
+ std::string value;
+
+ size_t size = walltime.size();
+ size_t pos = walltime.rfind(":");
+ if(pos!=std::string::npos) {
+ if((size-pos > 1)) {
+ value = walltime.substr(pos+1, size-1-pos);
+ if(isNumericalValue(value)) {
+ seconds = convertToInt(value);
+ }
+ }
+ } else {
+ if(walltime.size() > 0) {
+ value = walltime;
+ if(isNumericalValue(value)) {
+ seconds = convertToInt(value);
+ }
+ }
+ }
+
+ if((pos!=std::string::npos) && (pos > 0)) {
+ size = pos;
+ pos = walltime.rfind(":", size-1);
+ if(pos!=std::string::npos) {
+ if((size-pos > 1)) {
+ value = walltime.substr(pos+1, size-pos-1);
+ if(isNumericalValue(value)) {
+ minute = convertToInt(value);
+ }
+ }
+ } else {
+ value = walltime.substr(0, size);
+ if(isNumericalValue(value)) {
+ minute = convertToInt(value);
+ }
+ }
+ }
+
+ if((pos!=std::string::npos) && (pos > 0)) {
+ size = pos;
+ pos = walltime.rfind(":", size-1);
+ if(pos!=std::string::npos) {
+ if((size-pos > 1)) {
+ value = walltime.substr(pos+1, size-pos-1);
+ if(isNumericalValue(value)) {
+ heure = convertToInt(value);
+ }
+ }
+ } else {
+ value = walltime.substr(0, size);
+ if(isNumericalValue(value)) {
+ heure = convertToInt(value);
+ }
+ }
+ }
+
+ if((pos!=std::string::npos) && (pos > 0)) {
+ size = pos;
+ pos = walltime.rfind(":", size-1);
+ if(pos!=std::string::npos) {
+ if((size-pos > 1)) {
+ throw std::runtime_error("Invalid wallltime value: "+walltime);
+ }
+ } else {
+ value = walltime.substr(0, size);
+ if(isNumericalValue(value)) {
+ jour = convertToInt(value);
+ }
+ }
+ }
+
+ long walltimeInSeconds = (jour*86400+heure*3600+minute*60+seconds);
+
+ return walltimeInSeconds;
+
+ } else {
+ throw UserException(ERRCODE_INVALID_PARAM, ("Invalid walltime value: The given value is empty"));
+ }
}
@@ -530,9 +494,9 @@ long vishnu::convertStringToWallTime(const std::string& walltime_) {
void
vishnu::checkJobStatus(const int& status) {
- if ((status < -1) || (status > 8)) {
- throw UserException(ERRCODE_INVALID_PARAM, "The status value is incorrect");
- }
+ if ((status < -1) || (status > 8)) {
+ throw UserException(ERRCODE_INVALID_PARAM, "The status value is incorrect");
+ }
}
/**
@@ -543,9 +507,9 @@ vishnu::checkJobStatus(const int& status) {
void
vishnu::checkJobPriority(const int& priority) {
- if ((priority < -1) || (priority > 5)) {
- throw UserException(ERRCODE_INVALID_PARAM, "The priority value is incorrect");
- }
+ if ((priority < -1) || (priority > 5)) {
+ throw UserException(ERRCODE_INVALID_PARAM, "The priority value is incorrect");
+ }
}
@@ -557,24 +521,24 @@ vishnu::checkJobPriority(const int& priority) {
void
vishnu::checkJobNbNodesAndNbCpuPerNode(const std::string& nbNodesAndCpuPerNode) {
- if(nbNodesAndCpuPerNode.size()!=0) {
- size_t posNbNodes;
- try {
- posNbNodes = nbNodesAndCpuPerNode.find(":");
- if(posNbNodes!=std::string::npos) {
+ if(nbNodesAndCpuPerNode.size()!=0) {
+ size_t posNbNodes;
+ try {
+ posNbNodes = nbNodesAndCpuPerNode.find(":");
+ if(posNbNodes!=std::string::npos) {
- std::string nbNodes = nbNodesAndCpuPerNode.substr(0, posNbNodes);
- isNumericalValue(nbNodes);
+ std::string nbNodes = nbNodesAndCpuPerNode.substr(0, posNbNodes);
+ isNumericalValue(nbNodes);
- std::string cpuPerNode = nbNodesAndCpuPerNode.substr(posNbNodes+1);
- isNumericalValue(cpuPerNode);
- } else {
- throw UserException(ERRCODE_INVALID_PARAM, ("Invalid NbNodesAndNbCpuPerNode value: "+nbNodesAndCpuPerNode));
- }
- } catch(UserException& ue) {
- throw UserException(ERRCODE_INVALID_PARAM, ("Invalid NbNodesAndNbCpuPerNode value: "+nbNodesAndCpuPerNode));
- }
- }
+ std::string cpuPerNode = nbNodesAndCpuPerNode.substr(posNbNodes+1);
+ isNumericalValue(cpuPerNode);
+ } else {
+ throw UserException(ERRCODE_INVALID_PARAM, ("Invalid NbNodesAndNbCpuPerNode value: "+nbNodesAndCpuPerNode));
+ }
+ } catch(UserException& ue) {
+ throw UserException(ERRCODE_INVALID_PARAM, ("Invalid NbNodesAndNbCpuPerNode value: "+nbNodesAndCpuPerNode));
+ }
+ }
}
/**
@@ -583,7 +547,7 @@ vishnu::checkJobNbNodesAndNbCpuPerNode(const std::string& nbNodesAndCpuPerNode)
*/
time_t vishnu::getCurrentTimeInUTC() {
- return std::time(0);
+ return std::time(0);
}
/**
@@ -592,13 +556,13 @@ time_t vishnu::getCurrentTimeInUTC() {
*/
time_t vishnu::convertUTCtimeINLocaltime(const time_t& utctime) {
- //the current time
- boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
+ //the current time
+ boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
- time_t currentTime = string_to_time_t(to_simple_string(now));
+ time_t currentTime = string_to_time_t(to_simple_string(now));
- long diff = currentTime-std::time(0);
- return (utctime+diff);
+ long diff = currentTime-std::time(0);
+ return (utctime+diff);
}
/**
@@ -607,13 +571,13 @@ time_t vishnu::convertUTCtimeINLocaltime(const time_t& utctime) {
*/
time_t vishnu::convertLocaltimeINUTCtime(const time_t& localtime) {
- //the current time
- boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
+ //the current time
+ boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
- time_t currentTime = string_to_time_t(to_simple_string(now));
+ time_t currentTime = string_to_time_t(to_simple_string(now));
- long diff = currentTime-std::time(0);
- return (localtime-diff);
+ long diff = currentTime-std::time(0);
+ return (localtime-diff);
}
/**
@@ -622,13 +586,13 @@ time_t vishnu::convertLocaltimeINUTCtime(const time_t& localtime) {
*/
long vishnu::diffLocaltimeUTCtime() {
- //the current time
- boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
+ //the current time
+ boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
- time_t currentTime = string_to_time_t(to_simple_string(now));
+ time_t currentTime = string_to_time_t(to_simple_string(now));
- long diff = currentTime-std::time(0);
- return diff;
+ long diff = currentTime-std::time(0);
+ return diff;
}
/**
@@ -638,25 +602,25 @@ long vishnu::diffLocaltimeUTCtime() {
*/
void vishnu::createTmpFile(char* fileName, const std::string& file_content) {
- int file_descriptor = mkstemp( fileName ) ;
- size_t file_size = file_content.size();
- if( file_descriptor == -1 ) {
- throw SystemException(ERRCODE_SYSTEM, "vishnu::createTmpFile: Cannot create new tmp file");
- }
+ int file_descriptor = mkstemp( fileName ) ;
+ size_t file_size = file_content.size();
+ if( file_descriptor == -1 ) {
+ throw SystemException(ERRCODE_SYSTEM, "vishnu::createTmpFile: Cannot create new tmp file");
+ }
- if(fchmod(file_descriptor, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH)!=0) {
- close(file_descriptor);
- throw SystemException(ERRCODE_SYSTEM, "vishnu::createTmpFile: reading or writing rights have"
- " not been change on the path. This can lead to an error");
- }
+ if(fchmod(file_descriptor, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH)!=0) {
+ close(file_descriptor);
+ throw SystemException(ERRCODE_SYSTEM, "vishnu::createTmpFile: reading or writing rights have"
+ " not been change on the path. This can lead to an error");
+ }
- if( write(file_descriptor, file_content.c_str(), file_size) != file_size ) {
- close(file_descriptor);
- throw SystemException(ERRCODE_SYSTEM, "vishnu::createTmpFile: Cannot write the content int to"
- " new created file");
- }
+ if( write(file_descriptor, file_content.c_str(), file_size) != file_size ) {
+ close(file_descriptor);
+ throw SystemException(ERRCODE_SYSTEM, "vishnu::createTmpFile: Cannot write the content int to"
+ " new created file");
+ }
- close(file_descriptor);
+ close(file_descriptor);
}
/**
@@ -665,18 +629,18 @@ void vishnu::createTmpFile(char* fileName, const std::string& file_content) {
*/
void vishnu::createTmpFile(char* fileName) {
- int file_descriptor = mkstemp( fileName ) ;
- if( file_descriptor == -1 ) {
- throw SystemException(ERRCODE_SYSTEM, "vishnu::createTmpFile: Cannot create new tmp file");
- }
+ int file_descriptor = mkstemp( fileName ) ;
+ if( file_descriptor == -1 ) {
+ throw SystemException(ERRCODE_SYSTEM, "vishnu::createTmpFile: Cannot create new tmp file");
+ }
- if(fchmod(file_descriptor, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH ) !=0) {
- close(file_descriptor);
- throw SystemException(ERRCODE_SYSTEM, "vishnu::createTmpFile: reading or writing rights have not been"
- " change on the path. This can lead to an error");
- }
+ if(fchmod(file_descriptor, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH ) !=0) {
+ close(file_descriptor);
+ throw SystemException(ERRCODE_SYSTEM, "vishnu::createTmpFile: reading or writing rights have not been"
+ " change on the path. This can lead to an error");
+ }
- close(file_descriptor);
+ close(file_descriptor);
}
/**
@@ -684,7 +648,7 @@ void vishnu::createTmpFile(char* fileName) {
* \param fileName The name of the file to create
*/
int vishnu::deleteFile(const char* fileName) {
- return unlink(fileName);
+ return unlink(fileName);
}
/**
@@ -694,9 +658,9 @@ int vishnu::deleteFile(const char* fileName) {
*/
void
vishnu::checkMetricHistoryValue(const int& metric) {
- if ((metric < -1) || (metric > 6)) {
- throw UserException(ERRCODE_INVALID_PARAM, "The metric value is incorrect");
- }
+ if ((metric < -1) || (metric > 6)) {
+ throw UserException(ERRCODE_INVALID_PARAM, "The metric value is incorrect");
+ }
}
/**
@@ -706,9 +670,9 @@ vishnu::checkMetricHistoryValue(const int& metric) {
*/
void
vishnu::checkRemotePath(const std::string& path){
- if (path.find(":")==std::string::npos){
- throw FMSVishnuException(ERRCODE_INVALID_PATH, "The path must be a remote file and in the form machineId:path");
- }
+ if (path.find(":")==std::string::npos){
+ throw FMSVishnuException(ERRCODE_INVALID_PATH, "The path must be a remote file and in the form machineId:path");
+ }
}
/**
@@ -722,9 +686,9 @@ vishnu::checkRemotePath(const std::string& path){
bool
vishnu::process_exists(const std::string& pid, const bfs::path& proc_dir){
- bfs::path token(proc_dir);
- token /= pid;
- return bfs::exists(token);
+ bfs::path token(proc_dir);
+ token /= pid;
+ return bfs::exists(token);
}
@@ -737,27 +701,27 @@ vishnu::process_exists(const std::string& pid, const bfs::path& proc_dir){
std::string vishnu::getLocalMachineName(const std::string& port ){
- char hostname[MAXHOSTNAMELEN];
+ char hostname[MAXHOSTNAMELEN];
- gethostname(hostname, MAXHOSTNAMELEN);
+ gethostname(hostname, MAXHOSTNAMELEN);
- struct addrinfo hints, *servinfo;
+ struct addrinfo hints, *servinfo;
- int rv;
+ int rv;
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC; // ither IPV4 or IPV6 use AF_INET6 to force IPv6
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_CANONNAME;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC; // ither IPV4 or IPV6 use AF_INET6 to force IPv6
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_CANONNAME;
- if ((rv = getaddrinfo(hostname,port.c_str(), &hints, &servinfo)) != 0) {
- SystemException(ERRCODE_SYSTEM,gai_strerror(rv));
- }
- if(servinfo->ai_canonname==NULL){
- throw SystemException(ERRCODE_SYSTEM,"can not resolve the machine name");
- }
+ if ((rv = getaddrinfo(hostname,port.c_str(), &hints, &servinfo)) != 0) {
+ SystemException(ERRCODE_SYSTEM,gai_strerror(rv));
+ }
+ if(servinfo->ai_canonname==NULL){
+ throw SystemException(ERRCODE_SYSTEM,"can not resolve the machine name");
+ }
- return servinfo->ai_canonname;
+ return servinfo->ai_canonname;
}
@@ -769,11 +733,11 @@ std::string vishnu::getLocalMachineName(const std::string& port ){
*/
void
vishnu::checkEmptyString(const std::string& str,
- const std::string& compMsg) {
+ const std::string& compMsg) {
- if(str.empty()) {
- throw UserException(ERRCODE_INVALID_PARAM, compMsg+" must be not empty");
- }
+ if(str.empty()) {
+ throw UserException(ERRCODE_INVALID_PARAM, compMsg+" must be not empty");
+ }
}
@@ -787,51 +751,51 @@ vishnu::checkEmptyString(const std::string& str,
*/
int
vishnu::validateParameters(const boost::shared_ptr<Options> & opt,
- std::string & paramsStr,
- const std::string & paramOptName,
- const ListStrings & paramsVector){
-
- if( opt->count(paramOptName) ){
- paramsStr = opt->get< std::string >(paramOptName) ;
- }
-
- // Append other parameters in paramStr
- for(ListStrings::const_iterator it = paramsVector.begin(); it != paramsVector.end() ; it++) {
- paramsStr += " " + *it ;
- }
-
- //Now check the syntax of parameters and set them suitable for VISHNU
- ListStrings paramsVecBuffer ;
- boost::trim(paramsStr) ; boost::split(paramsVecBuffer, paramsStr, boost::is_any_of(" "), boost::token_compress_on);
-
- paramsStr = "" ; // Reinitialization for outpout
- for(ListStrings::iterator it = paramsVecBuffer.begin(); it != paramsVecBuffer.end() ; it++) {
-
- size_t pos = (*it).find("=") ;
- if( pos == 0 || pos == std::string::npos || pos == (*it).size() - 1 ){
- std::cerr << "Uncompleted definition for the parameter : '" << *it << "'"<< std::endl ;
- return CLI_ERROR_INVALID_PARAMETER;
- }
-
- std::string paramName = (*it).substr(0, pos) ; // Keep the parameter name in upper case
- std::string paramValue = (*it).substr(pos+1, std::string::npos) ;
-
- // Check whether the parameter is duplicate
- if( paramsStr.size() != 0) {
- size_t start = 0 ;
- while( pos = paramsStr.find(paramName+"=", start), pos != std::string::npos ){
- if( pos == 0 || paramsStr[pos-1] == char(' ') ) {
- std::cerr << "Duplicate parameter : '" << paramName << "'"<< std::endl ;
- return CLI_ERROR_INVALID_PARAMETER ;
- }
- start = pos + paramName.size() ;
- }
- paramsStr += " " ;
- }
- // Append the parameter
- paramsStr += paramName + "=" + paramValue ;
- }
- return 0 ;
+ std::string & paramsStr,
+ const std::string & paramOptName,
+ const ListStrings & paramsVector){
+
+ if( opt->count(paramOptName) ){
+ paramsStr = opt->get< std::string >(paramOptName) ;
+ }
+
+ // Append other parameters in paramStr
+ for(ListStrings::const_iterator it = paramsVector.begin(); it != paramsVector.end() ; it++) {
+ paramsStr += " " + *it ;
+ }
+
+ //Now check the syntax of parameters and set them suitable for VISHNU
+ ListStrings paramsVecBuffer ;
+ boost::trim(paramsStr) ; boost::split(paramsVecBuffer, paramsStr, boost::is_any_of(" "), boost::token_compress_on);
+
+ paramsStr = "" ; // Reinitialization for outpout
+ for(ListStrings::iterator it = paramsVecBuffer.begin(); it != paramsVecBuffer.end() ; it++) {
+
+ size_t pos = (*it).find("=") ;
+ if( pos == 0 || pos == std::string::npos || pos == (*it).size() - 1 ){
+ std::cerr << "Uncompleted definition for the parameter : '" << *it << "'"<< std::endl ;
+ return CLI_ERROR_INVALID_PARAMETER;
+ }
+
+ std::string paramName = (*it).substr(0, pos) ; // Keep the parameter name in upper case
+ std::string paramValue = (*it).substr(pos+1, std::string::npos) ;
+
+ // Check whether the parameter is duplicate
+ if( paramsStr.size() != 0) {
+ size_t start = 0 ;
+ while( pos = paramsStr.find(paramName+"=", start), pos != std::string::npos ){
+ if( pos == 0 || paramsStr[pos-1] == char(' ') ) {
+ std::cerr << "Duplicate parameter : '" << paramName << "'"<< std::endl ;
+ return CLI_ERROR_INVALID_PARAMETER ;
+ }
+ start = pos + paramName.size() ;
+ }
+ paramsStr += " " ;
+ }
+ // Append the parameter
+ paramsStr += paramName + "=" + paramValue ;
+ }
+ return 0 ;
}
@@ -845,13 +809,16 @@ vishnu::validateParameters(const boost::shared_ptr<Options> & opt,
void
vishnu::appendFilesFromDir(ListStrings& lFiles, std::ostringstream & fileNames, const std::string & dirPath) {
- if( ! bfs::exists( dirPath ) ) return ;
- for( bfs::directory_iterator it(dirPath) ; it != bfs::directory_iterator() ; ++it ) {
+ if(dirPath.size() == 0 ||
+ ! bfs::exists(dirPath)) {
+ return ;
+ }
+ for( bfs::directory_iterator it(dirPath) ; it != bfs::directory_iterator() ; ++it ) {
- if ( bfs::is_directory( *it ) ) continue ;
- lFiles.push_back( it->path().string() ) ;
- fileNames << ((fileNames.str().size() != 0)? " " : "") + it->path().string() ; //TODO Check if it's a absolute or a relative path
- }
+ if ( bfs::is_directory( *it ) ) continue ;
+ lFiles.push_back( it->path().string() ) ;
+ fileNames << ((fileNames.str().size() != 0)? " " : "") + it->path().string() ; //TODO Check if it's a absolute or a relative path
+ }
}
@@ -863,17 +830,17 @@ vishnu::appendFilesFromDir(ListStrings& lFiles, std::ostringstream & fileNames,
void
vishnu::createOutputDir(std::string& dirPath) {
- if(bfs::exists(dirPath) && bfs::is_directory(dirPath)) {
- return ;
- }
+ if(bfs::exists(dirPath) && bfs::is_directory(dirPath)) {
+ return ;
+ }
- try{
- if(! bfs::create_directory(bfs::path(dirPath))) {
- throw SystemException(ERRCODE_SYSTEM, "vishnu::createDir: Cannot create the directory: " + dirPath) ;
- }
- } catch(...) {
- throw SystemException(ERRCODE_SYSTEM, "Directory creation failed") ;
- }
+ try{
+ if(! bfs::create_directory(bfs::path(dirPath))) {
+ throw SystemException(ERRCODE_SYSTEM, "vishnu::createDir: Cannot create the directory: " + dirPath) ;
+ }
+ } catch(...) {
+ throw SystemException(ERRCODE_SYSTEM, "Directory creation failed") ;
+ }
}
/**
@@ -883,20 +850,20 @@ vishnu::createOutputDir(std::string& dirPath) {
std::string
vishnu::createSuffixFromCurTime() {
- std::ostringstream ossBuf ;
- time_t rawtime;
- time ( &rawtime );
- struct tm * tinfo;
- tinfo = localtime ( &rawtime );
+ std::ostringstream ossBuf ;
+ time_t rawtime;
+ time ( &rawtime );
+ struct tm * tinfo;
+ tinfo = localtime ( &rawtime );
- ossBuf << "_" << (1900 + tinfo->tm_year)
- << ( tinfo->tm_mon < 9? "0": "")<< tinfo->tm_mon + 1
- << ( tinfo->tm_mday < 10? "0": "" )<< tinfo->tm_mday
- << ( tinfo->tm_hour < 10? "0": "" )<< tinfo->tm_hour
- << ( tinfo->tm_min < 10? "0": "" )<< tinfo->tm_min
- << ( tinfo->tm_sec < 10? "0": "" )<< tinfo->tm_sec ;
+ ossBuf << "_" << (1900 + tinfo->tm_year)
+ << ( tinfo->tm_mon < 9? "0": "")<< tinfo->tm_mon + 1
+ << ( tinfo->tm_mday < 10? "0": "" )<< tinfo->tm_mday
+ << ( tinfo->tm_hour < 10? "0": "" )<< tinfo->tm_hour
+ << ( tinfo->tm_min < 10? "0": "" )<< tinfo->tm_min
+ << ( tinfo->tm_sec < 10? "0": "" )<< tinfo->tm_sec ;
- return ossBuf.str() ;
+ return ossBuf.str() ;
}
/**
@@ -908,81 +875,81 @@ vishnu::createSuffixFromCurTime() {
std::string
vishnu::mklink(const std::string& src) {
- if( ! bfs::exists(src) ) {
- throw UserException(ERRCODE_FILENOTFOUND, "SSHJobExec::mklink : "
- "the file "+ src + " doesnot exist.");
- }
- bfs::path dest ;
+ if( ! bfs::exists(src) ) {
+ throw UserException(ERRCODE_FILENOTFOUND, "SSHJobExec::mklink : "
+ "the file "+ src + " doesnot exist.");
+ }
+ bfs::path dest ;
- try {
- dest = bfs::unique_path("/tmp/vishnulink%%%%%%") ;
- bfs::create_symlink(src, dest) ;
- }catch (...) {
- throw SystemException(ERRCODE_SYSTEM, "SSHJobExec::mklink : "
- "error while making a link on the file " + src + " from " + dest.string());
- }
- return dest.string() ;
+ try {
+ dest = bfs::unique_path("/tmp/vishnulink%%%%%%") ;
+ bfs::create_symlink(src, dest) ;
+ }catch (...) {
+ throw SystemException(ERRCODE_SYSTEM, "SSHJobExec::mklink : "
+ "error while making a link on the file " + src + " from " + dest.string());
+ }
+ return dest.string() ;
}
// Cela fait une copie de la liste en retour, à modifier si cela gène
std::vector<std::string>
vishnu::getIPList(){
- std::vector<std::string> addresses;
-
- struct ifaddrs *ifa=NULL,*ifEntry=NULL;
- void *addPtr = NULL;
- int rc = 0;
- char addressBuffer[INET6_ADDRSTRLEN]; // Max size for ipv6 in case
-
- // Recuperation of the interfaces
- rc = getifaddrs(&ifa);
- // If interfaces gotten without error
- if (rc==0) {
- // Browing the list of interface
- for(ifEntry=ifa; ifEntry!=NULL; ifEntry=ifEntry->ifa_next) {
- // If not address continue
- if(ifEntry->ifa_addr->sa_data == NULL) {
- continue;
- }
- // If IPV4
- if(ifEntry->ifa_addr->sa_family==AF_INET) {
- addPtr = &((struct sockaddr_in *)ifEntry->ifa_addr)->sin_addr;
- } else {
- //It isn't IPv4
- continue;
- }
- // Converting address
- const char *a = inet_ntop(ifEntry->ifa_addr->sa_family,
- addPtr,
- addressBuffer,
- sizeof(addressBuffer));
- std::string localhost = "127.0.0.1";
- // Adding the found adress
- if(a != NULL && localhost.compare(std::string(a)) != 0) {
- addresses.push_back(std::string(a));
- }
- }
- }
- // Freeing memory
- freeifaddrs(ifa);
-
- return addresses;
+ std::vector<std::string> addresses;
+
+ struct ifaddrs *ifa=NULL,*ifEntry=NULL;
+ void *addPtr = NULL;
+ int rc = 0;
+ char addressBuffer[INET6_ADDRSTRLEN]; // Max size for ipv6 in case
+
+ // Recuperation of the interfaces
+ rc = getifaddrs(&ifa);
+ // If interfaces gotten without error
+ if (rc==0) {
+ // Browing the list of interface
+ for(ifEntry=ifa; ifEntry!=NULL; ifEntry=ifEntry->ifa_next) {
+ // If not address continue
+ if(ifEntry->ifa_addr->sa_data == NULL) {
+ continue;
+ }
+ // If IPV4
+ if(ifEntry->ifa_addr->sa_family==AF_INET) {
+ addPtr = &((struct sockaddr_in *)ifEntry->ifa_addr)->sin_addr;
+ } else {
+ //It isn't IPv4
+ continue;
+ }
+ // Converting address
+ const char *a = inet_ntop(ifEntry->ifa_addr->sa_family,
+ addPtr,
+ addressBuffer,
+ sizeof(addressBuffer));
+ std::string localhost = "127.0.0.1";
+ // Adding the found adress
+ if(a != NULL && localhost.compare(std::string(a)) != 0) {
+ addresses.push_back(std::string(a));
+ }
+ }
+ }
+ // Freeing memory
+ freeifaddrs(ifa);
+
+ return addresses;
}
void
vishnu::setIP(std::string& name, std::string IP){
- std::string tmp = std::string("localhost");
- name.replace(name.find(tmp), tmp.length(), IP);
+ std::string tmp = std::string("localhost");
+ name.replace(name.find(tmp), tmp.length(), IP);
}
bool
vishnu::isNotIP(std::string name){
- int pos=0;
- int cpt=0;
- while((pos=name.find(".", pos+1))!=std::string::npos) {
- cpt++;
- }
- return (cpt!=3);
+ size_t pos=0;
+ int cpt=0;
+ while((pos=name.find(".", pos+1))!=std::string::npos) {
+ cpt++;
+ }
+ return (cpt!=3);
}
/**
@@ -992,37 +959,37 @@ vishnu::isNotIP(std::string name){
*/
UMS_Data::Version_ptr
vishnu::parseVersion(const std::string& version) {
- UMS_Data::Version_ptr vers = NULL;
- std::string major;
- std::string minor;
- std::string patch;
-
- size_t found = version.find_first_of(".");
- if (found != std::string::npos) {
- major = version.substr(0, found) ;
- std::string rest = version.substr(found+1, version.size()) ;
- found = rest.find_first_of(".");
- if (found != std::string::npos) {
- minor = rest.substr(0, found);
- patch = rest.substr(found+1, rest.size());
- }
- //if the string major, minor, patch are not empty
- if ((major.size() != 0) && (minor.size() != 0)
- && (patch.size() != 0)) {
- //if the values major, minor, patch are positives and major value higher than zero
- if ((convertToInt(major) > 0) && (convertToInt(minor) >= 0)
- && (convertToInt(patch) >= 0)) {
- UMS_Data::UMS_DataFactory_ptr ecoreFactory = UMS_Data::UMS_DataFactory::_instance();
- vers = ecoreFactory->createVersion();
- vers->setMajor(convertToInt(major));
- vers->setMinor(convertToInt(minor));
- vers->setPatch(convertToInt(patch));
- vers->setStringformat(version);
- }
- }
- }
-
- return vers;
+ UMS_Data::Version_ptr vers = NULL;
+ std::string major;
+ std::string minor;
+ std::string patch;
+
+ size_t found = version.find_first_of(".");
+ if (found != std::string::npos) {
+ major = version.substr(0, found) ;
+ std::string rest = version.substr(found+1, version.size()) ;
+ found = rest.find_first_of(".");
+ if (found != std::string::npos) {
+ minor = rest.substr(0, found);
+ patch = rest.substr(found+1, rest.size());
+ }
+ //if the string major, minor, patch are not empty
+ if ((major.size() != 0) && (minor.size() != 0)
+ && (patch.size() != 0)) {
+ //if the values major, minor, patch are positives and major value higher than zero
+ if ((convertToInt(major) > 0) && (convertToInt(minor) >= 0)
+ && (convertToInt(patch) >= 0)) {
+ UMS_Data::UMS_DataFactory_ptr ecoreFactory = UMS_Data::UMS_DataFactory::_instance();
+ vers = ecoreFactory->createVersion();
+ vers->setMajor(convertToInt(major));
+ vers->setMinor(convertToInt(minor));
+ vers->setPatch(convertToInt(patch));
+ vers->setStringformat(version);
+ }
+ }
+ }
+
+ return vers;
}
Attachment 145:
diff --git a/TMS/src/sed/internalApi.cpp b/TMS/src/sed/internalApi.cpp
index 4a42108..f012c5d 100644
--- a/TMS/src/sed/internalApi.cpp
+++ b/TMS/src/sed/internalApi.cpp
@@ -555,20 +555,21 @@ solveJobOutPutGetResult(diet_profile_t* pb) {
ListStrings filePaths;
std::ostringstream ossFileName("");
+
ossFileName << result.getJobId(); /* each line starts with the associated job id */
- if( bfs::exists(result.getOutputPath())) {
- filePaths.push_back(result.getOutputPath());
- ossFileName << " " << result.getJobId() << ".stdout";
- } else {
- throw SystemException(ERRCODE_INVDATA, "The output file does not longer exist "+result.getErrorPath());
- }
- if( bfs::exists(result.getErrorPath())) {
- filePaths.push_back(result.getErrorPath());
- ossFileName << " " << result.getJobId() << ".stderr";
- } else {
- throw SystemException(ERRCODE_INVDATA, "The error file does not longer exist "+result.getErrorPath());
+
+ filePaths.push_back(result.getOutputPath());
+ ossFileName << " " << result.getJobId() << ".stdout";
+
+ filePaths.push_back(result.getErrorPath());
+ ossFileName << " " << result.getJobId() << ".stderr";
+
+ try {
+ vishnu::appendFilesFromDir(filePaths, ossFileName, result.getOutputDir());
+ } catch (...) {
+ throw UserException(ERRCODE_RUNTIME_ERROR, "Unable to read the output directory " + result.getOutputDir());
}
- vishnu::appendFilesFromDir(filePaths, ossFileName, result.getOutputDir());
+
ossFileName << std::endl;
char* fileNamesDescr = strdup("/tmp/vishnu-fdescXXXXXX");
@@ -673,15 +674,17 @@ solveJobOutPutGetCompletedJobs(diet_profile_t* pb) {
TMS_Data::JobResult_ptr result = completedJobsOutput->getResults().get(i);
ossFileName << result->getJobId(); /* each line starts with the associated job id */
- if( bfs::exists( result->getOutputPath() ) ) {
- filePaths.push_back( result->getOutputPath() );
- ossFileName << " " << result->getJobId() << ".stdout";
- }
- if( bfs::exists( result->getErrorPath() ) ) {
- filePaths.push_back( result->getErrorPath() );
- ossFileName << " " << result->getJobId() << ".stderr";
+
+ filePaths.push_back( result->getOutputPath() );
+ ossFileName << " " << result->getJobId() << ".stdout";
+
+ filePaths.push_back( result->getErrorPath() );
+ ossFileName << " " << result->getJobId() << ".stderr";
+ try {
+ vishnu::appendFilesFromDir(filePaths, ossFileName, result->getOutputDir());
+ } catch (...) {
+ throw UserException(ERRCODE_RUNTIME_ERROR, "Unable to read the output directory " + result->getOutputDir());
}
- vishnu::appendFilesFromDir(filePaths, ossFileName, result->getOutputDir());
ossFileName << std::endl;
}
@@ -725,6 +728,8 @@ solveJobOutPutGetCompletedJobs(diet_profile_t* pb) {
dagda_put_file(strdup(outputPath.c_str()), DIET_PERSISTENT_RETURN, &ID);
dagda_add_container_element((*diet_parameter(pb,5)).desc.id, ID, 0);
+ } catch(...) {
+ throw(ERRCODE_RUNTIME_ERROR, "unable to complete the operation due to an unknown error");
}
return 0;
}
diff --git a/core/src/utils/utilVishnu.cpp b/core/src/utils/utilVishnu.cpp
index ee6f09d..986634c 100644
--- a/core/src/utils/utilVishnu.cpp
+++ b/core/src/utils/utilVishnu.cpp
@@ -845,13 +845,16 @@ vishnu::validateParameters(const boost::shared_ptr<Options> & opt,
void
vishnu::appendFilesFromDir(ListStrings& lFiles, std::ostringstream & fileNames, const std::string & dirPath) {
- if( ! bfs::exists( dirPath ) ) return ;
- for( bfs::directory_iterator it(dirPath) ; it != bfs::directory_iterator() ; ++it ) {
-
- if ( bfs::is_directory( *it ) ) continue ;
- lFiles.push_back( it->path().string() ) ;
- fileNames << ((fileNames.str().size() != 0)? " " : "") + it->path().string() ; //TODO Check if it's a absolute or a relative path
- }
+ if(dirPath.size() == 0 ||
+ ! bfs::exists(dirPath)) {
+ return ;
+ }
+ for( bfs::directory_iterator it(dirPath) ; it != bfs::directory_iterator() ; ++it ) {
+
+ if ( bfs::is_directory( *it ) ) continue ;
+ lFiles.push_back( it->path().string() ) ;
+ fileNames << ((fileNames.str().size() != 0)? " " : "") + it->path().string() ; //TODO Check if it's a absolute or a relative path
+ }
}
critical bug in component TMS Reported in version 2.0.0 beta2 on platform Other