X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FResourcesManager%2FSALOME_ResourcesCatalog_Handler.cxx;h=f65db96c038e02206a098dba67123dff16560971;hb=cfb73ea195567454579b199b2b109e6f9373646f;hp=27adbdd41682e486941aab221af8b4ab20f4bac1;hpb=bdc8928913c4ae9cd7ca3bc0eca5d344be9ff992;p=modules%2Fkernel.git diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index 27adbdd41..f65db96c0 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// 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 @@ -28,6 +28,7 @@ // #include "SALOME_ResourcesCatalog_Handler.hxx" #include "Basics_Utils.hxx" +#include "Utils_SALOME_Exception.hxx" #include #include #include @@ -68,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"; } //============================================================================= @@ -304,18 +307,15 @@ SALOME_ResourcesCatalog_Handler::ProcessMember(xmlNodePtr member_descr, ParserRe if (xmlHasProp(member_descr, (const xmlChar*)test_protocol)) { xmlChar* protocol= xmlGetProp(member_descr, (const xmlChar*)test_protocol); - switch (protocol[0]) + try { - 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; + resource.Protocol = ParserResourcesType::stringToProtocol((const char *)protocol); + } + catch (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; + return false; } xmlFree(protocol); } @@ -329,18 +329,15 @@ SALOME_ResourcesCatalog_Handler::ProcessMember(xmlNodePtr member_descr, ParserRe if (xmlHasProp(member_descr, (const xmlChar*)test_cluster_internal_protocol)) { xmlChar* iprotocol= xmlGetProp(member_descr, (const xmlChar*)test_cluster_internal_protocol); - switch (iprotocol[0]) + try { - case 'r': - resource.ClusterInternalProtocol = rsh; - break; - case 's': - resource.ClusterInternalProtocol = 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; + resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol((const char *)iprotocol); + } + catch (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; + return false; } xmlFree(iprotocol); } @@ -456,18 +453,14 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser if (xmlHasProp(machine_descr, (const xmlChar*)test_protocol)) { xmlChar* protocol= xmlGetProp(machine_descr, (const xmlChar*)test_protocol); - switch ( protocol[0]) + try { - 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; + resource.Protocol = ParserResourcesType::stringToProtocol((const char *)protocol); + } + catch (SALOME_Exception e) + { + // If it'not in all theses cases, the protocol is affected to rsh + resource.Protocol = rsh; } xmlFree(protocol); } @@ -477,18 +470,14 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser if (xmlHasProp(machine_descr, (const xmlChar*)test_cluster_internal_protocol)) { xmlChar* iprotocol= xmlGetProp(machine_descr, (const xmlChar*)test_cluster_internal_protocol); - switch ( iprotocol[0]) + try { - case 'r': - resource.ClusterInternalProtocol = rsh; - break; - case 's': - resource.ClusterInternalProtocol = ssh; - break; - default: - // If it'not in all theses cases, the protocol is affected to rsh - resource.ClusterInternalProtocol = rsh; - break; + resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol((const char *)iprotocol); + } + catch (SALOME_Exception e) + { + // If it'not in all theses cases, the protocol is affected to rsh + resource.ClusterInternalProtocol = rsh; } xmlFree(iprotocol); } @@ -535,6 +524,8 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser resource.Batch = slurm; else if (aBatch == "ll") resource.Batch = ll; + else if (aBatch == "vishnu") + resource.Batch = vishnu; else resource.Batch = none; } @@ -609,6 +600,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) @@ -679,30 +700,17 @@ void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc) 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()); - - switch ((*iter).second.Protocol) - { - case rsh: - xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "rsh"); - break; - case ssh: - xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "ssh"); - break; - default: - xmlNewProp(node, BAD_CAST test_protocol, BAD_CAST "rsh"); - } - - switch ((*iter).second.ClusterInternalProtocol) - { - case rsh: - xmlNewProp(node, BAD_CAST test_cluster_internal_protocol, BAD_CAST "rsh"); - break; - case ssh: - xmlNewProp(node, BAD_CAST test_cluster_internal_protocol, BAD_CAST "ssh"); - break; - default: - xmlNewProp(node, BAD_CAST test_cluster_internal_protocol, BAD_CAST "rsh"); - } + 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_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) { @@ -739,6 +747,9 @@ void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc) 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 ""); }