From: ribes Date: Mon, 19 Mar 2012 16:54:58 +0000 (+0000) Subject: Working on PAL# 2078 X-Git-Tag: V6_5_0a1~25 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7e41030e6d5f26fbbb2bfdf851a05717a478dce9;p=modules%2Fkernel.git Working on PAL# 2078 Adding two new attributes to a SALOME resource: is_cluster_head -> set to "true" if the resource refers to a cluster head (false by default) working_directory -> defines a default working directory in a cluster --- diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index c984ace36..6964468f1 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -146,6 +146,12 @@ struct ResourceDefinition //! 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 diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index d4faed75c..73ac4ece0 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -69,6 +69,8 @@ SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& resources_list): _reso test_user_commands = "userCommands"; test_use = "use"; test_members = "members"; + test_is_cluster_head = "isClusterHead"; + test_working_directory = "workingDirectory"; } //============================================================================= @@ -596,6 +598,36 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser xmlFree(nb_of_proc_per_node); } + if (xmlHasProp(machine_descr, (const xmlChar*)test_is_cluster_head)) + { + 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.is_cluster_head = true; + } + else + { + resource.is_cluster_head = false; + } + xmlFree(is_cluster_head); + } + else + { + resource.is_cluster_head = false; + } + + if (xmlHasProp(machine_descr, (const xmlChar*)test_working_directory)) + { + xmlChar* working_directory = xmlGetProp(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; while(aCurSubNode != NULL) @@ -672,6 +704,11 @@ void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc) xmlNewProp(node, BAD_CAST test_cluster_internal_protocol, BAD_CAST ParserResourcesType::protocolToString((*iter).second.ClusterInternalProtocol).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) { diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx index cb8fe088c..dc171024d 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx @@ -89,6 +89,8 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesCatalog_Handler const char *test_user_commands; const char *test_use; const char *test_members; + const char *test_is_cluster_head; + const char *test_working_directory; }; diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx index 0dd68beac..13583cd2c 100644 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx @@ -188,7 +188,9 @@ void ParserResourcesType::Print() "use : " << use << std::endl << "NbOfProc : " << nbOfProc << std::endl << "Modules : " << std::endl << - "Components : " << 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 ClusterMembersList; unsigned int nbOfProc; + bool is_cluster_head; + std::string working_directory; void Print(); void Clear(); diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 0a4e5598a..090b2d353 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -226,6 +226,8 @@ SALOME_ResourcesManager::GetResourceDefinition(const char * name) 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"; @@ -273,6 +275,8 @@ SALOME_ResourcesManager::AddResource(const Engines::ResourceDefinition& new_reso 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") @@ -372,10 +376,10 @@ SALOME_ResourcesManager::AddResource(const Engines::ResourceDefinition& new_reso } } -void +void SALOME_ResourcesManager::RemoveResource(const char * resource_name, - CORBA::Boolean write, - const char * xml_file) + CORBA::Boolean write, + const char * xml_file) { _rm.DeleteResourceInCatalog(resource_name); if (write) @@ -431,7 +435,7 @@ SALOME_ResourcesManager::getMachineFile(std::string resource_name, // Creating machine file machine_file_name = tmpnam(NULL); - std::ofstream machine_file(machine_file_name.c_str(), std::ios_base::out); + std::ofstream machine_file(machine_file_name.c_str(), std::ios_base::out); CORBA::Long machine_number = 0; std::list::iterator it = list_of_machines.begin(); @@ -493,20 +497,20 @@ SALOME_ResourcesManager::getMachineFile(std::string resource_name, } else if (resource.mpi == openmpi) { - // Creating machine file - machine_file_name = tmpnam(NULL); - std::ofstream machine_file(machine_file_name.c_str(), std::ios_base::out); - - // We add all cluster machines to the file - std::list::iterator cluster_it = - resource.ClusterMembersList.begin(); - while (cluster_it != resource.ClusterMembersList.end()) - { - unsigned int number_of_proc = (*cluster_it).DataForSort._nbOfNodes * - (*cluster_it).DataForSort._nbOfProcPerNode; - machine_file << (*cluster_it).HostName << " slots=" << number_of_proc << std::endl; - cluster_it++; - } + // Creating machine file + machine_file_name = tmpnam(NULL); + std::ofstream machine_file(machine_file_name.c_str(), std::ios_base::out); + + // We add all cluster machines to the file + std::list::iterator cluster_it = + resource.ClusterMembersList.begin(); + while (cluster_it != resource.ClusterMembersList.end()) + { + unsigned int number_of_proc = (*cluster_it).DataForSort._nbOfNodes * + (*cluster_it).DataForSort._nbOfProcPerNode; + machine_file << (*cluster_it).HostName << " slots=" << number_of_proc << std::endl; + cluster_it++; + } } else if (resource.mpi == nompi) {