1 // Copyright (C) 2019-2023 CEA, EDF
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "Launcher.hxx"
24 #include "ResourcesManager.hxx"
26 struct ResourceDefinition_cpp
34 std::string applipath;
42 std::string iprotocol;
43 bool can_launch_batch_jobs;
44 bool can_run_containers;
45 std::string working_directory;
49 %include "std_string.i"
50 %include "std_vector.i"
55 %template(list_int) list<int>;
56 %template(list_str) list<string>;
57 %template(vector_str) vector<string>;
58 %template(map_ss) map<string,string>;
61 // see ResourceParameters from SALOME_ResourcesManager.idl
62 // see resourceParams from ResourcesManager.hxx
63 %naturalvar JobParameters_cpp::componentList;
64 %naturalvar JobParameters_cpp::resourceList;
71 bool can_launch_batch_jobs;
72 bool can_run_containers;
76 long nb_proc_per_node;
79 std::vector<std::string> componentList;
80 std::vector<std::string> resourceList;
83 // see JobParameters from SALOME_Launcher.idl
84 // see JobParameters_cpp from Launcher.hxx
85 %naturalvar JobParameters_cpp::in_files;
86 %naturalvar JobParameters_cpp::out_files;
87 %naturalvar JobParameters_cpp::specific_parameters;
88 struct JobParameters_cpp
94 std::string pre_command;
96 std::list<std::string> in_files;
97 std::list<std::string> out_files;
98 std::string work_directory;
99 std::string local_directory;
100 std::string result_directory;
101 std::string maximum_duration;
102 resourceParams resource_required;
104 std::string partition;
106 unsigned int mem_per_cpu;
108 std::string extra_params;
109 std::map<std::string, std::string> specific_parameters;
110 std::string launcher_file;
111 std::string launcher_args;
114 // see ResourceDefinition from SALOME_ResourcesManager.idl
115 // no other c++ equivalent. Convertion from ParserResourcesType
116 struct ResourceDefinition_cpp
120 std::string hostname;
122 std::string protocol;
123 std::string username;
124 std::string applipath;
129 int nb_proc_per_node;
132 std::string iprotocol;
133 bool can_launch_batch_jobs;
134 bool can_run_containers;
135 std::string working_directory;
144 catch (ResourcesException& e)
146 SWIG_exception_fail(SWIG_RuntimeError, e.msg.c_str());
150 SWIG_exception_fail(SWIG_RuntimeError,"Unknown exception");
154 %include <std_shared_ptr.i>
155 %shared_ptr(ResourcesManager_cpp)
157 class ResourcesManager_cpp
160 ResourcesManager_cpp(const char *xmlFilePath);
161 std::vector<std::string> GetFittingResources(const resourceParams& params);
164 ResourceDefinition_cpp GetResourceDefinition(const std::string& name)
166 ResourceDefinition_cpp swig_result;
167 ParserResourcesType cpp_result = $self->GetResourcesDescr(name);
169 swig_result.name = cpp_result.Name;
170 swig_result.hostname = cpp_result.HostName;
171 swig_result.type = cpp_result.getResourceTypeStr();
172 swig_result.protocol = cpp_result.getAccessProtocolTypeStr();
173 swig_result.username = cpp_result.UserName;
174 swig_result.applipath = cpp_result.AppliPath;
175 swig_result.OS = cpp_result.OS;
176 swig_result.mem_mb = cpp_result.DataForSort._memInMB;
177 swig_result.cpu_clock = cpp_result.DataForSort._CPUFreqMHz;
178 swig_result.nb_node = cpp_result.DataForSort._nbOfNodes;
179 swig_result.nb_proc_per_node = cpp_result.DataForSort._nbOfProcPerNode;
180 swig_result.batch = cpp_result.getBatchTypeStr();
181 swig_result.mpiImpl = cpp_result.getMpiImplTypeStr();
182 swig_result.iprotocol = cpp_result.getClusterInternalProtocolStr();
183 swig_result.can_launch_batch_jobs = cpp_result.can_launch_batch_jobs;
184 swig_result.can_run_containers = cpp_result.can_run_containers;
185 swig_result.working_directory = cpp_result.working_directory;
198 catch (LauncherException& e)
200 SWIG_exception_fail(SWIG_RuntimeError, e.msg.c_str());
204 SWIG_exception_fail(SWIG_RuntimeError,"Unknown exception");
212 virtual ~Launcher_cpp();
213 int createJob(const JobParameters_cpp& job_parameters);
214 void launchJob(int job_id);
215 std::string getJobState(int job_id);
216 std::string getAssignedHostnames(int job_id); // Get names or ids of hosts assigned to the job
217 void exportInputFiles(int job_id);
218 void getJobResults(int job_id, std::string directory);
219 void clearJobWorkingDir(int job_id);
220 bool getJobDumpState(int job_id, std::string directory);
221 bool getJobWorkFile(int job_id, std::string work_file, std::string directory);
222 void stopJob(int job_id);
223 void removeJob(int job_id);
224 std::string dumpJob(int job_id);
225 int restoreJob(const std::string& dumpedJob);
226 JobParameters_cpp getJobParameters(int job_id);
227 std::list<int> loadJobs(const char* jobs_file);
228 void saveJobs(const char* jobs_file);
229 long createJobWithFile(std::string xmlExecuteFile, std::string clusterName);
230 void SetResourcesManager(std::shared_ptr<ResourcesManager_cpp>& rm );