- Replace parameters "mode" and "is_cluster_head" by parameters "type", "can_launch_batch_jobs" and "can_run_containers"
- ContainerManager now only selects resources that can run containers
- Fixes bug #21503
string name;
//! host name
string hostname;
+ //! if true select only resources that can launch batch jobs
+ boolean can_launch_batch_jobs;
+ //! if true select only resources that can run containers
+ boolean can_run_containers;
//! if given required operating system
string OS;
//! if given list of components that could be loaded on a container
string name;
//! hostname
string hostname;
+ //! Type of the resource ("cluster" or "single_machine")
+ string type;
//! protocol to connect to the resource
//! protocol used to start a remote container (ssh or rsh)
string protocol;
string applipath;
//! list of available components
CompoList componentList;
- //! Type of resource: interactive or batch
- string mode;
//! operating system
string OS;
//! internal protocol to use to start a remote container (ssh or rsh) on the cluster
string iprotocol;
- //! Specify if the resource is a cluster head;
- boolean is_cluster_head;
+ //! Specify if the resource can launch batch jobs
+ boolean can_launch_batch_jobs;
+ //! Specify if the resource can run containers
+ boolean can_run_containers;
//! Predefined working directory on the resource
string working_directory;
}
// Step 2: Get all possibleResources from the parameters
+ // Consider only resources that can run containers
+ local_params.resource_params.can_run_containers = true;
Engines::ResourceList_var possibleResources = _ResManager->GetFittingResources(local_params.resource_params);
MESSAGE("[GiveContainer] - length of possible resources " << possibleResources->length());
std::vector<std::string> local_resources;
// Select a ressource for the job
std::vector<std::string> ResourceList;
resourceParams params = job->getResourceRequiredParams();
+ // Consider only resources that can launch batch jobs
+ params.can_launch_batch_jobs = true;
try
{
ResourceList = _ResManager->GetFittingResources(params);
launch_script_stream << "export SALOME_TMP_DIR=" << work_directory << "/logs" << std::endl;
// -- Generates Catalog Resources
- std::string resource_protocol = ParserResourcesType::protocolToString(_resource_definition.ClusterInternalProtocol);
+ std::string resource_protocol = _resource_definition.getClusterInternalProtocolStr();
launch_script_stream << "if [ \"x$LIBBATCH_NODEFILE\" != \"x\" ]; then " << std::endl;
launch_script_stream << "CATALOG_FILE=" << "CatalogResources_" << _launch_date << ".xml" << std::endl;
launch_script_stream << "export USER_CATALOG_RESOURCES_FILE=" << "$CATALOG_FILE" << std::endl;
launch_script_stream << "echo ' protocol=\"" << resource_protocol << "\"' >> $CATALOG_FILE" << std::endl;
launch_script_stream << "echo ' userName=\"" << _resource_definition.UserName << "\"' >> $CATALOG_FILE" << std::endl;
launch_script_stream << "echo ' appliPath=\"" << _resource_definition.AppliPath << "\"' >> $CATALOG_FILE" << std::endl;
- launch_script_stream << "echo ' mpi=\"" << _resource_definition.PrintMpiImplType() << "\"' >> $CATALOG_FILE" << std::endl;
- launch_script_stream << "echo ' nbOfNodes='\\\"$nbproc\\\" >> $CATALOG_FILE" << std::endl;
- launch_script_stream << "echo ' nbOfProcPerNode=\"1\"' >> $CATALOG_FILE" << std::endl;
+ launch_script_stream << "echo ' mpi=\"" << _resource_definition.getMpiImplTypeStr() << "\"' >> $CATALOG_FILE" << std::endl;
+ launch_script_stream << "echo ' nbOfNodes='\\\"$nbproc\\\" >> $CATALOG_FILE" << std::endl;
+ launch_script_stream << "echo ' nbOfProcPerNode=\"1\"' >> $CATALOG_FILE" << std::endl;
+ launch_script_stream << "echo ' can_run_containers=\"true\"' >> $CATALOG_FILE" << std::endl;
launch_script_stream << "echo '/>' >> $CATALOG_FILE" << std::endl;
launch_script_stream << "done" << std::endl;
launch_script_stream << "echo '</resources>' >> $CATALOG_FILE" << std::endl;
CORBA::Boolean rtn = false;
try
{
- // find a cluster matching the structure params
- Engines::ResourceList *aMachineList = _ResManager->GetFittingResources(params);
+ // Consider only resources that can run batch jobs
+ Engines::ResourceParameters new_params(params);
+ new_params.can_launch_batch_jobs = true;
+
+ // find a resource matching the required parameters
+ Engines::ResourceList *aMachineList = _ResManager->GetFittingResources(new_params);
if (aMachineList->length() == 0)
throw SALOME_Exception("No resources have been found with your parameters");
convert(params, new_params);
new_params.resource_params.componentList.length(1);
new_params.resource_params.componentList[0] = componentName;
+ new_params.resource_params.can_run_containers = true;
Engines::ResourceList_var listOfResources;
try
{
convert(params, new_params);
new_params.resource_params.componentList.length(1);
new_params.resource_params.componentList[0] = componentName;
+ new_params.resource_params.can_run_containers = true;
Engines::ResourceList_var listOfResources;
try
convert(params, new_params);
new_params.resource_params.componentList.length(1);
new_params.resource_params.componentList[0] = componentName;
+ new_params.resource_params.can_run_containers = true;
// For Compatibility -> if hostname == localhost put name == hostname
if (std::string(new_params.resource_params.hostname.in()) == "localhost")
Engines::ContainerParameters new_params(params);
new_params.resource_params.componentList.length(1);
new_params.resource_params.componentList[0] = componentName;
+ new_params.resource_params.can_run_containers = true;
Engines::ResourceList_var listOfResources;
try
params.nb_node = 0;
params.nb_proc_per_node = 0;
params.policy = "";
+ params.can_launch_batch_jobs = false;
+ params.can_run_containers = false;
}
void SALOME_LifeCycleCORBA::preSet( Engines::ContainerParameters& params)
_LCC.preSet(params); // empty params to get all the machines
params.resource_params.componentList.length(1);
params.resource_params.componentList[0]="SalomeTestComponent";
+ params.resource_params.can_run_containers = true;
Engines::ResourceList_var hostList = resourcesManager->GetFittingResources(params.resource_params);
CPPUNIT_ASSERT(hostList->length() > 1);
if (vec.size() == 0)
vec = vec_save;
+ // Step 7 : Filter on possible usage
+ vector<string> prev_list(vec);
+ vec.clear();
+ for (vector<string>::iterator iter = prev_list.begin() ; iter != prev_list.end() ; iter++)
+ {
+ MapOfParserResourcesType::const_iterator it = _resourcesList.find(*iter);
+ if (it != _resourcesList.end() &&
+ (!params.can_launch_batch_jobs || it->second.can_launch_batch_jobs) &&
+ (!params.can_run_containers || it->second.can_run_containers))
+ vec.push_back(*iter);
+ }
+
// End
// Send an exception if return list is empty...
if (vec.size() == 0)
void ResourcesManager_cpp::AddDefaultResourceInCatalog()
{
ParserResourcesType resource;
- resource.Clear();
resource.Name = DEFAULT_RESOURCE_NAME;
// We can't use "localhost" for parameter hostname because the containers are registered in the
// naming service with the real hostname, not "localhost"
resource.AppliPath = string(getenv("HOME")) + "/" + getenv("APPLI");
}
resource.working_directory = "/tmp/salome_localres_workdir";
+ resource.can_launch_batch_jobs = true;
+ resource.can_run_containers = true;
_resourcesList[resource.Name] = resource;
}
{
std::string name;
std::string hostname;
+ bool can_launch_batch_jobs;
+ bool can_run_containers;
std::string OS;
long nb_proc;
long nb_node;
#include <sstream>
#include <map>
+using namespace std;
+
//=============================================================================
/*!
* Constructor
test_cluster = "cluster";
test_name = "name";
test_hostname = "hostname";
+ test_type = "type";
test_protocol = "protocol";
test_cluster_internal_protocol = "iprotocol";
test_mode = "mode";
test_members = "members";
test_is_cluster_head = "isClusterHead";
test_working_directory = "workingDirectory";
+ test_can_launch_batch_jobs = "canLaunchBatchJobs";
+ test_can_run_containers = "canRunContainers";
}
//=============================================================================
// Processing the document nodes
while(aCurNode != NULL)
{
- // Cas d'une machine ou d'une machine batch
+ // Declaration of a single machine or a frontal node for a cluster managed by a batch manager
if (!xmlStrcmp(aCurNode->name,(const xmlChar*)test_machine))
{
- _resource.Clear();
- bool Ok = ProcessMachine(aCurNode, _resource);
+ ParserResourcesType resource;
+ bool Ok = ProcessMachine(aCurNode, resource);
if (Ok)
{
// Adding a resource
- if(_resource.HostName == "localhost")
+ if(resource.HostName == "localhost")
{
- _resource.HostName = Kernel_Utils::GetHostname();
+ resource.HostName = Kernel_Utils::GetHostname();
}
- std::map<std::string, ParserResourcesType>::const_iterator iter = _resources_list.find(_resource.Name);
+ std::map<std::string, ParserResourcesType>::const_iterator iter = _resources_list.find(resource.Name);
if (iter != _resources_list.end())
- RES_INFOS("Warning resource " << _resource.Name << " already added, keep last resource found !");
- _resources_list[_resource.Name] = _resource;
+ RES_INFOS("Warning resource " << resource.Name << " already added, keep last resource found !");
+ _resources_list[resource.Name] = resource;
}
}
- // Cas de la déclaration d'un cluster
+ // Declaration of a cluster
+ // Here, a cluster is NOT the frontal node of a cluster managed by a batch manager (classical
+ // usage of a cluster). It is a group of machines intended to be used for a parallel container.
+ // The methods ProcessCluster and ProcessMember are only used in the context of parallel
+ // containers. They are not used in classical Salome usage scenarios.
if (!xmlStrcmp(aCurNode->name,(const xmlChar*)test_cluster))
{
- _resource.Clear();
- if(ProcessCluster(aCurNode, _resource))
+ ParserResourcesType resource;
+ if(ProcessCluster(aCurNode, resource))
{
- std::map<std::string, ParserResourcesType>::const_iterator iter = _resources_list.find(_resource.Name);
+ std::map<std::string, ParserResourcesType>::const_iterator iter = _resources_list.find(resource.Name);
if (iter != _resources_list.end())
- RES_INFOS("Warning resource " << _resource.Name << " already added, keep last resource found !");
- _resources_list[_resource.Name] = _resource;
+ RES_INFOS("Warning resource " << resource.Name << " already added, keep last resource found !");
+ _resources_list[resource.Name] = resource;
}
}
aCurNode = aCurNode->next;
{
std::cerr << "************************************************" << std::endl;
std::cerr << "Resource " << (*iter).first << " found:" << std::endl;
- std::cerr << " Name: " << (*iter).second.Name << std::endl;
- std::cerr << " Hostname: " << (*iter).second.HostName << std::endl;
- std::cerr << " Username: " << (*iter).second.UserName << std::endl;
- std::cerr << " Appli path: " <<(*iter).second.AppliPath << std::endl;
- std::cerr << " OS: " << (*iter).second.OS << std::endl;
- std::cerr << " Protocol: " << (*iter).second.PrintAccessProtocolType() << std::endl;
- std::cerr << " Internal Protocol: " <<(*iter).second.PrintClusterInternalProtocol() << std::endl;
- std::cerr << " Mode: " << (*iter).second.PrintAccessModeType() << std::endl;
- std::cerr << " Batch Type: " << (*iter).second.PrintBatchType() << std::endl;
- std::cerr << " MPI Impl: " << (*iter).second.PrintMpiImplType() << std::endl;
+ std::cerr << (*iter).second;
std::cerr << "************************************************" << std::endl;
}
#endif
{
resource.Name = resource.HostName;
resource.DataForSort._Name = resource.HostName;
- std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! No Name found use Hostname for resource: " << _resource.Name << std::endl;
+ std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessCluster : !!! Warning !!! No Name found use Hostname for resource: " << resource.Name << std::endl;
}
if (xmlHasProp(cluster_descr, (const xmlChar*)test_use))
xmlChar* mpi = xmlGetProp(cluster_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 == "ompi")
- resource.mpi = ompi;
- else if (anMpi == "slurmmpi")
- resource.mpi = slurmmpi;
- else if (anMpi == "prun")
- resource.mpi = prun;
- else
- resource.mpi = nompi;
+ resource.setMpiImplTypeStr(anMpi);
}
// Parsing des membres du cluster
// Process members
if (!xmlStrcmp(members->name, (const xmlChar*)test_machine))
{
- ParserResourcesClusterMembersType new_member;
+ ParserResourcesType new_member;
if (ProcessMember(members, new_member))
resource.ClusterMembersList.push_back(new_member);
}
}
bool
-SALOME_ResourcesCatalog_Handler::ProcessMember(xmlNodePtr member_descr, ParserResourcesClusterMembersType & resource)
+SALOME_ResourcesCatalog_Handler::ProcessMember(xmlNodePtr member_descr, ParserResourcesType & resource)
{
if (xmlHasProp(member_descr, (const xmlChar*)test_hostname))
{
xmlChar* protocol= xmlGetProp(member_descr, (const xmlChar*)test_protocol);
try
{
- resource.Protocol = ParserResourcesType::stringToProtocol((const char *)protocol);
+ resource.setAccessProtocolTypeStr((const char *)protocol);
}
- catch (SALOME_Exception e)
+ catch (const 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;
xmlChar* iprotocol= xmlGetProp(member_descr, (const xmlChar*)test_cluster_internal_protocol);
try
{
- resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol((const char *)iprotocol);
+ resource.setClusterInternalProtocolStr((const char *)iprotocol);
}
- catch (SALOME_Exception e)
+ catch (const 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;
{
resource.Name = resource.HostName;
resource.DataForSort._Name = resource.HostName;
- std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMachine : !!! Warning !!! No Name found use Hostname for resource: " << _resource.Name << std::endl;
+ std::cerr << "SALOME_ResourcesCatalog_Handler::ProcessMachine : !!! Warning !!! No Name found use Hostname for resource: " << resource.Name << std::endl;
+ }
+
+ // This block is for compatibility with files created in Salome 6.
+ // It can safely be removed in Salome 8.
+ if (xmlHasProp(machine_descr, (const xmlChar*)test_mode))
+ {
+ cerr << "Warning: parameter \"" << test_mode << "\" defined for resource \"" <<
+ resource.Name << "\" is deprecated. It will be replaced when your resource " <<
+ "file is saved." << endl;
+ xmlChar* mode=xmlGetProp(machine_descr, (const xmlChar*)test_mode);
+ switch ( mode[0] )
+ {
+ case 'i':
+ resource.can_run_containers = true;
+ break;
+ case 'b':
+ resource.can_launch_batch_jobs = true;
+ break;
+ default:
+ break;
+ }
+ xmlFree(mode);
+ }
+
+ if (xmlHasProp(machine_descr, (const xmlChar*)test_is_cluster_head))
+ {
+ cerr << "Warning: parameter \"" << test_is_cluster_head << "\" defined for resource \"" <<
+ resource.Name << "\" is deprecated. It will be replaced when your resource " <<
+ "file is saved." << endl;
+ 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.type = cluster;
+ resource.can_launch_batch_jobs = true;
+ resource.can_run_containers = false;
+ }
+ else
+ {
+ resource.type = single_machine;
+ resource.can_run_containers = true;
+ }
+ xmlFree(is_cluster_head);
+ }
+ // End of compatibility block
+
+ if (xmlHasProp(machine_descr, (const xmlChar*)test_type))
+ {
+ xmlChar* type = xmlGetProp(machine_descr, (const xmlChar*)test_type);
+ try
+ {
+ resource.setResourceTypeStr((const char*)type);
+ }
+ catch (const SALOME_Exception & e)
+ {
+ cerr << "Warning, invalid type \"" << (const char*)type << "\" for resource \"" <<
+ resource.Name << "\", using default value \"" << resource.getResourceTypeStr() <<
+ "\"" << endl;
+ }
+ xmlFree(type);
+ }
+ else
+ {
+ cerr << "Warning, no type found for resource \"" << resource.Name <<
+ "\", using default value \"" << resource.getResourceTypeStr() << "\"" << endl;
}
if (xmlHasProp(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))
{
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);
try
{
- resource.Protocol = ParserResourcesType::stringToProtocol((const char *)protocol);
+ resource.setAccessProtocolTypeStr((const char *)protocol);
}
- catch (SALOME_Exception e)
+ catch (const SALOME_Exception & e)
{
- // If it'not in all theses cases, the protocol is affected to rsh
- resource.Protocol = rsh;
+ cerr << "Warning, invalid protocol \"" << (const char*)protocol << "\" for resource \"" <<
+ resource.Name << "\", using default value \"" <<
+ resource.getAccessProtocolTypeStr() << "\"" << endl;
}
xmlFree(protocol);
}
- else
- resource.Protocol = rsh;
if (xmlHasProp(machine_descr, (const xmlChar*)test_cluster_internal_protocol))
{
xmlChar* iprotocol= xmlGetProp(machine_descr, (const xmlChar*)test_cluster_internal_protocol);
try
{
- resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol((const char *)iprotocol);
+ resource.setClusterInternalProtocolStr((const char *)iprotocol);
}
- catch (SALOME_Exception e)
+ catch (const SALOME_Exception & e)
{
- // If it'not in all theses cases, the protocol is affected to rsh
- resource.ClusterInternalProtocol = rsh;
+ cerr << "Warning, invalid internal protocol \"" << (const char*)iprotocol <<
+ "\" for resource \"" << resource.Name << "\", using default value \"" <<
+ resource.getClusterInternalProtocolStr() << "\"" << endl;
}
xmlFree(iprotocol);
}
else
resource.ClusterInternalProtocol = resource.Protocol;
- 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;
+ try
+ {
+ resource.setBatchTypeStr((const char *)batch);
+ }
+ catch (const SALOME_Exception & e)
+ {
+ cerr << "Warning, invalid batch manager \"" << (const char*)batch <<
+ "\" for resource \"" << resource.Name << "\", using default value \"" <<
+ resource.getBatchTypeStr() << "\"" << endl;
+ }
xmlFree(batch);
- if (aBatch == "pbs")
- resource.Batch = pbs;
- else if (aBatch == "lsf")
- resource.Batch = lsf;
- else if (aBatch == "sge")
- resource.Batch = sge;
- else if (aBatch == "ssh_batch")
- resource.Batch = ssh_batch;
- else if (aBatch == "ccc")
- resource.Batch = ccc;
- else if (aBatch == "slurm")
- resource.Batch = slurm;
- else if (aBatch == "ll")
- resource.Batch = ll;
- else if (aBatch == "vishnu")
- resource.Batch = vishnu;
- 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;
+ try
+ {
+ resource.setMpiImplTypeStr((const char *)mpi);
+ }
+ catch (const SALOME_Exception & e)
+ {
+ cerr << "Warning, invalid MPI implementation \"" << (const char*)mpi <<
+ "\" for resource \"" << resource.Name << "\", using default value \"" <<
+ resource.getMpiImplTypeStr() << "\"" << endl;
+ }
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 == "ompi")
- resource.mpi = ompi;
- else if (anMpi == "slurmmpi")
- resource.mpi = slurmmpi;
- else if (anMpi == "prun")
- resource.mpi = prun;
- else
- resource.mpi = nompi;
}
if (xmlHasProp(machine_descr, (const xmlChar*)test_user_name))
xmlFree(nb_of_proc_per_node);
}
- if (xmlHasProp(machine_descr, (const xmlChar*)test_is_cluster_head))
+ if (xmlHasProp(machine_descr, (const xmlChar*)test_can_launch_batch_jobs))
{
- 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")
+ xmlChar* can_launch_batch_jobs = xmlGetProp(machine_descr, (const xmlChar*)test_can_launch_batch_jobs);
+ try
{
- resource.is_cluster_head = true;
+ resource.setCanLaunchBatchJobsStr((const char *)can_launch_batch_jobs);
}
- else
+ catch (const SALOME_Exception & e)
{
- resource.is_cluster_head = false;
+ cerr << "Warning, invalid can_launch_batch_jobs parameter value \"" <<
+ (const char*)can_launch_batch_jobs << "\" for resource \"" << resource.Name <<
+ "\", using default value \"" << resource.getCanLaunchBatchJobsStr() << "\"" << endl;
}
- xmlFree(is_cluster_head);
+ xmlFree(can_launch_batch_jobs);
}
- else
+
+ if (xmlHasProp(machine_descr, (const xmlChar*)test_can_run_containers))
{
- resource.is_cluster_head = false;
+ xmlChar* can_run_containers = xmlGetProp(machine_descr, (const xmlChar*)test_can_run_containers);
+ try
+ {
+ resource.setCanRunContainersStr((const char *)can_run_containers);
+ }
+ catch (const SALOME_Exception & e)
+ {
+ cerr << "Warning, invalid can_run_containers parameter value \"" <<
+ (const char*)can_run_containers << "\" for resource \"" << resource.Name <<
+ "\", using default value \"" << resource.getCanRunContainersStr() << "\"" << endl;
+ }
+ xmlFree(can_run_containers);
}
if (xmlHasProp(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;
{
xmlChar* component_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_component_name);
std::string aComponentName = (const char*)component_name;
- _resource.ComponentsList.push_back(aComponentName);
+ resource.ComponentsList.push_back(aComponentName);
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);
+ resource.ModulesList.push_back(aModuleName);
xmlFree(module_name);
}
else
- _resource.ModulesList.push_back(aComponentName);
+ resource.ModulesList.push_back(aComponentName);
xmlFree(component_name);
}
}
{
xmlChar* component_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name);
std::string aComponentName = (const char*)component_name;
- _resource.ComponentsList.push_back(aComponentName);
- _resource.ModulesList.push_back(aComponentName);
+ resource.ComponentsList.push_back(aComponentName);
+ resource.ModulesList.push_back(aComponentName);
xmlFree(component_name);
}
}
RES_MESSAGE("Add resource name = " << (*iter).second.Name.c_str());
xmlNewProp(node, BAD_CAST test_name, BAD_CAST (*iter).second.Name.c_str());
xmlNewProp(node, BAD_CAST test_hostname, BAD_CAST (*iter).second.HostName.c_str());
+ xmlNewProp(node, BAD_CAST test_type, BAD_CAST (*iter).second.getResourceTypeStr().c_str());
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());
- 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_protocol, BAD_CAST (*iter).second.getAccessProtocolTypeStr().c_str());
+ xmlNewProp(node, BAD_CAST test_cluster_internal_protocol,
+ BAD_CAST (*iter).second.getClusterInternalProtocolStr().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)
- {
- 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 sge:
- xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "sge");
- break;
- case ccc:
- xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "ccc");
- break;
- case slurm:
- xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "slurm");
- break;
- case ssh_batch:
- xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "ssh_batch");
- break;
- 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 "");
- }
-
- 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;
- case ompi:
- xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "ompi");
- break;
- case slurmmpi:
- xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "slurmmpi");
- break;
- case prun:
- xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "prun");
- break;
- default:
- xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "");
- }
-
+ xmlNewProp(node, BAD_CAST test_can_launch_batch_jobs,
+ BAD_CAST (*iter).second.getCanLaunchBatchJobsStr().c_str());
+ xmlNewProp(node, BAD_CAST test_can_run_containers,
+ BAD_CAST (*iter).second.getCanRunContainersStr().c_str());
+ xmlNewProp(node, BAD_CAST test_batch, BAD_CAST (*iter).second.getBatchTypeStr().c_str());
+ xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST (*iter).second.getMpiImplTypeStr().c_str());
xmlNewProp(node, BAD_CAST test_user_name, BAD_CAST (*iter).second.UserName.c_str());
std::vector<std::string>::const_iterator iter2 = (*iter).second.ComponentsList.begin();
bool ProcessMachine(xmlNodePtr machine_descr, ParserResourcesType & resource);
bool ProcessCluster(xmlNodePtr cluster_descr, ParserResourcesType & resource);
- bool ProcessMember(xmlNodePtr member_descr, ParserResourcesClusterMembersType & resource);
+ bool ProcessMember(xmlNodePtr member_descr, ParserResourcesType & resource);
void PrepareDocToXmlFile(xmlDocPtr theDoc);
private :
std::string previous_component_name;
- ParserResourcesType _resource;
MapOfParserResourcesType& _resources_list;
const char *test_machine;
const char *test_cluster;
const char *test_name;
const char *test_hostname;
+ const char *test_type;
const char *test_protocol;
const char *test_cluster_internal_protocol;
- const char *test_mode;
const char *test_batch;
const char *test_mpi;
const char *test_user_name;
const char *test_appli_path;
+ const char *test_can_launch_batch_jobs;
+ const char *test_can_run_containers;
// for compatibility
const char *test_modules;
const char *test_module_name;
const char *test_user_commands;
const char *test_use;
const char *test_members;
- const char *test_is_cluster_head;
const char *test_working_directory;
+ const char *test_mode; // To be removed in SALOME 8
+ const char *test_is_cluster_head; // To be removed in SALOME 8
+
};
#endif // SALOME_RESOURCES_CATALOG_HANDLER
#include <iostream>
#include <sstream>
+using namespace std;
+
#define NULL_VALUE 0
unsigned int ResourceDataToSort::_nbOfProcWanted = NULL_VALUE;
}
+ParserResourcesType::ParserResourcesType()
+: type(single_machine),
+ Protocol(ssh),
+ ClusterInternalProtocol(ssh),
+ Batch(none),
+ mpi(nompi),
+ nbOfProc(1),
+ can_launch_batch_jobs(false),
+ can_run_containers(false)
+{
+ DataForSort._Name = "";
+ DataForSort._nbOfNodes = 1;
+ DataForSort._nbOfProcPerNode = 1;
+ DataForSort._CPUFreqMHz = 0;
+ DataForSort._memInMB = 0;
+}
+
+ParserResourcesType::~ParserResourcesType()
+{
+}
+
std::string ParserResourcesType::protocolToString(AccessProtocolType protocol)
{
switch (protocol)
else if (protocolStr == "blaunch")
return blaunch;
else
- throw SALOME_Exception("Unknown protocol");
+ throw SALOME_Exception((string("Unknown protocol ") + protocolStr).c_str());
}
-void ParserResourcesType::Print()
+ostream & operator<<(ostream &os, const ParserResourcesType &prt)
{
- std::ostringstream oss;
- oss << std::endl <<
- "Name : " << Name << std::endl <<
- "HostName : " << HostName << std::endl <<
- "NbOfNodes : " << DataForSort._nbOfNodes << std::endl <<
- "NbOfProcPerNode : " << DataForSort._nbOfProcPerNode << std::endl <<
- "CPUFreqMHz : " << DataForSort._CPUFreqMHz << std::endl <<
- "MemInMB : " << DataForSort._memInMB << std::endl <<
- "Protocol : " << protocolToString(Protocol) << std::endl <<
- "ClusterInternalProtocol : " << protocolToString(ClusterInternalProtocol) << std::endl <<
- "Mode : " << Mode << std::endl <<
- "Batch : " << Batch << std::endl <<
- "mpi : " << mpi << std::endl <<
- "UserName : " << UserName << std::endl <<
- "AppliPath : " << AppliPath << std::endl <<
- "OS : " << OS << std::endl <<
- "batchQueue : " << batchQueue << std::endl <<
- "userCommands : " << userCommands << std::endl <<
- "use : " << use << std::endl <<
- "NbOfProc : " << nbOfProc << std::endl <<
- "Modules : " << std::endl <<
- "Components : " << std::endl <<
- "Is Cluster Head: " << is_cluster_head << std::endl <<
- "Working Directory: " << working_directory << std::endl;
-
- for(unsigned int i=0;i<ComponentsList.size();i++)
- oss << "Component " << i+1 << " called : " << ComponentsList[i] << std::endl;
-
-
- std::list<ParserResourcesClusterMembersType>::iterator it;
- for(it = ClusterMembersList.begin();
- it != ClusterMembersList.end();
- it++)
+ os << "Name: " << prt.Name << endl <<
+ "HostName: " << prt.HostName << endl <<
+ "Type: " << prt.getResourceTypeStr() << endl <<
+ "NbOfNodes: " << prt.DataForSort._nbOfNodes << endl <<
+ "NbOfProcPerNode: " << prt.DataForSort._nbOfProcPerNode << endl <<
+ "CPUFreqMHz: " << prt.DataForSort._CPUFreqMHz << endl <<
+ "MemInMB: " << prt.DataForSort._memInMB << endl <<
+ "Protocol: " << prt.getAccessProtocolTypeStr() << endl <<
+ "ClusterInternalProtocol: " << prt.getClusterInternalProtocolStr() << endl <<
+ "Batch: " << prt.getBatchTypeStr() << endl <<
+ "mpi: " << prt.getMpiImplTypeStr() << endl <<
+ "UserName: " << prt.UserName << endl <<
+ "AppliPath: " << prt.AppliPath << endl <<
+ "OS: " << prt.OS << endl <<
+ "batchQueue: " << prt.batchQueue << endl <<
+ "userCommands: " << prt.userCommands << endl <<
+ "use: " << prt.use << endl <<
+ "NbOfProc: " << prt.nbOfProc << endl <<
+ "Can Launch Batch Jobs: " << prt.can_launch_batch_jobs << endl <<
+ "Can Run Containers: " << prt.can_run_containers << endl <<
+ "Working Directory: " << prt.working_directory << endl;
+
+ for(unsigned int i=0 ; i<prt.ComponentsList.size() ; i++)
+ os << "Component " << i+1 << " called: " << prt.ComponentsList[i] << endl;
+
+ list<ParserResourcesType>::const_iterator it;
+ for(it = prt.ClusterMembersList.begin() ; it != prt.ClusterMembersList.end() ; it++)
{
- oss << "Cluster member called : " << (*it).HostName << std::endl;
+ os << "Cluster member called: " << (*it).HostName << endl;
}
- std::cout << oss.str() << std::endl;
+ return os;
}
std::string
-ParserResourcesType::PrintAccessProtocolType() const
+ParserResourcesType::getAccessProtocolTypeStr() const
{
return protocolToString(Protocol);
}
std::string
-ParserResourcesType::PrintClusterInternalProtocol() const
+ParserResourcesType::getClusterInternalProtocolStr() const
{
return protocolToString(ClusterInternalProtocol);
}
std::string
-ParserResourcesType::PrintAccessModeType() const
+ParserResourcesType::getResourceTypeStr() const
{
- if (Mode == interactive)
- return "interactive";
- else
- return "batch";
+ switch (type)
+ {
+ case cluster:
+ return "cluster";
+ case single_machine:
+ return "single_machine";
+ default:
+ throw SALOME_Exception("Unknown resource type");
+ }
}
std::string
-ParserResourcesType::PrintBatchType() const
+ParserResourcesType::getBatchTypeStr() const
{
- if (Batch == none)
+ switch (Batch)
+ {
+ case none:
return "none";
- else if (Batch == pbs)
+ case pbs:
return "pbs";
- else if (Batch == lsf)
+ case lsf:
return "lsf";
- else if (Batch == sge)
+ case sge:
return "sge";
- else if (Batch == ccc)
+ case ccc:
return "ccc";
- else if (Batch == slurm)
+ case slurm:
return "slurm";
- else if (Batch == ll)
+ case ll:
return "ll";
- else if (Batch == vishnu)
+ case vishnu:
return "vishnu";
- else
- return "ssh";
+ case ssh_batch:
+ return "ssh_batch";
+ default:
+ throw SALOME_Exception("Unknown batch type");
+ }
}
std::string
-ParserResourcesType::PrintMpiImplType() const
+ParserResourcesType::getMpiImplTypeStr() const
{
- if (mpi == nompi)
+ switch (mpi)
+ {
+ case nompi:
return "no mpi";
- else if (mpi == lam)
+ case lam:
return "lam";
- else if (mpi == mpich1)
+ case mpich1:
return "mpich1";
- else if (mpi == mpich2)
+ case mpich2:
return "mpich2";
- else if (mpi == openmpi)
+ case openmpi:
return "openmpi";
- else if (mpi == ompi)
+ case ompi:
return "ompi";
- else if (mpi == slurmmpi)
+ case slurmmpi:
return "slurmmpi";
- else
+ case prun:
return "prun";
+ default:
+ throw SALOME_Exception("Unknown MPI implementation type");
+ }
}
-void ParserResourcesType::Clear()
+string ParserResourcesType::getCanLaunchBatchJobsStr() const
{
- Name = "";
- HostName = "";
- Protocol = rsh;
- ClusterInternalProtocol = rsh;
- Mode = interactive;
- Batch = none;
- mpi = nompi;
- UserName = "";
- AppliPath = "";
- batchQueue = "";
- userCommands = "";
- ComponentsList.clear();
- OS = "";
- use = "";
- ClusterMembersList.clear();
- nbOfProc = 1;
- is_cluster_head = false;
- working_directory = "";
+ return can_launch_batch_jobs ? "true" : "false";
+}
- DataForSort._Name = "";
- DataForSort._nbOfNodes = 1;
- DataForSort._nbOfProcPerNode = 1;
- DataForSort._CPUFreqMHz = 0;
- DataForSort._memInMB = 0;
+string ParserResourcesType::getCanRunContainersStr() const
+{
+ return can_run_containers ? "true" : "false";
+}
+
+void ParserResourcesType::setAccessProtocolTypeStr(const string & protocolTypeStr)
+{
+ Protocol = stringToProtocol(protocolTypeStr);
+}
+
+void ParserResourcesType::setResourceTypeStr(const string & resourceTypeStr)
+{
+ if (resourceTypeStr == "cluster")
+ type = cluster;
+ else if (resourceTypeStr == "single_machine")
+ type = single_machine;
+ else
+ throw SALOME_Exception((string("Unknown resource type ") + resourceTypeStr).c_str());
+}
+
+void ParserResourcesType::setBatchTypeStr(const string & batchTypeStr)
+{
+ if (batchTypeStr == "pbs")
+ Batch = pbs;
+ else if (batchTypeStr == "lsf")
+ Batch = lsf;
+ else if (batchTypeStr == "sge")
+ Batch = sge;
+ else if (batchTypeStr == "slurm")
+ Batch = slurm;
+ else if (batchTypeStr == "ccc")
+ Batch = ccc;
+ else if (batchTypeStr == "ssh_batch")
+ Batch = ssh_batch;
+ else if (batchTypeStr == "ll")
+ Batch = ll;
+ else if (batchTypeStr == "vishnu")
+ Batch = vishnu;
+ else if (batchTypeStr == "")
+ Batch = none;
+ else
+ throw SALOME_Exception((string("Unknown batch type ") + batchTypeStr).c_str());
+}
+
+void ParserResourcesType::setMpiImplTypeStr(const string & mpiImplTypeStr)
+{
+ if (mpiImplTypeStr == "lam")
+ mpi = lam;
+ else if (mpiImplTypeStr == "mpich1")
+ mpi = mpich1;
+ else if (mpiImplTypeStr == "mpich2")
+ mpi = mpich2;
+ else if (mpiImplTypeStr == "openmpi")
+ mpi = openmpi;
+ else if (mpiImplTypeStr == "ompi")
+ mpi = ompi;
+ else if (mpiImplTypeStr == "slurmmpi")
+ mpi = slurmmpi;
+ else if (mpiImplTypeStr == "prun")
+ mpi = prun;
+ else if (mpiImplTypeStr == "" || mpiImplTypeStr == "no mpi")
+ mpi = nompi;
+ else
+ throw SALOME_Exception((string("Unknown MPI implementation type ") + mpiImplTypeStr).c_str());
+}
+
+void ParserResourcesType::setClusterInternalProtocolStr(const string & internalProtocolTypeStr)
+{
+ ClusterInternalProtocol = stringToProtocol(internalProtocolTypeStr);
+}
+
+void ParserResourcesType::setCanLaunchBatchJobsStr(const string & canLaunchBatchJobsStr)
+{
+ if (canLaunchBatchJobsStr == "true")
+ can_launch_batch_jobs = true;
+ else if (canLaunchBatchJobsStr == "false")
+ can_launch_batch_jobs = false;
+ else
+ throw SALOME_Exception((string("Invalid boolean value for can_launch_batch_jobs: ") +
+ canLaunchBatchJobsStr).c_str());
+}
+
+void ParserResourcesType::setCanRunContainersStr(const string & canRunContainersStr)
+{
+ if (canRunContainersStr == "true")
+ can_run_containers = true;
+ else if (canRunContainersStr == "false")
+ can_run_containers = false;
+ else
+ throw SALOME_Exception((string("Invalid boolean value for can_run_containers: ") +
+ canRunContainersStr).c_str());
}
enum AccessProtocolType {sh, rsh, ssh, srun, pbsdsh, blaunch};
-enum AccessModeType {interactive, batch};
+enum ResourceType {cluster, single_machine};
enum BatchType {none, pbs, lsf, sge, ssh_batch, ccc, ll, slurm, vishnu};
unsigned int GetNumberOfPoints() const;
};
-struct RESOURCESMANAGER_EXPORT ParserResourcesClusterMembersType
+class RESOURCESMANAGER_EXPORT ParserResourcesType
{
- std::string HostName;
- AccessProtocolType Protocol;
- AccessProtocolType ClusterInternalProtocol;
- std::string UserName;
- std::string AppliPath;
- ResourceDataToSort DataForSort;
-};
+public:
+ ParserResourcesType();
+ virtual ~ParserResourcesType();
+
+ std::string getAccessProtocolTypeStr() const;
+ std::string getResourceTypeStr() const;
+ std::string getBatchTypeStr() const;
+ std::string getMpiImplTypeStr() const;
+ std::string getClusterInternalProtocolStr() const;
+ std::string getCanLaunchBatchJobsStr() const;
+ std::string getCanRunContainersStr() const;
+
+ void setAccessProtocolTypeStr(const std::string & protocolTypeStr);
+ void setResourceTypeStr(const std::string & resourceTypeStr);
+ void setBatchTypeStr(const std::string & batchTypeStr);
+ void setMpiImplTypeStr(const std::string & mpiImplTypeStr);
+ void setClusterInternalProtocolStr(const std::string & internalProtocolTypeStr);
+ void setCanLaunchBatchJobsStr(const std::string & canLaunchBatchJobsStr);
+ void setCanRunContainersStr(const std::string & canRunContainersStr);
-struct RESOURCESMANAGER_EXPORT ParserResourcesType
-{
ResourceDataToSort DataForSort;
std::string Name;
std::string HostName;
AccessProtocolType Protocol;
AccessProtocolType ClusterInternalProtocol;
- AccessModeType Mode;
+ ResourceType type;
BatchType Batch;
MpiImplType mpi;
std::string UserName;
std::string batchQueue;
std::string userCommands;
std::string use;
- std::list<ParserResourcesClusterMembersType> ClusterMembersList;
+ std::list<ParserResourcesType> ClusterMembersList;
unsigned int nbOfProc;
- bool is_cluster_head;
+ bool can_launch_batch_jobs;
+ bool can_run_containers;
std::string working_directory;
- void Print();
- void Clear();
+protected:
static std::string protocolToString(AccessProtocolType protocol);
static AccessProtocolType stringToProtocol(const std::string & protocolStr);
- std::string PrintAccessProtocolType() const;
- std::string PrintAccessModeType() const;
- std::string PrintBatchType() const;
- std::string PrintMpiImplType() const;
- std::string PrintClusterInternalProtocol() const;
+ RESOURCESMANAGER_EXPORT friend std::ostream & operator<<(std::ostream &os,
+ const ParserResourcesType &rt);
+
};
typedef std::map<std::string, ParserResourcesType> MapOfParserResourcesType;
resourceParams p;
p.name = params.name;
p.hostname = params.hostname;
+ p.can_launch_batch_jobs = params.can_launch_batch_jobs;
+ p.can_run_containers = params.can_run_containers;
p.OS = params.OS;
p.nb_proc = params.nb_proc;
p.nb_node = params.nb_node;
p_ptr->name = CORBA::string_dup(resource.Name.c_str());
p_ptr->hostname = CORBA::string_dup(resource.HostName.c_str());
- p_ptr->protocol = ParserResourcesType::protocolToString(resource.Protocol).c_str();
- p_ptr->iprotocol = ParserResourcesType::protocolToString(resource.ClusterInternalProtocol).c_str();
+ p_ptr->type = CORBA::string_dup(resource.getResourceTypeStr().c_str());
+ p_ptr->protocol = CORBA::string_dup(resource.getAccessProtocolTypeStr().c_str());
+ p_ptr->iprotocol = CORBA::string_dup(resource.getClusterInternalProtocolStr().c_str());
p_ptr->username = CORBA::string_dup(resource.UserName.c_str());
p_ptr->applipath = CORBA::string_dup(resource.AppliPath.c_str());
p_ptr->componentList.length(resource.ComponentsList.size());
p_ptr->cpu_clock = resource.DataForSort._CPUFreqMHz;
p_ptr->nb_proc_per_node = resource.DataForSort._nbOfProcPerNode;
p_ptr->nb_node = resource.DataForSort._nbOfNodes;
- p_ptr->is_cluster_head = resource.is_cluster_head;
+ p_ptr->can_launch_batch_jobs = resource.can_launch_batch_jobs;
+ p_ptr->can_run_containers = resource.can_run_containers;
p_ptr->working_directory = CORBA::string_dup(resource.working_directory.c_str());
-
- if( resource.mpi == lam )
- p_ptr->mpiImpl = "lam";
- else if( resource.mpi == mpich1 )
- p_ptr->mpiImpl = "mpich1";
- else if( resource.mpi == mpich2 )
- p_ptr->mpiImpl = "mpich2";
- else if( resource.mpi == openmpi )
- p_ptr->mpiImpl = "openmpi";
- else if( resource.mpi == ompi )
- p_ptr->mpiImpl = "ompi";
- else if( resource.mpi == slurmmpi )
- p_ptr->mpiImpl = "slurmmpi";
- else if( resource.mpi == prun )
- p_ptr->mpiImpl = "prun";
-
- if( resource.Batch == pbs )
- p_ptr->batch = "pbs";
- else if( resource.Batch == lsf )
- p_ptr->batch = "lsf";
- else if( resource.Batch == sge )
- p_ptr->batch = "sge";
- else if( resource.Batch == ccc )
- p_ptr->batch = "ccc";
- else if( resource.Batch == slurm )
- p_ptr->batch = "slurm";
- else if( resource.Batch == ssh_batch )
- p_ptr->batch = "ssh";
- else if( resource.Batch == ll )
- p_ptr->batch = "ll";
- else if( resource.Batch == vishnu )
- p_ptr->batch = "vishnu";
+ p_ptr->mpiImpl = CORBA::string_dup(resource.getMpiImplTypeStr().c_str());
+ p_ptr->batch = CORBA::string_dup(resource.getBatchTypeStr().c_str());
} catch (const exception & ex) {
INFOS("Caught exception in GetResourceDefinition: " << ex.what());
THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::BAD_PARAM);
CORBA::Boolean write,
const char * xml_file)
{
- ParserResourcesType resource;
- resource.Name = new_resource.name.in();
- resource.HostName = new_resource.hostname.in();
- resource.OS = new_resource.OS.in();
- resource.AppliPath = new_resource.applipath.in();
- resource.DataForSort._memInMB = new_resource.mem_mb;
- resource.DataForSort._CPUFreqMHz = new_resource.cpu_clock;
- resource.DataForSort._nbOfNodes = new_resource.nb_node;
- resource.DataForSort._nbOfProcPerNode = new_resource.nb_proc_per_node;
- resource.UserName = new_resource.username.in();
- resource.is_cluster_head = new_resource.is_cluster_head;
- resource.working_directory = new_resource.working_directory.in();
-
- std::string aBatch = new_resource.batch.in();
- if (aBatch == "pbs")
- resource.Batch = pbs;
- else if (aBatch == "lsf")
- resource.Batch = lsf;
- else if (aBatch == "sge")
- resource.Batch = sge;
- else if (aBatch == "slurm")
- resource.Batch = slurm;
- else if (aBatch == "ccc")
- resource.Batch = ccc;
- else if (aBatch == "ssh_batch")
- resource.Batch = ssh_batch;
- else if (aBatch == "ll")
- resource.Batch = ll;
- else if (aBatch == "vishnu")
- resource.Batch = vishnu;
- else if (aBatch == "")
- resource.Batch = none;
- else {
- INFOS("Bad Batch definition in AddResource: " << aBatch);
- std::string message("Bad Batch definition in AddResource: ");
- message += aBatch;
- THROW_SALOME_CORBA_EXCEPTION(message.c_str(),SALOME::BAD_PARAM);
- }
-
- std::string anMpi = new_resource.mpiImpl.in();
- 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 == "ompi")
- resource.mpi = ompi;
- else if (anMpi == "slurmmpi")
- resource.mpi = slurmmpi;
- else if (anMpi == "prun")
- resource.mpi = prun;
- else if (anMpi == "")
- resource.mpi = nompi;
- else {
- INFOS("Bad MPI definition in AddResource: " << anMpi);
- std::string message("Bad MPI definition in AddResource: ");
- message += anMpi;
- THROW_SALOME_CORBA_EXCEPTION(message.c_str(),SALOME::BAD_PARAM);
- }
-
- std::string mode_str = new_resource.mode.in();
- if (mode_str == "interactive")
- resource.Mode = interactive;
- else if (mode_str == "batch")
- resource.Mode = batch;
- else if (mode_str == "")
- resource.Mode = interactive;
- else {
- INFOS("Bad mode definition in AddResource: " << mode_str);
- std::string message("Bad mode definition in AddResource: ");
- message += mode_str;
- THROW_SALOME_CORBA_EXCEPTION(message.c_str(),SALOME::BAD_PARAM);
- }
-
- std::string protocol = new_resource.protocol.in();
try
{
- resource.Protocol = ParserResourcesType::stringToProtocol(protocol);
- }
- catch (SALOME_Exception e)
- {
- INFOS("Bad protocol definition in AddResource: " << protocol);
- std::string message("Bad protocol definition in AddResource: ");
- message += protocol;
- THROW_SALOME_CORBA_EXCEPTION(message.c_str(),SALOME::BAD_PARAM);
- }
-
- std::string iprotocol = new_resource.iprotocol.in();
- try
- {
- resource.ClusterInternalProtocol = ParserResourcesType::stringToProtocol(iprotocol);
- }
- catch (SALOME_Exception e)
- {
- INFOS("Bad iprotocol definition in AddResource: " << iprotocol);
- std::string message("Bad iprotocol definition in AddResource: ");
- message += iprotocol;
- THROW_SALOME_CORBA_EXCEPTION(message.c_str(),SALOME::BAD_PARAM);
- }
+ ParserResourcesType resource;
+ resource.Name = new_resource.name.in();
+ resource.HostName = new_resource.hostname.in();
+ resource.setResourceTypeStr(new_resource.type.in());
+ resource.OS = new_resource.OS.in();
+ resource.AppliPath = new_resource.applipath.in();
+ resource.DataForSort._memInMB = new_resource.mem_mb;
+ resource.DataForSort._CPUFreqMHz = new_resource.cpu_clock;
+ resource.DataForSort._nbOfNodes = new_resource.nb_node;
+ resource.DataForSort._nbOfProcPerNode = new_resource.nb_proc_per_node;
+ resource.UserName = new_resource.username.in();
+ resource.can_launch_batch_jobs = new_resource.can_launch_batch_jobs;
+ resource.can_run_containers = new_resource.can_run_containers;
+ resource.working_directory = new_resource.working_directory.in();
+ resource.setBatchTypeStr(new_resource.batch.in());
+ resource.setMpiImplTypeStr(new_resource.mpiImpl.in());
+ resource.setAccessProtocolTypeStr(new_resource.protocol.in());
+ resource.setClusterInternalProtocolStr(new_resource.iprotocol.in());
+ for (CORBA::ULong i = 0; i < new_resource.componentList.length(); i++)
+ resource.ComponentsList.push_back(new_resource.componentList[i].in());
- for (CORBA::ULong i = 0; i < new_resource.componentList.length(); i++)
- resource.ComponentsList.push_back(new_resource.componentList[i].in());
-
- try
- {
_rm.AddResourceInCatalog(resource);
+
+ if (write)
+ {
+ _rm.WriteInXmlFile(std::string(xml_file));
+ _rm.ParseXmlFiles();
+ }
}
catch (const SALOME_Exception & e)
{
INFOS("Error in AddResourceInCatalog: " << e);
THROW_SALOME_CORBA_EXCEPTION(e.what(), SALOME::BAD_PARAM);
}
-
- if (write)
- {
- _rm.WriteInXmlFile(std::string(xml_file));
- _rm.ParseXmlFiles();
- }
}
void
if (resource.ClusterMembersList.empty())
{
//It is not a cluster so we create a cluster with one machine
- ParserResourcesClusterMembersType fake_node;
+ ParserResourcesType fake_node;
fake_node.HostName = resource.HostName;
fake_node.Protocol = resource.Protocol;
fake_node.ClusterInternalProtocol = resource.ClusterInternalProtocol;
// Creating list of machines for creating the machine file
std::list<std::string> list_of_machines;
- std::list<ParserResourcesClusterMembersType>::iterator cluster_it =
+ std::list<ParserResourcesType>::iterator cluster_it =
resource.ClusterMembersList.begin();
while (cluster_it != resource.ClusterMembersList.end())
{
if (resource.ClusterMembersList.empty())
{
//It is not a cluster so we create a cluster with one machine
- ParserResourcesClusterMembersType fake_node;
+ ParserResourcesType fake_node;
fake_node.HostName = resource.HostName;
fake_node.Protocol = resource.Protocol;
fake_node.ClusterInternalProtocol = resource.ClusterInternalProtocol;
std::ofstream machine_file(machine_file_name.c_str(), std::ios_base::out);
// We add all cluster machines to the file
- std::list<ParserResourcesClusterMembersType>::iterator cluster_it =
+ std::list<ParserResourcesType>::iterator cluster_it =
resource.ClusterMembersList.begin();
while (cluster_it != resource.ClusterMembersList.end())
{
std::ofstream machine_file(machine_file_name.c_str(), std::ios_base::out);
// We add all cluster machines to the file
- std::list<ParserResourcesClusterMembersType>::iterator cluster_it =
+ std::list<ParserResourcesType>::iterator cluster_it =
resource.ClusterMembersList.begin();
while (cluster_it != resource.ClusterMembersList.end())
{