f.write(command % ",".join(mods))
f.close()
- #Add default CatalogResources.xml file
- f =open(os.path.join(home_dir,'CatalogResources.xml'),'w')
- command="""<!DOCTYPE ResourcesCatalog>
-<resources>
- <machine name="localhost"
- hostname="localhost" />
-</resources>
-"""
- 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)
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
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 \
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 \
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 \
#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<string> ResourceList;
-//! components list
-typedef sequence<string> CompoList;
-//! files list
-typedef sequence<string> FilesList;
-//! modules list
-typedef sequence<string> ModulesList;
-
-//! A generic parameter
-struct Parameter
-{
- string name;
- string value;
-};
-//! Generic parameter list
-typedef sequence<Engines::Parameter> 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
{
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<Engines::JobDescription> 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
//! 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<string> 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
--- /dev/null
+// 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<string> FilesList;
+
+//! A generic parameter
+struct Parameter
+{
+ string name;
+ string value;
+};
+//! Generic parameter list
+typedef sequence<Engines::Parameter> 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<Engines::JobDescription> 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
--- /dev/null
+// 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<string> ResourceList;
+//! components list
+typedef sequence<string> 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
+++ /dev/null
-// 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<proc_info> 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<ContainerType> ListOfContainerType;
-
- //! a list of computer names
- typedef sequence<string> 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);
- };
-};
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)
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
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)
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"
LIBBATCH_LIBS="$LOCAL_LIBS"
fi
-AC_MSG_RESULT(for libBatch: $libbatch_ok)
+AC_MSG_RESULT(for libbatch: $libbatch_ok)
])
}
// 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<std::string> local_resources;
#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)
#include "Launcher.hxx"
#ifdef WITH_LIBBATCH
-#include <Batch/Batch_Date.hxx>
-#include <Batch/Batch_MpiImpl.hxx>
+#include <libbatch/MpiImpl.hxx>
#endif
#include "utilities.h"
_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
}
//
#ifdef WITH_LIBBATCH
-#include <Batch/Batch_Date.hxx>
-#include <Batch/Batch_BatchManagerCatalog.hxx>
-#include <Batch/Batch_FactBatchManager_eClient.hxx>
-#include <Batch/Batch_BatchManager_eClient.hxx>
+#include <libbatch/BatchManagerCatalog.hxx>
+#include <libbatch/FactBatchManager.hxx>
+#include <libbatch/BatchManager.hxx>
#endif
#include "Basics_Utils.hxx"
std::map<int, Launcher::Job *>::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 <int, Batch::BatchManager_eClient * >::const_iterator it1;
+ std::map <int, Batch::BatchManager * >::const_iterator it1;
for(it1=_batchmap.begin();it1!=_batchmap.end();it1++)
delete it1->second;
#endif
// Third step search batch manager for the job into the map -> instanciate one if does not exist
#ifdef WITH_LIBBATCH
- std::map<int, Batch::BatchManager_eClient *>::const_iterator it = _batchmap.find(job_id);
+ std::map<int, Batch::BatchManager *>::const_iterator it = _batchmap.find(job_id);
if(it == _batchmap.end())
{
createBatchManagerForJob(job);
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());
{
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());
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());
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());
* 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;
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<Batch::FactBatchManager_eClient*>(cata(bmType));
+ fact = dynamic_cast<Batch::FactBatchManager*>(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;
}
// Select a ressource for the job
std::vector<std::string> ResourceList;
resourceParams params = job->getResourceRequiredParams();
+ // Consider only resources that can launch batch jobs
+ params.can_launch_batch_jobs = true;
try
{
ResourceList = _ResManager->GetFittingResources(params);
// Step 2: We can now add a Factory if the resource is correctly define
#ifdef WITH_LIBBATCH
- std::map<int, Batch::BatchManager_eClient *>::const_iterator it = _batchmap.find(job_id);
+ std::map<int, Batch::BatchManager *>::const_iterator it = _batchmap.find(job_id);
if(it == _batchmap.end())
{
try
// 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)
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);
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());
class MpiImpl;
namespace Batch{
- class BatchManager_eClient;
+ class BatchManager;
class Job;
}
// Methods used by user interface methods
#ifdef WITH_LIBBATCH
- Batch::BatchManager_eClient *FactoryBatchManager(ParserResourcesType& params);
- std::map <int, Batch::BatchManager_eClient*> _batchmap;
+ Batch::BatchManager *FactoryBatchManager(ParserResourcesType& params);
+ std::map <int, Batch::BatchManager*> _batchmap;
#endif
ParserLauncherType ParseXmlFile(std::string xmlExecuteFile);
#include "Launcher.hxx"
#ifdef WITH_LIBBATCH
-#include <Batch/Batch_Constants.hxx>
+#include <libbatch/Constants.hxx>
#endif
Launcher::Job::Job()
{
_batch_job_id.deleteJob();
}
- catch (const Batch::EmulationException &ex)
+ catch (const Batch::GenericException &ex)
{
LAUNCHER_INFOS("WARNING: exception when stopping the job: " << ex.message);
}
{
_batch_job_id.deleteJob();
}
- catch (const Batch::EmulationException &ex)
+ catch (const Batch::GenericException &ex)
{
LAUNCHER_INFOS("WARNING: exception when removing the job: " << ex.message);
}
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)
// 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 == "")
#include <exception>
#ifdef WITH_LIBBATCH
-#include <Batch/Batch_Job.hxx>
-#include <Batch/Batch_Date.hxx>
-#include <Batch/Batch_JobId.hxx>
-#include <Batch/Batch_EmulationException.hxx>
+#include <libbatch/Job.hxx>
+#include <libbatch/JobId.hxx>
+#include <libbatch/GenericException.hxx>
#endif
#include <libxml/parser.h>
#include "Basics_DirUtils.hxx"
#ifdef WITH_LIBBATCH
-#include <Batch/Batch_Constants.hxx>
+#include <libbatch/Constants.hxx>
#endif
#ifdef WNT
#include "Launcher.hxx"
#ifdef WITH_LIBBATCH
-#include <Batch/Batch_Job.hxx>
+#include <libbatch/Job.hxx>
#endif
namespace Launcher
#include "Basics_DirUtils.hxx"
#ifdef WITH_LIBBATCH
-#include <Batch/Batch_Constants.hxx>
+#include <libbatch/Constants.hxx>
#endif
#ifdef WNT
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;
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 '</resources>' >> $CATALOG_FILE" << std::endl;
#include "Launcher.hxx"
#ifdef WITH_LIBBATCH
-#include <Batch/Batch_Job.hxx>
+#include <libbatch/Job.hxx>
#endif
namespace Launcher
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");
#include "SALOME_Launcher_defs.hxx"
#include <SALOMEconfig.h>
-#include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
+#include CORBA_CLIENT_HEADER(SALOME_Launcher)
#include "Launcher.hxx"
#include <string>
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");
#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"
//=============================================================================
/*! \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
{
}
//=============================================================================
-/*! \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
//=============================================================================
Engines::EngineComponent_ptr
-SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params,
+SALOME_LifeCycleCORBA::LoadComponent(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
//=============================================================================
/*! \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,
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
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);
}
}
//=============================================================================
-/*!
- * 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)
{
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 = "";
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
int SALOME_LifeCycleCORBA::NbProc(const Engines::ContainerParameters& params)
{
- if( !isMpiContainer(params) )
+ if( !params.isMPI )
return 0;
else if( params.nb_proc <= 0 )
return 1;
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);
{
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);
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,
Engines::EngineComponent_ptr
FindOrLoad_Component(const char *containerName,
- const char *componentName); // for compatibility
+ const char *componentName);
// Parallel extension
Engines::EngineComponent_ptr
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);
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
{
SALOME_LifeCycleCORBA _LCC(&_NS);
- Engines::MachineParameters params;
+ Engines::ContainerParameters params;
_LCC.preSet(params);
Engines::EngineComponent_var mycompo =
_LCC.FindOrLoad_Component(params,"SalomeTestComponent");
{
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));
{
SALOME_LifeCycleCORBA _LCC(&_NS);
- Engines::MachineParameters params;
+ Engines::ContainerParameters params;
_LCC.preSet(params);
std::string containerName = "myContainer";
params.container_name = containerName.c_str();
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");
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 =
_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);
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()
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=[],
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)
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)
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'
}
}
-%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;
{
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)
{
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;
}
// ============================================================================
-/*! \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)
{
*/
// ============================================================================
-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,
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)
${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
SET(COMMON_LIBS
${CPPUNIT_LIBS}
SalomeNS
+ SalomeLifeCycleCORBA
${OMNIORB_LIBRARIES}
${PLATFORM_LIBS}
)
-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@
#
# ===============================================================
#include "Utils_ORB_INIT.hxx"
#include "Utils_SINGLETON.hxx"
#include "Basics_Utils.hxx"
+#include "SALOME_LifeCycleCORBA.hxx"
#include <iostream>
#include <fstream>
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);
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";
#include <algorithm>
+#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;
_resourceManagerMap["altcycl"]=&altcycl;
_resourceManagerMap["best"]=&altcycl;
_resourceManagerMap[""]=&altcycl;
+
+ AddDefaultResourceInCatalog();
}
//=============================================================================
_resourceManagerMap["best"]=&altcycl;
_resourceManagerMap[""]=&altcycl;
+ AddDefaultResourceInCatalog();
+
bool default_catalog_resource = true;
if (getenv("USER_CATALOG_RESOURCES_FILE") != 0)
{
// Step 5
SelectOnlyResourcesWithOS(vec, params.OS.c_str());
-
+
// Step 6
std::vector<std::string> vec_save(vec);
KeepOnlyResourcesWithComponent(vec, params.componentList);
if (vec.size() == 0)
vec = vec_save;
+ // Step 7 : Filter on possible usage
+ vector<string> prev_list(vec);
+ vec.clear();
+ for (vector<string>::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)
//=============================================================================
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;
}
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);
{
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();
xmlNewDocComment(aDoc, BAD_CAST "ResourcesCatalog");
SALOME_ResourcesCatalog_Handler* handler =
- new SALOME_ResourcesCatalog_Handler(_resourcesList);
+ new SALOME_ResourcesCatalog_Handler(resourceListToSave);
handler->PrepareDocToXmlFile(aDoc);
delete handler;
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;
}
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)
{
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;
}
}
}
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;
+}
{
std::string name;
std::string hostname;
+ bool can_launch_batch_jobs;
+ bool can_run_containers;
std::string OS;
long nb_proc;
long nb_node;
std::string Find(const std::string& policy,
const std::vector<std::string>& listOfResources);
- void AddResourceInCatalog (const ParserResourcesType & new_resource) throw(ResourcesException);
+ void AddResourceInCatalog (const ParserResourcesType & new_resource);
void DeleteResourceInCatalog(const char * name);
void KeepOnlyResourcesWithComponent(std::vector<std::string>& resources,
const std::vector<std::string>& componentList);
+ /**
+ * Add the default local resource in the catalog
+ */
+ void AddDefaultResourceInCatalog();
+
//! will contain the path to the ressources catalog
std::list<std::string> _path_resources;
std::list<std::string>::iterator _path_resources_it;
//! 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__
#include <sstream>
#include <map>
+using namespace std;
+
//=============================================================================
/*!
* Constructor
test_cluster = "cluster";
test_name = "name";
test_hostname = "hostname";
+ test_type = "type";
test_protocol = "protocol";
test_cluster_internal_protocol = "iprotocol";
test_mode = "mode";
test_members = "members";
test_is_cluster_head = "isClusterHead";
test_working_directory = "workingDirectory";
+ test_can_launch_batch_jobs = "canLaunchBatchJobs";
+ test_can_run_containers = "canRunContainers";
}
//=============================================================================
// 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);
// 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<std::string, ParserResourcesType>::const_iterator iter = _resources_list.find(_resource.Name);
+ std::map<std::string, ParserResourcesType>::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<std::string, ParserResourcesType>::const_iterator iter = _resources_list.find(_resource.Name);
+ std::map<std::string, ParserResourcesType>::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;
{
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
{
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))
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
// 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);
}
}
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))
{
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;
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;
{
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))
resource.batchQueue = (const char*)batch_queue;
xmlFree(batch_queue);
}
- else
- resource.batchQueue = "";
if (xmlHasProp(machine_descr, (const xmlChar*)test_user_commands))
{
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))
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))
resource.working_directory = (const char*)working_directory;
xmlFree(working_directory);
}
- else
- {
- resource.working_directory = "";
- }
// Process children nodes
xmlNodePtr aCurSubNode = machine_descr->xmlChildrenNode;
{
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);
}
}
{
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);
}
}
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<std::string>::const_iterator iter2 = (*iter).second.ComponentsList.begin();
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;
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
#include <iostream>
#include <sstream>
+using namespace std;
+
#define NULL_VALUE 0
unsigned int ResourceDataToSort::_nbOfProcWanted = NULL_VALUE;
}
+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:
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;
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<ComponentsList.size();i++)
- oss << "Component " << i+1 << " called : " << ComponentsList[i] << std::endl;
-
-
- std::list<ParserResourcesClusterMembersType>::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<prt.ComponentsList.size() ; i++)
+ os << "Component " << i+1 << " called: " << prt.ComponentsList[i] << endl;
+
+ list<ParserResourcesType>::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());
}
#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};
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;
std::string batchQueue;
std::string userCommands;
std::string use;
- std::list<ParserResourcesClusterMembersType> ClusterMembersList;
+ std::list<ParserResourcesType> 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<std::string, ParserResourcesType> MapOfParserResourcesType;
#define MAX_SIZE_FOR_HOSTNAME 256;
+using namespace std;
+
const char *SALOME_ResourcesManager::_ResourcesManagerNameInNS = "/ResourcesManager";
//=============================================================================
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;
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;i<resource.ComponentsList.size();i++)
- p_ptr->componentList[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;i<resource.ComponentsList.size();i++)
+ p_ptr->componentList[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;
}
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);
}
}
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));
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;
// Creating list of machines for creating the machine file
std::list<std::string> list_of_machines;
- std::list<ParserResourcesClusterMembersType>::iterator cluster_it =
+ std::list<ParserResourcesType>::iterator cluster_it =
resource.ClusterMembersList.begin();
while (cluster_it != resource.ClusterMembersList.end())
{
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;
std::ofstream machine_file(machine_file_name.c_str(), std::ios_base::out);
// We add all cluster machines to the file
- std::list<ParserResourcesClusterMembersType>::iterator cluster_it =
+ std::list<ParserResourcesType>::iterator cluster_it =
resource.ClusterMembersList.begin();
while (cluster_it != resource.ClusterMembersList.end())
{
std::ofstream machine_file(machine_file_name.c_str(), std::ios_base::out);
// We add all cluster machines to the file
- std::list<ParserResourcesClusterMembersType>::iterator cluster_it =
+ std::list<ParserResourcesType>::iterator cluster_it =
resource.ClusterMembersList.begin();
while (cluster_it != resource.ClusterMembersList.end())
{