1 #ifndef __SALOME_RESOURCESMANAGER_HXX__
2 #define __SALOME_RESOURCESMANAGER_HXX__
4 #include "Utils_SALOME_Exception.hxx"
6 #include <SALOMEconfig.h>
7 #include "SALOME_ResourcesCatalog_Handler.hxx"
8 #include "SALOME_LoadRateManager.hxx"
9 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
14 //WARNING the call of BuildTempFileToLaunchRemoteContainer and RmTmpFile must be done in a critical section to be sure to be clean.
15 //Only one thread should use the SALOME_ResourcesManager class in a SALOME session.
17 class SALOME_ResourcesManager
20 //! standard constructor
21 SALOME_ResourcesManager();
24 SALOME_ResourcesManager(const char *xmlFilePath);
26 //! standard destructor
27 ~SALOME_ResourcesManager();
29 //! method to get the list of name of ressources fitting for the specified module.
30 std::vector<std::string> GetFittingResources(const Engines::MachineParameters& params,const char *moduleName) throw(SALOME_Exception);
32 //! method to dynamically obtain the best machines
33 std::string FindBest(const Engines::MachineList& listOfMachines);
35 //! method that builds in a temporary file the script to be launched
36 std::string BuildTempFileToLaunchRemoteContainer(const std::string& machine,const char *containerName);
38 //! method that builds the command to be launched.
39 std::string BuildCommandToLaunchLocalContainer(const char *containerName);
41 //! method that remove the generated temporary file in case of a remote launch.
44 //! method that builds the script to be launched
45 std::string BuildCommand(const std::string& machine,const char *containerName);
47 //! add an entry in the ressources catalog xml file. Return 1 if OK. Return 0 if the ressource with the same hostname already exists.
48 int AddResourceInCatalog(const Engines::MachineParameters& paramsOfNewResources, const std::map<std::string,std::string>& modulesOnNewResources,
49 const char *environPathOfPrerequired,
50 const char *alias, const char *userName, AccessModeType mode, AccessProtocolType prot) throw(SALOME_Exception);
52 //! delete a ressource from the Catalog.
53 void DeleteResourceInCatalog(const char *hostname);
55 //! write the current data in memory in file.
56 void WriteInXmlFile();
58 //! method to parse the data type catalog
59 const MapOfParserResourcesType& ParseXmlFile();
61 //! to consult the content of the list
62 const MapOfParserResourcesType& GetList() const;
66 //! method to verify ressources catalog content - return true if verfication is OK
67 bool _verify_resources(MapOfParserResourcesType resourceslist);
69 //! method that fill hosts with only resources in xml files that are on the specified OS
70 void SelectOnlyResourcesWithOS(std::vector<std::string>& hosts,const char *OS) const throw(SALOME_Exception);
72 //! method that keep from hosts only those having component of name moduleName.
73 void KeepOnlyResourcesWithModule(std::vector<std::string>& hosts,const char *moduleName) const throw(SALOME_Exception);
75 //! methode that add to command all options relative to naming service.
76 void AddOmninamesParams(std::string& command) const;
78 //! method that add to command all options relative to naming service.
79 void AddOmninamesParams(std::ofstream& fileStream) const;
81 //! method that generate a file name in /tmp directory
82 std::string BuildTemporaryFileName() const;
84 // will contain the path to the ressources catalog
85 QString _path_resources;
87 //! attribute that contains current tmp files generated
88 std::string _TmpFileName;
90 //! attribute that contains the rsh or ssh command to access directly to machine. Only used by this->RmTmpFile in case of a remote launch.
91 std::string _CommandForRemAccess;
93 //will contain the informations on the data type catalog(after parsing)
94 MapOfParserResourcesType _resourcesList;
96 SALOME_LoadRateManager _dynamicResourcesSelecter;
99 #endif // RESSOURCESCATALOG_IMPL_H