Salome HOME
Some parameters of the localhost resource can be changed.
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Thu, 7 Jun 2018 14:10:11 +0000 (16:10 +0200)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Thu, 7 Jun 2018 14:10:11 +0000 (16:10 +0200)
src/ResourcesManager/ResourcesManager.cxx

index 0603eb51debcf2af8fd0336e86208a1a003b0734..b2ed58fa572a64ffb0ae935932a33572a36649df 100644 (file)
@@ -327,8 +327,21 @@ void
 ResourcesManager_cpp::AddResourceInCatalog(const ParserResourcesType & new_resource)
 {
   if (new_resource.Name == DEFAULT_RESOURCE_NAME){
-    std::string error("Cannot modify default local resource \"" + DEFAULT_RESOURCE_NAME + "\"");
-    throw ResourcesException(error);
+    ParserResourcesType default_resource = _resourcesList[DEFAULT_RESOURCE_NAME];
+    // some of the properties of the default resource shouldn't be modified
+    std::string check;
+    if( default_resource.HostName != new_resource.HostName)
+      check += "The Hostname property of the default resource can not be modified.\n";
+    if( default_resource.AppliPath != new_resource.AppliPath)
+      check += "The Applipath property of the default resource can not be modified.\n";
+    if( !new_resource.can_run_containers)
+      check += "The default resource should be able to run containers.\n";
+    if( !new_resource.can_launch_batch_jobs)
+      check += "The default resource should be able to launch batch jobs.\n";
+    if( default_resource.Protocol != new_resource.Protocol)
+      check += "The Protocol property of the default resource can not be modified.\n";
+    if(!check.empty())
+      throw ResourcesException(check);
   }
   // TODO - Add minimal check
   _resourcesList[new_resource.Name] = new_resource;
@@ -364,12 +377,9 @@ void ResourcesManager_cpp::WriteInXmlFile(std::string xml_file)
   RES_MESSAGE("WriteInXmlFile : start");
 
   MapOfParserResourcesType resourceListToSave(_resourcesList);
-  // We do not save default local resource because it is automatically created at startup
-  resourceListToSave.erase(DEFAULT_RESOURCE_NAME);
   if (resourceListToSave.empty())
   {
-    RES_MESSAGE("WriteInXmlFile: nothing to do, no resource except default \"" <<
-                DEFAULT_RESOURCE_NAME << "\"");
+    RES_MESSAGE("WriteInXmlFile: nothing to do, no resource to save!");
     return;
   }