From: ribes Date: Thu, 2 Apr 2009 14:53:12 +0000 (+0000) Subject: Adding new type of SALOME CatalogResource : cluster X-Git-Tag: new_launcher_alpha_091119~25 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a36a3f214d7574c770274dd0aca4d8d5b2948b6b;p=modules%2Fkernel.git Adding new type of SALOME CatalogResource : cluster It is the base to generate a MPI machine file for launching a parallel container in distributed resources --- diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index 5b068ea31..52247dc11 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -184,7 +184,9 @@ ResourcesManager_cpp::GetFittingResources(const machineParams& params, #if defined(_DEBUG_) || defined(_DEBUG) cerr << "ResourcesManager_cpp::GetFittingResources : SALOME_Exception" << endl; #endif - throw ResourcesException("unknown host"); + std::string error("GetFittinResouces : ResourcesManager doesn't find the host requested : "); + error += hostname; + throw ResourcesException(error); } } } diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index 1032e8fa4..76ec27e66 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -47,8 +47,7 @@ SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& resources_list, { //XML tags initialisation test_machine = "machine"; - test_resources = "resources"; - + test_cluster = "cluster"; test_hostname = "hostname"; test_alias = "alias"; test_protocol = "protocol"; @@ -63,9 +62,12 @@ SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& resources_list, test_mem_in_mb = "memInMB"; test_cpu_freq_mhz = "CPUFreqMHz"; test_nb_of_nodes = "nbOfNodes"; + test_nb_of_proc = "nbOfProc"; test_nb_of_proc_per_node = "nbOfProcPerNode"; test_batch_queue = "batchQueue"; test_user_commands = "userCommands"; + test_use = "use"; + test_members = "members"; } //============================================================================= @@ -109,246 +111,428 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) // Processing the document nodes while(aCurNode != NULL) + { + // Cas d'une machine ou d'une machine batch + if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_machine) ) { - if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_machine) ) + _resource.Clear(); + bool Ok = ProcessMachine(aCurNode, _resource); + if (Ok) + { + // There is two lists + // _resources_list for interactive resources + // _resources_batch_list for batch resources + // This choice is done with Mode parameter + if (_resource.Mode == interactive) { - _resource.Clear(); - if (xmlHasProp(aCurNode, (const xmlChar*)test_hostname)) - { - xmlChar* hostname = xmlGetProp(aCurNode, (const xmlChar*)test_hostname); - _resource.DataForSort._hostName = (const char*)hostname; - _resource.HostName = (const char*)hostname; - xmlFree(hostname); - } - else - break; - - if (xmlHasProp(aCurNode, (const xmlChar*)test_alias)) - { - xmlChar* alias = xmlGetProp(aCurNode, (const xmlChar*)test_alias); - _resource.Alias = (const char*)alias; - xmlFree(alias); - } + // Adding a generic cluster + int aNbNodes = _resource.DataForSort._nbOfNodes; + if( aNbNodes > 1 ){ + string clusterNode = _resource.DataForSort._hostName ; + for( int i=0; i < aNbNodes; i++ ){ + char inode[64]; + inode[0] = '\0' ; + sprintf(inode,"%s%d",clusterNode.c_str(),i+1); + std::string nodeName(inode); + _resource.DataForSort._hostName = nodeName ; + _resource.HostName = nodeName ; + _resources_list[nodeName] = _resource; + } + } else - _resource.Alias = ""; - - if (xmlHasProp(aCurNode, (const xmlChar*)test_batch_queue)) - { - xmlChar* batch_queue = xmlGetProp(aCurNode, (const xmlChar*)test_batch_queue); - _resource.batchQueue = (const char*)batch_queue; - xmlFree(batch_queue); - } - else - _resource.batchQueue = ""; - - if (xmlHasProp(aCurNode, (const xmlChar*)test_user_commands)) - { - xmlChar* user_commands= xmlGetProp(aCurNode, (const xmlChar*)test_user_commands); - _resource.userCommands = (const char*)user_commands; - xmlFree(user_commands); - } - else - _resource.userCommands = ""; - - if (xmlHasProp(aCurNode, (const xmlChar*)test_protocol)) - { - xmlChar* protocol= xmlGetProp(aCurNode, (const xmlChar*)test_protocol); - switch ( protocol[0]) - { - case 'r': - _resource.Protocol = rsh; - break; - case 's': - _resource.Protocol = ssh; - break; - default: - // If it'not in all theses cases, the protocol is affected to rsh - _resource.Protocol = rsh; - break; - } - xmlFree(protocol); - } - else - _resource.Protocol = rsh; - - if (xmlHasProp(aCurNode, (const xmlChar*)test_mode)) - { - xmlChar* mode=xmlGetProp(aCurNode, (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(aCurNode, (const xmlChar*)test_batch)) - { - xmlChar* batch = xmlGetProp(aCurNode, (const xmlChar*)test_batch); - std::string aBatch = (const char*)batch; - xmlFree(batch); - if (aBatch == "pbs") - _resource.Batch = pbs; - else if (aBatch == "lsf") - _resource.Batch = lsf; - else if (aBatch == "sge") - _resource.Batch = sge; - else - _resource.Batch = none; - } - - if (xmlHasProp(aCurNode, (const xmlChar*)test_mpi)) - { - xmlChar* mpi = xmlGetProp(aCurNode, (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 == "slurm") - _resource.mpi = slurm; - else if (anMpi == "prun") - _resource.mpi = prun; - else - _resource.mpi = nompi; - } - - if (xmlHasProp(aCurNode, (const xmlChar*)test_user_name)) - { - xmlChar* user_name= xmlGetProp(aCurNode, (const xmlChar*)test_user_name); - _resource.UserName = (const char*)user_name; - xmlFree(user_name); - } - - if (xmlHasProp(aCurNode, (const xmlChar*)test_appli_path)) - { - xmlChar* appli_path = xmlGetProp(aCurNode, (const xmlChar*)test_appli_path); - _resource.AppliPath = (const char*)appli_path; - xmlFree(appli_path); - } - - if (xmlHasProp(aCurNode, (const xmlChar*)test_os)) - { - xmlChar* os = xmlGetProp(aCurNode, (const xmlChar*)test_os); - _resource.OS = (const char*)os; - xmlFree(os); - } - - if (xmlHasProp(aCurNode, (const xmlChar*)test_mem_in_mb)) - { - xmlChar* mem_in_mb = xmlGetProp(aCurNode, (const xmlChar*)test_mem_in_mb); - _resource.DataForSort._memInMB = atoi((const char*)mem_in_mb); - xmlFree(mem_in_mb); - } - - if (xmlHasProp(aCurNode, (const xmlChar*)test_cpu_freq_mhz)) - { - xmlChar* cpu_freq_mhz = xmlGetProp(aCurNode, (const xmlChar*)test_cpu_freq_mhz); - _resource.DataForSort._CPUFreqMHz = atoi((const char*)cpu_freq_mhz); - xmlFree(cpu_freq_mhz); - } - - if (xmlHasProp(aCurNode, (const xmlChar*)test_nb_of_nodes)) - { - xmlChar* nb_of_nodes = xmlGetProp(aCurNode, (const xmlChar*)test_nb_of_nodes); - _resource.DataForSort._nbOfNodes = atoi((const char*)nb_of_nodes); - xmlFree(nb_of_nodes); - } - - if (xmlHasProp(aCurNode, (const xmlChar*)test_nb_of_proc_per_node)) - { - xmlChar* nb_of_proc_per_node = xmlGetProp(aCurNode, (const xmlChar*)test_nb_of_proc_per_node); - _resource.DataForSort._nbOfProcPerNode = atoi((const char*)nb_of_proc_per_node); - xmlFree(nb_of_proc_per_node); - } - - // Process modules - xmlNodePtr aCurSubNode = aCurNode->xmlChildrenNode; - while(aCurSubNode != NULL) + { + // Adding a machine + _resources_list[_resource.HostName] = _resource; + if(_resource.HostName == "localhost") { - if ( !xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_modules) ) - { - 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); - xmlFree(module_name); - } - } - aCurSubNode = aCurSubNode->next; + _resource.HostName = Kernel_Utils::GetHostname(); + _resource.DataForSort._hostName = Kernel_Utils::GetHostname(); + _resources_list[Kernel_Utils::GetHostname()] = _resource; } - - // There is two lists - // _resources_list for interactive resources - // _resources_batch_list for batch resources - // This choice is done with Mode parameter - if (_resource.Mode == interactive) - { - int aNbNodes = _resource.DataForSort._nbOfNodes; - if( aNbNodes > 1 ){ - string clusterNode = _resource.DataForSort._hostName ; - for( int i=0; i < aNbNodes; i++ ){ - char inode[64]; - inode[0] = '\0' ; - sprintf(inode,"%s%d",clusterNode.c_str(),i+1); - std::string nodeName(inode); - _resource.DataForSort._hostName = nodeName ; - _resource.HostName = nodeName ; - _resources_list[nodeName] = _resource; - } - } - else - { - _resources_list[_resource.HostName] = _resource; - if(_resource.HostName == "localhost") - { - _resource.HostName = Kernel_Utils::GetHostname(); - _resource.DataForSort._hostName = Kernel_Utils::GetHostname(); - _resources_list[Kernel_Utils::GetHostname()] = _resource; - } - } - } - else - _resources_batch_list[_resource.HostName] = _resource; - } - aCurNode = aCurNode->next; + } + } + else + // Adding a batch machine/cluster + _resources_batch_list[_resource.HostName] = _resource; + } } + if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_cluster) ) + { + // Cas de la déclaration d'un cluster + _resource.Clear(); + if(ProcessCluster(aCurNode, _resource)) + _resources_list[_resource.HostName] = _resource; + } + aCurNode = aCurNode->next; + } #ifdef _DEBUG_ - for (map::const_iterator iter = - _resources_list.begin(); - iter != _resources_list.end(); - iter++) - { - std::cerr << (*iter).first << std::endl; - std::cerr << (*iter).second.HostName << std::endl; - std::cerr << (*iter).second.Alias << std::endl; - std::cerr << (*iter).second.UserName << std::endl; - std::cerr << (*iter).second.AppliPath << std::endl; - std::cerr << (*iter).second.OS << std::endl; - std::cerr << (*iter).second.Protocol << std::endl; - std::cerr << (*iter).second.Mode << std::endl; - } + for (map::const_iterator iter = _resources_list.begin(); + iter != _resources_list.end(); + iter++) + { + std::cerr << (*iter).first << std::endl; + std::cerr << (*iter).second.HostName << std::endl; + std::cerr << (*iter).second.Alias << std::endl; + std::cerr << (*iter).second.UserName << std::endl; + std::cerr << (*iter).second.AppliPath << std::endl; + std::cerr << (*iter).second.OS << std::endl; + std::cerr << (*iter).second.Protocol << std::endl; + std::cerr << (*iter).second.Mode << std::endl; + } #endif } +bool +SALOME_ResourcesCatalog_Handler::ProcessCluster(xmlNodePtr cluster_descr, ParserResourcesType & resource) +{ + // Ajout d'un cluster + // hostname, use et nbOfProc sont obligatoires + if (xmlHasProp(cluster_descr, (const xmlChar*)test_hostname)) + { + xmlChar* hostname = xmlGetProp(cluster_descr, (const xmlChar*)test_hostname); + resource.DataForSort._hostName = (const char*)hostname; + resource.HostName = (const char*)hostname; + xmlFree(hostname); + } + else + { + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! found a cluster without a hostname" << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! this cluster will not be added" << std::endl; + return false; + } + + if (xmlHasProp(cluster_descr, (const xmlChar*)test_use)) + { + xmlChar* use = xmlGetProp(cluster_descr, (const xmlChar*)test_use); + resource.use = (const char*)use; + xmlFree(use); + } + else + { + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! found a cluster without a use" << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! this cluster will not be added" << std::endl; + return false; + } + + if (xmlHasProp(cluster_descr, (const xmlChar*)test_nb_of_proc)) + { + xmlChar* nb_of_proc = xmlGetProp(cluster_descr, (const xmlChar*)test_nb_of_proc); + resource.nbOfProc = atoi((const char*)nb_of_proc); + xmlFree(nb_of_proc); + } + else + { + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! found a cluster without a nbOfProc" << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! this cluster will not be added" << std::endl; + return false; + } + + // Parsing des membres du cluster + xmlNodePtr aCurSubNode = cluster_descr->xmlChildrenNode; + while(aCurSubNode != NULL) + { + if (!xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_members)) + { + xmlNodePtr members = aCurSubNode->xmlChildrenNode; + while (members != NULL) + { + // Process members + if (!xmlStrcmp(members->name, (const xmlChar*)test_machine)) + { + ParserResourcesClusterMembersType new_member; + if (ProcessMember(members, new_member)) + resource.ClusterMembersList.push_back(new_member); + } + members = members->next; + } + } + aCurSubNode = aCurSubNode->next; + } + + // Test: Il faut au moins un membre pour que le cluster soit correct ! + if (resource.ClusterMembersList.empty()) + { + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! found a cluster without a member" << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! this cluster will not be added" << std::endl; + return false; + } + return true; +} + +bool +SALOME_ResourcesCatalog_Handler::ProcessMember(xmlNodePtr member_descr, ParserResourcesClusterMembersType & resource) +{ + if (xmlHasProp(member_descr, (const xmlChar*)test_hostname)) + { + xmlChar* hostname = xmlGetProp(member_descr, (const xmlChar*)test_hostname); + resource.DataForSort._hostName = (const char*)hostname; + resource.HostName = (const char*)hostname; + xmlFree(hostname); + } + else + { + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine without a hostname" << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl; + return false; + } + + if (xmlHasProp(member_descr, (const xmlChar*)test_protocol)) + { + xmlChar* protocol= xmlGetProp(member_descr, (const xmlChar*)test_protocol); + switch (protocol[0]) + { + case 'r': + resource.Protocol = rsh; + break; + case 's': + resource.Protocol = ssh; + break; + default: + 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; + return false; + } + xmlFree(protocol); + } + else + { + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine without a protocol" << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl; + return false; + } + + if (xmlHasProp(member_descr, (const xmlChar*)test_user_name)) + { + xmlChar* user_name= xmlGetProp(member_descr, (const xmlChar*)test_user_name); + resource.UserName = (const char*)user_name; + xmlFree(user_name); + } + else + { + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine without a user name" << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl; + return false; + } + + if (xmlHasProp(member_descr, (const xmlChar*)test_nb_of_nodes)) + { + xmlChar* nb_of_nodes = xmlGetProp(member_descr, (const xmlChar*)test_nb_of_nodes); + resource.DataForSort._nbOfNodes = atoi((const char*)nb_of_nodes); + xmlFree(nb_of_nodes); + } + else + { + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine without a nbOfNodes" << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl; + return false; + } + + if (xmlHasProp(member_descr, (const xmlChar*)test_nb_of_proc_per_node)) + { + xmlChar* nb_of_proc_per_node = xmlGetProp(member_descr, (const xmlChar*)test_nb_of_proc_per_node); + resource.DataForSort._nbOfProcPerNode = atoi((const char*)nb_of_proc_per_node); + xmlFree(nb_of_proc_per_node); + } + else + { + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine without a nbOfProcPerNode" << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl; + return false; + } +} + +bool +SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, ParserResourcesType & resource) +{ + if (xmlHasProp(machine_descr, (const xmlChar*)test_hostname)) + { + xmlChar* hostname = xmlGetProp(machine_descr, (const xmlChar*)test_hostname); + resource.DataForSort._hostName = (const char*)hostname; + resource.HostName = (const char*)hostname; + xmlFree(hostname); + } + else + { + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMachine : Warning found a machine without a hostname" << std::endl; + std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMachine : Warning this machine will not be added" << std::endl; + return false; + } + + if (xmlHasProp(machine_descr, (const xmlChar*)test_alias)) + { + xmlChar* alias = xmlGetProp(machine_descr, (const xmlChar*)test_alias); + resource.Alias = (const char*)alias; + xmlFree(alias); + } + else + resource.Alias = ""; + + if (xmlHasProp(machine_descr, (const xmlChar*)test_batch_queue)) + { + xmlChar* batch_queue = xmlGetProp(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)) + { + xmlChar* user_commands= xmlGetProp(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); + switch ( protocol[0]) + { + case 'r': + resource.Protocol = rsh; + break; + case 's': + resource.Protocol = ssh; + break; + default: + // If it'not in all theses cases, the protocol is affected to rsh + resource.Protocol = rsh; + break; + } + xmlFree(protocol); + } + else + resource.Protocol = rsh; + + 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; + xmlFree(batch); + if (aBatch == "pbs") + resource.Batch = pbs; + else if (aBatch == "lsf") + resource.Batch = lsf; + else if (aBatch == "sge") + resource.Batch = sge; + 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; + 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 == "slurm") + resource.mpi = slurm; + else if (anMpi == "prun") + resource.mpi = prun; + else + resource.mpi = nompi; + } + + if (xmlHasProp(machine_descr, (const xmlChar*)test_user_name)) + { + xmlChar* user_name= xmlGetProp(machine_descr, (const xmlChar*)test_user_name); + resource.UserName = (const char*)user_name; + xmlFree(user_name); + } + + if (xmlHasProp(machine_descr, (const xmlChar*)test_appli_path)) + { + xmlChar* appli_path = xmlGetProp(machine_descr, (const xmlChar*)test_appli_path); + resource.AppliPath = (const char*)appli_path; + xmlFree(appli_path); + } + + if (xmlHasProp(machine_descr, (const xmlChar*)test_os)) + { + xmlChar* os = xmlGetProp(machine_descr, (const xmlChar*)test_os); + resource.OS = (const char*)os; + xmlFree(os); + } + + if (xmlHasProp(machine_descr, (const xmlChar*)test_mem_in_mb)) + { + xmlChar* mem_in_mb = xmlGetProp(machine_descr, (const xmlChar*)test_mem_in_mb); + resource.DataForSort._memInMB = atoi((const char*)mem_in_mb); + xmlFree(mem_in_mb); + } + + if (xmlHasProp(machine_descr, (const xmlChar*)test_cpu_freq_mhz)) + { + xmlChar* cpu_freq_mhz = xmlGetProp(machine_descr, (const xmlChar*)test_cpu_freq_mhz); + resource.DataForSort._CPUFreqMHz = atoi((const char*)cpu_freq_mhz); + xmlFree(cpu_freq_mhz); + } + + if (xmlHasProp(machine_descr, (const xmlChar*)test_nb_of_nodes)) + { + xmlChar* nb_of_nodes = xmlGetProp(machine_descr, (const xmlChar*)test_nb_of_nodes); + resource.DataForSort._nbOfNodes = atoi((const char*)nb_of_nodes); + xmlFree(nb_of_nodes); + } + + if (xmlHasProp(machine_descr, (const xmlChar*)test_nb_of_proc_per_node)) + { + xmlChar* nb_of_proc_per_node = xmlGetProp(machine_descr, (const xmlChar*)test_nb_of_proc_per_node); + resource.DataForSort._nbOfProcPerNode = atoi((const char*)nb_of_proc_per_node); + xmlFree(nb_of_proc_per_node); + } + + // Process children nodes + xmlNodePtr aCurSubNode = machine_descr->xmlChildrenNode; + while(aCurSubNode != NULL) + { + // Process modules + if ( !xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_modules) ) + { + 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); + xmlFree(module_name); + } + } + aCurSubNode = aCurSubNode->next; + } + return true; +} //============================================================================= /*! diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx index 35cd21296..8fa1ca5da 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx @@ -50,6 +50,10 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesCatalog_Handler virtual ~SALOME_ResourcesCatalog_Handler(); void ProcessXmlDocument(xmlDocPtr theDoc); + + bool ProcessMachine(xmlNodePtr machine_descr, ParserResourcesType & resource); + bool ProcessCluster(xmlNodePtr cluster_descr, ParserResourcesType & resource); + bool ProcessMember(xmlNodePtr member_descr, ParserResourcesClusterMembersType & resource); void PrepareDocToXmlFile(xmlDocPtr theDoc); @@ -61,8 +65,7 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesCatalog_Handler MapOfParserResourcesType& _resources_batch_list; const char *test_machine; - const char *test_resources; - + const char *test_cluster; const char *test_hostname; const char *test_alias; const char *test_protocol; @@ -77,9 +80,12 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesCatalog_Handler const char *test_mem_in_mb; const char *test_cpu_freq_mhz; const char *test_nb_of_nodes; + const char *test_nb_of_proc; const char *test_nb_of_proc_per_node; const char *test_batch_queue; const char *test_user_commands; + const char *test_use; + const char *test_members; }; diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx index fff95034a..a09d02cb3 100644 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx @@ -114,7 +114,7 @@ void ResourceDataToSort::Print() const cout << _memInMB << endl; } -void ParserResourcesType::Print() const +void ParserResourcesType::Print() { ostringstream oss; oss << endl << @@ -133,11 +133,21 @@ void ParserResourcesType::Print() const "OS : " << OS << endl << "batchQueue : " << batchQueue << endl << "userCommands : " << userCommands << endl << + "use : " << use << endl << + "NbOfProc : " << nbOfProc << endl << "Modules : " << endl; for(int i=0;i::iterator it; + for(it = ClusterMembersList.begin(); + it != ClusterMembersList.end(); + it++) + { + oss << "Cluster member called : " << (*it).HostName << endl; + } cout << oss.str() << endl; } @@ -161,4 +171,7 @@ void ParserResourcesType::Clear() userCommands = ""; ModulesList.clear(); OS = ""; + use = ""; + ClusterMembersList.clear(); + nbOfProc = 1; } diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx index b8767a6da..fe187cb5c 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -71,25 +72,36 @@ class RESOURCESMANAGER_EXPORT ResourceDataToSort unsigned int GetNumberOfPoints() const; }; +struct RESOURCESMANAGER_EXPORT ParserResourcesClusterMembersType +{ + std::string HostName; + AccessProtocolType Protocol; + std::string UserName; + ResourceDataToSort DataForSort; +}; + struct RESOURCESMANAGER_EXPORT ParserResourcesType - { - ResourceDataToSort DataForSort; - std::string HostName; - std::string Alias; - AccessProtocolType Protocol; - AccessModeType Mode; - BatchType Batch; - MpiImplType mpi; - std::string UserName; - std::string AppliPath; - std::vector ModulesList; - std::string OS; - std::string batchQueue; - std::string userCommands; +{ + ResourceDataToSort DataForSort; + std::string HostName; + std::string Alias; + AccessProtocolType Protocol; + AccessModeType Mode; + BatchType Batch; + MpiImplType mpi; + std::string UserName; + std::string AppliPath; + std::vector ModulesList; + std::string OS; + std::string batchQueue; + std::string userCommands; + std::string use; + std::list ClusterMembersList; + unsigned int nbOfProc; - void Print() const; - void Clear(); - }; + void Print(); + void Clear(); +}; typedef std::map MapOfParserResourcesType; typedef std::map::iterator MapOfParserResourcesType_it;