// export input files on cluster
- // This part will be removed in the final version
- copyInputFilesFromLocalToVishnu(job);
- // This part will be kept in the final version
copyInputFilesFromVishnuToCluster(job);
- // build command file to submit the job and copy it on the server
+ // build command file to submit the job
string cmdFile = buildCommandFile(job);
// define name of log file (local)
string logFile = generateTemporaryFileName("vishnu-submitlog");
// define command to submit batch
- string subCommand = string("cd ") + params[VISHNU_HOST_WORKDIR].str() + "; ";
- subCommand += ". ~/.vishnu/vishnu.env ;";
- subCommand += "vishnu_connect -p 2 " + _username +
- " -w " + params[VISHNU_PASSWORD].str() + "; ";
+ string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; ");
+ subCommand += "vishnu_connect; ";
subCommand += "vishnu_submit_job " + _hostname + " " + cmdFile;
string command = _protocol.getExecCommand(subCommand,
- params[VISHNU_HOST_NAME],
- params[VISHNU_HOST_LOGIN]);
+ _hostname,
+ _username);
command += " > ";
command += logFile;
cerr << command.c_str() << endl;
if (jobref.size() == 0)
throw EmulationException("Error in the submission of the job on the remote host");
- // Store the Vishnu password, host name and login with the jobId in the job reference
- // (for further queries)
- jobref = params[VISHNU_PASSWORD].str() + ":" + params[VISHNU_HOST_NAME].str() + ":" + \
- params[VISHNU_HOST_LOGIN].str() + ":" + jobref;
JobId id(this, jobref);
return id;
}
- void BatchManager_eVishnu::copyInputFilesFromLocalToVishnu(const Job& job)
- {
- int status;
- Parametre params = job.getParametre();
- const Versatile & V = params[INFILE];
- Versatile::const_iterator Vit;
-
- // Create working directory on Vishnu host
- status = _protocol.makeDirectory(params[VISHNU_HOST_WORKDIR],
- params[VISHNU_HOST_NAME],
- params[VISHNU_HOST_LOGIN]);
- if(status) {
- std::ostringstream oss;
- oss << status;
- std::string ex_mess("Error of connection on remote host ! status = ");
- ex_mess += oss.str();
- throw EmulationException(ex_mess.c_str());
- }
-
- // copy executable
- string executeFile = params[EXECUTABLE];
- if (executeFile.size() != 0) {
- status = _protocol.copyFile(executeFile, "", "",
- params[VISHNU_HOST_WORKDIR],
- params[VISHNU_HOST_NAME],
- params[VISHNU_HOST_LOGIN]);
- if(status) {
- std::ostringstream oss;
- oss << status;
- std::string ex_mess("Error of connection on remote host ! status = ");
- ex_mess += oss.str();
- throw EmulationException(ex_mess.c_str());
- }
-
- }
-
- // copy filesToExportList
- for(Vit=V.begin(); Vit!=V.end(); Vit++) {
- CoupleType cpt = *static_cast< CoupleType * >(*Vit);
- Couple inputFile = cpt;
-
- // remote file -> transform to get path on Vishnu host
- size_t found = inputFile.getRemote().find_last_of("/");
- string remote = params[VISHNU_HOST_WORKDIR].str() + "/" + inputFile.getRemote().substr(found+1);
-
- status = _protocol.copyFile(inputFile.getLocal(), "", "",
- remote,
- params[VISHNU_HOST_NAME],
- params[VISHNU_HOST_LOGIN]);
- if(status) {
- std::ostringstream oss;
- oss << status;
- std::string ex_mess("Error of connection on remote host ! status = ");
- ex_mess += oss.str();
- throw EmulationException(ex_mess.c_str());
- }
- }
-
- }
-
void BatchManager_eVishnu::copyInputFilesFromVishnuToCluster(const Job& job)
{
int status;
Versatile::const_iterator Vit;
// create remote directories
- string subCommand = ". ~/.vishnu/vishnu.env ;";
- subCommand += "vishnu_connect -p 2 " + _username + " -w " + params[VISHNU_PASSWORD].str() + "; ";
+ string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; ");
+ subCommand += "vishnu_connect; ";
subCommand += "vishnu_create_dir " + _hostname + ":" + params[WORKDIR].str() + "; ";
subCommand += "vishnu_create_dir " + _hostname + ":" + params[WORKDIR].str() + "/logs";
string command = _protocol.getExecCommand(subCommand,
- params[VISHNU_HOST_NAME],
- params[VISHNU_HOST_LOGIN]);
+ _hostname,
+ _username);
cerr << command.c_str() << endl;
status = system(command.c_str());
if (status != 0)
string executeFile = params[EXECUTABLE];
if (executeFile.size() != 0) {
- // transform to get path on Vishnu host
- size_t found = executeFile.find_last_of("/");
- string origin = params[VISHNU_HOST_WORKDIR].str() + "/" + executeFile.substr(found+1);
-
- string subCommand = ". ~/.vishnu/vishnu.env ;";
- subCommand += "vishnu_connect -p 2 " + _username + " -w " + params[VISHNU_PASSWORD].str() + "; ";
- subCommand += "vishnu_copy_file " + origin + " " + _hostname + ":" + params[WORKDIR].str();
+ string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; ");
+ subCommand += "vishnu_connect; ";
+ subCommand += "vishnu_copy_file " + executeFile + " " + _hostname + ":" + params[WORKDIR].str() + "/";
string command = _protocol.getExecCommand(subCommand,
- params[VISHNU_HOST_NAME],
- params[VISHNU_HOST_LOGIN]);
+ _hostname,
+ _username);
cerr << command.c_str() << endl;
status = system(command.c_str());
if (status != 0)
CoupleType cpt = *static_cast< CoupleType * >(*Vit);
Couple inputFile = cpt;
- // transform to get path on Vishnu host
- size_t found = inputFile.getRemote().find_last_of("/");
- string origin = params[VISHNU_HOST_WORKDIR].str() + "/" + inputFile.getRemote().substr(found+1);
-
- string subCommand = ". ~/.vishnu/vishnu.env ;";
- subCommand += "vishnu_connect -p 2 " + _username + " -w " + params[VISHNU_PASSWORD].str() + "; ";
- subCommand += "vishnu_copy_file " + origin + " " + _hostname + ":" + inputFile.getRemote();
+ string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; ");
+ subCommand += "vishnu_connect; ";
+ subCommand += "vishnu_copy_file " + inputFile.getLocal() + " " + _hostname + ":" + params[WORKDIR].str() + "/" + inputFile.getRemote();
string command = _protocol.getExecCommand(subCommand,
- params[VISHNU_HOST_NAME],
- params[VISHNU_HOST_LOGIN]);
+ _hostname,
+ _username);
cerr << command.c_str() << endl;
status = system(command.c_str());
if (status != 0)
string remoteFileName = rootNameToExecute + "_vishnu";
int status = _protocol.copyFile(tmpFileName, "", "",
- params[VISHNU_HOST_WORKDIR].str() + "/" + remoteFileName,
- params[VISHNU_HOST_NAME],
- params[VISHNU_HOST_LOGIN]);
+ remoteFileName,
+ _hostname,
+ _username);
if (status)
throw EmulationException("Cannot copy command file on host " + _hostname);
void BatchManager_eVishnu::deleteJob(const JobId & jobid)
{
- // split job reference in Vishnu password / host name / host login / jobId
- string vishnuPassword, vishnuHostName, vishnuHostLogin, vishnuJobId;
+ string vishnuJobId;
istringstream iss(jobid.getReference());
- getline(iss, vishnuPassword, ':');
- getline(iss, vishnuHostName, ':');
- getline(iss, vishnuHostLogin, ':');
getline(iss, vishnuJobId, ':');
// define command to delete job
- string subCommand = ". ~/.vishnu/vishnu.env ;";
- subCommand += "vishnu_connect -p 2 " + _username + " -w " + vishnuPassword + "; ";
+ string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; ");
+ subCommand += "vishnu_connect; ";
subCommand += "vishnu_cancel_job " + _hostname + " " + vishnuJobId;
- string command = _protocol.getExecCommand(subCommand, vishnuHostName, vishnuHostLogin);
+ string command = _protocol.getExecCommand(subCommand, _hostname, _username);
cerr << command.c_str() << endl;
int status = system(command.c_str());
// define name of log file (local)
string logFile = generateTemporaryFileName("vishnu-querylog-" + jobid.getReference());
- // split job reference in Vishnu password / host name / host login / jobId
- string vishnuPassword, vishnuHostName, vishnuHostLogin, vishnuJobId;
+ string vishnuJobId;
istringstream iss(jobid.getReference());
- getline(iss, vishnuPassword, ':');
- getline(iss, vishnuHostName, ':');
- getline(iss, vishnuHostLogin, ':');
getline(iss, vishnuJobId, ':');
// define command to query batch
- string subCommand = ". ~/.vishnu/vishnu.env ;";
- subCommand += "vishnu_connect -p 2 " + _username + " -w " + vishnuPassword + "; ";
+ string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; ");
+ subCommand += "vishnu_connect; ";
subCommand += "vishnu_get_job_info " + _hostname + " " + vishnuJobId;
- string command = _protocol.getExecCommand(subCommand, vishnuHostName, vishnuHostLogin);
+ string command = _protocol.getExecCommand(subCommand, _hostname, _username);
command += " > ";
command += logFile;
cerr << command.c_str() << endl;
void BatchManager_eVishnu::importOutputFiles(const Job & job, const std::string directory)
{
- // This part will be kept in the final version
copyOutputFilesFromClusterToVishnu(job);
-
- // This part will be removed in the final version
- copyOutputFilesFromVishnuToLocal(job, directory);
}
void BatchManager_eVishnu::copyOutputFilesFromClusterToVishnu(const Job & job)
CoupleType cpt = *static_cast< CoupleType * >(*Vit);
Couple outputFile = cpt;
- // transform to get path on Vishnu host
- size_t found = outputFile.getRemote().find_last_of("/");
- string dest = params[VISHNU_HOST_WORKDIR].str() + "/" + outputFile.getRemote().substr(found+1);
-
- string subCommand = ". ~/.vishnu/vishnu.env ;";
- subCommand += "vishnu_connect -p 2 " + _username + " -w " + params[VISHNU_PASSWORD].str() + "; ";
- subCommand += "vishnu_copy_file " + _hostname + ":" + outputFile.getRemote() + " " + dest;
+ string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; ");
+ subCommand += "vishnu_connect; ";
+ subCommand += "vishnu_copy_file " + _hostname + ":" + params[WORKDIR].str() + "/" + outputFile.getRemote() + " " + outputFile.getLocal();
string command = _protocol.getExecCommand(subCommand,
- params[VISHNU_HOST_NAME],
- params[VISHNU_HOST_LOGIN]);
+ _hostname,
+ _username);
cerr << command.c_str() << endl;
status = system(command.c_str());
if (status != 0)
}
// Copy logs
- string subCommand = ". ~/.vishnu/vishnu.env ;";
- subCommand += "vishnu_connect -p 2 " + _username + " -w " + params[VISHNU_PASSWORD].str() + "; ";
- subCommand += "vishnu_copy_file -r " +_hostname + ":" + params[WORKDIR].str() + "/logs" + " " + \
- params[VISHNU_HOST_WORKDIR].str();
+ string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; ");
+ subCommand += "vishnu_connect; ";
+ subCommand += "vishnu_copy_file -r " +_hostname + ":" + params[WORKDIR].str() + "/logs" + " .";
string command = _protocol.getExecCommand(subCommand,
- params[VISHNU_HOST_NAME],
- params[VISHNU_HOST_LOGIN]);
+ _hostname,
+ _username);
cerr << command.c_str() << endl;
status = system(command.c_str());
if (status != 0)
throw EmulationException("Can't copy logs");
}
- void BatchManager_eVishnu::copyOutputFilesFromVishnuToLocal(const Job & job,
- const std::string directory)
- {
- Parametre params = job.getParametre();
- const Versatile & V = params[OUTFILE];
- Versatile::const_iterator Vit;
-
- // Create local result directory
- int status = CommunicationProtocol::getInstance(SH).makeDirectory(directory, "", "");
- if (status) {
- string mess("Directory creation failed. Status is :");
- ostringstream status_str;
- status_str << status;
- mess += status_str.str();
- cerr << mess << endl;
- }
-
- for(Vit=V.begin(); Vit!=V.end(); Vit++) {
- CoupleType cpt = *static_cast< CoupleType * >(*Vit);
- Couple outputFile = cpt;
-
- // remote file -> transform to get path on Vishnu host
- size_t found = outputFile.getRemote().find_last_of("/");
- string remote = params[VISHNU_HOST_WORKDIR].str() + "/" + outputFile.getRemote().substr(found+1);
-
- status = _protocol.copyFile(remote,
- params[VISHNU_HOST_NAME],
- params[VISHNU_HOST_LOGIN],
- directory, "", "");
- if (status) {
- // Try to get what we can (logs files)
- // throw BatchException("Error of connection on remote host");
- std::string mess("Copy command failed ! status is :");
- ostringstream status_str;
- status_str << status;
- mess += status_str.str();
- cerr << mess << endl;
- }
- }
-
- // Copy logs
- status = _protocol.copyFile(params[VISHNU_HOST_WORKDIR].str() + "/logs",
- params[VISHNU_HOST_NAME],
- params[VISHNU_HOST_LOGIN],
- directory, "", "");
- if (status) {
- std::string mess("Copy logs directory failed ! status is :");
- ostringstream status_str;
- status_str << status;
- mess += status_str.str();
- cerr << mess << endl;
- }
- }
-
}