From: barate Date: Fri, 15 Feb 2013 12:57:01 +0000 (+0000) Subject: Merge from BR_LIBBATCH_2_0 X-Git-Tag: V7_1_0b1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b83f7739ffb0509786b791c57366a57a4cc7c3e2;p=modules%2Fkernel.git Merge from BR_LIBBATCH_2_0 --- diff --git a/bin/appli_gen.py b/bin/appli_gen.py index 648656c83..b627b5649 100644 --- a/bin/appli_gen.py +++ b/bin/appli_gen.py @@ -270,17 +270,6 @@ export MMGT_REENTRANT=1 f.write(command % ",".join(mods)) f.close() - #Add default CatalogResources.xml file - f =open(os.path.join(home_dir,'CatalogResources.xml'),'w') - command=""" - - - -""" - f.write(command) - f.close() - #Add USERS directory with 777 permission to store users configuration files users_dir=os.path.join(home_dir,'USERS') makedirs(users_dir) diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index d1392bd21..483f808af 100755 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -30,7 +30,8 @@ SET(SalomeIDLKernel_IDLSOURCES SALOME_Exception.idl SALOME_Comm.idl SALOME_ModuleCatalog.idl - SALOME_RessourcesCatalog.idl + SALOME_ResourcesManager.idl + SALOME_Launcher.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl diff --git a/idl/Makefile.am b/idl/Makefile.am index cf953c8e7..13d4db038 100644 --- a/idl/Makefile.am +++ b/idl/Makefile.am @@ -33,7 +33,8 @@ BASEIDL_FILES = \ SALOME_Exception.idl \ SALOME_Comm.idl \ SALOME_ModuleCatalog.idl \ - SALOME_RessourcesCatalog.idl \ + SALOME_ResourcesManager.idl \ + SALOME_Launcher.idl \ SALOMEDS.idl \ SALOMEDS_Attributes.idl \ SALOME_Component.idl \ @@ -86,7 +87,8 @@ BASEIDL_SOURCES =\ SALOME_ExceptionSK.cc \ SALOME_CommSK.cc \ SALOME_ModuleCatalogSK.cc \ - SALOME_RessourcesCatalogSK.cc \ + SALOME_ResourcesManagerSK.cc \ + SALOME_LauncherSK.cc \ SALOMEDSSK.cc \ SALOMEDS_AttributesSK.cc \ SALOME_ComponentSK.cc \ @@ -112,7 +114,7 @@ BASEIDL_SOURCES =\ DYNIDL_SRCS = \ SALOME_PortsDynSK.cc Calcium_PortsDynSK.cc SALOME_ContainerManagerDynSK.cc \ SALOME_CommDynSK.cc SALOME_RegistryDynSK.cc SALOME_ModuleCatalogDynSK.cc \ - SALOMEDSDynSK.cc SALOME_SessionDynSK.cc SALOME_RessourcesCatalogDynSK.cc \ + SALOMEDSDynSK.cc SALOME_SessionDynSK.cc SALOME_ResourcesManagerDynSK.cc SALOME_LauncherDynSK.cc \ DSC_EnginesDynSK.cc SALOME_ComponentDynSK.cc SALOME_GenericObjDynSK.cc SALOME_TypesDynSK.cc \ Palm_PortsDynSK.cc SALOME_ExceptionDynSK.cc SALOMEDS_AttributesDynSK.cc \ LoggerDynSK.cc SALOME_PACOExtensionDynSK.cc SALOME_ParamPortsDynSK.cc SALOME_PyNodeDynSK.cc \ diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index b15f357f7..27e34a110 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -25,63 +25,14 @@ #include "SALOME_Exception.idl" #include "SALOME_Component.idl" +#include "SALOME_ResourcesManager.idl" -/*! \file SALOME_ContainerManager.idl \brief interfaces for %SALOME launcher and container manager +/*! \file SALOME_ContainerManager.idl \brief interfaces for %SALOME Container Manager service */ module Engines { -//! Type to transmit list of resources. -typedef sequence ResourceList; -//! components list -typedef sequence CompoList; -//! files list -typedef sequence FilesList; -//! modules list -typedef sequence ModulesList; - -//! A generic parameter -struct Parameter -{ - string name; - string value; -}; -//! Generic parameter list -typedef sequence ParameterList; - -//! Type to describe required properties of a resource -struct ResourceParameters -{ - //! resource name - manual selection - string name; - //! host name - string hostname; - //! if given required operating system - string OS; - //! if given list of components that could be loaded on a container - //! Optional if no resource are found with this constraint - CompoList componentList; - - // Permits to order resources - //! required number of proc - long nb_proc; - //! required memory size - long mem_mb; - //! required frequency - long cpu_clock; - //! required number of node - long nb_node; - //! required number of proc per node - long nb_proc_per_node; - - // Permits to configure SALOME resource management - //! resource management policy : first, cycl, altcycl or best (can be extended) - string policy; - //! restricted list of resources to search in - ResourceList resList; -}; - //! Type to describe required properties of a container struct ContainerParameters { @@ -110,135 +61,6 @@ struct ContainerParameters ResourceParameters resource_params; }; -//! Type to describe a resource -struct ResourceDefinition -{ - //! name - string name; - //! hostname - string hostname; - //! protocol to connect to the resource - //! protocol used to start a remote container (ssh or rsh) - string protocol; - //! login name to use to start a remote container - string username; - //! salome application to use to start a remote container - string applipath; - //! list of available components - CompoList componentList; - //! Type of resource: interactive or batch - string mode; - - //! operating system - string OS; - //! memory size per node - long mem_mb; - //! frequency - long cpu_clock; - //! number of node - long nb_node; - //! number of proc per node - long nb_proc_per_node; - //! batch system - string batch; - //! MPI implementation - string mpiImpl; - //! if the resource is a cluster: - //! internal protocol to use to start a remote container (ssh or rsh) on the cluster - string iprotocol; - - //! Specify if the resource is a cluster head; - boolean is_cluster_head; - - //! Predefined working directory on the resource - string working_directory; -}; - -//! exception thrown if a computer is not found in the catalog -exception NotFound {}; - -struct JobParameters -{ - string job_name; - //! Job Type - Could be equal to "command" or "yacs_file" or "python_salome" - string job_type; - - // Common values - string job_file; - string env_file; - FilesList in_files; - FilesList out_files; - string work_directory; - string local_directory; - string result_directory; - - /*! Time for the batch (has to be like this : hh:mm) - Could be empty, in - this case, default value of the selected resource will be used. - */ - string maximum_duration; - - // Memory is expressed in megabytes -> mem_mb - // Number of Processors -> nb_proc - ResourceParameters resource_required; - - /*! - Name of the batch queue choosed - optional - */ - string queue; - - /*! - Specific parameters for each type of job - optional - */ - Engines::ParameterList specific_parameters; -}; - -struct JobDescription -{ - long job_id; - Engines::JobParameters job_parameters; -}; -typedef sequence JobsList; - -interface SalomeLauncherObserver -{ - void notify(in string event_name, in string event_data); -}; - -/*! \brief Interface of the %salomelauncher - This interface is used for interaction with the unique instance - of SalomeLauncher -*/ -interface SalomeLauncher -{ - // Main methods - long createJob (in Engines::JobParameters job_parameters) raises (SALOME::SALOME_Exception); - void launchJob (in long job_id) raises (SALOME::SALOME_Exception); - string getJobState (in long job_id) raises (SALOME::SALOME_Exception); - void getJobResults(in long job_id, in string directory) raises (SALOME::SALOME_Exception); - boolean getJobDumpState(in long job_id, in string directory) raises (SALOME::SALOME_Exception); - void stopJob (in long job_id) raises (SALOME::SALOME_Exception); - void removeJob (in long job_id) raises (SALOME::SALOME_Exception); - - // Useful methods - long createJobWithFile(in string xmlJobFile, in string clusterName) raises (SALOME::SALOME_Exception); - boolean testBatch (in ResourceParameters params) raises (SALOME::SALOME_Exception); - - // SALOME kernel service methods - void Shutdown(); - long getPID(); - - // Observer and introspection methods - void addObserver(in Engines::SalomeLauncherObserver observer); - void removeObserver(in Engines::SalomeLauncherObserver observer); - Engines::JobsList getJobsList(); - Engines::JobParameters getJobParameters(in long job_id) raises (SALOME::SALOME_Exception); - - // Save and load methods - void loadJobs(in string jobs_file) raises (SALOME::SALOME_Exception); - void saveJobs(in string jobs_file) raises (SALOME::SALOME_Exception); - -}; - /*! \brief Interface of the %containerManager This interface is used for interaction with the unique instance of ContainerManager @@ -253,88 +75,7 @@ interface ContainerManager //! Shutdown all containers that have been launched by the container manager void ShutdownContainers(); } ; - -/*! \brief Interface of the %resourcesManager - This interface is used for interaction with the unique instance - of ResourcesManager -*/ -interface ResourcesManager -{ - //! Find first available resource in a resources list - string FindFirst(in ResourceList possibleResources); - - //! Find best available computer according to policy in a computers list - string Find(in string policy, in ResourceList possibleResources); - - //! Get a list of resources that are best suited to launch a container given constraints - /*! - The constraints are resource constraints (params) and components constraints (componentList) - */ - ResourceList GetFittingResources(in ResourceParameters params) raises (SALOME::SALOME_Exception); - - //! Get definition of a resource - ResourceDefinition GetResourceDefinition(in string name); - - //! Add a new resource to the resource_manager - /*! - write -> true, resource manager will add it into a xml_file - xml_file -> could be empty, in this case if write is true, resource manager will write - the resource in its first ResourceCatalog file - */ - void AddResource(in ResourceDefinition new_resource, in boolean write, in string xml_file) - raises (SALOME::SALOME_Exception); - - //! Remove a new resource to the resource_manager - /*! - write -> true, resource manager will write a new xml_file - xml_file -> could be empty, in this case if write is true, resource manager will write - the resource in its first ResourceCatalog file - */ - void RemoveResource(in string resource_name, in boolean write, in string xml_file) - raises (SALOME::SALOME_Exception); -}; - -// For compatibility - will be erased on SALOME 6 -typedef sequence MachineList; -//! Type to describe required properties of a container. -struct MachineParameters -{ - //! container name if given else automatic - string container_name; - //! host name if given else automatic - string hostname; - //! if given list of components that could be loaded on the container - CompoList componentList; - //! if given restricted list of machines to search in - MachineList computerList; - //! required operating system - string OS; - //! required memory size - long mem_mb; - //! required frequency - long cpu_clock; - //! required number of proc per node - long nb_proc_per_node; - //! required number of node - long nb_node; - //! if true start a MPI container - boolean isMPI; - //! container working directory - string workingdir; - //! creation mode for GiveContainer. - /*!start creates a new container - * get try to find an existing container - * getorstart use an existing container if it exists or creates a new one - */ - string mode; - //! resource management policy : first, cycl, altcycl or best (can be extended) - string policy; - - //! PaCO specific informations - string parallelLib; - long nb_component_nodes; -}; }; #endif diff --git a/idl/SALOME_Launcher.idl b/idl/SALOME_Launcher.idl new file mode 100644 index 000000000..8b72b422c --- /dev/null +++ b/idl/SALOME_Launcher.idl @@ -0,0 +1,131 @@ +// Copyright (C) 2007-2012 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 +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _SALOME_LAUNCHER_IDL_ +#define _SALOME_LAUNCHER_IDL_ + +#include "SALOME_Exception.idl" +#include "SALOME_ResourcesManager.idl" + +/*! \file SALOME_Launcher.idl \brief interfaces for %SALOME Launcher service +*/ + +module Engines +{ + +//! files list +typedef sequence FilesList; + +//! A generic parameter +struct Parameter +{ + string name; + string value; +}; +//! Generic parameter list +typedef sequence ParameterList; + +struct JobParameters +{ + string job_name; + //! Job Type - Could be equal to "command" or "yacs_file" or "python_salome" + string job_type; + + // Common values + string job_file; + string env_file; + FilesList in_files; + FilesList out_files; + string work_directory; + string local_directory; + string result_directory; + + /*! Time for the batch (has to be like this : hh:mm) - Could be empty, in + this case, default value of the selected resource will be used. + */ + string maximum_duration; + + // Memory is expressed in megabytes -> mem_mb + // Number of Processors -> nb_proc + ResourceParameters resource_required; + + /*! + Name of the batch queue choosed - optional + */ + string queue; + + /*! + Specific parameters for each type of job - optional + */ + Engines::ParameterList specific_parameters; +}; + +struct JobDescription +{ + long job_id; + Engines::JobParameters job_parameters; +}; +typedef sequence JobsList; + +interface SalomeLauncherObserver +{ + void notify(in string event_name, in string event_data); +}; + +/*! \brief Interface of the %salomelauncher + This interface is used for interaction with the unique instance + of SalomeLauncher +*/ +interface SalomeLauncher +{ + // Main methods + long createJob (in Engines::JobParameters job_parameters) raises (SALOME::SALOME_Exception); + void launchJob (in long job_id) raises (SALOME::SALOME_Exception); + string getJobState (in long job_id) raises (SALOME::SALOME_Exception); + void getJobResults(in long job_id, in string directory) raises (SALOME::SALOME_Exception); + boolean getJobDumpState(in long job_id, in string directory) raises (SALOME::SALOME_Exception); + void stopJob (in long job_id) raises (SALOME::SALOME_Exception); + void removeJob (in long job_id) raises (SALOME::SALOME_Exception); + + // Useful methods + long createJobWithFile(in string xmlJobFile, in string clusterName) raises (SALOME::SALOME_Exception); + boolean testBatch (in ResourceParameters params) raises (SALOME::SALOME_Exception); + + // SALOME kernel service methods + void Shutdown(); + long getPID(); + + // Observer and introspection methods + void addObserver(in Engines::SalomeLauncherObserver observer); + void removeObserver(in Engines::SalomeLauncherObserver observer); + Engines::JobsList getJobsList(); + Engines::JobParameters getJobParameters(in long job_id) raises (SALOME::SALOME_Exception); + + // Save and load methods + void loadJobs(in string jobs_file) raises (SALOME::SALOME_Exception); + void saveJobs(in string jobs_file) raises (SALOME::SALOME_Exception); + +}; + +}; + +#endif diff --git a/idl/SALOME_ResourcesManager.idl b/idl/SALOME_ResourcesManager.idl new file mode 100644 index 000000000..a43f9e815 --- /dev/null +++ b/idl/SALOME_ResourcesManager.idl @@ -0,0 +1,163 @@ +// Copyright (C) 2007-2012 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 +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _SALOME_RESOURCESMANAGER_IDL_ +#define _SALOME_RESOURCESMANAGER_IDL_ + +#include "SALOME_Exception.idl" + +/*! \file SALOME_ResourcesManager.idl \brief interfaces for %SALOME Resources Manager service +*/ + +module Engines +{ + +//! Type to transmit list of resources. +typedef sequence ResourceList; +//! components list +typedef sequence CompoList; + +//! Type to describe required properties of a resource +struct ResourceParameters +{ + //! resource name - manual selection + string name; + //! host name + string hostname; + //! if true select only resources that can launch batch jobs + boolean can_launch_batch_jobs; + //! if true select only resources that can run containers + boolean can_run_containers; + //! if given required operating system + string OS; + //! if given list of components that could be loaded on a container + //! Optional if no resource are found with this constraint + CompoList componentList; + + // Permits to order resources + //! required number of proc + long nb_proc; + //! required memory size + long mem_mb; + //! required frequency + long cpu_clock; + //! required number of node + long nb_node; + //! required number of proc per node + long nb_proc_per_node; + + // Permits to configure SALOME resource management + //! resource management policy : first, cycl, altcycl or best (can be extended) + string policy; + //! restricted list of resources to search in + ResourceList resList; +}; + +//! Type to describe a resource +struct ResourceDefinition +{ + //! name + string name; + //! hostname + string hostname; + //! Type of the resource ("cluster" or "single_machine") + string type; + //! protocol to connect to the resource + //! protocol used to start a remote container (ssh or rsh) + string protocol; + //! login name to use to start a remote container + string username; + //! salome application to use to start a remote container + string applipath; + //! list of available components + CompoList componentList; + + //! operating system + string OS; + //! memory size per node + long mem_mb; + //! frequency + long cpu_clock; + //! number of node + long nb_node; + //! number of proc per node + long nb_proc_per_node; + //! batch system + string batch; + //! MPI implementation + string mpiImpl; + //! if the resource is a cluster: + //! internal protocol to use to start a remote container (ssh or rsh) on the cluster + string iprotocol; + + //! Specify if the resource can launch batch jobs + boolean can_launch_batch_jobs; + //! Specify if the resource can run containers + boolean can_run_containers; + + //! Predefined working directory on the resource + string working_directory; +}; + +/*! \brief Interface of the %resourcesManager + This interface is used for interaction with the unique instance + of ResourcesManager +*/ +interface ResourcesManager +{ + //! Find first available resource in a resources list + string FindFirst(in ResourceList possibleResources); + + //! Find best available computer according to policy in a computers list + string Find(in string policy, in ResourceList possibleResources); + + //! Get a list of resources that are best suited to launch a container given constraints + /*! + The constraints are resource constraints (params) and components constraints (componentList) + */ + ResourceList GetFittingResources(in ResourceParameters params) raises (SALOME::SALOME_Exception); + + //! Get definition of a resource + ResourceDefinition GetResourceDefinition(in string name) raises (SALOME::SALOME_Exception); + + //! Add a new resource to the resource_manager + /*! + write -> true, resource manager will add it into a xml_file + xml_file -> could be empty, in this case if write is true, resource manager will write + the resource in its first ResourceCatalog file + */ + void AddResource(in ResourceDefinition new_resource, in boolean write, in string xml_file) + raises (SALOME::SALOME_Exception); + + //! Remove a new resource to the resource_manager + /*! + write -> true, resource manager will write a new xml_file + xml_file -> could be empty, in this case if write is true, resource manager will write + the resource in its first ResourceCatalog file + */ + void RemoveResource(in string resource_name, in boolean write, in string xml_file) + raises (SALOME::SALOME_Exception); +}; + +}; + +#endif diff --git a/idl/SALOME_RessourcesCatalog.idl b/idl/SALOME_RessourcesCatalog.idl deleted file mode 100755 index ff254ef94..000000000 --- a/idl/SALOME_RessourcesCatalog.idl +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2007-2012 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 -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : SALOME_RessourcesCatalog.idl -// Author : Estelle Deville -// $Header$ -// -/*! \file SALOME_RessourcesCatalog.idl \brief interfaces for %SALOME Resources Catalog -*/ - -/*! \brief module that provides interface to manage the Resources Catalog of %SALOME -*/ -module SALOME_RessourcesCatalog{ - - //! Information about a processor - struct proc_info{ - //! processor number - long number; - //! model name - string model_name; - //! frequency in MHz - float cpu_mhz; - //! cache size in MB - float cache_size; - }; - - //! a list of processor informations - typedef sequence ListOfProc; - - //! Information about a computer - /*! - Os and informations about processors - */ - struct computer_info{ - //! computer name - string name; - //! OS name - string OS; - //! OS version - string OS_version; - //! processors list - ListOfProc procs; - }; - - //! Container type - enum ContainerType { - Cpp, /*!< C++ container */ - python, /*!< python container */ - NP /*!< NP container */ - }; - //! a list of container types - typedef sequence ListOfContainerType; - - //! a list of computer names - typedef sequence ListOfComputer; - - //! exception thrown if a computer is not found in the catalog - exception NotFound {}; - - //------------------------------------------------------------------ -/*! \brief interface to get information about Resources -*/ - interface RessourcesCatalog { - //! Get the catalog computers list - ListOfComputer GetComputerList(); - //! Get the container types list for a given computer - ListOfContainerType GetContainerTypeList (in string computer) raises(NotFound); - //! Get computer information for a given computer - computer_info GetComputerInfo(in string computer) raises(NotFound); - }; -}; diff --git a/salome_adm/cmake_files/FindLIBBATCH.cmake b/salome_adm/cmake_files/FindLIBBATCH.cmake index aee305de4..809075722 100644 --- a/salome_adm/cmake_files/FindLIBBATCH.cmake +++ b/salome_adm/cmake_files/FindLIBBATCH.cmake @@ -75,7 +75,7 @@ IF(LIBBATCH_STATUS) ELSE(LIBBATCH_ROOT_USER) SET(LIBBATCH_INCLUDE_PATHS) ENDIF(LIBBATCH_ROOT_USER) - SET(LIBBATCH_INCLUDE_TO_FIND Batch/Batch_BatchManager.hxx) + SET(LIBBATCH_INCLUDE_TO_FIND Batch/BatchManager.hxx) FIND_PATH(LIBBATCH_INCLUDE_DIR ${LIBBATCH_INCLUDE_TO_FIND} PATHS ${LIBBATCH_INCLUDE_PATHS} ${LIBBATCH_FIND_PATHS_OPTION}) IF(LIBBATCH_INCLUDE_DIR) IF(LIBBATCH_ROOT_USER) diff --git a/salome_adm/unix/config_files/check_libbatch.m4 b/salome_adm/unix/config_files/check_libbatch.m4 index 53d3ebd0f..bd2dd2b99 100644 --- a/salome_adm/unix/config_files/check_libbatch.m4 +++ b/salome_adm/unix/config_files/check_libbatch.m4 @@ -1,5 +1,8 @@ dnl Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE dnl +dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +dnl dnl This library is free software; you can redistribute it and/or dnl modify it under the terms of the GNU Lesser General Public dnl License as published by the Free Software Foundation; either @@ -14,18 +17,19 @@ dnl You should have received a copy of the GNU Lesser General Public dnl License along with this library; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA dnl -dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +dnl See http://www.salome-platform.org/ or +dnl email : webmaster.salome@opencascade.com dnl # CHECK_LIBBATCH -# This macro can be used to find libBatch and set the associated variables in +# This macro can be used to find libbatch and set the associated variables in # a project based on autoconf. You can copy this file in your own project and # eventually modify it according to your own needs. # ---------------------------------------------------------------------------- AC_DEFUN([CHECK_LIBBATCH],[ -AC_MSG_NOTICE(Checking for libBatch library) +AC_MSG_NOTICE(Checking for libbatch library) AC_SUBST(LIBBATCH_INCLUDES) AC_SUBST(LIBBATCH_LIBS) @@ -55,27 +59,27 @@ LOCAL_LIBS="" if test "x$LIBBATCH_DIR" != "x" ; then LOCAL_INCLUDES="-I$LIBBATCH_DIR/include" if test "x$LIBBATCH_DIR" = "x/usr" ; then - LOCAL_LIBS="-lBatch" + LOCAL_LIBS="-lbatch" else - LOCAL_LIBS="-L$LIBBATCH_DIR/lib -lBatch" + LOCAL_LIBS="-L$LIBBATCH_DIR/lib -lbatch" fi else LOCAL_INCLUDES="-I/usr/include" - LOCAL_LIBS="-lBatch" + LOCAL_LIBS="-lbatch" fi -# libBatch headers +# libbatch headers CPPFLAGS_old="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES" -AC_CHECK_HEADER(Batch/Batch_BatchManager.hxx, +AC_CHECK_HEADER(libbatch/BatchManager.hxx, libbatch_ok="yes", libbatch_ok="no") CPPFLAGS="$CPPFLAGS_old" if test "x$libbatch_ok" = "xyes" ; then - # libBatch library + # libbatch library LIBS_old=$LIBS LIBS="$LIBS $LOCAL_LIBS" @@ -106,6 +110,6 @@ if test "x$libbatch_ok" = "xyes" ; then LIBBATCH_LIBS="$LOCAL_LIBS" fi -AC_MSG_RESULT(for libBatch: $libbatch_ok) +AC_MSG_RESULT(for libbatch: $libbatch_ok) ]) diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 3a6cebdf7..1eae28218 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -297,6 +297,8 @@ SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& param } // Step 2: Get all possibleResources from the parameters + // Consider only resources that can run containers + local_params.resource_params.can_run_containers = true; Engines::ResourceList_var possibleResources = _ResManager->GetFittingResources(local_params.resource_params); MESSAGE("[GiveContainer] - length of possible resources " << possibleResources->length()); std::vector local_resources; diff --git a/src/KernelHelpers/SALOME_KernelServices.hxx b/src/KernelHelpers/SALOME_KernelServices.hxx index 572e818d0..257eced8c 100644 --- a/src/KernelHelpers/SALOME_KernelServices.hxx +++ b/src/KernelHelpers/SALOME_KernelServices.hxx @@ -26,7 +26,7 @@ #include "SALOMEconfig.h" #include CORBA_SERVER_HEADER(SALOMEDS) #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) -#include CORBA_SERVER_HEADER(SALOME_ContainerManager) +#include CORBA_SERVER_HEADER(SALOME_Launcher) #include CORBA_CLIENT_HEADER(SALOME_Session) #include CORBA_SERVER_HEADER(SALOME_Exception) diff --git a/src/Launcher/BatchTest.cxx b/src/Launcher/BatchTest.cxx index d765f51e8..80f15513a 100644 --- a/src/Launcher/BatchTest.cxx +++ b/src/Launcher/BatchTest.cxx @@ -24,8 +24,7 @@ #include "Launcher.hxx" #ifdef WITH_LIBBATCH -#include -#include +#include #endif #include "utilities.h" @@ -42,24 +41,16 @@ BatchTest::BatchTest(const Engines::ResourceDefinition& batch_descr) _batch_descr = batch_descr; // Getting date - Batch::Date date = Batch::Date(time(0)); - _date = date.str(); - int lend = _date.size() ; - int i = 0 ; - while (i < lend) - { - if (_date[i] == '/' || _date[i] == '-' || _date[i] == ':' ) - { - _date[i] = '_' ; - } - i++ ; - } - + const size_t BUFSIZE = 32; + char date[BUFSIZE]; + time_t curtime = time(NULL); + strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime)); + // Creating test temporary file _test_filename = "/tmp/"; - _test_filename += _date + "_test_cluster_file_"; + _test_filename += std::string(date) + "_test_cluster_file_"; _test_filename += _batch_descr.hostname.in(); - _base_filename = _date + "_test_cluster_file_" + _batch_descr.hostname.in(); + _base_filename = std::string(date) + "_test_cluster_file_" + _batch_descr.hostname.in(); #endif } diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index d749f8258..f33eb976d 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -21,10 +21,9 @@ // #ifdef WITH_LIBBATCH -#include -#include -#include -#include +#include +#include +#include #endif #include "Basics_Utils.hxx" @@ -65,7 +64,7 @@ Launcher_cpp::~Launcher_cpp() std::map::const_iterator it_job; for(it_job = _launcher_job_map.begin(); it_job != _launcher_job_map.end(); it_job++) delete it_job->second; - std::map ::const_iterator it1; + std::map ::const_iterator it1; for(it1=_batchmap.begin();it1!=_batchmap.end();it1++) delete it1->second; #endif @@ -131,7 +130,7 @@ Launcher_cpp::launchJob(int job_id) // Third step search batch manager for the job into the map -> instanciate one if does not exist #ifdef WITH_LIBBATCH - std::map::const_iterator it = _batchmap.find(job_id); + std::map::const_iterator it = _batchmap.find(job_id); if(it == _batchmap.end()) { createBatchManagerForJob(job); @@ -143,7 +142,7 @@ Launcher_cpp::launchJob(int job_id) job->setBatchManagerJobId(batch_manager_job_id); job->setState("QUEUED"); } - catch(const Batch::EmulationException &ex) + catch(const Batch::GenericException &ex) { LAUNCHER_INFOS("Job is not launched, exception in submitJob: " << ex.message); throw LauncherException(ex.message.c_str()); @@ -176,12 +175,7 @@ Launcher_cpp::getJobState(int job_id) { state = job->updateJobState(); } - catch(const Batch::EmulationException &ex) - { - LAUNCHER_INFOS("getJobState failed, exception: " << ex.message); - throw LauncherException(ex.message.c_str()); - } - catch(const Batch::RunTimeException &ex) + catch(const Batch::GenericException &ex) { LAUNCHER_INFOS("getJobState failed, exception: " << ex.message); throw LauncherException(ex.message.c_str()); @@ -217,7 +211,7 @@ Launcher_cpp::getJobResults(int job_id, std::string directory) else _batchmap[job_id]->importOutputFiles(*(job->getBatchJob()), job->getResultDirectory()); } - catch(const Batch::EmulationException &ex) + catch(const Batch::GenericException &ex) { LAUNCHER_INFOS("getJobResult is maybe incomplete, exception: " << ex.message); throw LauncherException(ex.message.c_str()); @@ -253,7 +247,7 @@ Launcher_cpp::getJobDumpState(int job_id, std::string directory) else rtn = _batchmap[job_id]->importDumpStateFile(*(job->getBatchJob()), job->getResultDirectory()); } - catch(const Batch::EmulationException &ex) + catch(const Batch::GenericException &ex) { LAUNCHER_INFOS("getJobResult is maybe incomplete, exception: " << ex.message); throw LauncherException(ex.message.c_str()); @@ -366,18 +360,20 @@ Launcher_cpp::createJobWithFile(const std::string xmlExecuteFile, * Factory to instanciate the good batch manager for choosen cluster. */ //============================================================================= -Batch::BatchManager_eClient * +Batch::BatchManager * Launcher_cpp::FactoryBatchManager(ParserResourcesType& params) { std::string mpi; Batch::CommunicationProtocolType protocol; - Batch::FactBatchManager_eClient* fact; + Batch::FactBatchManager * fact; - int nb_proc_per_node = params.DataForSort._nbOfProcPerNode; std::string hostname = params.HostName; switch(params.Protocol) { + case sh: + protocol = Batch::SH; + break; case rsh: protocol = Batch::RSH; break; @@ -420,42 +416,42 @@ Launcher_cpp::FactoryBatchManager(ParserResourcesType& params) switch( params.Batch ) { case pbs: - bmType = "ePBS"; + bmType = "PBS"; break; case lsf: - bmType = "eLSF"; + bmType = "LSF"; break; case sge: - bmType = "eSGE"; + bmType = "SGE"; break; case ccc: - bmType = "eCCC"; + bmType = "CCC"; break; case slurm: - bmType = "eSLURM"; + bmType = "SLURM"; break; case ssh_batch: - bmType = "eSSH"; + bmType = "LOCAL"; break; case ll: - bmType = "eLL"; + bmType = "LL"; break; case vishnu: - bmType = "eVISHNU"; + bmType = "VISHNU"; break; default: LAUNCHER_MESSAGE("Bad batch description of the resource: Batch = " << params.Batch); throw LauncherException("No batchmanager for that cluster - Bad batch description of the resource"); } Batch::BatchManagerCatalog & cata = Batch::BatchManagerCatalog::getInstance(); - fact = dynamic_cast(cata(bmType)); + fact = dynamic_cast(cata(bmType)); if (fact == NULL) { LAUNCHER_MESSAGE("Cannot find batch manager factory for " << bmType << ". Check your version of libBatch."); throw LauncherException("Cannot find batch manager factory"); } LAUNCHER_MESSAGE("Instanciation of batch manager of type: " << bmType); - Batch::BatchManager_eClient * batch_client = (*fact)(hostname.c_str(), params.UserName.c_str(), - protocol, mpi.c_str(), nb_proc_per_node); + Batch::BatchManager * batch_client = (*fact)(hostname.c_str(), params.UserName.c_str(), + protocol, mpi.c_str()); return batch_client; } @@ -581,6 +577,8 @@ Launcher_cpp::createBatchManagerForJob(Launcher::Job * job) // Select a ressource for the job std::vector ResourceList; resourceParams params = job->getResourceRequiredParams(); + // Consider only resources that can launch batch jobs + params.can_launch_batch_jobs = true; try { ResourceList = _ResManager->GetFittingResources(params); @@ -614,7 +612,7 @@ Launcher_cpp::createBatchManagerForJob(Launcher::Job * job) // Step 2: We can now add a Factory if the resource is correctly define #ifdef WITH_LIBBATCH - std::map::const_iterator it = _batchmap.find(job_id); + std::map::const_iterator it = _batchmap.find(job_id); if(it == _batchmap.end()) { try @@ -622,7 +620,7 @@ Launcher_cpp::createBatchManagerForJob(Launcher::Job * job) // Warning cannot write on one line like this, because map object is constructed before // the method is called... //_batchmap[job_id] = FactoryBatchManager(resource_definition); - Batch::BatchManager_eClient * batch_client = FactoryBatchManager(resource_definition); + Batch::BatchManager * batch_client = FactoryBatchManager(resource_definition); _batchmap[job_id] = batch_client; } catch(const LauncherException &ex) @@ -630,12 +628,7 @@ Launcher_cpp::createBatchManagerForJob(Launcher::Job * job) LAUNCHER_INFOS("Error during creation of the batch manager of the job, mess: " << ex.msg); throw ex; } - catch(const Batch::EmulationException &ex) - { - LAUNCHER_INFOS("Error during creation of the batch manager of the job, mess: " << ex.message); - throw LauncherException(ex.message); - } - catch(const Batch::InvalidArgumentException &ex) + catch(const Batch::GenericException &ex) { LAUNCHER_INFOS("Error during creation of the batch manager of the job, mess: " << ex.message); throw LauncherException(ex.message); @@ -665,7 +658,7 @@ Launcher_cpp::addJobDirectlyToMap(Launcher::Job * new_job, const std::string job job_reference); new_job->setBatchManagerJobId(batch_manager_job_id); } - catch(const Batch::EmulationException &ex) + catch(const Batch::GenericException &ex) { LAUNCHER_INFOS("Job cannot be added, exception in addJob: " << ex.message); throw LauncherException(ex.message.c_str()); diff --git a/src/Launcher/Launcher.hxx b/src/Launcher/Launcher.hxx index f459fca2c..9faae9206 100644 --- a/src/Launcher/Launcher.hxx +++ b/src/Launcher/Launcher.hxx @@ -39,7 +39,7 @@ class MpiImpl; namespace Batch{ - class BatchManager_eClient; + class BatchManager; class Job; } @@ -83,8 +83,8 @@ protected: // Methods used by user interface methods #ifdef WITH_LIBBATCH - Batch::BatchManager_eClient *FactoryBatchManager(ParserResourcesType& params); - std::map _batchmap; + Batch::BatchManager *FactoryBatchManager(ParserResourcesType& params); + std::map _batchmap; #endif ParserLauncherType ParseXmlFile(std::string xmlExecuteFile); diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index 1307fbf22..b6744859c 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -23,7 +23,7 @@ #include "Launcher.hxx" #ifdef WITH_LIBBATCH -#include +#include #endif Launcher::Job::Job() @@ -79,7 +79,7 @@ Launcher::Job::stopJob() { _batch_job_id.deleteJob(); } - catch (const Batch::EmulationException &ex) + catch (const Batch::GenericException &ex) { LAUNCHER_INFOS("WARNING: exception when stopping the job: " << ex.message); } @@ -99,7 +99,7 @@ Launcher::Job::removeJob() { _batch_job_id.deleteJob(); } - catch (const Batch::EmulationException &ex) + catch (const Batch::GenericException &ex) { LAUNCHER_INFOS("WARNING: exception when removing the job: " << ex.message); } @@ -455,8 +455,8 @@ Launcher::Job::common_job_params() Batch::Parametre params; params[Batch::NAME] = getJobName(); - params[Batch::USER] = _resource_definition.UserName; params[Batch::NBPROC] = _resource_required_params.nb_proc; + params[Batch::NBPROCPERNODE] = _resource_required_params.nb_proc_per_node; // Memory in megabytes if (_resource_required_params.mem_mb > 0) @@ -467,22 +467,14 @@ Launcher::Job::common_job_params() // We define a default directory based on user time if (_work_directory == "") { - std::string thedate; - Batch::Date date = Batch::Date(time(0)); - thedate = date.str(); - int lend = thedate.size() ; - int i = 0 ; - while ( i < lend ) { - if ( thedate[i] == '/' || thedate[i] == '-' || thedate[i] == ':' ) { - thedate[i] = '_' ; - } - i++ ; - } - _work_directory = std::string("$HOME/Batch/"); - _work_directory += thedate; + const size_t BUFSIZE = 32; + char date[BUFSIZE]; + time_t curtime = time(NULL); + strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime)); + _work_directory = std::string("$HOME/Batch/workdir_"); + _work_directory += date; } params[Batch::WORKDIR] = _work_directory; - params[Batch::TMPDIR] = _work_directory; // To Compatibility -- remove ??? TODO // If result_directory is not defined, we use HOME environnement if (_result_directory == "") diff --git a/src/Launcher/Launcher_Job.hxx b/src/Launcher/Launcher_Job.hxx index bbff80f54..02b9d538a 100644 --- a/src/Launcher/Launcher_Job.hxx +++ b/src/Launcher/Launcher_Job.hxx @@ -38,10 +38,9 @@ #include #ifdef WITH_LIBBATCH -#include -#include -#include -#include +#include +#include +#include #endif #include diff --git a/src/Launcher/Launcher_Job_Command.cxx b/src/Launcher/Launcher_Job_Command.cxx index 6f2fecebd..0b00b6fb3 100644 --- a/src/Launcher/Launcher_Job_Command.cxx +++ b/src/Launcher/Launcher_Job_Command.cxx @@ -23,7 +23,7 @@ #include "Basics_DirUtils.hxx" #ifdef WITH_LIBBATCH -#include +#include #endif #ifdef WNT diff --git a/src/Launcher/Launcher_Job_Command.hxx b/src/Launcher/Launcher_Job_Command.hxx index ead4fb5b2..1d82c9d45 100644 --- a/src/Launcher/Launcher_Job_Command.hxx +++ b/src/Launcher/Launcher_Job_Command.hxx @@ -26,7 +26,7 @@ #include "Launcher.hxx" #ifdef WITH_LIBBATCH -#include +#include #endif namespace Launcher diff --git a/src/Launcher/Launcher_Job_SALOME.cxx b/src/Launcher/Launcher_Job_SALOME.cxx index 85f6e1015..655ecd9dc 100644 --- a/src/Launcher/Launcher_Job_SALOME.cxx +++ b/src/Launcher/Launcher_Job_SALOME.cxx @@ -23,7 +23,7 @@ #include "Basics_DirUtils.hxx" #ifdef WITH_LIBBATCH -#include +#include #endif #ifdef WNT @@ -87,7 +87,7 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params) launch_script_stream << "export SALOME_TMP_DIR=" << work_directory << "/logs" << std::endl; // -- Generates Catalog Resources - std::string resource_protocol = ParserResourcesType::protocolToString(_resource_definition.ClusterInternalProtocol); + std::string resource_protocol = _resource_definition.getClusterInternalProtocolStr(); launch_script_stream << "if [ \"x$LIBBATCH_NODEFILE\" != \"x\" ]; then " << std::endl; launch_script_stream << "CATALOG_FILE=" << "CatalogResources_" << _launch_date << ".xml" << std::endl; launch_script_stream << "export USER_CATALOG_RESOURCES_FILE=" << "$CATALOG_FILE" << std::endl; @@ -99,9 +99,10 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params) launch_script_stream << "echo ' protocol=\"" << resource_protocol << "\"' >> $CATALOG_FILE" << std::endl; launch_script_stream << "echo ' userName=\"" << _resource_definition.UserName << "\"' >> $CATALOG_FILE" << std::endl; launch_script_stream << "echo ' appliPath=\"" << _resource_definition.AppliPath << "\"' >> $CATALOG_FILE" << std::endl; - launch_script_stream << "echo ' mpi=\"" << _resource_definition.PrintMpiImplType() << "\"' >> $CATALOG_FILE" << std::endl; - launch_script_stream << "echo ' nbOfNodes='\\\"$nbproc\\\" >> $CATALOG_FILE" << std::endl; - launch_script_stream << "echo ' nbOfProcPerNode=\"1\"' >> $CATALOG_FILE" << std::endl; + launch_script_stream << "echo ' mpi=\"" << _resource_definition.getMpiImplTypeStr() << "\"' >> $CATALOG_FILE" << std::endl; + launch_script_stream << "echo ' nbOfNodes='\\\"$nbproc\\\" >> $CATALOG_FILE" << std::endl; + launch_script_stream << "echo ' nbOfProcPerNode=\"1\"' >> $CATALOG_FILE" << std::endl; + launch_script_stream << "echo ' can_run_containers=\"true\"' >> $CATALOG_FILE" << std::endl; launch_script_stream << "echo '/>' >> $CATALOG_FILE" << std::endl; launch_script_stream << "done" << std::endl; launch_script_stream << "echo '' >> $CATALOG_FILE" << std::endl; diff --git a/src/Launcher/Launcher_Job_SALOME.hxx b/src/Launcher/Launcher_Job_SALOME.hxx index 30351b184..a377a76b3 100644 --- a/src/Launcher/Launcher_Job_SALOME.hxx +++ b/src/Launcher/Launcher_Job_SALOME.hxx @@ -26,7 +26,7 @@ #include "Launcher.hxx" #ifdef WITH_LIBBATCH -#include +#include #endif namespace Launcher diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 433c30b14..c710f4187 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -329,8 +329,12 @@ SALOME_Launcher::testBatch(const Engines::ResourceParameters& params) CORBA::Boolean rtn = false; try { - // find a cluster matching the structure params - Engines::ResourceList *aMachineList = _ResManager->GetFittingResources(params); + // Consider only resources that can run batch jobs + Engines::ResourceParameters new_params(params); + new_params.can_launch_batch_jobs = true; + + // find a resource matching the required parameters + Engines::ResourceList *aMachineList = _ResManager->GetFittingResources(new_params); if (aMachineList->length() == 0) throw SALOME_Exception("No resources have been found with your parameters"); diff --git a/src/Launcher/SALOME_Launcher.hxx b/src/Launcher/SALOME_Launcher.hxx index f33466fe5..8e3df22f3 100644 --- a/src/Launcher/SALOME_Launcher.hxx +++ b/src/Launcher/SALOME_Launcher.hxx @@ -26,7 +26,7 @@ #include "SALOME_Launcher_defs.hxx" #include -#include CORBA_CLIENT_HEADER(SALOME_ContainerManager) +#include CORBA_CLIENT_HEADER(SALOME_Launcher) #include "Launcher.hxx" #include diff --git a/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx b/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx index fce9c4905..73ae4bac9 100644 --- a/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx @@ -125,15 +125,12 @@ std::string SALOME_FileTransferCORBA::getLocalFile(std::string localFile) Engines::ContainerManager_var contManager = LCC.getContainerManager(); Engines::ResourcesManager_var resManager = LCC.getResourcesManager(); - Engines::MachineParameters params; + Engines::ContainerParameters params; LCC.preSet(params); params.container_name = _containerName.c_str(); - params.hostname = _refMachine.c_str(); - - Engines::ContainerParameters new_params; - LCC.convert(params, new_params); - new_params.mode = CORBA::string_dup("findorstart"); - container = contManager->GiveContainer(new_params); + params.resource_params.hostname = _refMachine.c_str(); + params.mode = CORBA::string_dup("findorstart"); + container = contManager->GiveContainer(params); if (CORBA::is_nil(container)) { INFOS("machine " << _refMachine << " unreachable"); diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 6d138af19..7b341e213 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -48,6 +48,7 @@ #include CORBA_CLIENT_HEADER(SALOME_Registry) #include CORBA_CLIENT_HEADER(SALOMEDS) #include CORBA_CLIENT_HEADER(Logger) +#include CORBA_CLIENT_HEADER(SALOME_Launcher) #include "SALOME_ContainerManager.hxx" #include "SALOME_Component_i.hxx" @@ -124,24 +125,24 @@ SALOME_LifeCycleCORBA::~SALOME_LifeCycleCORBA() //============================================================================= /*! \brief Find an already existing and registered component instance. * - * \param params machine parameters like type or name... + * \param params container parameters like type or name... * \param componentName the name of component class * \param studyId default = 0 : multistudy instance * \return a CORBA reference of the component instance, or _nil if not found */ //============================================================================= Engines::EngineComponent_ptr -SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params, +SALOME_LifeCycleCORBA::FindComponent(const Engines::ContainerParameters& params, const char *componentName, int studyId) { if (! isKnownComponentClass(componentName)) return Engines::EngineComponent::_nil(); - Engines::ContainerParameters new_params; - convert(params, new_params); + Engines::ContainerParameters new_params(params); new_params.resource_params.componentList.length(1); new_params.resource_params.componentList[0] = componentName; + new_params.resource_params.can_run_containers = true; Engines::ResourceList_var listOfResources; try { @@ -161,9 +162,9 @@ SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params, } //============================================================================= -/*! \brief Load a component instance on a container defined by machine parameters +/*! \brief Load a component instance on a container defined by its parameters * - * \param params machine parameters like type or name... + * \param params container parameters like type or name... * \param componentName the name of component class * \param studyId default = 0 : multistudy instance * \return a CORBA reference of the component instance, or _nil if problem @@ -171,7 +172,7 @@ SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params, //============================================================================= Engines::EngineComponent_ptr -SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params, +SALOME_LifeCycleCORBA::LoadComponent(const Engines::ContainerParameters& params, const char *componentName, int studyId) { @@ -180,10 +181,10 @@ SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params, if (! isKnownComponentClass(componentName)) return Engines::EngineComponent::_nil(); - Engines::ContainerParameters new_params; - convert(params, new_params); + Engines::ContainerParameters new_params(params); new_params.resource_params.componentList.length(1); new_params.resource_params.componentList[0] = componentName; + new_params.resource_params.can_run_containers = true; Engines::ResourceList_var listOfResources; try @@ -205,64 +206,15 @@ SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params, //============================================================================= /*! \brief Find an already existing and registered component instance or load a new - * component instance on a container defined by machine parameters. + * component instance on a container defined by its parameters. * - * \param params machine parameters like type or name... + * \param params container parameters like type or name... * \param componentName the name of component class * \param studyId default = 0 : multistudy instance * \return a CORBA reference of the component instance, or _nil if problem */ //============================================================================= -Engines::EngineComponent_ptr -SALOME_LifeCycleCORBA:: -FindOrLoad_Component(const Engines::MachineParameters& params, - const char *componentName, - int studyId) -{ - // --- Check if Component Name is known in ModuleCatalog - - if (! isKnownComponentClass(componentName)) - return Engines::EngineComponent::_nil(); - - Engines::ContainerParameters new_params; - convert(params, new_params); - new_params.resource_params.componentList.length(1); - new_params.resource_params.componentList[0] = componentName; - - // For Compatibility -> if hostname == localhost put name == hostname - if (std::string(new_params.resource_params.hostname.in()) == "localhost") - { - new_params.resource_params.hostname = CORBA::string_dup(Kernel_Utils::GetHostname().c_str()); - new_params.resource_params.name = CORBA::string_dup(Kernel_Utils::GetHostname().c_str()); - } - - Engines::ResourceList_var listOfResources; - try - { - listOfResources = _ResManager->GetFittingResources(new_params.resource_params); - } - catch( const SALOME::SALOME_Exception& ex ) - { - return Engines::EngineComponent::_nil(); - } - - Engines::EngineComponent_var compo = _FindComponent(new_params, - componentName, - studyId, - listOfResources); - - if(CORBA::is_nil(compo)) - { - new_params.resource_params.resList = listOfResources; - compo = _LoadComponent(new_params, - componentName, - studyId); - } - - return compo._retn(); -} - Engines::EngineComponent_ptr SALOME_LifeCycleCORBA:: FindOrLoad_Component(const Engines::ContainerParameters& params, @@ -277,6 +229,7 @@ FindOrLoad_Component(const Engines::ContainerParameters& params, Engines::ContainerParameters new_params(params); new_params.resource_params.componentList.length(1); new_params.resource_params.componentList[0] = componentName; + new_params.resource_params.can_run_containers = true; Engines::ResourceList_var listOfResources; try @@ -331,22 +284,21 @@ SALOME_LifeCycleCORBA::FindOrLoad_Component(const char *containerName, std::string st2Container(stContainer); int rg=st2Container.find("/"); - Engines::MachineParameters_var params=new Engines::MachineParameters; + Engines::ContainerParameters params; preSet(params); if (rg<0) { // containerName doesn't contain "/" => Local container - params->container_name=CORBA::string_dup(stContainer); - params->hostname=""; + params.container_name = CORBA::string_dup(stContainer); } else { stContainer[rg]='\0'; - params->container_name=CORBA::string_dup(stContainer+rg+1); - params->hostname=CORBA::string_dup(stContainer); + params.container_name = CORBA::string_dup(stContainer+rg+1); + params.resource_params.hostname = CORBA::string_dup(stContainer); } - params->isMPI = false; - SCRUTE(params->container_name); + params.isMPI = false; + SCRUTE(params.container_name); free(stContainer); return FindOrLoad_Component(params, componentName); } @@ -388,54 +340,10 @@ bool SALOME_LifeCycleCORBA::isKnownComponentClass(const char *componentName) } //============================================================================= -/*! - * Not so complex... useful ? +/*! \brief Initialisation of a given Engines::ResourceParameters with default values. */ //============================================================================= -bool -SALOME_LifeCycleCORBA::isMpiContainer(const Engines::ContainerParameters& params) - throw(IncompatibleComponent) -{ - if( params.isMPI ) - return true; - else - return false; -} - - -//============================================================================= -/*! \brief Initialisation of a given Engines::MachineParameters with default values. - * - * - container_name = "" : not relevant - * - hostname = "" : not relevant - * - OS = "" : not relevant - * - nb_proc = 0 : not relevant - * - mem_mb = 0 : not relevant - * - cpu_clock = 0 : not relevant - * - nb_proc_per_node = 0 : not relevant - * - nb_node = 0 : not relevant - * - isMPI = false : standard components - */ -//============================================================================= - -void SALOME_LifeCycleCORBA::preSet(Engines::MachineParameters& params) -{ - params.container_name = ""; - params.hostname = ""; - params.OS = ""; - params.mem_mb = 0; - params.cpu_clock = 0; - params.nb_proc_per_node = 0; - params.nb_node = 0; - params.isMPI = false; - params.workingdir = ""; - params.mode = ""; - params.policy = ""; - params.parallelLib = ""; - params.nb_component_nodes = 0; -} - void SALOME_LifeCycleCORBA::preSet(Engines::ResourceParameters& params) { @@ -448,8 +356,15 @@ SALOME_LifeCycleCORBA::preSet(Engines::ResourceParameters& params) params.nb_node = 0; params.nb_proc_per_node = 0; params.policy = ""; + params.can_launch_batch_jobs = false; + params.can_run_containers = false; } +//============================================================================= +/*! \brief Initialisation of a given Engines::ContainerParameters with default values. + */ +//============================================================================= + void SALOME_LifeCycleCORBA::preSet( Engines::ContainerParameters& params) { params.container_name = ""; @@ -461,34 +376,6 @@ void SALOME_LifeCycleCORBA::preSet( Engines::ContainerParameters& params) SALOME_LifeCycleCORBA::preSet(params.resource_params); } -void -SALOME_LifeCycleCORBA::convert(const Engines::MachineParameters& params_in, - Engines::ContainerParameters& params_out) -{ - SALOME_LifeCycleCORBA::preSet(params_out); - - // Container part - params_out.container_name = params_in.container_name; - params_out.mode = params_in.mode; - params_out.workingdir = params_in.workingdir; - params_out.isMPI = params_in.isMPI; - params_out.parallelLib = params_in.parallelLib; - - // Resource part - params_out.resource_params.hostname = params_in.hostname; - params_out.resource_params.OS = params_in.OS; - params_out.resource_params.mem_mb = params_in.mem_mb; - params_out.resource_params.cpu_clock = params_in.cpu_clock; - params_out.resource_params.nb_node = params_in.nb_node; - params_out.resource_params.nb_proc_per_node = params_in.nb_proc_per_node; - params_out.resource_params.policy = params_in.policy; - params_out.resource_params.componentList = params_in.componentList; - - params_out.resource_params.resList.length(params_in.computerList.length()); - for (CORBA::ULong i = 0; i < params_in.computerList.length(); i++) - params_out.resource_params.resList[i] = params_in.computerList[i]; -} - //============================================================================= /*! * \return a number of processors not 0, only for MPI containers @@ -497,7 +384,7 @@ SALOME_LifeCycleCORBA::convert(const Engines::MachineParameters& params_in, int SALOME_LifeCycleCORBA::NbProc(const Engines::ContainerParameters& params) { - if( !isMpiContainer(params) ) + if( !params.isMPI ) return 0; else if( params.nb_proc <= 0 ) return 1; @@ -768,7 +655,9 @@ _FindComponent(const Engines::ContainerParameters& params, for(unsigned int i=0; i < listOfResources.length(); i++) { const char * currentResource = listOfResources[i]; - CORBA::Object_var obj = _NS->ResolveComponent(currentResource, + Engines::ResourceDefinition_var resource_definition = + _ResManager->GetResourceDefinition(currentResource); + CORBA::Object_var obj = _NS->ResolveComponent(resource_definition->hostname.in(), containerName, componentName, nbproc); @@ -781,7 +670,9 @@ _FindComponent(const Engines::ContainerParameters& params, { resourcesOK->length(lghtOfresourcesOK); CORBA::String_var bestResource = _ResManager->FindFirst(resourcesOK); - CORBA::Object_var obj = _NS->ResolveComponent(bestResource, + Engines::ResourceDefinition_var resource_definition = + _ResManager->GetResourceDefinition(bestResource); + CORBA::Object_var obj = _NS->ResolveComponent(resource_definition->hostname.in(), containerName, componentName, nbproc); diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index be24867f0..671af8fcd 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -65,21 +65,15 @@ public: virtual ~SALOME_LifeCycleCORBA(); Engines::EngineComponent_ptr - FindComponent(const Engines::MachineParameters& params, + FindComponent(const Engines::ContainerParameters& params, const char *componentName, int studyId=0); Engines::EngineComponent_ptr - LoadComponent(const Engines::MachineParameters& params, + LoadComponent(const Engines::ContainerParameters& params, const char *componentName, int studyId=0); - Engines::EngineComponent_ptr - FindOrLoad_Component(const Engines::MachineParameters& params, - const char *componentName, - int studyId =0); - - // SALOME 6 - Interface Engines::EngineComponent_ptr FindOrLoad_Component(const Engines::ContainerParameters& params, const char *componentName, @@ -87,7 +81,7 @@ public: Engines::EngineComponent_ptr FindOrLoad_Component(const char *containerName, - const char *componentName); // for compatibility + const char *componentName); // Parallel extension Engines::EngineComponent_ptr @@ -97,12 +91,8 @@ public: bool isKnownComponentClass(const char *componentName); - bool isMpiContainer(const Engines::ContainerParameters& params) - throw(IncompatibleComponent); - int NbProc(const Engines::ContainerParameters& params); - static void preSet(Engines::MachineParameters& outparams); static void preSet(Engines::ResourceParameters& outparams); static void preSet(Engines::ContainerParameters& outparams); @@ -115,10 +105,6 @@ public: void shutdownServers(); static void killOmniNames(); - // For SALOME 5.1.x - // Will be deleted on SALOME 6 - void convert(const Engines::MachineParameters& params_in, - Engines::ContainerParameters& params_out); protected: /*! Establish if a component called "componentName" in a container called diff --git a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx index 1212c0fb7..410c80706 100644 --- a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx +++ b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx @@ -420,7 +420,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsEmpty() { SALOME_LifeCycleCORBA _LCC(&_NS); - Engines::MachineParameters params; + Engines::ContainerParameters params; _LCC.preSet(params); Engines::EngineComponent_var mycompo = _LCC.FindOrLoad_Component(params,"SalomeTestComponent"); @@ -443,10 +443,10 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsLocalContainer() { SALOME_LifeCycleCORBA _LCC(&_NS); - Engines::MachineParameters params; + Engines::ContainerParameters params; _LCC.preSet(params); std::string hostname=Kernel_Utils::GetHostname(); - params.hostname=hostname.c_str(); + params.resource_params.hostname=hostname.c_str(); Engines::EngineComponent_var mycompo = _LCC.FindOrLoad_Component(params,"SalomeTestComponent"); CPPUNIT_ASSERT(!CORBA::is_nil(mycompo)); @@ -477,7 +477,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsContainerName() { SALOME_LifeCycleCORBA _LCC(&_NS); - Engines::MachineParameters params; + Engines::ContainerParameters params; _LCC.preSet(params); std::string containerName = "myContainer"; params.container_name = containerName.c_str(); @@ -551,9 +551,9 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsRemoteComputer() std::string remoteHost = GetRemoteHost(); - Engines::MachineParameters params; + Engines::ContainerParameters params; _LCC.preSet(params); - params.hostname = remoteHost.c_str(); + params.resource_params.hostname = remoteHost.c_str(); Engines::EngineComponent_var mycompo1 = _LCC.FindOrLoad_Component(params,"SalomeTestComponent"); @@ -589,9 +589,9 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsRemoteComputer2() std::string remoteHost = GetRemoteHost(); - Engines::MachineParameters params; + Engines::ContainerParameters params; _LCC.preSet(params); - params.hostname = remoteHost.c_str(); + params.resource_params.hostname = remoteHost.c_str(); params.container_name = "anotherContainer"; Engines::EngineComponent_var mycompo1 = @@ -686,6 +686,7 @@ std::string LifeCycleCORBATest::GetRemoteHost() _LCC.preSet(params); // empty params to get all the machines params.resource_params.componentList.length(1); params.resource_params.componentList[0]="SalomeTestComponent"; + params.resource_params.can_run_containers = true; Engines::ResourceList_var hostList = resourcesManager->GetFittingResources(params.resource_params); CPPUNIT_ASSERT(hostList->length() > 1); diff --git a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py index 44d42461f..ab676f635 100644 --- a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py +++ b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py @@ -40,14 +40,6 @@ class LifeCycleCORBA (SALOME_LifeCycleCORBA): containerName, componentName) -class MachineParameters (Engines.MachineParameters): - def __init__(self, container_name='', hostname='', componentList=[], computerList=[], OS='', - mem_mb=0, cpu_clock=0, nb_proc_per_node=0, nb_node=0, isMPI=False, workingdir='', - mode='start', policy='altcycl', parallelLib='', nb_component_nodes=0): - Engines.MachineParameters.__init__(self,container_name, hostname, componentList, computerList, OS, - mem_mb, cpu_clock, nb_proc_per_node, nb_node, isMPI, workingdir, - mode, policy, parallelLib, nb_component_nodes) - class ContainerParameters (Engines.ContainerParameters): def __init__(self, container_name='', mode='start', workingdir='', nb_proc=0, isMPI=False, parallelLib='',resource_params=None): if resource_params is None:resource_params=ResourceParameters() @@ -56,10 +48,10 @@ class ContainerParameters (Engines.ContainerParameters): class ResourceParameters (Engines.ResourceParameters): def __init__(self, name="", hostname="", OS="", componentList=[], nb_proc=0, mem_mb=0, cpu_clock=0, nb_node=0, nb_proc_per_node=0, - policy="", resList=[]): - Engines.ResourceParameters.__init__(self, name, hostname, OS, componentList, - nb_proc, mem_mb, cpu_clock, nb_node, nb_proc_per_node, - policy, resList) + policy="", resList=[], can_launch_batch_jobs = False, can_run_containers = False): + Engines.ResourceParameters.__init__(self, name, hostname, can_launch_batch_jobs, can_run_containers, + OS, componentList, nb_proc, mem_mb, cpu_clock, nb_node, + nb_proc_per_node, policy, resList) class JobParameters (Engines.JobParameters): def __init__(self, job_name="", job_type="", job_file="", env_file="", in_files=[], out_files=[], @@ -72,7 +64,9 @@ class JobParameters (Engines.JobParameters): class ResourceDefinition(Engines.ResourceDefinition): def __init__(self, name="", hostname="", protocol="rsh", username="", applipath="", componentList=[], mode="interactive", OS="", mem_mb=1, cpu_clock=1, nb_node=1, nb_proc_per_node=1, - batch="", mpiImpl="", iprotocol="rsh"): - Engines.ResourceDefinition.__init__(self, name, hostname, protocol, username, applipath, componentList, - mode, OS, mem_mb, cpu_clock, nb_node, nb_proc_per_node, batch, - mpiImpl, iprotocol) + batch="", mpiImpl="", iprotocol="rsh", type = "single_machine", + can_launch_batch_jobs = False, can_run_containers = False, working_directory = ""): + Engines.ResourceDefinition.__init__(self, name, hostname, type, protocol, username, applipath, + componentList, OS, mem_mb, cpu_clock, nb_node, nb_proc_per_node, + batch, mpiImpl, iprotocol, can_launch_batch_jobs, + can_run_containers, working_directory) diff --git a/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py index 31d1d310f..7fb60dfeb 100644 --- a/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py +++ b/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py @@ -37,10 +37,9 @@ try : obj=lcc.FindOrLoad_Component("FactoryServer","SalomeTestComponent") comp=obj._narrow(Engines.TestComponent) comp.Coucou(1) - param={} - #param['hostname']='cli76cc' - param['hostname']=host - param['container_name']='FactoryServer' + param = LifeCycleCORBA.ContainerParameters() + param.resource_params.hostname = host + param.container_name = 'FactoryServer' comp=lcc.FindOrLoad_Component(param,'SalomeTestComponent') engine=lcc.FindComponent(param,'SalomeTestComponent') engine.Coucou(1) @@ -58,31 +57,32 @@ context_name.append(CosNaming.NameComponent( 'ContainerManager' , 'object' ) ) ContainerManager = rootContext.resolve( context_name ) try : - myContainerparamsCPP = Engines.MachineParameters( 'myContainer' , host , 'osf' , 0 , 0 , 0 , 0 , 0 ) + myContainerparamsCPP = LifeCycleCORBA.ContainerParameters() + param.resource_params.hostname = host + param.container_name = 'myContainer' computerlistCPP = [host] containerCPP = ContainerManager.FindOrStartContainer( myContainerparamsCPP , computerlistCPP ) containerCPP.ping() ComponentparamsCPP={} ComponentparamsCPP['hostname']=host ComponentparamsCPP['container_name']='myContainer' - compCPP=lcc.FindOrLoad_Component(ComponentparamsCPP,'SalomeTestComponent') + compCPP=lcc.FindOrLoad_Component(myContainerparamsCPP,'SalomeTestComponent') compCPP.Coucou(1) - engineCPP=lcc.FindComponent(ComponentparamsCPP,'SalomeTestComponent') + engineCPP=lcc.FindComponent(myContainerparamsCPP,'SalomeTestComponent') engineCPP.Coucou(1) except : print 'ContainerManager.FindOrStartContainer( myContainerparams , computerlist ) C++ failed' try : - myContainerparamsPy = Engines.MachineParameters( 'myContainerPy' , host , 'osf' , 0 , 0 , 0 , 0 , 0 ) + myContainerparamsPy = LifeCycleCORBA.ContainerParameters() + param.resource_params.hostname = host + param.container_name = 'myContainerPy' computerlistPy = [host] containerPy = ContainerManager.FindOrStartContainer( myContainerparamsPy , computerlistPy ) containerPy.ping() - ComponentparamsPy={} - ComponentparamsPy['hostname']=host - ComponentparamsPy['container_name']='myContainerPy' - compPy=lcc.FindOrLoad_Component(ComponentparamsPy,'SALOME_TestComponentPy') + compPy=lcc.FindOrLoad_Component(myContainerparamsPy,'SALOME_TestComponentPy') compPy.Coucou(1) - enginePy=lcc.FindComponent(ComponentparamsPy,'SALOME_TestComponentPy') + enginePy=lcc.FindComponent(myContainerparamsPy,'SALOME_TestComponentPy') enginePy.Coucou(1) except : print 'ContainerManager.FindOrStartContainer( myContainerparams , computerlist ) Python failed' diff --git a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i index 3990d9d86..59ccceaa6 100644 --- a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i +++ b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i @@ -119,18 +119,21 @@ omniORBpyAPI* api; } } -%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) const Engines::MachineParameters & +// We use a dictionary to represent ContainerParameters structure instead of the CORBA +// structure itself because it would require a transformation from the Python +// ContainerParameters structure, generated by omniOrbPy, to a C++ ContainerParameters +// structure, generated by omniOrb, and this would be quite complex. +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) const Engines::ContainerParameters & { $1 = PyDict_Check($input)? 1 : 0; } -%typemap(in) const Engines::MachineParameters & +%typemap(in) const Engines::ContainerParameters & { - //printf("typemap in on Engines::MachineParameters\n"); - MESSAGE("typemap in on Engines::MachineParameters"); + MESSAGE("typemap in on Engines::ContainerParameters"); if (PyDict_Check($input) == 1) { - Engines::MachineParameters *param = new Engines::MachineParameters ; + Engines::ContainerParameters *param = new Engines::ContainerParameters ; SALOME_LifeCycleCORBA::preSet(*param); PyObject *key, *value; @@ -142,29 +145,33 @@ omniORBpyAPI* api; { param->container_name = CORBA::string_dup(PyString_AsString(value)); } + else if (strcmp(keystr,"resource_name")==0) + { + param->resource_params.name = CORBA::string_dup(PyString_AsString(value)); + } else if (strcmp(keystr,"hostname")==0) { - param->hostname = CORBA::string_dup(PyString_AsString(value)); + param->resource_params.hostname = CORBA::string_dup(PyString_AsString(value)); } else if (strcmp(keystr,"OS")==0) { - param->OS = CORBA::string_dup(PyString_AsString(value)); + param->resource_params.OS = CORBA::string_dup(PyString_AsString(value)); } else if (strcmp(keystr,"mem_mb")==0) { - param->mem_mb = PyLong_AsLong(value); + param->resource_params.mem_mb = PyLong_AsLong(value); } else if (strcmp(keystr,"cpu_clock")==0) { - param->cpu_clock = PyLong_AsLong(value); + param->resource_params.cpu_clock = PyLong_AsLong(value); } else if (strcmp(keystr,"nb_proc_per_node")==0) { - param->nb_proc_per_node = PyLong_AsLong(value); + param->resource_params.nb_proc_per_node = PyLong_AsLong(value); } else if (strcmp(keystr,"nb_node")==0) { - param->nb_node = PyLong_AsLong(value); + param->resource_params.nb_node = PyLong_AsLong(value); } else if (strcmp(keystr,"isMPI")==0) { @@ -175,28 +182,24 @@ omniORBpyAPI* api; else if (strcmp(keystr,"mode")==0) param->mode = CORBA::string_dup(PyString_AsString(value)); else if (strcmp(keystr,"policy")==0) - param->policy = CORBA::string_dup(PyString_AsString(value)); + param->resource_params.policy = CORBA::string_dup(PyString_AsString(value)); else if (strcmp(keystr,"parallelLib")==0) { param->parallelLib = CORBA::string_dup(PyString_AsString(value)); } - else if (strcmp(keystr,"nb_component_nodes")==0) - { - param->nb_component_nodes = PyLong_AsLong(value); - } } $1 = param; } else { - MESSAGE("Not a dictionnary"); - PyErr_SetString(PyExc_TypeError,"Must Be a Python Dictionnary"); + MESSAGE("Not a ContainerParameters struct"); + PyErr_SetString(PyExc_TypeError,"Must Be a Python ContainerParameters object"); return NULL; } } -%typemap(freearg) const Engines::MachineParameters & +%typemap(freearg) const Engines::ContainerParameters & { MESSAGE("delete $1"); delete $1; diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index b58acc661..31acb78c4 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -587,48 +587,18 @@ std::string SALOME_NamingService::ContainerName(const char *containerName) } // ============================================================================ -/*! \brief build a container name, given a MachineParameters struct. +/*! \brief build a container name, given a ContainerParameters struct. * - * Build a container name with a MachineParameters struct. In case of multi - * processor machine, container name is suffixed with _nbproc. nproc equals - * (number of nodes)*(number of processor per nodes). - * \param params struct from which we get container name (may be - * empty), number of nodes and number of processor - * per node. + * Build a container name with a ContainerParameters struct. In case of multi + * processor machine, container name is suffixed with number of processors. + * \param params struct from which we get container name (may be empty) and + * number of processors. * \return a container name without the path. - * \sa BuildContainerNameForNS(const Engines::MachineParameters& params, + * \sa BuildContainerNameForNS(const Engines::ContainerParameters& params, * const char *hostname) */ // ============================================================================ -std::string -SALOME_NamingService::ContainerName(const Engines::MachineParameters& params) -{ - int nbproc; - - if ( !params.isMPI ) - nbproc = 0; - else if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) ) - nbproc = 1; - else if ( params.nb_node == 0 ) - nbproc = params.nb_proc_per_node; - else if ( params.nb_proc_per_node == 0 ) - nbproc = params.nb_node; - else - nbproc = params.nb_node * params.nb_proc_per_node; - - std::string ret = ContainerName(params.container_name); - - if ( nbproc >= 1 ) - { - char *suffix = new char[8]; - sprintf(suffix, "_%d", nbproc); - ret += suffix; - } - - return ret; -} - std::string SALOME_NamingService::ContainerName(const Engines::ContainerParameters& params) { @@ -690,19 +660,6 @@ std::string SALOME_NamingService::BuildContainerNameForNS(const char *containerN */ // ============================================================================ -std::string -SALOME_NamingService:: -BuildContainerNameForNS(const Engines::MachineParameters& params, - const char *hostname) -{ - std::string ret = "/Containers/"; - ret += hostname; - ret += "/"; - ret += ContainerName(params); - - return ret; -} - std::string SALOME_NamingService:: BuildContainerNameForNS(const Engines::ContainerParameters& params, diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx index fa30e8db6..def34d138 100644 --- a/src/NamingService/SALOME_NamingService.hxx +++ b/src/NamingService/SALOME_NamingService.hxx @@ -74,11 +74,6 @@ public: BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname); - // Will Be deleted on SALOME 6 - std::string ContainerName(const Engines::MachineParameters& params); - std::string - BuildContainerNameForNS(const Engines::MachineParameters& params, - const char *hostname); int Find(const char* name) throw(ServiceUnreachable); bool Create_Directory(const char* Path) diff --git a/src/NamingService/Test/CMakeLists.txt b/src/NamingService/Test/CMakeLists.txt index ad43dbd1c..af3df9a10 100755 --- a/src/NamingService/Test/CMakeLists.txt +++ b/src/NamingService/Test/CMakeLists.txt @@ -26,6 +26,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../../Utils + ${CMAKE_CURRENT_SOURCE_DIR}/../../LifeCycleCORBA ${CMAKE_BINARY_DIR}/idl ${CMAKE_CURRENT_SOURCE_DIR}/../../SALOMELocalTrace/Test ${CMAKE_CURRENT_SOURCE_DIR}/../../SALOMETraceCollector/Test @@ -37,6 +38,7 @@ INCLUDE_DIRECTORIES( SET(COMMON_LIBS ${CPPUNIT_LIBS} SalomeNS + SalomeLifeCycleCORBA ${OMNIORB_LIBRARIES} ${PLATFORM_LIBS} ) diff --git a/src/NamingService/Test/Makefile.am b/src/NamingService/Test/Makefile.am index f8073e03c..113e088f4 100644 --- a/src/NamingService/Test/Makefile.am +++ b/src/NamingService/Test/Makefile.am @@ -55,13 +55,16 @@ COMMON_CPPFLAGS=\ -I$(srcdir)/$(RPATH)/Basics \ -I$(srcdir)/$(RPATH)/SALOMELocalTrace \ -I$(srcdir)/$(RPATH)/Utils \ + -I$(srcdir)/$(RPATH)/LifeCycleCORBA \ -I$(top_builddir)/idl \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ # This local variable defines the list of dependant libraries common to all target in this package. COMMON_LIBS =\ @CPPUNIT_LIBS@ \ - ../libSalomeNS.la @CORBA_LIBS@ + ../libSalomeNS.la \ + ../../LifeCycleCORBA/libSalomeLifeCycleCORBA.la \ + @CORBA_LIBS@ # # =============================================================== diff --git a/src/NamingService/Test/NamingServiceTest.cxx b/src/NamingService/Test/NamingServiceTest.cxx index b36194d05..e48ebc1ed 100644 --- a/src/NamingService/Test/NamingServiceTest.cxx +++ b/src/NamingService/Test/NamingServiceTest.cxx @@ -24,6 +24,7 @@ #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" #include "Basics_Utils.hxx" +#include "SALOME_LifeCycleCORBA.hxx" #include #include @@ -824,15 +825,8 @@ NamingServiceTest::testContainerName() void NamingServiceTest::testContainerNameParams() { - Engines::MachineParameters params; - params.container_name = ""; - params.hostname = ""; - params.OS = ""; - params.mem_mb = 0; - params.cpu_clock = 0; - params.nb_proc_per_node = 0; - params.nb_node = 0; - params.isMPI = false; + Engines::ContainerParameters params; + SALOME_LifeCycleCORBA::preSet(params); std::string ref0 = "FactoryServer"; std::string ret = _NS.ContainerName(params); @@ -871,15 +865,8 @@ NamingServiceTest::testBuildContainerNameForNS() void NamingServiceTest::testBuildContainerNameForNSParams() { - Engines::MachineParameters params; - params.container_name = ""; - params.hostname = ""; - params.OS = ""; - params.mem_mb = 0; - params.cpu_clock = 0; - params.nb_proc_per_node = 0; - params.nb_node = 0; - params.isMPI = false; + Engines::ContainerParameters params; + SALOME_LifeCycleCORBA::preSet(params); params.container_name = "theContainerName"; std::string ref0 = "/Containers/theHostName/theContainerName"; diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index 23d8e781e..44e3f577e 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -38,8 +38,14 @@ #include +#include "Utils_SALOME_Exception.hxx" + #define MAX_SIZE_FOR_HOSTNAME 256; +using namespace std; + +const string ResourcesManager_cpp::DEFAULT_RESOURCE_NAME = "localhost"; + static LoadRateManagerFirst first; static LoadRateManagerCycl cycl; static LoadRateManagerAltCycl altcycl; @@ -61,6 +67,8 @@ ResourcesManager_cpp(const char *xmlFilePath) _resourceManagerMap["altcycl"]=&altcycl; _resourceManagerMap["best"]=&altcycl; _resourceManagerMap[""]=&altcycl; + + AddDefaultResourceInCatalog(); } //============================================================================= @@ -84,6 +92,8 @@ ResourcesManager_cpp::ResourcesManager_cpp() throw(ResourcesException) _resourceManagerMap["best"]=&altcycl; _resourceManagerMap[""]=&altcycl; + AddDefaultResourceInCatalog(); + bool default_catalog_resource = true; if (getenv("USER_CATALOG_RESOURCES_FILE") != 0) { @@ -266,13 +276,25 @@ ResourcesManager_cpp::GetFittingResources(const resourceParams& params) throw(Re // Step 5 SelectOnlyResourcesWithOS(vec, params.OS.c_str()); - + // Step 6 std::vector vec_save(vec); KeepOnlyResourcesWithComponent(vec, params.componentList); if (vec.size() == 0) vec = vec_save; + // Step 7 : Filter on possible usage + vector prev_list(vec); + vec.clear(); + for (vector::iterator iter = prev_list.begin() ; iter != prev_list.end() ; iter++) + { + MapOfParserResourcesType::const_iterator it = _resourcesList.find(*iter); + if (it != _resourcesList.end() && + (!params.can_launch_batch_jobs || it->second.can_launch_batch_jobs) && + (!params.can_run_containers || it->second.can_run_containers)) + vec.push_back(*iter); + } + // End // Send an exception if return list is empty... if (vec.size() == 0) @@ -291,8 +313,11 @@ ResourcesManager_cpp::GetFittingResources(const resourceParams& params) throw(Re //============================================================================= void -ResourcesManager_cpp::AddResourceInCatalog(const ParserResourcesType & new_resource) throw(ResourcesException) +ResourcesManager_cpp::AddResourceInCatalog(const ParserResourcesType & new_resource) { + if (new_resource.Name == DEFAULT_RESOURCE_NAME) + throw SALOME_Exception((string("Cannot modify default local resource \"") + + DEFAULT_RESOURCE_NAME + "\"").c_str()); // TODO - Add minimal check _resourcesList[new_resource.Name] = new_resource; } @@ -305,6 +330,9 @@ ResourcesManager_cpp::AddResourceInCatalog(const ParserResourcesType & new_resou void ResourcesManager_cpp::DeleteResourceInCatalog(const char * name) { + if (DEFAULT_RESOURCE_NAME == name) + throw SALOME_Exception((string("Cannot delete default local resource \"") + + DEFAULT_RESOURCE_NAME + "\"").c_str()); MapOfParserResourcesType_it it = _resourcesList.find(name); if (it != _resourcesList.end()) _resourcesList.erase(name); @@ -322,6 +350,16 @@ void ResourcesManager_cpp::WriteInXmlFile(std::string xml_file) { RES_MESSAGE("WriteInXmlFile : start"); + MapOfParserResourcesType resourceListToSave(_resourcesList); + // We do not save default local resource because it is automatically created at startup + resourceListToSave.erase(DEFAULT_RESOURCE_NAME); + if (resourceListToSave.empty()) + { + RES_MESSAGE("WriteInXmlFile: nothing to do, no resource except default \"" << + DEFAULT_RESOURCE_NAME << "\""); + return; + } + if (xml_file == "") { _path_resources_it = _path_resources.begin(); @@ -341,7 +379,7 @@ void ResourcesManager_cpp::WriteInXmlFile(std::string xml_file) xmlNewDocComment(aDoc, BAD_CAST "ResourcesCatalog"); SALOME_ResourcesCatalog_Handler* handler = - new SALOME_ResourcesCatalog_Handler(_resourcesList); + new SALOME_ResourcesCatalog_Handler(resourceListToSave); handler->PrepareDocToXmlFile(aDoc); delete handler; @@ -371,7 +409,7 @@ const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFiles() int result = stat((*_path_resources_it).c_str(), &statinfo); if (result < 0) { - std::cerr << "Error in method stat for file : " << (*_path_resources_it).c_str() << " no new xml file is parsed" << std::endl; + RES_MESSAGE("Resource file " << *_path_resources_it << " does not exist"); return _resourcesList; } @@ -385,6 +423,7 @@ const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFiles() if (to_parse) { _resourcesList.clear(); + AddDefaultResourceInCatalog(); // On parse tous les fichiers for(_path_resources_it = _path_resources.begin(); _path_resources_it != _path_resources.end(); ++_path_resources_it) { @@ -406,13 +445,19 @@ const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFiles() for (MapOfParserResourcesType_it i = _resourcesList_tmp.begin(); i != _resourcesList_tmp.end(); ++i) { MapOfParserResourcesType_it j = _resourcesList.find(i->first); - if (j == _resourcesList.end()) + if (i->second.HostName == "localhost" || i->second.HostName == Kernel_Utils::GetHostname()) { - _resourcesList[i->first] = i->second; + RES_MESSAGE("Resource " << i->first << " is not added because it is the same " + "machine as default local resource \"" << DEFAULT_RESOURCE_NAME << "\""); + } + else if (j != _resourcesList.end()) + { + cerr << "ParseXmlFiles Warning, two resources with the same name were found, " + "taking the first declaration : " << i->first << endl; } else { - std::cerr << "ParseXmlFiles Warning, two resources with the same name were found, taking the first declaration : " << i->first << std::endl; + _resourcesList[i->first] = i->second; } } } @@ -525,3 +570,23 @@ ResourcesManager_cpp::GetResourcesDescr(const std::string & name) throw ResourcesException(error); } } + +void ResourcesManager_cpp::AddDefaultResourceInCatalog() +{ + ParserResourcesType resource; + resource.Name = DEFAULT_RESOURCE_NAME; + // We can't use "localhost" for parameter hostname because the containers are registered in the + // naming service with the real hostname, not "localhost" + resource.HostName = Kernel_Utils::GetHostname(); + resource.DataForSort._Name = DEFAULT_RESOURCE_NAME; + resource.Protocol = sh; + resource.Batch = ssh_batch; + if (getenv("HOME") != NULL && getenv("APPLI") != NULL) + { + resource.AppliPath = string(getenv("HOME")) + "/" + getenv("APPLI"); + } + resource.working_directory = "/tmp/salome_localres_workdir"; + resource.can_launch_batch_jobs = true; + resource.can_run_containers = true; + _resourcesList[resource.Name] = resource; +} diff --git a/src/ResourcesManager/ResourcesManager.hxx b/src/ResourcesManager/ResourcesManager.hxx index a85f68497..d1400b3c6 100644 --- a/src/ResourcesManager/ResourcesManager.hxx +++ b/src/ResourcesManager/ResourcesManager.hxx @@ -53,6 +53,8 @@ struct resourceParams { std::string name; std::string hostname; + bool can_launch_batch_jobs; + bool can_run_containers; std::string OS; long nb_proc; long nb_node; @@ -87,7 +89,7 @@ class RESOURCESMANAGER_EXPORT ResourcesManager_cpp std::string Find(const std::string& policy, const std::vector& listOfResources); - void AddResourceInCatalog (const ParserResourcesType & new_resource) throw(ResourcesException); + void AddResourceInCatalog (const ParserResourcesType & new_resource); void DeleteResourceInCatalog(const char * name); @@ -106,6 +108,11 @@ class RESOURCESMANAGER_EXPORT ResourcesManager_cpp void KeepOnlyResourcesWithComponent(std::vector& resources, const std::vector& componentList); + /** + * Add the default local resource in the catalog + */ + void AddDefaultResourceInCatalog(); + //! will contain the path to the ressources catalog std::list _path_resources; std::list::iterator _path_resources_it; @@ -118,6 +125,9 @@ class RESOURCESMANAGER_EXPORT ResourcesManager_cpp //! contain the time where resourcesList was created time_t _lasttime; + + //! the name of the default local resource + static const std::string DEFAULT_RESOURCE_NAME; }; #endif // __RESOURCESMANAGER_HXX__ diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index ae42569dd..40b7d943f 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -33,6 +33,8 @@ #include #include +using namespace std; + //============================================================================= /*! * Constructor @@ -48,6 +50,7 @@ SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& resources_list): _reso test_cluster = "cluster"; test_name = "name"; test_hostname = "hostname"; + test_type = "type"; test_protocol = "protocol"; test_cluster_internal_protocol = "iprotocol"; test_mode = "mode"; @@ -71,6 +74,8 @@ SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& resources_list): _reso test_members = "members"; test_is_cluster_head = "isClusterHead"; test_working_directory = "workingDirectory"; + test_can_launch_batch_jobs = "canLaunchBatchJobs"; + test_can_run_containers = "canRunContainers"; } //============================================================================= @@ -107,13 +112,6 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) // Empty private elements _resources_list.clear(); - //default resources - _resource.Clear(); - _resource.HostName = Kernel_Utils::GetHostname(); - _resource.Name = Kernel_Utils::GetHostname(); - _resource.DataForSort._Name = Kernel_Utils::GetHostname(); - _resources_list[Kernel_Utils::GetHostname()] = _resource; - // Get the document root node xmlNodePtr aCurNode = xmlDocGetRootElement(theDoc); @@ -122,34 +120,38 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) // Processing the document nodes while(aCurNode != NULL) { - // Cas d'une machine ou d'une machine batch + // Declaration of a single machine or a frontal node for a cluster managed by a batch manager if (!xmlStrcmp(aCurNode->name,(const xmlChar*)test_machine)) { - _resource.Clear(); - bool Ok = ProcessMachine(aCurNode, _resource); + ParserResourcesType resource; + bool Ok = ProcessMachine(aCurNode, resource); if (Ok) { // Adding a resource - if(_resource.HostName == "localhost") + if(resource.HostName == "localhost") { - _resource.HostName = Kernel_Utils::GetHostname(); + resource.HostName = Kernel_Utils::GetHostname(); } - std::map::const_iterator iter = _resources_list.find(_resource.Name); + std::map::const_iterator iter = _resources_list.find(resource.Name); if (iter != _resources_list.end()) - RES_INFOS("Warning resource " << _resource.Name << " already added, keep last resource found !"); - _resources_list[_resource.Name] = _resource; + RES_INFOS("Warning resource " << resource.Name << " already added, keep last resource found !"); + _resources_list[resource.Name] = resource; } } - // Cas de la déclaration d'un cluster + // Declaration of a cluster + // Here, a cluster is NOT the frontal node of a cluster managed by a batch manager (classical + // usage of a cluster). It is a group of machines intended to be used for a parallel container. + // The methods ProcessCluster and ProcessMember are only used in the context of parallel + // containers. They are not used in classical Salome usage scenarios. if (!xmlStrcmp(aCurNode->name,(const xmlChar*)test_cluster)) { - _resource.Clear(); - if(ProcessCluster(aCurNode, _resource)) + ParserResourcesType resource; + if(ProcessCluster(aCurNode, resource)) { - std::map::const_iterator iter = _resources_list.find(_resource.Name); + std::map::const_iterator iter = _resources_list.find(resource.Name); if (iter != _resources_list.end()) - RES_INFOS("Warning resource " << _resource.Name << " already added, keep last resource found !"); - _resources_list[_resource.Name] = _resource; + RES_INFOS("Warning resource " << resource.Name << " already added, keep last resource found !"); + _resources_list[resource.Name] = resource; } } aCurNode = aCurNode->next; @@ -162,16 +164,7 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) { std::cerr << "************************************************" << std::endl; std::cerr << "Resource " << (*iter).first << " found:" << std::endl; - std::cerr << " Name: " << (*iter).second.Name << std::endl; - std::cerr << " Hostname: " << (*iter).second.HostName << std::endl; - std::cerr << " Username: " << (*iter).second.UserName << std::endl; - std::cerr << " Appli path: " <<(*iter).second.AppliPath << std::endl; - std::cerr << " OS: " << (*iter).second.OS << std::endl; - std::cerr << " Protocol: " << (*iter).second.PrintAccessProtocolType() << std::endl; - std::cerr << " Internal Protocol: " <<(*iter).second.PrintClusterInternalProtocol() << std::endl; - std::cerr << " Mode: " << (*iter).second.PrintAccessModeType() << std::endl; - std::cerr << " Batch Type: " << (*iter).second.PrintBatchType() << std::endl; - std::cerr << " MPI Impl: " << (*iter).second.PrintMpiImplType() << std::endl; + std::cerr << (*iter).second; std::cerr << "************************************************" << std::endl; } #endif @@ -206,7 +199,7 @@ SALOME_ResourcesCatalog_Handler::ProcessCluster(xmlNodePtr cluster_descr, Parser { resource.Name = resource.HostName; resource.DataForSort._Name = resource.HostName; - std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! No Name found use Hostname for resource: " << _resource.Name << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! No Name found use Hostname for resource: " << resource.Name << std::endl; } if (xmlHasProp(cluster_descr, (const xmlChar*)test_use)) @@ -240,22 +233,7 @@ SALOME_ResourcesCatalog_Handler::ProcessCluster(xmlNodePtr cluster_descr, Parser xmlChar* mpi = xmlGetProp(cluster_descr, (const xmlChar*)test_mpi); std::string anMpi = (const char*)mpi; xmlFree(mpi); - if (anMpi == "lam") - resource.mpi = lam; - else if (anMpi == "mpich1") - resource.mpi = mpich1; - else if (anMpi == "mpich2") - resource.mpi = mpich2; - else if (anMpi == "openmpi") - resource.mpi = openmpi; - else if (anMpi == "ompi") - resource.mpi = ompi; - else if (anMpi == "slurmmpi") - resource.mpi = slurmmpi; - else if (anMpi == "prun") - resource.mpi = prun; - else - resource.mpi = nompi; + resource.setMpiImplTypeStr(anMpi); } // Parsing des membres du cluster @@ -270,7 +248,7 @@ SALOME_ResourcesCatalog_Handler::ProcessCluster(xmlNodePtr cluster_descr, Parser // Process members if (!xmlStrcmp(members->name, (const xmlChar*)test_machine)) { - ParserResourcesClusterMembersType new_member; + ParserResourcesType new_member; if (ProcessMember(members, new_member)) resource.ClusterMembersList.push_back(new_member); } @@ -291,7 +269,7 @@ SALOME_ResourcesCatalog_Handler::ProcessCluster(xmlNodePtr cluster_descr, Parser } bool -SALOME_ResourcesCatalog_Handler::ProcessMember(xmlNodePtr member_descr, ParserResourcesClusterMembersType & resource) +SALOME_ResourcesCatalog_Handler::ProcessMember(xmlNodePtr member_descr, ParserResourcesType & resource) { if (xmlHasProp(member_descr, (const xmlChar*)test_hostname)) { @@ -311,9 +289,9 @@ SALOME_ResourcesCatalog_Handler::ProcessMember(xmlNodePtr member_descr, ParserRe xmlChar* protocol= xmlGetProp(member_descr, (const xmlChar*)test_protocol); try { - resource.Protocol = ParserResourcesType::stringToProtocol((const char *)protocol); + resource.setAccessProtocolTypeStr((const char *)protocol); } - catch (SALOME_Exception e) + catch (const SALOME_Exception & e) { std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine with a bad protocol" << std::endl; std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl; @@ -333,9 +311,9 @@ SALOME_ResourcesCatalog_Handler::ProcessMember(xmlNodePtr member_descr, ParserRe xmlChar* iprotocol= xmlGetProp(member_descr, (const xmlChar*)test_cluster_internal_protocol); try { - resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol((const char *)iprotocol); + resource.setClusterInternalProtocolStr((const char *)iprotocol); } - catch (SALOME_Exception e) + catch (const SALOME_Exception & e) { std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine with a bad protocol" << std::endl; std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl; @@ -431,7 +409,72 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser { resource.Name = resource.HostName; resource.DataForSort._Name = resource.HostName; - std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMachine : !!! Warning !!! No Name found use Hostname for resource: " << _resource.Name << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMachine : !!! Warning !!! No Name found use Hostname for resource: " << resource.Name << std::endl; + } + + // This block is for compatibility with files created in Salome 6. + // It can safely be removed in Salome 8. + if (xmlHasProp(machine_descr, (const xmlChar*)test_mode)) + { + cerr << "Warning: parameter \"" << test_mode << "\" defined for resource \"" << + resource.Name << "\" is deprecated. It will be replaced when your resource " << + "file is saved." << endl; + xmlChar* mode=xmlGetProp(machine_descr, (const xmlChar*)test_mode); + switch ( mode[0] ) + { + case 'i': + resource.can_run_containers = true; + break; + case 'b': + resource.can_launch_batch_jobs = true; + break; + default: + break; + } + xmlFree(mode); + } + + if (xmlHasProp(machine_descr, (const xmlChar*)test_is_cluster_head)) + { + cerr << "Warning: parameter \"" << test_is_cluster_head << "\" defined for resource \"" << + resource.Name << "\" is deprecated. It will be replaced when your resource " << + "file is saved." << endl; + xmlChar* is_cluster_head = xmlGetProp(machine_descr, (const xmlChar*)test_is_cluster_head); + std::string str_ich = (const char*)is_cluster_head; + if (str_ich == "true") + { + resource.type = cluster; + resource.can_launch_batch_jobs = true; + resource.can_run_containers = false; + } + else + { + resource.type = single_machine; + resource.can_run_containers = true; + } + xmlFree(is_cluster_head); + } + // End of compatibility block + + if (xmlHasProp(machine_descr, (const xmlChar*)test_type)) + { + xmlChar* type = xmlGetProp(machine_descr, (const xmlChar*)test_type); + try + { + resource.setResourceTypeStr((const char*)type); + } + catch (const SALOME_Exception & e) + { + cerr << "Warning, invalid type \"" << (const char*)type << "\" for resource \"" << + resource.Name << "\", using default value \"" << resource.getResourceTypeStr() << + "\"" << endl; + } + xmlFree(type); + } + else + { + cerr << "Warning, no type found for resource \"" << resource.Name << + "\", using default value \"" << resource.getResourceTypeStr() << "\"" << endl; } if (xmlHasProp(machine_descr, (const xmlChar*)test_batch_queue)) @@ -440,8 +483,6 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser resource.batchQueue = (const char*)batch_queue; xmlFree(batch_queue); } - else - resource.batchQueue = ""; if (xmlHasProp(machine_descr, (const xmlChar*)test_user_commands)) { @@ -449,110 +490,71 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser resource.userCommands = (const char*)user_commands; xmlFree(user_commands); } - else - resource.userCommands = ""; if (xmlHasProp(machine_descr, (const xmlChar*)test_protocol)) { xmlChar* protocol= xmlGetProp(machine_descr, (const xmlChar*)test_protocol); try { - resource.Protocol = ParserResourcesType::stringToProtocol((const char *)protocol); + resource.setAccessProtocolTypeStr((const char *)protocol); } - catch (SALOME_Exception e) + catch (const SALOME_Exception & e) { - // If it'not in all theses cases, the protocol is affected to rsh - resource.Protocol = rsh; + cerr << "Warning, invalid protocol \"" << (const char*)protocol << "\" for resource \"" << + resource.Name << "\", using default value \"" << + resource.getAccessProtocolTypeStr() << "\"" << endl; } xmlFree(protocol); } - else - resource.Protocol = rsh; if (xmlHasProp(machine_descr, (const xmlChar*)test_cluster_internal_protocol)) { xmlChar* iprotocol= xmlGetProp(machine_descr, (const xmlChar*)test_cluster_internal_protocol); try { - resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol((const char *)iprotocol); + resource.setClusterInternalProtocolStr((const char *)iprotocol); } - catch (SALOME_Exception e) + catch (const SALOME_Exception & e) { - // If it'not in all theses cases, the protocol is affected to rsh - resource.ClusterInternalProtocol = rsh; + cerr << "Warning, invalid internal protocol \"" << (const char*)iprotocol << + "\" for resource \"" << resource.Name << "\", using default value \"" << + resource.getClusterInternalProtocolStr() << "\"" << endl; } xmlFree(iprotocol); } else resource.ClusterInternalProtocol = resource.Protocol; - if (xmlHasProp(machine_descr, (const xmlChar*)test_mode)) - { - xmlChar* mode=xmlGetProp(machine_descr, (const xmlChar*)test_mode); - switch ( mode[0] ) - { - case 'i': - resource.Mode = interactive; - break; - case 'b': - resource.Mode = batch; - break; - default: - // If it'not in all theses cases, the mode is affected to interactive - resource.Mode = interactive; - break; - } - xmlFree(mode); - } - else - resource.Mode = interactive; - if (xmlHasProp(machine_descr, (const xmlChar*)test_batch)) { xmlChar* batch = xmlGetProp(machine_descr, (const xmlChar*)test_batch); - std::string aBatch = (const char*)batch; + try + { + resource.setBatchTypeStr((const char *)batch); + } + catch (const SALOME_Exception & e) + { + cerr << "Warning, invalid batch manager \"" << (const char*)batch << + "\" for resource \"" << resource.Name << "\", using default value \"" << + resource.getBatchTypeStr() << "\"" << endl; + } xmlFree(batch); - if (aBatch == "pbs") - resource.Batch = pbs; - else if (aBatch == "lsf") - resource.Batch = lsf; - else if (aBatch == "sge") - resource.Batch = sge; - else if (aBatch == "ssh_batch") - resource.Batch = ssh_batch; - else if (aBatch == "ccc") - resource.Batch = ccc; - else if (aBatch == "slurm") - resource.Batch = slurm; - else if (aBatch == "ll") - resource.Batch = ll; - else if (aBatch == "vishnu") - resource.Batch = vishnu; - else - resource.Batch = none; } if (xmlHasProp(machine_descr, (const xmlChar*)test_mpi)) { xmlChar* mpi = xmlGetProp(machine_descr, (const xmlChar*)test_mpi); - std::string anMpi = (const char*)mpi; + try + { + resource.setMpiImplTypeStr((const char *)mpi); + } + catch (const SALOME_Exception & e) + { + cerr << "Warning, invalid MPI implementation \"" << (const char*)mpi << + "\" for resource \"" << resource.Name << "\", using default value \"" << + resource.getMpiImplTypeStr() << "\"" << endl; + } xmlFree(mpi); - if (anMpi == "lam") - resource.mpi = lam; - else if (anMpi == "mpich1") - resource.mpi = mpich1; - else if (anMpi == "mpich2") - resource.mpi = mpich2; - else if (anMpi == "openmpi") - resource.mpi = openmpi; - else if (anMpi == "ompi") - resource.mpi = ompi; - else if (anMpi == "slurmmpi") - resource.mpi = slurmmpi; - else if (anMpi == "prun") - resource.mpi = prun; - else - resource.mpi = nompi; } if (xmlHasProp(machine_descr, (const xmlChar*)test_user_name)) @@ -604,23 +606,36 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser xmlFree(nb_of_proc_per_node); } - if (xmlHasProp(machine_descr, (const xmlChar*)test_is_cluster_head)) + if (xmlHasProp(machine_descr, (const xmlChar*)test_can_launch_batch_jobs)) { - xmlChar* is_cluster_head = xmlGetProp(machine_descr, (const xmlChar*)test_is_cluster_head); - std::string str_ich = (const char*)is_cluster_head; - if (str_ich == "true") + xmlChar* can_launch_batch_jobs = xmlGetProp(machine_descr, (const xmlChar*)test_can_launch_batch_jobs); + try { - resource.is_cluster_head = true; + resource.setCanLaunchBatchJobsStr((const char *)can_launch_batch_jobs); } - else + catch (const SALOME_Exception & e) { - resource.is_cluster_head = false; + cerr << "Warning, invalid can_launch_batch_jobs parameter value \"" << + (const char*)can_launch_batch_jobs << "\" for resource \"" << resource.Name << + "\", using default value \"" << resource.getCanLaunchBatchJobsStr() << "\"" << endl; } - xmlFree(is_cluster_head); + xmlFree(can_launch_batch_jobs); } - else + + if (xmlHasProp(machine_descr, (const xmlChar*)test_can_run_containers)) { - resource.is_cluster_head = false; + xmlChar* can_run_containers = xmlGetProp(machine_descr, (const xmlChar*)test_can_run_containers); + try + { + resource.setCanRunContainersStr((const char *)can_run_containers); + } + catch (const SALOME_Exception & e) + { + cerr << "Warning, invalid can_run_containers parameter value \"" << + (const char*)can_run_containers << "\" for resource \"" << resource.Name << + "\", using default value \"" << resource.getCanRunContainersStr() << "\"" << endl; + } + xmlFree(can_run_containers); } if (xmlHasProp(machine_descr, (const xmlChar*)test_working_directory)) @@ -629,10 +644,6 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser resource.working_directory = (const char*)working_directory; xmlFree(working_directory); } - else - { - resource.working_directory = ""; - } // Process children nodes xmlNodePtr aCurSubNode = machine_descr->xmlChildrenNode; @@ -647,16 +658,16 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser { xmlChar* component_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_component_name); std::string aComponentName = (const char*)component_name; - _resource.ComponentsList.push_back(aComponentName); + resource.ComponentsList.push_back(aComponentName); if (xmlHasProp(aCurSubNode, (const xmlChar*)test_module_name)) { xmlChar* module_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name); std::string aModuleName = (const char*)module_name; - _resource.ModulesList.push_back(aModuleName); + resource.ModulesList.push_back(aModuleName); xmlFree(module_name); } else - _resource.ModulesList.push_back(aComponentName); + resource.ModulesList.push_back(aComponentName); xmlFree(component_name); } } @@ -669,8 +680,8 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser { xmlChar* component_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name); std::string aComponentName = (const char*)component_name; - _resource.ComponentsList.push_back(aComponentName); - _resource.ModulesList.push_back(aComponentName); + resource.ComponentsList.push_back(aComponentName); + resource.ModulesList.push_back(aComponentName); xmlFree(component_name); } } @@ -701,90 +712,20 @@ void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc) RES_MESSAGE("Add resource name = " << (*iter).second.Name.c_str()); xmlNewProp(node, BAD_CAST test_name, BAD_CAST (*iter).second.Name.c_str()); xmlNewProp(node, BAD_CAST test_hostname, BAD_CAST (*iter).second.HostName.c_str()); + xmlNewProp(node, BAD_CAST test_type, BAD_CAST (*iter).second.getResourceTypeStr().c_str()); xmlNewProp(node, BAD_CAST test_appli_path, BAD_CAST (*iter).second.AppliPath.c_str()); xmlNewProp(node, BAD_CAST test_batch_queue, BAD_CAST (*iter).second.batchQueue.c_str()); xmlNewProp(node, BAD_CAST test_user_commands, BAD_CAST (*iter).second.userCommands.c_str()); - xmlNewProp(node, - BAD_CAST test_protocol, - BAD_CAST ParserResourcesType::protocolToString((*iter).second.Protocol).c_str()); - xmlNewProp(node, - BAD_CAST test_cluster_internal_protocol, - BAD_CAST ParserResourcesType::protocolToString((*iter).second.ClusterInternalProtocol).c_str()); + xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST (*iter).second.getAccessProtocolTypeStr().c_str()); + xmlNewProp(node, BAD_CAST test_cluster_internal_protocol, + BAD_CAST (*iter).second.getClusterInternalProtocolStr().c_str()); xmlNewProp(node, BAD_CAST test_working_directory, BAD_CAST (*iter).second.working_directory.c_str()); - if ((*iter).second.is_cluster_head) - xmlNewProp(node, BAD_CAST test_is_cluster_head, BAD_CAST "true"); - else - xmlNewProp(node, BAD_CAST test_is_cluster_head, BAD_CAST "false"); - - switch ((*iter).second.Mode) - { - case interactive: - xmlNewProp(node, BAD_CAST test_mode, BAD_CAST "interactive"); - break; - case batch: - xmlNewProp(node, BAD_CAST test_mode, BAD_CAST "batch"); - break; - default: - xmlNewProp(node, BAD_CAST test_mode, BAD_CAST "interactive"); - } - - switch ((*iter).second.Batch) - { - case pbs: - xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "pbs"); - break; - case lsf: - xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "lsf"); - break; - case sge: - xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "sge"); - break; - case ccc: - xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "ccc"); - break; - case slurm: - xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "slurm"); - break; - case ssh_batch: - xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "ssh_batch"); - break; - case ll: - xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "ll"); - break; - case vishnu: - xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "vishnu"); - break; - default: - xmlNewProp(node, BAD_CAST test_batch, BAD_CAST ""); - } - - switch ((*iter).second.mpi) - { - case lam: - xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "lam"); - break; - case mpich1: - xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "mpich1"); - break; - case mpich2: - xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "mpich2"); - break; - case openmpi: - xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "openmpi"); - break; - case ompi: - xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "ompi"); - break; - case slurmmpi: - xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "slurmmpi"); - break; - case prun: - xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "prun"); - break; - default: - xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST ""); - } - + xmlNewProp(node, BAD_CAST test_can_launch_batch_jobs, + BAD_CAST (*iter).second.getCanLaunchBatchJobsStr().c_str()); + xmlNewProp(node, BAD_CAST test_can_run_containers, + BAD_CAST (*iter).second.getCanRunContainersStr().c_str()); + xmlNewProp(node, BAD_CAST test_batch, BAD_CAST (*iter).second.getBatchTypeStr().c_str()); + xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST (*iter).second.getMpiImplTypeStr().c_str()); xmlNewProp(node, BAD_CAST test_user_name, BAD_CAST (*iter).second.UserName.c_str()); std::vector::const_iterator iter2 = (*iter).second.ComponentsList.begin(); diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx index 8d94c3d82..7705c222e 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx @@ -53,27 +53,28 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesCatalog_Handler bool ProcessMachine(xmlNodePtr machine_descr, ParserResourcesType & resource); bool ProcessCluster(xmlNodePtr cluster_descr, ParserResourcesType & resource); - bool ProcessMember(xmlNodePtr member_descr, ParserResourcesClusterMembersType & resource); + bool ProcessMember(xmlNodePtr member_descr, ParserResourcesType & resource); void PrepareDocToXmlFile(xmlDocPtr theDoc); private : std::string previous_component_name; - ParserResourcesType _resource; MapOfParserResourcesType& _resources_list; const char *test_machine; const char *test_cluster; const char *test_name; const char *test_hostname; + const char *test_type; const char *test_protocol; const char *test_cluster_internal_protocol; - const char *test_mode; const char *test_batch; const char *test_mpi; const char *test_user_name; const char *test_appli_path; + const char *test_can_launch_batch_jobs; + const char *test_can_run_containers; // for compatibility const char *test_modules; const char *test_module_name; @@ -89,9 +90,11 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesCatalog_Handler const char *test_user_commands; const char *test_use; const char *test_members; - const char *test_is_cluster_head; const char *test_working_directory; + const char *test_mode; // To be removed in SALOME 8 + const char *test_is_cluster_head; // To be removed in SALOME 8 + }; #endif // SALOME_RESOURCES_CATALOG_HANDLER diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx index 9cf3cfa99..a937d0fe4 100644 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx @@ -25,6 +25,8 @@ #include #include +using namespace std; + #define NULL_VALUE 0 unsigned int ResourceDataToSort::_nbOfProcWanted = NULL_VALUE; @@ -130,10 +132,33 @@ void ResourceDataToSort::Print() const } +ParserResourcesType::ParserResourcesType() +: type(single_machine), + Protocol(ssh), + ClusterInternalProtocol(ssh), + Batch(none), + mpi(nompi), + nbOfProc(1), + can_launch_batch_jobs(false), + can_run_containers(false) +{ + DataForSort._Name = ""; + DataForSort._nbOfNodes = 1; + DataForSort._nbOfProcPerNode = 1; + DataForSort._CPUFreqMHz = 0; + DataForSort._memInMB = 0; +} + +ParserResourcesType::~ParserResourcesType() +{ +} + std::string ParserResourcesType::protocolToString(AccessProtocolType protocol) { switch (protocol) { + case sh: + return "sh"; case rsh: return "rsh"; case ssh: @@ -151,7 +176,9 @@ std::string ParserResourcesType::protocolToString(AccessProtocolType protocol) AccessProtocolType ParserResourcesType::stringToProtocol(const std::string & protocolStr) { - if (protocolStr == "rsh") + if (protocolStr == "sh") + return sh; + else if (protocolStr == "rsh") return rsh; else if (protocolStr == "ssh") return ssh; @@ -162,139 +189,218 @@ AccessProtocolType ParserResourcesType::stringToProtocol(const std::string & pro else if (protocolStr == "blaunch") return blaunch; else - throw SALOME_Exception("Unknown protocol"); + throw SALOME_Exception((string("Unknown protocol ") + protocolStr).c_str()); } -void ParserResourcesType::Print() +ostream & operator<<(ostream &os, const ParserResourcesType &prt) { - std::ostringstream oss; - oss << std::endl << - "Name : " << Name << std::endl << - "HostName : " << HostName << std::endl << - "NbOfNodes : " << DataForSort._nbOfNodes << std::endl << - "NbOfProcPerNode : " << DataForSort._nbOfProcPerNode << std::endl << - "CPUFreqMHz : " << DataForSort._CPUFreqMHz << std::endl << - "MemInMB : " << DataForSort._memInMB << std::endl << - "Protocol : " << protocolToString(Protocol) << std::endl << - "ClusterInternalProtocol : " << protocolToString(ClusterInternalProtocol) << std::endl << - "Mode : " << Mode << std::endl << - "Batch : " << Batch << std::endl << - "mpi : " << mpi << std::endl << - "UserName : " << UserName << std::endl << - "AppliPath : " << AppliPath << std::endl << - "OS : " << OS << std::endl << - "batchQueue : " << batchQueue << std::endl << - "userCommands : " << userCommands << std::endl << - "use : " << use << std::endl << - "NbOfProc : " << nbOfProc << std::endl << - "Modules : " << std::endl << - "Components : " << std::endl << - "Is Cluster Head: " << is_cluster_head << std::endl << - "Working Directory: " << working_directory << std::endl; - - for(unsigned int i=0;i::iterator it; - for(it = ClusterMembersList.begin(); - it != ClusterMembersList.end(); - it++) + os << "Name: " << prt.Name << endl << + "HostName: " << prt.HostName << endl << + "Type: " << prt.getResourceTypeStr() << endl << + "NbOfNodes: " << prt.DataForSort._nbOfNodes << endl << + "NbOfProcPerNode: " << prt.DataForSort._nbOfProcPerNode << endl << + "CPUFreqMHz: " << prt.DataForSort._CPUFreqMHz << endl << + "MemInMB: " << prt.DataForSort._memInMB << endl << + "Protocol: " << prt.getAccessProtocolTypeStr() << endl << + "ClusterInternalProtocol: " << prt.getClusterInternalProtocolStr() << endl << + "Batch: " << prt.getBatchTypeStr() << endl << + "mpi: " << prt.getMpiImplTypeStr() << endl << + "UserName: " << prt.UserName << endl << + "AppliPath: " << prt.AppliPath << endl << + "OS: " << prt.OS << endl << + "batchQueue: " << prt.batchQueue << endl << + "userCommands: " << prt.userCommands << endl << + "use: " << prt.use << endl << + "NbOfProc: " << prt.nbOfProc << endl << + "Can Launch Batch Jobs: " << prt.can_launch_batch_jobs << endl << + "Can Run Containers: " << prt.can_run_containers << endl << + "Working Directory: " << prt.working_directory << endl; + + for(unsigned int i=0 ; i::const_iterator it; + for(it = prt.ClusterMembersList.begin() ; it != prt.ClusterMembersList.end() ; it++) { - oss << "Cluster member called : " << (*it).HostName << std::endl; + os << "Cluster member called: " << (*it).HostName << endl; } - std::cout << oss.str() << std::endl; + return os; } std::string -ParserResourcesType::PrintAccessProtocolType() const +ParserResourcesType::getAccessProtocolTypeStr() const { return protocolToString(Protocol); } std::string -ParserResourcesType::PrintClusterInternalProtocol() const +ParserResourcesType::getClusterInternalProtocolStr() const { return protocolToString(ClusterInternalProtocol); } std::string -ParserResourcesType::PrintAccessModeType() const +ParserResourcesType::getResourceTypeStr() const { - if (Mode == interactive) - return "interactive"; - else - return "batch"; + switch (type) + { + case cluster: + return "cluster"; + case single_machine: + return "single_machine"; + default: + throw SALOME_Exception("Unknown resource type"); + } } std::string -ParserResourcesType::PrintBatchType() const +ParserResourcesType::getBatchTypeStr() const { - if (Batch == none) + switch (Batch) + { + case none: return "none"; - else if (Batch == pbs) + case pbs: return "pbs"; - else if (Batch == lsf) + case lsf: return "lsf"; - else if (Batch == sge) + case sge: return "sge"; - else if (Batch == ccc) + case ccc: return "ccc"; - else if (Batch == slurm) + case slurm: return "slurm"; - else if (Batch == ll) + case ll: return "ll"; - else if (Batch == vishnu) + case vishnu: return "vishnu"; - else - return "ssh"; + case ssh_batch: + return "ssh_batch"; + default: + throw SALOME_Exception("Unknown batch type"); + } } std::string -ParserResourcesType::PrintMpiImplType() const +ParserResourcesType::getMpiImplTypeStr() const { - if (mpi == nompi) + switch (mpi) + { + case nompi: return "no mpi"; - else if (mpi == lam) + case lam: return "lam"; - else if (mpi == mpich1) + case mpich1: return "mpich1"; - else if (mpi == mpich2) + case mpich2: return "mpich2"; - else if (mpi == openmpi) + case openmpi: return "openmpi"; - else if (mpi == ompi) + case ompi: return "ompi"; - else if (mpi == slurmmpi) + case slurmmpi: return "slurmmpi"; - else + case prun: return "prun"; + default: + throw SALOME_Exception("Unknown MPI implementation type"); + } } -void ParserResourcesType::Clear() +string ParserResourcesType::getCanLaunchBatchJobsStr() const { - Name = ""; - HostName = ""; - Protocol = rsh; - ClusterInternalProtocol = rsh; - Mode = interactive; - Batch = none; - mpi = nompi; - UserName = ""; - AppliPath = ""; - batchQueue = ""; - userCommands = ""; - ComponentsList.clear(); - OS = ""; - use = ""; - ClusterMembersList.clear(); - nbOfProc = 1; - is_cluster_head = false; - working_directory = ""; + return can_launch_batch_jobs ? "true" : "false"; +} - DataForSort._Name = ""; - DataForSort._nbOfNodes = 1; - DataForSort._nbOfProcPerNode = 1; - DataForSort._CPUFreqMHz = 0; - DataForSort._memInMB = 0; +string ParserResourcesType::getCanRunContainersStr() const +{ + return can_run_containers ? "true" : "false"; +} + +void ParserResourcesType::setAccessProtocolTypeStr(const string & protocolTypeStr) +{ + Protocol = stringToProtocol(protocolTypeStr); +} + +void ParserResourcesType::setResourceTypeStr(const string & resourceTypeStr) +{ + if (resourceTypeStr == "cluster") + type = cluster; + else if (resourceTypeStr == "single_machine") + type = single_machine; + else + throw SALOME_Exception((string("Unknown resource type ") + resourceTypeStr).c_str()); +} + +void ParserResourcesType::setBatchTypeStr(const string & batchTypeStr) +{ + if (batchTypeStr == "pbs") + Batch = pbs; + else if (batchTypeStr == "lsf") + Batch = lsf; + else if (batchTypeStr == "sge") + Batch = sge; + else if (batchTypeStr == "slurm") + Batch = slurm; + else if (batchTypeStr == "ccc") + Batch = ccc; + else if (batchTypeStr == "ssh_batch") + Batch = ssh_batch; + else if (batchTypeStr == "ll") + Batch = ll; + else if (batchTypeStr == "vishnu") + Batch = vishnu; + else if (batchTypeStr == "") + Batch = none; + else + throw SALOME_Exception((string("Unknown batch type ") + batchTypeStr).c_str()); +} + +void ParserResourcesType::setMpiImplTypeStr(const string & mpiImplTypeStr) +{ + if (mpiImplTypeStr == "lam") + mpi = lam; + else if (mpiImplTypeStr == "mpich1") + mpi = mpich1; + else if (mpiImplTypeStr == "mpich2") + mpi = mpich2; + else if (mpiImplTypeStr == "openmpi") + mpi = openmpi; + else if (mpiImplTypeStr == "ompi") + mpi = ompi; + else if (mpiImplTypeStr == "slurmmpi") + mpi = slurmmpi; + else if (mpiImplTypeStr == "prun") + mpi = prun; + else if (mpiImplTypeStr == "" || mpiImplTypeStr == "no mpi") + mpi = nompi; + else + throw SALOME_Exception((string("Unknown MPI implementation type ") + mpiImplTypeStr).c_str()); +} + +void ParserResourcesType::setClusterInternalProtocolStr(const string & internalProtocolTypeStr) +{ + ClusterInternalProtocol = stringToProtocol(internalProtocolTypeStr); +} + +void ParserResourcesType::setCanLaunchBatchJobsStr(const string & canLaunchBatchJobsStr) +{ + if (canLaunchBatchJobsStr == "true") + can_launch_batch_jobs = true; + else if (canLaunchBatchJobsStr == "false") + can_launch_batch_jobs = false; + else + throw SALOME_Exception((string("Invalid boolean value for can_launch_batch_jobs: ") + + canLaunchBatchJobsStr).c_str()); +} + +void ParserResourcesType::setCanRunContainersStr(const string & canRunContainersStr) +{ + if (canRunContainersStr == "true") + can_run_containers = true; + else if (canRunContainersStr == "false") + can_run_containers = false; + else + throw SALOME_Exception((string("Invalid boolean value for can_run_containers: ") + + canRunContainersStr).c_str()); } diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx index 1ac87b340..5b659c9e0 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx @@ -41,9 +41,9 @@ #pragma warning(disable:4251) // Warning DLL Interface ... #endif -enum AccessProtocolType {rsh, ssh, srun, pbsdsh, blaunch}; +enum AccessProtocolType {sh, rsh, ssh, srun, pbsdsh, blaunch}; -enum AccessModeType {interactive, batch}; +enum ResourceType {cluster, single_machine}; enum BatchType {none, pbs, lsf, sge, ssh_batch, ccc, ll, slurm, vishnu}; @@ -78,24 +78,34 @@ class RESOURCESMANAGER_EXPORT ResourceDataToSort unsigned int GetNumberOfPoints() const; }; -struct RESOURCESMANAGER_EXPORT ParserResourcesClusterMembersType +class RESOURCESMANAGER_EXPORT ParserResourcesType { - std::string HostName; - AccessProtocolType Protocol; - AccessProtocolType ClusterInternalProtocol; - std::string UserName; - std::string AppliPath; - ResourceDataToSort DataForSort; -}; +public: + ParserResourcesType(); + virtual ~ParserResourcesType(); + + std::string getAccessProtocolTypeStr() const; + std::string getResourceTypeStr() const; + std::string getBatchTypeStr() const; + std::string getMpiImplTypeStr() const; + std::string getClusterInternalProtocolStr() const; + std::string getCanLaunchBatchJobsStr() const; + std::string getCanRunContainersStr() const; + + void setAccessProtocolTypeStr(const std::string & protocolTypeStr); + void setResourceTypeStr(const std::string & resourceTypeStr); + void setBatchTypeStr(const std::string & batchTypeStr); + void setMpiImplTypeStr(const std::string & mpiImplTypeStr); + void setClusterInternalProtocolStr(const std::string & internalProtocolTypeStr); + void setCanLaunchBatchJobsStr(const std::string & canLaunchBatchJobsStr); + void setCanRunContainersStr(const std::string & canRunContainersStr); -struct RESOURCESMANAGER_EXPORT ParserResourcesType -{ ResourceDataToSort DataForSort; std::string Name; std::string HostName; AccessProtocolType Protocol; AccessProtocolType ClusterInternalProtocol; - AccessModeType Mode; + ResourceType type; BatchType Batch; MpiImplType mpi; std::string UserName; @@ -106,22 +116,20 @@ struct RESOURCESMANAGER_EXPORT ParserResourcesType std::string batchQueue; std::string userCommands; std::string use; - std::list ClusterMembersList; + std::list ClusterMembersList; unsigned int nbOfProc; - bool is_cluster_head; + bool can_launch_batch_jobs; + bool can_run_containers; std::string working_directory; - void Print(); - void Clear(); +protected: static std::string protocolToString(AccessProtocolType protocol); static AccessProtocolType stringToProtocol(const std::string & protocolStr); - std::string PrintAccessProtocolType() const; - std::string PrintAccessModeType() const; - std::string PrintBatchType() const; - std::string PrintMpiImplType() const; - std::string PrintClusterInternalProtocol() const; + RESOURCESMANAGER_EXPORT friend std::ostream & operator<<(std::ostream &os, + const ParserResourcesType &rt); + }; typedef std::map MapOfParserResourcesType; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 30a1c1b44..e1e9ec187 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -46,6 +46,8 @@ #define MAX_SIZE_FOR_HOSTNAME 256; +using namespace std; + const char *SALOME_ResourcesManager::_ResourcesManagerNameInNS = "/ResourcesManager"; //============================================================================= @@ -148,6 +150,8 @@ SALOME_ResourcesManager::GetFittingResources(const Engines::ResourceParameters& resourceParams p; p.name = params.name; p.hostname = params.hostname; + p.can_launch_batch_jobs = params.can_launch_batch_jobs; + p.can_run_containers = params.can_run_containers; p.OS = params.OS; p.nb_proc = params.nb_proc; p.nb_node = params.nb_node; @@ -209,57 +213,35 @@ SALOME_ResourcesManager::Find(const char* policy, const Engines::ResourceList& l Engines::ResourceDefinition* SALOME_ResourcesManager::GetResourceDefinition(const char * name) { - ParserResourcesType resource = _rm.GetResourcesDescr(name); - Engines::ResourceDefinition *p_ptr = new Engines::ResourceDefinition; - - p_ptr->name = CORBA::string_dup(resource.Name.c_str()); - p_ptr->hostname = CORBA::string_dup(resource.HostName.c_str()); - p_ptr->protocol = ParserResourcesType::protocolToString(resource.Protocol).c_str(); - p_ptr->iprotocol = ParserResourcesType::protocolToString(resource.ClusterInternalProtocol).c_str(); - p_ptr->username = CORBA::string_dup(resource.UserName.c_str()); - p_ptr->applipath = CORBA::string_dup(resource.AppliPath.c_str()); - p_ptr->componentList.length(resource.ComponentsList.size()); - for(unsigned int i=0;icomponentList[i] = CORBA::string_dup(resource.ComponentsList[i].c_str()); - p_ptr->OS = CORBA::string_dup(resource.OS.c_str()); - p_ptr->mem_mb = resource.DataForSort._memInMB; - p_ptr->cpu_clock = resource.DataForSort._CPUFreqMHz; - p_ptr->nb_proc_per_node = resource.DataForSort._nbOfProcPerNode; - p_ptr->nb_node = resource.DataForSort._nbOfNodes; - p_ptr->is_cluster_head = resource.is_cluster_head; - p_ptr->working_directory = CORBA::string_dup(resource.working_directory.c_str()); - - if( resource.mpi == lam ) - p_ptr->mpiImpl = "lam"; - else if( resource.mpi == mpich1 ) - p_ptr->mpiImpl = "mpich1"; - else if( resource.mpi == mpich2 ) - p_ptr->mpiImpl = "mpich2"; - else if( resource.mpi == openmpi ) - p_ptr->mpiImpl = "openmpi"; - else if( resource.mpi == ompi ) - p_ptr->mpiImpl = "ompi"; - else if( resource.mpi == slurmmpi ) - p_ptr->mpiImpl = "slurmmpi"; - else if( resource.mpi == prun ) - p_ptr->mpiImpl = "prun"; - - if( resource.Batch == pbs ) - p_ptr->batch = "pbs"; - else if( resource.Batch == lsf ) - p_ptr->batch = "lsf"; - else if( resource.Batch == sge ) - p_ptr->batch = "sge"; - else if( resource.Batch == ccc ) - p_ptr->batch = "ccc"; - else if( resource.Batch == slurm ) - p_ptr->batch = "slurm"; - else if( resource.Batch == ssh_batch ) - p_ptr->batch = "ssh"; - else if( resource.Batch == ll ) - p_ptr->batch = "ll"; - else if( resource.Batch == vishnu ) - p_ptr->batch = "vishnu"; + Engines::ResourceDefinition * p_ptr = NULL; + try { + ParserResourcesType resource = _rm.GetResourcesDescr(name); + p_ptr = new Engines::ResourceDefinition; + + p_ptr->name = CORBA::string_dup(resource.Name.c_str()); + p_ptr->hostname = CORBA::string_dup(resource.HostName.c_str()); + p_ptr->type = CORBA::string_dup(resource.getResourceTypeStr().c_str()); + p_ptr->protocol = CORBA::string_dup(resource.getAccessProtocolTypeStr().c_str()); + p_ptr->iprotocol = CORBA::string_dup(resource.getClusterInternalProtocolStr().c_str()); + p_ptr->username = CORBA::string_dup(resource.UserName.c_str()); + p_ptr->applipath = CORBA::string_dup(resource.AppliPath.c_str()); + p_ptr->componentList.length(resource.ComponentsList.size()); + for(unsigned int i=0;icomponentList[i] = CORBA::string_dup(resource.ComponentsList[i].c_str()); + p_ptr->OS = CORBA::string_dup(resource.OS.c_str()); + p_ptr->mem_mb = resource.DataForSort._memInMB; + p_ptr->cpu_clock = resource.DataForSort._CPUFreqMHz; + p_ptr->nb_proc_per_node = resource.DataForSort._nbOfProcPerNode; + p_ptr->nb_node = resource.DataForSort._nbOfNodes; + p_ptr->can_launch_batch_jobs = resource.can_launch_batch_jobs; + p_ptr->can_run_containers = resource.can_run_containers; + p_ptr->working_directory = CORBA::string_dup(resource.working_directory.c_str()); + p_ptr->mpiImpl = CORBA::string_dup(resource.getMpiImplTypeStr().c_str()); + p_ptr->batch = CORBA::string_dup(resource.getBatchTypeStr().c_str()); + } catch (const exception & ex) { + INFOS("Caught exception in GetResourceDefinition: " << ex.what()); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::BAD_PARAM); + } return p_ptr; } @@ -269,118 +251,41 @@ SALOME_ResourcesManager::AddResource(const Engines::ResourceDefinition& new_reso CORBA::Boolean write, const char * xml_file) { - ParserResourcesType resource; - resource.Name = new_resource.name.in(); - resource.HostName = new_resource.hostname.in(); - resource.OS = new_resource.OS.in(); - resource.AppliPath = new_resource.applipath.in(); - resource.DataForSort._memInMB = new_resource.mem_mb; - resource.DataForSort._CPUFreqMHz = new_resource.cpu_clock; - resource.DataForSort._nbOfNodes = new_resource.nb_node; - resource.DataForSort._nbOfProcPerNode = new_resource.nb_proc_per_node; - resource.UserName = new_resource.username.in(); - resource.is_cluster_head = new_resource.is_cluster_head; - resource.working_directory = new_resource.working_directory.in(); - - std::string aBatch = new_resource.batch.in(); - if (aBatch == "pbs") - resource.Batch = pbs; - else if (aBatch == "lsf") - resource.Batch = lsf; - else if (aBatch == "sge") - resource.Batch = sge; - else if (aBatch == "slurm") - resource.Batch = slurm; - else if (aBatch == "ccc") - resource.Batch = ccc; - else if (aBatch == "ssh_batch") - resource.Batch = ssh_batch; - else if (aBatch == "ll") - resource.Batch = ll; - else if (aBatch == "vishnu") - resource.Batch = vishnu; - else if (aBatch == "") - resource.Batch = none; - else { - INFOS("Bad Batch definition in AddResource: " << aBatch); - std::string message("Bad Batch definition in AddResource: "); - message += aBatch; - THROW_SALOME_CORBA_EXCEPTION(message.c_str(),SALOME::BAD_PARAM); - } - - std::string anMpi = new_resource.mpiImpl.in(); - if (anMpi == "lam") - resource.mpi = lam; - else if (anMpi == "mpich1") - resource.mpi = mpich1; - else if (anMpi == "mpich2") - resource.mpi = mpich2; - else if (anMpi == "openmpi") - resource.mpi = openmpi; - else if (anMpi == "ompi") - resource.mpi = ompi; - else if (anMpi == "slurmmpi") - resource.mpi = slurmmpi; - else if (anMpi == "prun") - resource.mpi = prun; - else if (anMpi == "") - resource.mpi = nompi; - else { - INFOS("Bad MPI definition in AddResource: " << anMpi); - std::string message("Bad MPI definition in AddResource: "); - message += anMpi; - THROW_SALOME_CORBA_EXCEPTION(message.c_str(),SALOME::BAD_PARAM); - } - - std::string mode_str = new_resource.mode.in(); - if (mode_str == "interactive") - resource.Mode = interactive; - else if (mode_str == "batch") - resource.Mode = batch; - else if (mode_str == "") - resource.Mode = interactive; - else { - INFOS("Bad mode definition in AddResource: " << mode_str); - std::string message("Bad mode definition in AddResource: "); - message += mode_str; - THROW_SALOME_CORBA_EXCEPTION(message.c_str(),SALOME::BAD_PARAM); - } - - std::string protocol = new_resource.protocol.in(); try { - resource.Protocol = ParserResourcesType::stringToProtocol(protocol); - } - catch (SALOME_Exception e) - { - INFOS("Bad protocol definition in AddResource: " << protocol); - std::string message("Bad protocol definition in AddResource: "); - message += protocol; - THROW_SALOME_CORBA_EXCEPTION(message.c_str(),SALOME::BAD_PARAM); - } - - std::string iprotocol = new_resource.iprotocol.in(); - try - { - resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol(iprotocol); - } - catch (SALOME_Exception e) - { - INFOS("Bad iprotocol definition in AddResource: " << iprotocol); - std::string message("Bad iprotocol definition in AddResource: "); - message += iprotocol; - THROW_SALOME_CORBA_EXCEPTION(message.c_str(),SALOME::BAD_PARAM); + ParserResourcesType resource; + resource.Name = new_resource.name.in(); + resource.HostName = new_resource.hostname.in(); + resource.setResourceTypeStr(new_resource.type.in()); + resource.OS = new_resource.OS.in(); + resource.AppliPath = new_resource.applipath.in(); + resource.DataForSort._memInMB = new_resource.mem_mb; + resource.DataForSort._CPUFreqMHz = new_resource.cpu_clock; + resource.DataForSort._nbOfNodes = new_resource.nb_node; + resource.DataForSort._nbOfProcPerNode = new_resource.nb_proc_per_node; + resource.UserName = new_resource.username.in(); + resource.can_launch_batch_jobs = new_resource.can_launch_batch_jobs; + resource.can_run_containers = new_resource.can_run_containers; + resource.working_directory = new_resource.working_directory.in(); + resource.setBatchTypeStr(new_resource.batch.in()); + resource.setMpiImplTypeStr(new_resource.mpiImpl.in()); + resource.setAccessProtocolTypeStr(new_resource.protocol.in()); + resource.setClusterInternalProtocolStr(new_resource.iprotocol.in()); + for (CORBA::ULong i = 0; i < new_resource.componentList.length(); i++) + resource.ComponentsList.push_back(new_resource.componentList[i].in()); + + _rm.AddResourceInCatalog(resource); + + if (write) + { + _rm.WriteInXmlFile(std::string(xml_file)); + _rm.ParseXmlFiles(); + } } - - for (CORBA::ULong i = 0; i < new_resource.componentList.length(); i++) - resource.ComponentsList.push_back(new_resource.componentList[i].in()); - - _rm.AddResourceInCatalog(resource); - - if (write) + catch (const SALOME_Exception & e) { - _rm.WriteInXmlFile(std::string(xml_file)); - _rm.ParseXmlFiles(); + INFOS("Error in AddResourceInCatalog: " << e); + THROW_SALOME_CORBA_EXCEPTION(e.what(), SALOME::BAD_PARAM); } } @@ -389,7 +294,16 @@ SALOME_ResourcesManager::RemoveResource(const char * resource_name, CORBA::Boolean write, const char * xml_file) { - _rm.DeleteResourceInCatalog(resource_name); + try + { + _rm.DeleteResourceInCatalog(resource_name); + } + catch (const SALOME_Exception & e) + { + INFOS("Error in DeleteResourceInCatalog: " << e); + THROW_SALOME_CORBA_EXCEPTION(e.what(), SALOME::BAD_PARAM); + } + if (write) { _rm.WriteInXmlFile(std::string(xml_file)); @@ -416,7 +330,7 @@ SALOME_ResourcesManager::getMachineFile(std::string resource_name, if (resource.ClusterMembersList.empty()) { //It is not a cluster so we create a cluster with one machine - ParserResourcesClusterMembersType fake_node; + ParserResourcesType fake_node; fake_node.HostName = resource.HostName; fake_node.Protocol = resource.Protocol; fake_node.ClusterInternalProtocol = resource.ClusterInternalProtocol; @@ -429,7 +343,7 @@ SALOME_ResourcesManager::getMachineFile(std::string resource_name, // Creating list of machines for creating the machine file std::list list_of_machines; - std::list::iterator cluster_it = + std::list::iterator cluster_it = resource.ClusterMembersList.begin(); while (cluster_it != resource.ClusterMembersList.end()) { @@ -474,7 +388,7 @@ SALOME_ResourcesManager::getMachineFile(std::string resource_name, if (resource.ClusterMembersList.empty()) { //It is not a cluster so we create a cluster with one machine - ParserResourcesClusterMembersType fake_node; + ParserResourcesType fake_node; fake_node.HostName = resource.HostName; fake_node.Protocol = resource.Protocol; fake_node.ClusterInternalProtocol = resource.ClusterInternalProtocol; @@ -493,7 +407,7 @@ SALOME_ResourcesManager::getMachineFile(std::string resource_name, std::ofstream machine_file(machine_file_name.c_str(), std::ios_base::out); // We add all cluster machines to the file - std::list::iterator cluster_it = + std::list::iterator cluster_it = resource.ClusterMembersList.begin(); while (cluster_it != resource.ClusterMembersList.end()) { @@ -510,7 +424,7 @@ SALOME_ResourcesManager::getMachineFile(std::string resource_name, std::ofstream machine_file(machine_file_name.c_str(), std::ios_base::out); // We add all cluster machines to the file - std::list::iterator cluster_it = + std::list::iterator cluster_it = resource.ClusterMembersList.begin(); while (cluster_it != resource.ClusterMembersList.end()) {