From 1e4840fec1a460900dec9af4a5767afec088c36d Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 18 Apr 2024 13:57:12 +0200 Subject: [PATCH] Direct manipulation of resource map singleton --- src/Launcher_SWIG/Launcher.i | 24 +++++++++++++++++++++++ src/ResourcesManager/ResourcesManager.cxx | 7 ++++++- src/ResourcesManager/ResourcesManager.hxx | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Launcher_SWIG/Launcher.i b/src/Launcher_SWIG/Launcher.i index 9a50dafc1..04646de0b 100644 --- a/src/Launcher_SWIG/Launcher.i +++ b/src/Launcher_SWIG/Launcher.i @@ -230,6 +230,30 @@ public: new_resource_cpp.working_directory = new_resource.working_directory; $self->AddResourceInCatalog(new_resource_cpp); } + + void AddResourceInCatalogNoQuestion (const ResourceDefinition_cpp& new_resource) + { + ParserResourcesType new_resource_cpp; + new_resource_cpp.Name = new_resource.name; + new_resource_cpp.HostName = new_resource.hostname; + new_resource_cpp.setResourceTypeStr( new_resource.type ); + new_resource_cpp.setAccessProtocolTypeStr( new_resource.protocol ); + new_resource_cpp.UserName = new_resource.username; + new_resource_cpp.AppliPath = new_resource.applipath; + new_resource_cpp.OS = new_resource.OS; + new_resource_cpp.DataForSort._Name = new_resource.name; + new_resource_cpp.DataForSort._memInMB = new_resource.mem_mb; + new_resource_cpp.DataForSort._CPUFreqMHz = new_resource.cpu_clock; + new_resource_cpp.DataForSort._nbOfNodes = new_resource.nb_node; + new_resource_cpp.DataForSort._nbOfProcPerNode = new_resource.nb_proc_per_node; + new_resource_cpp.setBatchTypeStr(new_resource.batch); + new_resource_cpp.setMpiImplTypeStr(new_resource.mpiImpl); + new_resource_cpp.setClusterInternalProtocolStr(new_resource.iprotocol); + new_resource_cpp.can_launch_batch_jobs = new_resource.can_launch_batch_jobs; + new_resource_cpp.can_run_containers = new_resource.can_run_containers; + new_resource_cpp.working_directory = new_resource.working_directory; + $self->AddResourceInCatalogNoQuestion(new_resource_cpp); + } void ParseXmlFiles() { diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index cb85bc0c1..fc5586178 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -330,6 +330,11 @@ ResourcesManager_cpp::GetFittingResources(const resourceParams& params) return vec; } +void ResourcesManager_cpp::AddResourceInCatalogNoQuestion (const ParserResourcesType & new_resource) +{ + _resourcesList[new_resource.Name] = new_resource; +} + //============================================================================= /*! * add an entry in the resources catalog xml file. @@ -357,7 +362,7 @@ ResourcesManager_cpp::AddResourceInCatalog(const ParserResourcesType & new_resou throw ResourcesException(check); } // TODO - Add minimal check - _resourcesList[new_resource.Name] = new_resource; + this->AddResourceInCatalogNoQuestion( new_resource ); } void ResourcesManager_cpp::DeleteAllResourcesInCatalog() diff --git a/src/ResourcesManager/ResourcesManager.hxx b/src/ResourcesManager/ResourcesManager.hxx index 54f8a75d8..117945966 100644 --- a/src/ResourcesManager/ResourcesManager.hxx +++ b/src/ResourcesManager/ResourcesManager.hxx @@ -81,6 +81,8 @@ class RESOURCESMANAGER_EXPORT ResourcesManager_cpp std::string Find(const std::string& policy, const std::vector& listOfResources) const; + void AddResourceInCatalogNoQuestion (const ParserResourcesType & new_resource); + void AddResourceInCatalog (const ParserResourcesType & new_resource); void DeleteAllResourcesInCatalog(); -- 2.39.2