Salome HOME
2082b221e744d910eba0a61b4b26c8911a11147c
[modules/jobmanager.git] / src / engine / BL_SALOMEServices.cxx
1 // Copyright (C) 2009-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "BL_SALOMEServices.hxx"
21 #include <sstream>
22
23 static std::ostream & 
24 operator<<(std::ostream & os, const CORBA::Exception & e)
25 {
26   CORBA::Any tmp;
27   tmp <<=e ;
28   CORBA::TypeCode_var tc = tmp.type();
29   const char * p = tc->name ();
30   if (*p != '\0')
31     os << p;
32   else
33     os << tc->id();
34   return os;
35 }
36
37 BL::SALOMEServices::SALOMEServices()
38 {
39   int nbargs = 0; char **args = 0;
40   _orb = CORBA::ORB_init (nbargs, args);
41   _salome_naming_service = NULL;
42   _lcc = NULL;
43   _state = false;
44   _manager = NULL;
45 }
46
47 BL::SALOMEServices::~SALOMEServices() {}
48
49 void
50 BL::SALOMEServices::end()
51 {
52   if (!CORBA::is_nil(_salome_launcher))
53     _salome_launcher->removeObserver(_this());
54   if (_salome_naming_service)
55     delete _salome_naming_service;
56   if (_lcc)
57     delete _lcc;
58 }
59
60 bool
61 BL::SALOMEServices::initNS()
62 {
63   bool return_value = true;
64   _salome_naming_service = new SALOME_NamingService(_orb);
65   _lcc = new SALOME_LifeCycleCORBA(_salome_naming_service);
66   CORBA::Object_var obj = _salome_naming_service->Resolve("/SalomeLauncher");
67   _salome_launcher = Engines::SalomeLauncher::_narrow(obj);
68
69   if (CORBA::is_nil(_salome_launcher))
70   {
71     DEBMSG("SALOME Launcher is not reachable!")
72     return_value = false;
73   }
74   _salome_launcher->addObserver(_this());
75   _remove_ref(); // POA will automatically destroy the object
76
77   obj = _salome_naming_service->Resolve("/ResourcesManager");
78   _resources_manager = Engines::ResourcesManager::_narrow(obj);
79   if (CORBA::is_nil(_resources_manager))
80   {
81     DEBMSG("SALOME Resource Manager is not reachable !");
82     return_value = false;
83   }
84
85   _state = return_value;
86   return return_value;
87 }
88
89 std::list<std::string> 
90 BL::SALOMEServices::getResourceList(bool batch_only)
91 {
92   std::list<std::string> resource_list;
93   
94   if (_state)
95   {
96     Engines::ResourceParameters params;
97     _lcc->preSet(params);
98     params.can_launch_batch_jobs = batch_only;
99     Engines::ResourceList * resourceList = NULL;
100     try
101     {
102       resourceList = _resources_manager->GetFittingResources(params);
103     }
104     catch (const SALOME::SALOME_Exception & ex)
105     {
106       DEBMSG("SALOME Exception in addResource ! " << ex.details.text.in());
107     }
108     catch (const CORBA::SystemException& ex)
109     {
110       DEBMSG("Receive SALOME System Exception: " << ex);
111       DEBMSG("Check SALOME servers...");
112     }
113     if (resourceList)
114     {
115       for (int i = 0; i < resourceList->length(); i++)
116       {
117         const char* aResource = (*resourceList)[i];
118         resource_list.push_back(aResource);
119       }
120       delete resourceList;
121     }
122   }
123   return resource_list;
124 }
125
126 BL::ResourceDescr
127 BL::SALOMEServices::getResourceDescr(const std::string& name)
128 {
129   Engines::ResourceDefinition * resource_definition = NULL;
130   BL::ResourceDescr resource_descr;
131
132   try 
133   {
134     resource_definition = _resources_manager-> GetResourceDefinition(name.c_str());
135   }
136   catch (const SALOME::SALOME_Exception & ex)
137   {
138     DEBMSG("SALOME Exception in addResource ! " << ex.details.text.in());
139   }
140   catch (const CORBA::SystemException& ex)
141   {
142     DEBMSG("Receive SALOME System Exception: " << ex);
143     DEBMSG("Check SALOME servers...");
144   }
145
146   if(resource_definition)
147   {
148     resource_descr.name = resource_definition->name.in();
149     resource_descr.hostname = resource_definition->hostname.in();
150     resource_descr.protocol = resource_definition->protocol.in();
151     resource_descr.username = resource_definition->username.in();
152     resource_descr.applipath = resource_definition->applipath.in();
153     for (int i = 0; i < resource_definition->componentList.length(); i++)
154     {
155       resource_descr.componentList.push_back(resource_definition->componentList[i].in());
156     }
157
158     resource_descr.OS = resource_definition->OS.in();
159     resource_descr.mem_mb = resource_definition->mem_mb;
160     resource_descr.cpu_clock = resource_definition->cpu_clock;
161     resource_descr.nb_node = resource_definition->nb_node;
162     resource_descr.nb_proc_per_node = resource_definition->nb_proc_per_node;
163     resource_descr.batch = resource_definition->batch.in();
164     resource_descr.mpiImpl = resource_definition->mpiImpl.in();
165     resource_descr.iprotocol = resource_definition->iprotocol.in();
166     resource_descr.can_launch_batch_jobs = resource_definition->can_launch_batch_jobs;
167     resource_descr.can_run_containers = resource_definition->can_run_containers;
168     resource_descr.working_directory = resource_definition->working_directory.in();
169
170     delete resource_definition;
171   }
172   return resource_descr;
173 }
174
175 void
176 BL::SALOMEServices::addResource(BL::ResourceDescr & new_resource)
177 {
178   Engines::ResourceDefinition_var resource_definition = new Engines::ResourceDefinition;
179
180   resource_definition->name = CORBA::string_dup(new_resource.name.c_str());
181   resource_definition->hostname = CORBA::string_dup(new_resource.hostname.c_str());
182   if (new_resource.batch == "none")
183     resource_definition->type = CORBA::string_dup("single_machine");
184   else
185     resource_definition->type = CORBA::string_dup("cluster");
186   resource_definition->protocol = CORBA::string_dup(new_resource.protocol.c_str());
187   resource_definition->username = CORBA::string_dup(new_resource.username.c_str());
188   resource_definition->applipath = CORBA::string_dup(new_resource.applipath.c_str());
189
190   int i = 0;
191   std::list<std::string>::iterator it = new_resource.componentList.begin();
192   resource_definition->componentList.length(new_resource.componentList.size());
193   for(; it != new_resource.componentList.end(); it++)
194   {
195     resource_definition->componentList[i] = CORBA::string_dup((*it).c_str());
196     i++;
197   }
198
199   resource_definition->OS = CORBA::string_dup(new_resource.OS.c_str());
200   resource_definition->mem_mb = new_resource.mem_mb;
201   resource_definition->cpu_clock = new_resource.cpu_clock;
202   resource_definition->nb_node = new_resource.nb_node;
203   resource_definition->nb_proc_per_node = new_resource.nb_proc_per_node;  
204   resource_definition->batch = CORBA::string_dup(new_resource.batch.c_str());
205   resource_definition->mpiImpl = CORBA::string_dup(new_resource.mpiImpl.c_str());
206   resource_definition->iprotocol = CORBA::string_dup(new_resource.iprotocol.c_str());
207   resource_definition->can_launch_batch_jobs = new_resource.can_launch_batch_jobs;
208   resource_definition->can_run_containers = new_resource.can_run_containers;
209   resource_definition->working_directory = CORBA::string_dup(new_resource.working_directory.c_str());
210
211   try
212   {
213     _resources_manager->AddResource(resource_definition, true, "");
214   }
215   catch (const SALOME::SALOME_Exception & ex)
216   {
217     DEBMSG("SALOME Exception in addResource ! " << ex.details.text.in());
218     throw(BL::Exception(ex.details.text.in()));
219   }
220   catch (const CORBA::SystemException& ex)
221   {
222     DEBMSG("Receive SALOME System Exception: " << ex);
223     DEBMSG("Check SALOME servers...");
224     throw(BL::Exception("SALOME System Exception"));
225   }
226 }
227
228 void 
229 BL::SALOMEServices::removeResource(const std::string & name)
230 {
231   try
232   {
233     _resources_manager->RemoveResource(name.c_str(), true, "");
234   }
235   catch (const SALOME::SALOME_Exception & ex)
236   {
237     DEBMSG("SALOME Exception in removeResource ! " << ex.details.text.in());
238   }
239   catch (const CORBA::SystemException& ex)
240   {
241     DEBMSG("Receive SALOME System Exception: " << ex);
242     DEBMSG("Check SALOME servers...");
243   }
244 }
245
246 std::string
247 BL::SALOMEServices::create_job(BL::Job * job)
248 {
249   DEBMSG("Begin of create_job");
250   std::string ret = "";
251   Engines::JobParameters_var job_parameters = new Engines::JobParameters;
252
253   // Job type
254   if (job->getType() == BL::Job::COMMAND)
255   {
256     job_parameters->job_type = CORBA::string_dup("command");
257   }
258   else if (job->getType() == BL::Job::YACS_SCHEMA)
259   {
260     job_parameters->job_type = CORBA::string_dup("yacs_file");
261   }
262   else if (job->getType() == BL::Job::PYTHON_SALOME)
263   {
264     job_parameters->job_type = CORBA::string_dup("python_salome");
265   }
266
267   // Specific parameters
268   if (job->getType() == BL::Job::YACS_SCHEMA)
269   {
270     if (job->getDumpYACSState() > 0)
271     {
272       job_parameters->specific_parameters.length(job_parameters->specific_parameters.length() + 1);
273       std::ostringstream oss;
274       oss << job->getDumpYACSState();
275       Engines::Parameter_var new_parameter = new Engines::Parameter;
276       new_parameter->name = CORBA::string_dup("EnableDumpYACS");
277       new_parameter->value = CORBA::string_dup(oss.str().c_str());
278       job_parameters->specific_parameters[job_parameters->specific_parameters.length() - 1] = new_parameter;
279     }
280     if (not job->getYacsDriverOptions().empty())
281     {
282       job_parameters->specific_parameters.length(job_parameters->specific_parameters.length() + 1);
283       Engines::Parameter_var new_parameter = new Engines::Parameter;
284       new_parameter->name = CORBA::string_dup("YACSDriverOptions");
285       new_parameter->value = CORBA::string_dup(job->getYacsDriverOptions().c_str());
286       job_parameters->specific_parameters[job_parameters->specific_parameters.length() - 1] = new_parameter;
287     }
288   }
289   if (job->getLoadLevelerJobType() != "")
290   {
291     job_parameters->specific_parameters.length(job_parameters->specific_parameters.length() + 1);
292     Engines::Parameter_var new_parameter = new Engines::Parameter;
293     new_parameter->name = CORBA::string_dup("LoalLevelerJobType");
294     new_parameter->value = CORBA::string_dup(job->getLoadLevelerJobType().c_str());
295     job_parameters->specific_parameters[job_parameters->specific_parameters.length() - 1] = new_parameter;
296   }
297
298   // Files
299   job_parameters->job_name = CORBA::string_dup(job->getName().c_str());
300   job_parameters->job_file = CORBA::string_dup(job->getJobFile().c_str());
301   job_parameters->env_file = CORBA::string_dup(job->getEnvFile().c_str());
302   BL::Job::FilesParam files = job->getFilesParameters();
303   std::list<std::string>::iterator it;
304   int i = 0;
305   int j = 0;
306
307   job_parameters->in_files.length(files.input_files_list.size());
308   for (it = files.input_files_list.begin() ; it != files.input_files_list.end(); it++)
309   {
310     job_parameters->in_files[i] = CORBA::string_dup((*it).c_str());
311     i++;
312   }
313
314   job_parameters->out_files.length(files.output_files_list.size());
315   for (it = files.output_files_list.begin() ; it != files.output_files_list.end(); it++)
316   {
317     job_parameters->out_files[j] = CORBA::string_dup((*it).c_str());
318     j++;
319   }
320   job_parameters->local_directory = CORBA::string_dup("");
321   job_parameters->result_directory = CORBA::string_dup(files.result_directory.c_str());
322
323   BL::Job::BatchParam cpp_batch_params =  job->getBatchParameters();
324   job_parameters->work_directory = CORBA::string_dup(cpp_batch_params.batch_directory.c_str());
325
326   // Resource
327   job_parameters->maximum_duration = CORBA::string_dup(cpp_batch_params.maximum_duration.c_str());
328   job_parameters->resource_required.name = CORBA::string_dup(job->getResource().c_str());
329   job_parameters->resource_required.nb_proc = cpp_batch_params.nb_proc;
330   job_parameters->queue = CORBA::string_dup(job->getBatchQueue().c_str());
331   job_parameters->exclusive = cpp_batch_params.exclusive;
332   job_parameters->wckey = CORBA::string_dup(job->getWCKey().c_str());
333   job_parameters->extra_params = CORBA::string_dup(job->getExtraParams().c_str());
334
335   // Memory
336   switch (cpp_batch_params.mem_req_type)
337   {
338   case BL::Job::MEM_PER_NODE:
339     job_parameters->resource_required.mem_mb = cpp_batch_params.mem_limit;
340     job_parameters->mem_per_cpu = 0;
341     break;
342   case BL::Job::MEM_PER_CPU:
343     job_parameters->resource_required.mem_mb = 0;
344     job_parameters->mem_per_cpu = cpp_batch_params.mem_limit;
345     break;
346   default:
347     throw Exception("Unknown memory requirement, unable to create job");
348   }
349
350   // Unused parameters
351   job_parameters->resource_required.nb_node = -1;
352   job_parameters->resource_required.nb_proc_per_node = -1;
353   job_parameters->resource_required.cpu_clock = -1;
354
355   // Parameters for COORM
356   job_parameters->launcher_file = CORBA::string_dup(cpp_batch_params.launcher_file.c_str());
357   job_parameters->launcher_args = CORBA::string_dup(cpp_batch_params.launcher_args.c_str());
358
359   // Create Job
360   try
361   {
362     int job_id = _salome_launcher->createJob(job_parameters);
363     job->setSalomeLauncherId(job_id);
364   }
365   catch (const SALOME::SALOME_Exception & ex)
366   {
367     DEBMSG("SALOME Exception in createJob !");
368     ret = ex.details.text.in();
369   }
370   catch (const CORBA::SystemException& ex)
371   {
372     DEBMSG("Receive SALOME System Exception: " << ex);
373     DEBMSG("Check SALOME servers...");
374     ret = "SALOME System Exception - see logs";
375   }
376   return ret;
377 }
378
379 std::string
380 BL::SALOMEServices::start_job(BL::Job * job)
381 {
382   std::string ret = "";
383   // Launch Job !
384   try
385   {
386     _salome_launcher->launchJob(job->getSalomeLauncherId());
387   }
388   catch (const SALOME::SALOME_Exception & ex)
389   {
390     DEBMSG("SALOME Exception in launchJob !");
391     ret = ex.details.text.in();
392   }
393   catch (const CORBA::SystemException& ex)
394   {
395     DEBMSG("Receive SALOME System Exception: " << ex);
396     DEBMSG("Check SALOME servers...");
397     ret = "SALOME System Exception - see logs";
398   }
399   return ret;
400 }
401
402 std::string
403 BL::SALOMEServices::refresh_job(BL::Job * job)
404 {
405   std::string ret = "";
406
407   // Refresh Job !
408   try
409   {
410     CORBA::String_var result = _salome_launcher->getJobState(job->getSalomeLauncherId());
411     ret = result.in();
412   }
413   catch (const SALOME::SALOME_Exception & ex)
414   {
415     DEBMSG("SALOME Exception in getJobState !");
416     ret = ex.details.text.in();
417   }
418   catch (const CORBA::SystemException& ex)
419   {
420     DEBMSG("Receive SALOME System Exception: " << ex);
421     DEBMSG("Check SALOME servers...");
422     ret = "SALOME System Exception - see logs";
423   }
424   return ret;
425 }
426
427 std::string
428 BL::SALOMEServices::delete_job(BL::Job * job)
429 {
430   std::string ret = "";
431   // Delete Job !
432   try
433   {
434     _salome_launcher->removeJob(job->getSalomeLauncherId());
435   }
436   catch (const SALOME::SALOME_Exception & ex)
437   {
438     DEBMSG("SALOME Exception in removeJob !");
439     ret = ex.details.text.in();
440   }
441   catch (const CORBA::SystemException& ex)
442   {
443     DEBMSG("Receive SALOME System Exception: " << ex);
444     DEBMSG("Check SALOME servers...");
445     ret = "SALOME System Exception - see logs";
446   }
447   return ret;
448 }
449
450 std::string
451 BL::SALOMEServices::stop_job(BL::Job * job)
452 {
453   std::string ret = "";
454   try
455   {
456     _salome_launcher->stopJob(job->getSalomeLauncherId());
457   }
458   catch (const SALOME::SALOME_Exception & ex)
459   {
460     DEBMSG("SALOME Exception in stopJob !");
461     ret = ex.details.text.in();
462   }
463   catch (const CORBA::SystemException& ex)
464   {
465     DEBMSG("Receive SALOME System Exception: " << ex);
466     DEBMSG("Check SALOME servers...");
467     ret = "SALOME System Exception - see logs";
468   }
469   return ret;
470 }
471
472 std::string
473 BL::SALOMEServices::get_results_job(BL::Job * job)
474 {
475   std::string ret = "";
476
477   BL::Job::FilesParam files = job->getFilesParameters();
478   CORBA::String_var directory = CORBA::string_dup(files.result_directory.c_str());
479
480   // get job results !
481   try
482   {
483     _salome_launcher->getJobResults(job->getSalomeLauncherId(), directory);
484   }
485   catch (const SALOME::SALOME_Exception & ex)
486   {
487     DEBMSG("SALOME Exception in refresh_job !");
488     ret = ex.details.text.in();
489   }
490   catch (const CORBA::SystemException& ex)
491   {
492     DEBMSG("Receive SALOME System Exception: " << ex);
493     DEBMSG("Check SALOME servers...");
494     ret = "SALOME System Exception - see logs";
495   }
496   return ret;
497 }
498
499 // Get names or ids of hosts assigned to the job
500 std::string
501 BL::SALOMEServices::get_assigned_hostnames(BL::Job * job)
502 {
503   std::string ret = "";
504
505   try
506   {
507     CORBA::String_var result = _salome_launcher->getAssignedHostnames(job->getSalomeLauncherId());
508     ret = result.in();
509   }
510   catch (const SALOME::SALOME_Exception & ex)
511   {
512     DEBMSG("SALOME Exception in get_assigned_hostnames !");
513     ret = ex.details.text.in();
514   }
515   catch (const CORBA::SystemException& ex)
516   {
517     DEBMSG("Receive SALOME System Exception: " << ex);
518     DEBMSG("Check SALOME servers...");
519     ret = "SALOME System Exception - see logs";
520   }
521   return ret;
522 }
523
524 std::string
525 BL::SALOMEServices::save_jobs(const std::string & file_name)
526 {
527   CORBA::String_var file = CORBA::string_dup(file_name.c_str());
528   std::string ret = "";
529   try
530   {
531     _salome_launcher->saveJobs(file);
532   }
533   catch (const SALOME::SALOME_Exception & ex)
534   {
535     DEBMSG("SALOME Exception in saveJobs !");
536     ret = ex.details.text.in();
537   }
538   catch (const CORBA::SystemException& ex)
539   {
540     DEBMSG("Receive CORBA System Exception: " << ex);
541     DEBMSG("Check SALOME servers...");
542     ret = "CORBA System Exception - see SALOME logs";
543   }
544   return ret;
545 }
546
547 std::string
548 BL::SALOMEServices::load_jobs(const std::string & file_name)
549 {
550   CORBA::String_var file = CORBA::string_dup(file_name.c_str());
551   std::string ret = "";
552   try
553   {
554     _salome_launcher->loadJobs(file);
555   }
556   catch (const SALOME::SALOME_Exception & ex)
557   {
558     DEBMSG("SALOME Exception in loadJobs !");
559     ret = ex.details.text.in();
560   }
561   catch (const CORBA::SystemException& ex)
562   {
563     DEBMSG("Receive CORBA System Exception: " << ex);
564     DEBMSG("Check SALOME servers...");
565     ret = "CORBA System Exception - see SALOME logs";
566   }
567   return ret;
568 }
569
570 void
571 BL::SALOMEServices::notify(const char* event_name, const char * event_data)
572 {
573   DEBMSG("Launcher event received " << event_name << " " << event_data);
574
575   std::string event(event_name);
576   std::string data(event_data);
577
578   if (event == "SAVE_JOBS")
579   {
580     _manager->launcher_event_save_jobs(data);
581   }
582   else if (event == "LOAD_JOBS")
583   {
584     _manager->launcher_event_load_jobs(data);
585   }
586   else if (event == "NEW_JOB")
587   {
588     _manager->launcher_event_new_job(data);
589   }
590   else if (event == "REMOVE_JOB")
591   {
592     _manager->launcher_event_remove_job(data);
593   }
594   else if (event == "UPDATE_JOB_STATE")
595   {
596     _manager->launcher_event_update_job_state(data);
597   }
598   else
599   {
600     DEBMSG("Unkown launcher event received");
601   }
602 }
603
604 BL::Job * 
605 BL::SALOMEServices::get_new_job(int job_number)
606 {
607   DEBMSG("Start of BL::SALOMEServices::get_new_job");
608   BL::Job * job_return = NULL;
609   Engines::JobParameters * job_parameters = NULL;
610   try
611   {
612     job_parameters = _salome_launcher->getJobParameters(job_number);
613   }
614   catch (const SALOME::SALOME_Exception & ex)
615   {
616     DEBMSG("SALOME Exception in saveJobs !");
617   }
618   catch (const CORBA::SystemException& ex)
619   {
620     DEBMSG("Receive CORBA System Exception: " << ex);
621     DEBMSG("Check SALOME servers...");
622   }
623
624   if (job_parameters)
625   {
626     job_return = new BL::Job();
627     job_return->setSalomeLauncherId(job_number);
628
629     job_return->setName(job_parameters->job_name.in());
630     job_return->setType(job_parameters->job_type.in());
631     job_return->setJobFile(job_parameters->job_file.in());
632     job_return->setEnvFile(job_parameters->env_file.in());
633     job_return->setBatchQueue(job_parameters->queue.in());
634     job_return->setWCKey(job_parameters->wckey.in());
635     job_return->setExtraParams(job_parameters->extra_params.in());
636
637     BL::Job::FilesParam param;
638     param.result_directory = job_parameters->result_directory.in();
639     for (CORBA::ULong i = 0; i < job_parameters->in_files.length(); i++)
640       param.input_files_list.push_back(job_parameters->in_files[i].in());
641     for (CORBA::ULong i = 0; i < job_parameters->out_files.length(); i++)
642       param.output_files_list.push_back(job_parameters->out_files[i].in());
643     job_return->setFilesParameters(param);
644
645     BL::Job::BatchParam batch_param;
646     batch_param.batch_directory = job_parameters->work_directory.in();
647     batch_param.maximum_duration = job_parameters->maximum_duration.in();
648     batch_param.nb_proc = job_parameters->resource_required.nb_proc;
649     batch_param.exclusive = job_parameters->exclusive;
650
651     if (job_parameters->mem_per_cpu != 0)
652     {
653       batch_param.mem_limit = job_parameters->mem_per_cpu;
654       batch_param.mem_req_type = BL::Job::MEM_PER_CPU;
655     }
656     else
657     {
658       batch_param.mem_limit = job_parameters->resource_required.mem_mb;
659       batch_param.mem_req_type = BL::Job::MEM_PER_NODE;
660     }
661
662     // Parameters for COORM
663     batch_param.launcher_file = job_parameters->launcher_file.in();
664     batch_param.launcher_args = job_parameters->launcher_args.in();
665
666     job_return->setBatchParameters(batch_param);
667
668     job_return->setResource(job_parameters->resource_required.name.in());
669
670     // Specific parameters
671     for (CORBA::ULong i = 0; i < job_parameters->specific_parameters.length(); i++)
672     {
673       if (std::string(job_parameters->specific_parameters[i].name.in()) == "EnableDumpYACS")
674       {
675         std::string user_value = job_parameters->specific_parameters[i].value.in();
676         std::istringstream iss(user_value);
677         int value;
678         iss >> value;
679         job_return->setDumpYACSState(value);
680       }
681       if (std::string(job_parameters->specific_parameters[i].name.in()) == "YACSDriverOptions")
682       {
683         std::string user_value = job_parameters->specific_parameters[i].value.in();
684         job_return->setYacsDriverOptions(user_value);
685       }
686       if (std::string(job_parameters->specific_parameters[i].name.in()) == "LoalLevelerJobType")
687       {
688         std::string user_value = job_parameters->specific_parameters[i].value.in();
689         job_return->setLoadLevelerJobType(user_value);
690       }
691     }
692
693     // Get current state
694     std::string result_job = job_return->setStringState(refresh_job(job_return));
695     if (result_job != "RefreshError") {}
696     else
697     {
698       // Error in getting state
699       DEBMSG("Error in getting state of the new job!");
700       delete job_return;
701       job_return = NULL;
702     }
703     delete job_parameters;
704   }
705
706   return job_return;
707 }