Salome HOME
updated copyright message
[modules/kernel.git] / idl / SALOME_ResourcesManager.idl
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef _SALOME_RESOURCESMANAGER_IDL_
24 #define _SALOME_RESOURCESMANAGER_IDL_
25
26 #include "SALOME_Exception.idl"
27
28 /*! \file SALOME_ResourcesManager.idl \brief interfaces for %SALOME Resources Manager service
29 */
30
31 module Engines
32 {
33
34 //!  Type to transmit list of resources.
35 typedef sequence<string> ResourceList;
36 //! components list
37 typedef sequence<string> CompoList;
38 typedef sequence<long> IntegerList;
39   
40 //! Type to describe required properties of a resource
41 struct ResourceParameters
42 {
43   //! resource name - manual selection
44   /*! If a name is provided, the resource will be imposed.
45       If the name is an empty string, the resource will be chosen to match
46       the other parameters.
47   */
48   string name;
49
50   //! host name
51   string hostname;
52   //! if true select only resources that can launch batch jobs
53   boolean can_launch_batch_jobs;
54   //! if true select only resources that can run containers
55   boolean can_run_containers;
56   //! if given required operating system 
57   string OS;
58   //! if given, list of components that could be loaded on a container.
59   /*! Ignored if no resources are found with this constraint.*/
60   CompoList componentList;
61
62   // Permits to order resources
63   //! required number of processors
64   /*! This parameter must be specified explicitly, because it is not provided
65       by the resource definition.
66   */
67   long nb_proc;
68
69   //! required memory size
70   /*! This parameter must be specified explicitly, because it is not provided
71       by the resource definition.
72
73       The parameter specifies the maximum memory value that could be allocated
74       for executing the job. This takes into account not only the data that
75       could be loaded by the batch process but also the linked dynamic library.
76       A possible problem, for example in the case where you use the ssh
77       emulation of a batch system, is to get an error message as below
78       when libBatch tries to run the ssh command:
79 \verbatim
80 /usr/bin/ssh: error while loading shared libraries: libcrypto.so.0.9.8: failed
81 to map segment from shared object: Cannot allocate memory
82 \endverbatim
83       In this example, the mem_mb was set to 1MB, value that is not
84       sufficient to load the dynamic libraries linked to the ssh
85       executable (libcrypto.so in the error message).
86       So, even in the case of a simple test shell script, you should
87       set this value at least to a standard threshold as 500MB.
88   */
89   long mem_mb;
90   //! required frequency
91   long cpu_clock;
92   //! required number of nodes. Can be used when submitting slurm jobs.
93   long nb_node;
94   //! required number of proc per node
95   long nb_proc_per_node;
96
97   // Permits to configure SALOME resource management
98   //! resource management policy : first, cycl, altcycl or best (can be extended)
99   string policy;
100   //! restricted list of resources to search in
101   ResourceList resList;
102 };
103
104 //!  Type to describe a resource
105 struct ResourceDefinition
106 {
107   //! name 
108   string name;
109   //! hostname 
110   string hostname;
111   //! Type of the resource ("cluster" or "single_machine")
112   string type;
113   //! protocol to connect to the resource and to start a remote container
114   //! Possible values:
115   //!   "rsh"   : uses rsh and rcp
116   //!   "ssh"   : uses ssh and scp
117   //!   "rsync" : uses ssh and rsync
118   string protocol;
119   //! login name to use to start a remote container
120   string username;
121   //! salome application to use to start a remote container
122   string applipath;
123   //! list of available components.
124   //! An empty list means every component is available.
125   CompoList componentList;
126
127   //! operating system 
128   string OS;
129   //! memory size per node
130   long mem_mb;
131   //! frequency
132   long cpu_clock;
133   //! number of node
134   long nb_node;
135   //! number of proc per node
136   long nb_proc_per_node;
137   //! batch system
138   string batch;
139   //! MPI implementation
140   string mpiImpl;
141   //! if the resource is a cluster:
142   //! internal protocol to use to start a remote container (ssh or rsh) on the cluster
143   string iprotocol;
144
145   //! Specify if the resource can launch batch jobs
146   boolean can_launch_batch_jobs;
147   //! Specify if the resource can run containers
148   boolean can_run_containers;
149
150   //! Predefined working directory on the resource
151   string working_directory;
152 };
153
154 /*! \brief Interface of the %resourcesManager
155     This interface is used for interaction with the unique instance
156     of ResourcesManager
157 */
158 interface ResourcesManager
159 {
160   //!  Find first available resource in a resources list
161   string FindFirst(in ResourceList possibleResources);
162
163   //!  Find best available computer according to policy in a computers list
164   string Find(in string policy, in ResourceList possibleResources);
165
166   //!  Get a list of resources that are best suited to launch a container given constraints 
167   /*! 
168        The constraints are resource constraints (params) and components constraints (componentList)
169   */
170   ResourceList GetFittingResources(in ResourceParameters params) raises (SALOME::SALOME_Exception);
171
172   //!  Get definition of a resource
173   ResourceDefinition GetResourceDefinition(in string name) raises (SALOME::SALOME_Exception);
174
175   //! Add a new resource to the resource_manager
176   /*!
177       write -> true, resource manager will add it into a xml_file
178       xml_file -> could be empty, in this case if write is true, resource manager will write
179       the resource in its first ResourceCatalog file
180     */
181   void AddResource(in ResourceDefinition new_resource, in boolean write, in string xml_file) 
182     raises (SALOME::SALOME_Exception);
183
184   //! Remove a new resource to the resource_manager
185   /*!
186       write -> true, resource manager will write a new xml_file
187       xml_file -> could be empty, in this case if write is true, resource manager will write
188       the resource in its first ResourceCatalog file
189     */
190   void RemoveResource(in string resource_name, in boolean write, in string xml_file) 
191     raises (SALOME::SALOME_Exception);
192
193   //! Create a machine file for PaCO container
194   string getMachineFile(in string resource_name, in long nb_procs, in string parallelLib)
195     raises (SALOME::SALOME_Exception);
196
197   //! Return list of resources available (regarding content of CatalogResources.xml). And for each resource the number of proc available of it.
198   void ListAllAvailableResources(out ResourceList machines, out IntegerList nbProcsOfMachines) raises (SALOME::SALOME_Exception);
199
200   ResourceList ListAllResourcesInCatalog() raises (SALOME::SALOME_Exception);
201 };
202
203 };
204   
205 #endif