-//=============================================================================
-/*!
- * get the list of name of ressources fitting for the specified module.
- * If hostname specified, check it is local or known in resources catalog.
- *
- * Else
- * - select first machines with corresponding OS (all machines if
- * parameter OS empty),
- * - then select the sublist of machines on witch the module is known
- * (if the result is empty, that probably means that the inventory of
- * modules is probably not done, so give complete list from previous step)
- */
-//=============================================================================
-
-vector<string>
-SALOME_ResourcesManager::
-GetFittingResources(const Engines::MachineParameters& params,
- const char *moduleName)
-throw(SALOME_Exception)
-{
- MESSAGE("ResourcesManager::GetFittingResources");
- vector <std::string> ret;
-
- // --- To be sure that we search in a correct list.
- ParseXmlFile();
-
- const char *hostname = (const char *)params.hostname;
- MESSAGE("GetFittingResources " << hostname << " " << GetHostname().c_str());
-
- if (hostname[0] != '\0')
- {
- MESSAGE("ResourcesManager::GetFittingResources : hostname specified" );
-
- if ( strcmp(hostname, "localhost") == 0 ||
- strcmp(hostname, GetHostname().c_str()) == 0 )
- {
- MESSAGE("ResourcesManager::GetFittingResources : localhost" );
- ret.push_back(GetHostname().c_str());
- MESSAGE("ResourcesManager::GetFittingResources : " << ret.size());
- }
-
- else if (_resourcesList.find(hostname) != _resourcesList.end())
- {
- // --- params.hostname is in the list of resources so return it.
- ret.push_back(hostname);
- }
-
- else
- {
- // --- user specified an unknown hostame so notify him.
- MESSAGE("ResourcesManager::GetFittingResources : SALOME_Exception");
- throw SALOME_Exception("unknown host");
- }
- }
-
- else
- // --- Search for available resources sorted by priority
- {
- SelectOnlyResourcesWithOS(ret, params.OS);
-
- KeepOnlyResourcesWithModule(ret, moduleName);
-
- if (ret.size() == 0)
- SelectOnlyResourcesWithOS(ret, params.OS);
-
- // --- set wanted parameters
- ResourceDataToSort::_nbOfNodesWanted = params.nb_node;
-
- ResourceDataToSort::_nbOfProcPerNodeWanted = params.nb_proc_per_node;
-
- ResourceDataToSort::_CPUFreqMHzWanted = params.cpu_clock;
-
- ResourceDataToSort::_memInMBWanted = params.mem_mb;
-
- // --- end of set
-
- list<ResourceDataToSort> li;
-
- for (vector<string>::iterator iter = ret.begin();
- iter != ret.end();
- iter++)
- li.push_back(_resourcesList[(*iter)].DataForSort);
-
- li.sort();
-
- unsigned int i = 0;
-
- for (list<ResourceDataToSort>::iterator iter2 = li.begin();
- iter2 != li.end();
- iter2++)
- ret[i++] = (*iter2)._hostName;
- }
-
- MESSAGE("ResourcesManager::GetFittingResources : return" << ret.size());
- return ret;
-}