//=============================================================================
SALOME_ResourcesCatalog_Handler::
-SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& listOfResources):
- _resources_list(listOfResources)
+SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& resources_list,
+ MapOfParserResourcesType& resources_batch_list):
+ _resources_list(resources_list),
+ _resources_batch_list(resources_batch_list)
{
MESSAGE("SALOME_ResourcesCatalog_Handler creation");
//XML tags initialisation
}
aCurSubNode = aCurSubNode->next;
}
-
- 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 ;
- _resources_list[nodeName] = _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;
}
else
- _resources_list[_resource.DataForSort._hostName] = _resource;
+ _resources_batch_list[_resource.HostName] = _resource;
}
-
aCurNode = aCurNode->next;
}
iter != _resources_list.end();
iter++)
{
+ SCRUTE((*iter).second.HostName);
SCRUTE((*iter).second.Alias);
SCRUTE((*iter).second.UserName);
SCRUTE((*iter).second.AppliPath);
iter++)
{
node = xmlNewChild(root_node, NULL, BAD_CAST test_machine, NULL);
- xmlNewProp(node, BAD_CAST test_hostname, BAD_CAST (*iter).first.c_str());
+ xmlNewProp(node, BAD_CAST test_hostname, BAD_CAST (*iter).second.HostName.c_str());
+ xmlNewProp(node, BAD_CAST test_alias, BAD_CAST (*iter).second.Alias.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.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 slurm:
+ xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "slurm");
+ 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;
+ default:
+ xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "");
+ }
+
+ xmlNewProp(node, BAD_CAST test_user_name, BAD_CAST (*iter).second.UserName.c_str());
+
+ for (vector<string>::const_iterator iter2 =
+ (*iter).second.ModulesList.begin();
+ iter2 != (*iter).second.ModulesList.end();
+ iter2++)
+ {
+ node1 = xmlNewChild(node, NULL, BAD_CAST test_modules, NULL);
+ xmlNewProp(node1, BAD_CAST test_module_name, BAD_CAST (*iter2).c_str());
+ }
+
+ xmlNewProp(node, BAD_CAST test_os, BAD_CAST (*iter).second.OS.c_str());
+ xmlNewProp(node, BAD_CAST test_mem_in_mb, BAD_CAST sprintf(string_buf, "%u", (*iter).second.DataForSort._memInMB));
+ xmlNewProp(node, BAD_CAST test_cpu_freq_mhz, BAD_CAST sprintf(string_buf, "%u", (*iter).second.DataForSort._CPUFreqMHz));
+ xmlNewProp(node, BAD_CAST test_nb_of_nodes, BAD_CAST sprintf(string_buf, "%u", (*iter).second.DataForSort._nbOfNodes));
+ xmlNewProp(node, BAD_CAST test_nb_of_proc_per_node, BAD_CAST sprintf(string_buf, "%u", (*iter).second.DataForSort._nbOfProcPerNode));
+ }
+ for (map<string, ParserResourcesType>::iterator iter =
+ _resources_batch_list.begin();
+ iter != _resources_batch_list.end();
+ iter++)
+ {
+ node = xmlNewChild(root_node, NULL, BAD_CAST test_machine, NULL);
+ xmlNewProp(node, BAD_CAST test_hostname, BAD_CAST (*iter).second.HostName.c_str());
xmlNewProp(node, BAD_CAST test_alias, BAD_CAST (*iter).second.Alias.c_str());
switch ((*iter).second.Protocol)
Engines::MachineList *
SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& params,
const Engines::CompoList& componentList)
-//throw(SALOME_Exception)
{
-// MESSAGE("ResourcesManager::GetFittingResources");
vector <std::string> vec;
Engines::MachineList *ret=new Engines::MachineList;
-
try{
// --- To be sure that we search in a correct list.
- ParseXmlFile();
+ // ParseXmlFile();
const char *hostname = (const char *)params.hostname;
MESSAGE("GetFittingResources " << hostname << " " << GetHostname().c_str());
// --- params.hostname is in the list of resources so return it.
vec.push_back(hostname);
}
-
+ else if (_resourcesBatchList.find(hostname) != _resourcesBatchList.end())
+ {
+ // --- params.hostname is in the list of resources so return it.
+ vec.push_back(hostname);
+ }
else
{
- // Cas d'un cluster: nombre de noeuds > 1
+ // Cas d'un cluster interactif: nombre de noeuds > 1
int cpt=0;
for (map<string, ParserResourcesType>::const_iterator iter = _resourcesList.begin(); iter != _resourcesList.end(); iter++){
if( (*iter).second.DataForSort._nbOfNodes > 1 ){
{
ParserResourcesType newElt;
newElt.DataForSort._hostName = paramsOfNewResources.hostname;
+ newElt.HostName = paramsOfNewResources.hostname;
newElt.Alias = alias;
newElt.Protocol = prot;
newElt.Mode = mode;
xmlNewDocComment(aDoc, BAD_CAST "ResourcesCatalog");
SALOME_ResourcesCatalog_Handler* handler =
- new SALOME_ResourcesCatalog_Handler(_resourcesList);
+ new SALOME_ResourcesCatalog_Handler(_resourcesList, _resourcesBatchList);
handler->PrepareDocToXmlFile(aDoc);
delete handler;
const MapOfParserResourcesType& SALOME_ResourcesManager::ParseXmlFile()
{
SALOME_ResourcesCatalog_Handler* handler =
- new SALOME_ResourcesCatalog_Handler(_resourcesList);
+ new SALOME_ResourcesCatalog_Handler(_resourcesList, _resourcesBatchList);
const char* aFilePath = _path_resources.c_str();
FILE* aFile = fopen(aFilePath, "r");
Engines::MachineParameters* SALOME_ResourcesManager::GetMachineParameters(const char *hostname)
{
- ParserResourcesType resource = _resourcesList[string(hostname)];
+ ParserResourcesType resource;
+ if (_resourcesList.find(hostname) != _resourcesList.end())
+ resource = _resourcesList[string(hostname)];
+ else
+ resource = _resourcesBatchList[string(hostname)];
+
Engines::MachineParameters *p_ptr = new Engines::MachineParameters;
p_ptr->container_name = CORBA::string_dup("");
p_ptr->hostname = CORBA::string_dup(resource.HostName.c_str());
p_ptr->batch = "lsf";
else if( resource.Batch == slurm )
p_ptr->batch = "slurm";
+
return p_ptr;
}