Salome HOME
Merge branch 'omu/launcher_evol'
[modules/kernel.git] / src / Launcher / SALOME_Launcher.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 4fc419d..cc7129b
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #include "BatchTest.hxx"
 #include "OpUtil.hxx"
 #include "SALOME_ContainerManager.hxx"
+#include "SALOME_NamingService.hxx"
+#include "SALOME_ResourcesManager.hxx"
 #include "Utils_CorbaException.hxx"
 
 
 #include "Launcher_Job_Command.hxx"
 #include "Launcher_Job_YACSFile.hxx"
 #include "Launcher_Job_PythonSALOME.hxx"
+#include "Launcher_Job_CommandSALOME.hxx"
+
+#include "utilities.h"
 
 #ifdef WIN32
 # include <process.h>
@@ -59,7 +64,7 @@ SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa
   _NS = new SALOME_NamingService(orb);
   _ResManager = new SALOME_ResourcesManager(orb,poa,_NS);
   _l.SetResourcesManager(_ResManager->GetImpl());
-  _ContManager = new SALOME_ContainerManager(orb,poa,_ResManager,_NS);
+  _ContManager = new SALOME_ContainerManager(orb,poa,_NS);
   _ResManager->_remove_ref();
   _ContManager->_remove_ref();
 
@@ -91,21 +96,22 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters)
 {
   std::string job_type = job_parameters.job_type.in();
 
-  if (job_type != "command" && job_type != "yacs_file" && job_type != "python_salome")
-  {
-    std::string message("SALOME_Launcher::createJob: bad job type: ");
-    message += job_type;
-    THROW_SALOME_CORBA_EXCEPTION(message.c_str(), SALOME::INTERNAL_ERROR);
-  }
-
   Launcher::Job * new_job; // It is Launcher_cpp that is going to destroy it
 
-  if (job_type == "command")
+  if (job_type == Launcher::Job_Command::TYPE_NAME)
     new_job = new Launcher::Job_Command();
-  else if (job_type == "yacs_file")
+  else if (job_type == Launcher::Job_CommandSALOME::TYPE_NAME)
+    new_job = new Launcher::Job_CommandSALOME();
+  else if (job_type == Launcher::Job_YACSFile::TYPE_NAME)
     new_job = new Launcher::Job_YACSFile();
-  else if (job_type == "python_salome")
+  else if (job_type == Launcher::Job_PythonSALOME::TYPE_NAME)
     new_job = new Launcher::Job_PythonSALOME();
+  else
+  {
+    std::string message("SALOME_Launcher::createJob: bad job type: ");
+    message += job_type;
+    THROW_SALOME_CORBA_EXCEPTION(message.c_str(), SALOME::INTERNAL_ERROR);
+  }
 
   // Name
   new_job->setJobName(job_parameters.job_name.in());
@@ -135,6 +141,7 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters)
     INFOS(ex.msg.c_str());
     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
   }
+  new_job->setPreCommand(job_parameters.pre_command.in());
 
   // Files
   std::string env_file = job_parameters.env_file.in();
@@ -159,12 +166,24 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters)
   std::string queue = job_parameters.queue.in();
   new_job->setQueue(queue);
 
+  // Partition
+  std::string partition = job_parameters.partition.in();
+  new_job->setPartition(partition);
+
   // Exclusive
   new_job->setExclusive(job_parameters.exclusive);
 
   // Memory required per CPU
   new_job->setMemPerCpu(job_parameters.mem_per_cpu);
 
+  // WC Key
+  std::string wckey = job_parameters.wckey.in();
+  new_job->setWCKey(wckey);
+
+  // Extra params
+  std::string extra_params = job_parameters.extra_params.in();
+  new_job->setExtraParams(extra_params);
+
   // Resources requirements
   try
   {
@@ -274,6 +293,20 @@ SALOME_Launcher::getJobResults(CORBA::Long job_id, const char * directory)
   }
 }
 
+void
+SALOME_Launcher::clearJobWorkingDir(CORBA::Long job_id)
+{
+  try
+  {
+    _l.clearJobWorkingDir(job_id);
+  }
+  catch(const LauncherException &ex)
+  {
+    INFOS(ex.msg.c_str());
+    THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
+  }
+}
+
 CORBA::Boolean
 SALOME_Launcher::getJobDumpState(CORBA::Long job_id, const char * directory)
 {
@@ -290,6 +323,22 @@ SALOME_Launcher::getJobDumpState(CORBA::Long job_id, const char * directory)
   return rtn;
 }
 
+CORBA::Boolean
+SALOME_Launcher::getJobWorkFile(CORBA::Long job_id, const char * work_file, const char * directory)
+{
+  CORBA::Boolean rtn = false;
+  try
+  {
+    rtn = _l.getJobWorkFile(job_id, work_file, directory);
+  }
+  catch(const LauncherException &ex)
+  {
+    INFOS(ex.msg.c_str());
+    THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
+  }
+  return rtn;
+}
+
 void 
 SALOME_Launcher::removeJob(CORBA::Long job_id)
 {
@@ -328,7 +377,7 @@ SALOME_Launcher::stopJob(CORBA::Long job_id)
 /*! CORBA Method:
  *  Create a job in the launcher with a file
  *  \param xmlExecuteFile     : .xml to parse that contains job description
- *  \param clusterName        : machine choosed
+ *  \param clusterName        : machine chosen
  */
 //=============================================================================
 CORBA::Long 
@@ -476,6 +525,7 @@ SALOME_Launcher::getJobParameters(CORBA::Long job_id)
   job_parameters->work_directory   = CORBA::string_dup(job->getWorkDirectory().c_str());
   job_parameters->local_directory  = CORBA::string_dup(job->getLocalDirectory().c_str());
   job_parameters->result_directory = CORBA::string_dup(job->getResultDirectory().c_str());
+  job_parameters->pre_command      = CORBA::string_dup(job->getPreCommand().c_str());
 
   // Parameters for COORM
   job_parameters->launcher_file = CORBA::string_dup(job->getLauncherFile().c_str());
@@ -500,8 +550,11 @@ SALOME_Launcher::getJobParameters(CORBA::Long job_id)
 
   job_parameters->maximum_duration = CORBA::string_dup(job->getMaximumDuration().c_str());
   job_parameters->queue            = CORBA::string_dup(job->getQueue().c_str());
+  job_parameters->partition        = CORBA::string_dup(job->getPartition().c_str());
   job_parameters->exclusive        = job->getExclusive();
   job_parameters->mem_per_cpu      = job->getMemPerCpu();
+  job_parameters->wckey            = CORBA::string_dup(job->getWCKey().c_str());
+  job_parameters->extra_params     = CORBA::string_dup(job->getExtraParams().c_str());
 
   resourceParams resource_params = job->getResourceRequiredParams();
   job_parameters->resource_required.name             = CORBA::string_dup(resource_params.name.c_str());