1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
24 // File : SALOME_ResourcesCatalog_Handler.cxx
25 // Author : Estelle Deville
29 #include "SALOME_ResourcesCatalog_Handler.hxx"
30 #include "Basics_Utils.hxx"
31 #include "Utils_SALOME_Exception.hxx"
36 //=============================================================================
39 * \param listOfResources: map of ParserResourcesType to fill when parsing
41 //=============================================================================
43 SALOME_ResourcesCatalog_Handler::
44 SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& resources_list): _resources_list(resources_list)
46 //XML tags initialisation
47 test_machine = "machine";
48 test_cluster = "cluster";
50 test_hostname = "hostname";
51 test_protocol = "protocol";
52 test_cluster_internal_protocol = "iprotocol";
56 test_user_name = "userName";
57 test_appli_path = "appliPath";
58 test_modules = "modules";
59 test_module_name = "moduleName";
60 test_components = "component";
61 test_component_name = "name";
63 test_mem_in_mb = "memInMB";
64 test_cpu_freq_mhz = "CPUFreqMHz";
65 test_nb_of_nodes = "nbOfNodes";
66 test_nb_of_proc = "nbOfProc";
67 test_nb_of_proc_per_node = "nbOfProcPerNode";
68 test_batch_queue = "batchQueue";
69 test_user_commands = "userCommands";
71 test_members = "members";
72 test_is_cluster_head = "isClusterHead";
73 test_working_directory = "workingDirectory";
76 //=============================================================================
80 //=============================================================================
82 SALOME_ResourcesCatalog_Handler::~SALOME_ResourcesCatalog_Handler()
84 // cout << "SALOME_ResourcesCatalog_Handler destruction") << endl;
87 //=============================================================================
89 * Retrieves DS after the file parse.
91 //=============================================================================
93 const MapOfParserResourcesType&
94 SALOME_ResourcesCatalog_Handler::GetResourcesAfterParsing() const
96 return _resources_list;
99 //=============================================================================
101 * Processes XML document and fills the list of resources
103 //=============================================================================
105 void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc)
107 // Empty private elements
108 _resources_list.clear();
112 _resource.HostName = Kernel_Utils::GetHostname();
113 _resource.Name = Kernel_Utils::GetHostname();
114 _resource.DataForSort._Name = Kernel_Utils::GetHostname();
115 _resources_list[Kernel_Utils::GetHostname()] = _resource;
117 // Get the document root node
118 xmlNodePtr aCurNode = xmlDocGetRootElement(theDoc);
120 aCurNode = aCurNode->xmlChildrenNode;
122 // Processing the document nodes
123 while(aCurNode != NULL)
125 // Cas d'une machine ou d'une machine batch
126 if (!xmlStrcmp(aCurNode->name,(const xmlChar*)test_machine))
129 bool Ok = ProcessMachine(aCurNode, _resource);
133 if(_resource.HostName == "localhost")
135 _resource.HostName = Kernel_Utils::GetHostname();
137 std::map<std::string, ParserResourcesType>::const_iterator iter = _resources_list.find(_resource.Name);
138 if (iter != _resources_list.end())
139 RES_INFOS("Warning resource " << _resource.Name << " already added, keep last resource found !");
140 _resources_list[_resource.Name] = _resource;
143 // Cas de la déclaration d'un cluster
144 if (!xmlStrcmp(aCurNode->name,(const xmlChar*)test_cluster))
147 if(ProcessCluster(aCurNode, _resource))
149 std::map<std::string, ParserResourcesType>::const_iterator iter = _resources_list.find(_resource.Name);
150 if (iter != _resources_list.end())
151 RES_INFOS("Warning resource " << _resource.Name << " already added, keep last resource found !");
152 _resources_list[_resource.Name] = _resource;
155 aCurNode = aCurNode->next;
159 for (std::map<std::string, ParserResourcesType>::const_iterator iter = _resources_list.begin();
160 iter != _resources_list.end();
163 std::cerr << "************************************************" << std::endl;
164 std::cerr << "Resource " << (*iter).first << " found:" << std::endl;
165 std::cerr << " Name: " << (*iter).second.Name << std::endl;
166 std::cerr << " Hostname: " << (*iter).second.HostName << std::endl;
167 std::cerr << " Username: " << (*iter).second.UserName << std::endl;
168 std::cerr << " Appli path: " <<(*iter).second.AppliPath << std::endl;
169 std::cerr << " OS: " << (*iter).second.OS << std::endl;
170 std::cerr << " Protocol: " << (*iter).second.PrintAccessProtocolType() << std::endl;
171 std::cerr << " Internal Protocol: " <<(*iter).second.PrintClusterInternalProtocol() << std::endl;
172 std::cerr << " Mode: " << (*iter).second.PrintAccessModeType() << std::endl;
173 std::cerr << " Batch Type: " << (*iter).second.PrintBatchType() << std::endl;
174 std::cerr << " MPI Impl: " << (*iter).second.PrintMpiImplType() << std::endl;
175 std::cerr << "************************************************" << std::endl;
181 SALOME_ResourcesCatalog_Handler::ProcessCluster(xmlNodePtr cluster_descr, ParserResourcesType & resource)
183 // Ajout d'un cluster
184 // hostname, use et nbOfProc sont obligatoires
185 if (xmlHasProp(cluster_descr, (const xmlChar*)test_hostname))
187 xmlChar* hostname = xmlGetProp(cluster_descr, (const xmlChar*)test_hostname);
188 resource.HostName = (const char*)hostname;
193 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! found a cluster without a hostname" << std::endl;
194 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! this cluster will not be added" << std::endl;
198 if (xmlHasProp(cluster_descr, (const xmlChar*)test_name))
200 xmlChar* name = xmlGetProp(cluster_descr, (const xmlChar*)test_name);
201 resource.Name = (const char*)name;
202 resource.DataForSort._Name = (const char*)name;
207 resource.Name = resource.HostName;
208 resource.DataForSort._Name = resource.HostName;
209 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! No Name found use Hostname for resource: " << _resource.Name << std::endl;
212 if (xmlHasProp(cluster_descr, (const xmlChar*)test_use))
214 xmlChar* use = xmlGetProp(cluster_descr, (const xmlChar*)test_use);
215 resource.use = (const char*)use;
220 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! found a cluster without a use" << std::endl;
221 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! this cluster will not be added" << std::endl;
225 if (xmlHasProp(cluster_descr, (const xmlChar*)test_nb_of_proc))
227 xmlChar* nb_of_proc = xmlGetProp(cluster_descr, (const xmlChar*)test_nb_of_proc);
228 resource.nbOfProc = atoi((const char*)nb_of_proc);
233 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! found a cluster without a nbOfProc" << std::endl;
234 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! this cluster will not be added" << std::endl;
238 if (xmlHasProp(cluster_descr, (const xmlChar*)test_mpi))
240 xmlChar* mpi = xmlGetProp(cluster_descr, (const xmlChar*)test_mpi);
241 std::string anMpi = (const char*)mpi;
245 else if (anMpi == "mpich1")
246 resource.mpi = mpich1;
247 else if (anMpi == "mpich2")
248 resource.mpi = mpich2;
249 else if (anMpi == "openmpi")
250 resource.mpi = openmpi;
251 else if (anMpi == "slurmmpi")
252 resource.mpi = slurmmpi;
253 else if (anMpi == "prun")
256 resource.mpi = nompi;
259 // Parsing des membres du cluster
260 xmlNodePtr aCurSubNode = cluster_descr->xmlChildrenNode;
261 while(aCurSubNode != NULL)
263 if (!xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_members))
265 xmlNodePtr members = aCurSubNode->xmlChildrenNode;
266 while (members != NULL)
269 if (!xmlStrcmp(members->name, (const xmlChar*)test_machine))
271 ParserResourcesClusterMembersType new_member;
272 if (ProcessMember(members, new_member))
273 resource.ClusterMembersList.push_back(new_member);
275 members = members->next;
278 aCurSubNode = aCurSubNode->next;
281 // Test: Il faut au moins un membre pour que le cluster soit correct !
282 if (resource.ClusterMembersList.empty())
284 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! found a cluster without a member" << std::endl;
285 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! this cluster will not be added" << std::endl;
292 SALOME_ResourcesCatalog_Handler::ProcessMember(xmlNodePtr member_descr, ParserResourcesClusterMembersType & resource)
294 if (xmlHasProp(member_descr, (const xmlChar*)test_hostname))
296 xmlChar* hostname = xmlGetProp(member_descr, (const xmlChar*)test_hostname);
297 resource.HostName = (const char*)hostname;
302 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine without a hostname" << std::endl;
303 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl;
307 if (xmlHasProp(member_descr, (const xmlChar*)test_protocol))
309 xmlChar* protocol= xmlGetProp(member_descr, (const xmlChar*)test_protocol);
312 resource.Protocol = ParserResourcesType::stringToProtocol((const char *)protocol);
314 catch (SALOME_Exception e)
316 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine with a bad protocol" << std::endl;
317 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl;
324 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine without a protocol" << std::endl;
325 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl;
329 if (xmlHasProp(member_descr, (const xmlChar*)test_cluster_internal_protocol))
331 xmlChar* iprotocol= xmlGetProp(member_descr, (const xmlChar*)test_cluster_internal_protocol);
334 resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol((const char *)iprotocol);
336 catch (SALOME_Exception e)
338 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine with a bad protocol" << std::endl;
339 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl;
346 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine without a protocol" << std::endl;
347 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl;
351 if (xmlHasProp(member_descr, (const xmlChar*)test_user_name))
353 xmlChar* user_name= xmlGetProp(member_descr, (const xmlChar*)test_user_name);
354 resource.UserName = (const char*)user_name;
359 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine without a user name" << std::endl;
360 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl;
364 if (xmlHasProp(member_descr, (const xmlChar*)test_nb_of_nodes))
366 xmlChar* nb_of_nodes = xmlGetProp(member_descr, (const xmlChar*)test_nb_of_nodes);
367 resource.DataForSort._nbOfNodes = atoi((const char*)nb_of_nodes);
368 xmlFree(nb_of_nodes);
372 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine without a nbOfNodes" << std::endl;
373 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl;
377 if (xmlHasProp(member_descr, (const xmlChar*)test_nb_of_proc_per_node))
379 xmlChar* nb_of_proc_per_node = xmlGetProp(member_descr, (const xmlChar*)test_nb_of_proc_per_node);
380 resource.DataForSort._nbOfProcPerNode = atoi((const char*)nb_of_proc_per_node);
381 xmlFree(nb_of_proc_per_node);
385 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine without a nbOfProcPerNode" << std::endl;
386 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl;
390 if (xmlHasProp(member_descr, (const xmlChar*)test_appli_path))
392 xmlChar* appli_path = xmlGetProp(member_descr, (const xmlChar*)test_appli_path);
393 resource.AppliPath = (const char*)appli_path;
398 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning found a machine without a AppliPath" << std::endl;
399 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMember : Warning this machine will not be added" << std::endl;
406 SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, ParserResourcesType & resource)
408 if (xmlHasProp(machine_descr, (const xmlChar*)test_hostname))
410 xmlChar* hostname = xmlGetProp(machine_descr, (const xmlChar*)test_hostname);
411 resource.HostName = (const char*)hostname;
416 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMachine : Warning found a machine without a hostname" << std::endl;
417 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMachine : Warning this machine will not be added" << std::endl;
421 if (xmlHasProp(machine_descr, (const xmlChar*)test_name))
423 xmlChar* name = xmlGetProp(machine_descr, (const xmlChar*)test_name);
424 resource.Name = (const char*)name;
425 resource.DataForSort._Name = (const char*)name;
430 resource.Name = resource.HostName;
431 resource.DataForSort._Name = resource.HostName;
432 std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMachine : !!! Warning !!! No Name found use Hostname for resource: " << _resource.Name << std::endl;
435 if (xmlHasProp(machine_descr, (const xmlChar*)test_batch_queue))
437 xmlChar* batch_queue = xmlGetProp(machine_descr, (const xmlChar*)test_batch_queue);
438 resource.batchQueue = (const char*)batch_queue;
439 xmlFree(batch_queue);
442 resource.batchQueue = "";
444 if (xmlHasProp(machine_descr, (const xmlChar*)test_user_commands))
446 xmlChar* user_commands= xmlGetProp(machine_descr, (const xmlChar*)test_user_commands);
447 resource.userCommands = (const char*)user_commands;
448 xmlFree(user_commands);
451 resource.userCommands = "";
453 if (xmlHasProp(machine_descr, (const xmlChar*)test_protocol))
455 xmlChar* protocol= xmlGetProp(machine_descr, (const xmlChar*)test_protocol);
458 resource.Protocol = ParserResourcesType::stringToProtocol((const char *)protocol);
460 catch (SALOME_Exception e)
462 // If it'not in all theses cases, the protocol is affected to rsh
463 resource.Protocol = rsh;
468 resource.Protocol = rsh;
470 if (xmlHasProp(machine_descr, (const xmlChar*)test_cluster_internal_protocol))
472 xmlChar* iprotocol= xmlGetProp(machine_descr, (const xmlChar*)test_cluster_internal_protocol);
475 resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol((const char *)iprotocol);
477 catch (SALOME_Exception e)
479 // If it'not in all theses cases, the protocol is affected to rsh
480 resource.ClusterInternalProtocol = rsh;
485 resource.ClusterInternalProtocol = resource.Protocol;
487 if (xmlHasProp(machine_descr, (const xmlChar*)test_mode))
489 xmlChar* mode=xmlGetProp(machine_descr, (const xmlChar*)test_mode);
493 resource.Mode = interactive;
496 resource.Mode = batch;
499 // If it'not in all theses cases, the mode is affected to interactive
500 resource.Mode = interactive;
506 resource.Mode = interactive;
508 if (xmlHasProp(machine_descr, (const xmlChar*)test_batch))
510 xmlChar* batch = xmlGetProp(machine_descr, (const xmlChar*)test_batch);
511 std::string aBatch = (const char*)batch;
514 resource.Batch = pbs;
515 else if (aBatch == "lsf")
516 resource.Batch = lsf;
517 else if (aBatch == "sge")
518 resource.Batch = sge;
519 else if (aBatch == "ssh_batch")
520 resource.Batch = ssh_batch;
521 else if (aBatch == "ccc")
522 resource.Batch = ccc;
523 else if (aBatch == "slurm")
524 resource.Batch = slurm;
525 else if (aBatch == "ll")
527 else if (aBatch == "vishnu")
528 resource.Batch = vishnu;
530 resource.Batch = none;
533 if (xmlHasProp(machine_descr, (const xmlChar*)test_mpi))
535 xmlChar* mpi = xmlGetProp(machine_descr, (const xmlChar*)test_mpi);
536 std::string anMpi = (const char*)mpi;
540 else if (anMpi == "mpich1")
541 resource.mpi = mpich1;
542 else if (anMpi == "mpich2")
543 resource.mpi = mpich2;
544 else if (anMpi == "openmpi")
545 resource.mpi = openmpi;
546 else if (anMpi == "slurmmpi")
547 resource.mpi = slurmmpi;
548 else if (anMpi == "prun")
551 resource.mpi = nompi;
554 if (xmlHasProp(machine_descr, (const xmlChar*)test_user_name))
556 xmlChar* user_name= xmlGetProp(machine_descr, (const xmlChar*)test_user_name);
557 resource.UserName = (const char*)user_name;
561 if (xmlHasProp(machine_descr, (const xmlChar*)test_appli_path))
563 xmlChar* appli_path = xmlGetProp(machine_descr, (const xmlChar*)test_appli_path);
564 resource.AppliPath = (const char*)appli_path;
568 if (xmlHasProp(machine_descr, (const xmlChar*)test_os))
570 xmlChar* os = xmlGetProp(machine_descr, (const xmlChar*)test_os);
571 resource.OS = (const char*)os;
575 if (xmlHasProp(machine_descr, (const xmlChar*)test_mem_in_mb))
577 xmlChar* mem_in_mb = xmlGetProp(machine_descr, (const xmlChar*)test_mem_in_mb);
578 resource.DataForSort._memInMB = atoi((const char*)mem_in_mb);
582 if (xmlHasProp(machine_descr, (const xmlChar*)test_cpu_freq_mhz))
584 xmlChar* cpu_freq_mhz = xmlGetProp(machine_descr, (const xmlChar*)test_cpu_freq_mhz);
585 resource.DataForSort._CPUFreqMHz = atoi((const char*)cpu_freq_mhz);
586 xmlFree(cpu_freq_mhz);
589 if (xmlHasProp(machine_descr, (const xmlChar*)test_nb_of_nodes))
591 xmlChar* nb_of_nodes = xmlGetProp(machine_descr, (const xmlChar*)test_nb_of_nodes);
592 resource.DataForSort._nbOfNodes = atoi((const char*)nb_of_nodes);
593 xmlFree(nb_of_nodes);
596 if (xmlHasProp(machine_descr, (const xmlChar*)test_nb_of_proc_per_node))
598 xmlChar* nb_of_proc_per_node = xmlGetProp(machine_descr, (const xmlChar*)test_nb_of_proc_per_node);
599 resource.DataForSort._nbOfProcPerNode = atoi((const char*)nb_of_proc_per_node);
600 xmlFree(nb_of_proc_per_node);
603 if (xmlHasProp(machine_descr, (const xmlChar*)test_is_cluster_head))
605 xmlChar* is_cluster_head = xmlGetProp(machine_descr, (const xmlChar*)test_is_cluster_head);
606 std::string str_ich = (const char*)is_cluster_head;
607 if (str_ich == "true")
609 resource.is_cluster_head = true;
613 resource.is_cluster_head = false;
615 xmlFree(is_cluster_head);
619 resource.is_cluster_head = false;
622 if (xmlHasProp(machine_descr, (const xmlChar*)test_working_directory))
624 xmlChar* working_directory = xmlGetProp(machine_descr, (const xmlChar*)test_working_directory);
625 resource.working_directory = (const char*)working_directory;
626 xmlFree(working_directory);
630 resource.working_directory = "";
633 // Process children nodes
634 xmlNodePtr aCurSubNode = machine_descr->xmlChildrenNode;
635 while(aCurSubNode != NULL)
637 // Process components
638 if ( !xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_components) )
640 //If a component is given, it is in a module with the same name
641 //except if the module name is given
642 if (xmlHasProp(aCurSubNode, (const xmlChar*)test_component_name))
644 xmlChar* component_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_component_name);
645 std::string aComponentName = (const char*)component_name;
646 _resource.ComponentsList.push_back(aComponentName);
647 if (xmlHasProp(aCurSubNode, (const xmlChar*)test_module_name))
649 xmlChar* module_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name);
650 std::string aModuleName = (const char*)module_name;
651 _resource.ModulesList.push_back(aModuleName);
652 xmlFree(module_name);
655 _resource.ModulesList.push_back(aComponentName);
656 xmlFree(component_name);
660 else if ( !xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_modules) )
662 // If a module is given, we create an entry in componentsList and modulesList
663 // with the same name (module == component)
664 if (xmlHasProp(aCurSubNode, (const xmlChar*)test_module_name))
666 xmlChar* component_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name);
667 std::string aComponentName = (const char*)component_name;
668 _resource.ComponentsList.push_back(aComponentName);
669 _resource.ModulesList.push_back(aComponentName);
670 xmlFree(component_name);
673 aCurSubNode = aCurSubNode->next;
678 //=============================================================================
680 * Fill the document tree in xml file, used to write in an xml file.
681 * \param theDoc document to fill.
683 //=============================================================================
685 void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc)
688 xmlNodePtr root_node = NULL, node = NULL, node1 = NULL;
690 root_node = xmlNewNode(NULL, BAD_CAST "resources");
691 xmlDocSetRootElement(theDoc, root_node);
693 std::map<std::string, ParserResourcesType>::iterator iter = _resources_list.begin();
694 for (; iter != _resources_list.end(); iter++)
696 node = xmlNewChild(root_node, NULL, BAD_CAST test_machine, NULL);
697 RES_MESSAGE("Add resource name = " << (*iter).second.Name.c_str());
698 xmlNewProp(node, BAD_CAST test_name, BAD_CAST (*iter).second.Name.c_str());
699 xmlNewProp(node, BAD_CAST test_hostname, BAD_CAST (*iter).second.HostName.c_str());
700 xmlNewProp(node, BAD_CAST test_appli_path, BAD_CAST (*iter).second.AppliPath.c_str());
701 xmlNewProp(node, BAD_CAST test_batch_queue, BAD_CAST (*iter).second.batchQueue.c_str());
702 xmlNewProp(node, BAD_CAST test_user_commands, BAD_CAST (*iter).second.userCommands.c_str());
704 BAD_CAST test_protocol,
705 BAD_CAST ParserResourcesType::protocolToString((*iter).second.Protocol).c_str());
707 BAD_CAST test_cluster_internal_protocol,
708 BAD_CAST ParserResourcesType::protocolToString((*iter).second.ClusterInternalProtocol).c_str());
709 xmlNewProp(node, BAD_CAST test_working_directory, BAD_CAST (*iter).second.working_directory.c_str());
710 if ((*iter).second.is_cluster_head)
711 xmlNewProp(node, BAD_CAST test_is_cluster_head, BAD_CAST "true");
713 xmlNewProp(node, BAD_CAST test_is_cluster_head, BAD_CAST "false");
715 switch ((*iter).second.Mode)
718 xmlNewProp(node, BAD_CAST test_mode, BAD_CAST "interactive");
721 xmlNewProp(node, BAD_CAST test_mode, BAD_CAST "batch");
724 xmlNewProp(node, BAD_CAST test_mode, BAD_CAST "interactive");
727 switch ((*iter).second.Batch)
730 xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "pbs");
733 xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "lsf");
736 xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "sge");
739 xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "ccc");
742 xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "slurm");
745 xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "ssh_batch");
748 xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "ll");
751 xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "vishnu");
754 xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "");
757 switch ((*iter).second.mpi)
760 xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "lam");
763 xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "mpich1");
766 xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "mpich2");
769 xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "openmpi");
772 xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "slurmmpi");
775 xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "prun");
778 xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "");
781 xmlNewProp(node, BAD_CAST test_user_name, BAD_CAST (*iter).second.UserName.c_str());
783 std::vector<std::string>::const_iterator iter2 = (*iter).second.ComponentsList.begin();
784 for(;iter2 != (*iter).second.ComponentsList.end(); iter2++)
786 node1 = xmlNewChild(node, NULL, BAD_CAST test_components, NULL);
787 xmlNewProp(node1, BAD_CAST test_component_name, BAD_CAST (*iter2).c_str());
790 xmlNewProp(node, BAD_CAST test_os, BAD_CAST (*iter).second.OS.c_str());
791 std::ostringstream mem_stream;
792 mem_stream << (*iter).second.DataForSort._memInMB;
793 xmlNewProp(node, BAD_CAST test_mem_in_mb, BAD_CAST mem_stream.str().c_str());
794 std::ostringstream cpu_stream;
795 cpu_stream << (*iter).second.DataForSort._CPUFreqMHz;
796 xmlNewProp(node, BAD_CAST test_cpu_freq_mhz, BAD_CAST cpu_stream.str().c_str());
797 std::ostringstream nb_nodes_stream;
798 nb_nodes_stream << (*iter).second.DataForSort._nbOfNodes;
799 xmlNewProp(node, BAD_CAST test_nb_of_nodes, BAD_CAST nb_nodes_stream.str().c_str());
800 std::ostringstream nb_proc_per_nodes_stream;
801 nb_proc_per_nodes_stream << (*iter).second.DataForSort._nbOfProcPerNode;
802 xmlNewProp(node, BAD_CAST test_nb_of_proc_per_node, BAD_CAST nb_proc_per_nodes_stream.str().c_str());