SALOME_ResourcesManager::GetFittingResources(const Engines::ResourceParameters& params)
{
MESSAGE("ResourcesManager::GetFittingResources");
- Engines::ResourceList * ret = new Engines::ResourceList;
+ Engines::ResourceList_var ret;
// CORBA -> C++
- 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.nb_proc_per_node = params.nb_proc_per_node;
- p.cpu_clock = params.cpu_clock;
- p.mem_mb = params.mem_mb;
- for(unsigned int i=0; i<params.componentList.length(); i++)
- p.componentList.push_back(std::string(params.componentList[i]));
- for(unsigned int i=0; i<params.resList.length(); i++)
- p.resourceList.push_back(std::string(params.resList[i]));
-
+ resourceParams p = resourceParameters_CORBAtoCPP(params);
+
try
{
// Call C++ ResourceManager
std::vector <std::string> vec = _rm.GetFittingResources(p);
// C++ -> CORBA
- ret->length(vec.size());
- for(unsigned int i=0;i<vec.size();i++)
- (*ret)[i] = (vec[i]).c_str();
+ ret = resourceList_CPPtoCORBA(vec);
}
catch(const ResourcesException &ex)
{
THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
}
- return ret;
+ return ret._retn();
}
//=============================================================================
SALOME_ResourcesManager::FindFirst(const Engines::ResourceList& listOfResources)
{
// CORBA -> C++
- std::vector<std::string> rl;
- for(unsigned int i=0; i<listOfResources.length(); i++)
- rl.push_back(std::string(listOfResources[i]));
+ std::vector<std::string> rl = resourceList_CORBAtoCPP(listOfResources);
return CORBA::string_dup(_rm.Find("first", rl).c_str());
}
SALOME_ResourcesManager::Find(const char* policy, const Engines::ResourceList& listOfResources)
{
// CORBA -> C++
- std::vector<std::string> rl;
- for(unsigned int i=0; i<listOfResources.length(); i++)
- rl.push_back(std::string(listOfResources[i]));
+ std::vector<std::string> rl = resourceList_CORBAtoCPP(listOfResources);
return CORBA::string_dup(_rm.Find(policy, rl).c_str());
}
-Engines::ResourceDefinition*
+Engines::ResourceDefinition*
SALOME_ResourcesManager::GetResourceDefinition(const char * name)
{
- Engines::ResourceDefinition * p_ptr = NULL;
+ Engines::ResourceDefinition_var resDef;
try {
ParserResourcesType resource = _rm.GetResourcesDescr(name);
- p_ptr = new Engines::ResourceDefinition;
-
- p_ptr->name = CORBA::string_dup(resource.Name.c_str());
- p_ptr->hostname = CORBA::string_dup(resource.HostName.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());
- for(unsigned int i=0;i<resource.ComponentsList.size();i++)
- p_ptr->componentList[i] = CORBA::string_dup(resource.ComponentsList[i].c_str());
- p_ptr->OS = CORBA::string_dup(resource.OS.c_str());
- p_ptr->mem_mb = resource.DataForSort._memInMB;
- 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->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());
- p_ptr->mpiImpl = CORBA::string_dup(resource.getMpiImplTypeStr().c_str());
- p_ptr->batch = CORBA::string_dup(resource.getBatchTypeStr().c_str());
+ resDef = resourceDefinition_CPPtoCORBA(resource);
} catch (const exception & ex) {
INFOS("Caught exception in GetResourceDefinition: " << ex.what());
THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::BAD_PARAM);
}
- return p_ptr;
+ return resDef._retn();
}
void
{
try
{
- 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());
-
+ ParserResourcesType resource = resourceDefinition_CORBAtoCPP(new_resource);
_rm.AddResourceInCatalog(resource);
if (write)
resource.ComponentsList = strvec_CORBAtoCPP<Engines::CompoList>(resDef.componentList);
return resource;
}
+
+Engines::ResourceDefinition_var resourceDefinition_CPPtoCORBA(const ParserResourcesType & resource)
+{
+ Engines::ResourceDefinition_var resCorba = new Engines::ResourceDefinition;
+ resCorba->name = resource.Name.c_str();
+ resCorba->hostname = resource.HostName.c_str();
+ resCorba->type = resource.getResourceTypeStr().c_str();
+ resCorba->protocol = resource.getAccessProtocolTypeStr().c_str();
+ resCorba->iprotocol = resource.getClusterInternalProtocolStr().c_str();
+ resCorba->username = resource.UserName.c_str();
+ resCorba->applipath = resource.AppliPath.c_str();
+ resCorba->componentList = strvec_CPPtoCORBA<Engines::CompoList>(resource.ComponentsList);
+ resCorba->OS = resource.OS.c_str();
+ resCorba->mem_mb = resource.DataForSort._memInMB;
+ resCorba->cpu_clock = resource.DataForSort._CPUFreqMHz;
+ resCorba->nb_proc_per_node = resource.DataForSort._nbOfProcPerNode;
+ resCorba->nb_node = resource.DataForSort._nbOfNodes;
+ resCorba->can_launch_batch_jobs = resource.can_launch_batch_jobs;
+ resCorba->can_run_containers = resource.can_run_containers;
+ resCorba->working_directory = resource.working_directory.c_str();
+ resCorba->mpiImpl = resource.getMpiImplTypeStr().c_str();
+ resCorba->batch = resource.getBatchTypeStr().c_str();
+ return resCorba;
+}