]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Working on PAL# 2078
authorribes <ribes>
Mon, 19 Mar 2012 16:54:58 +0000 (16:54 +0000)
committerribes <ribes>
Mon, 19 Mar 2012 16:54:58 +0000 (16:54 +0000)
Adding two new attributes to a SALOME resource:

is_cluster_head ->  set to "true" if the resource refers to a cluster head (false by default)
working_directory -> defines a default working directory in a cluster

idl/SALOME_ContainerManager.idl
src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx
src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx
src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx
src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx
src/ResourcesManager/SALOME_ResourcesManager.cxx

index c984ace36d78883e4f1bd2094e862941e8e69db9..6964468f1ae82a5758aec3b33672c03aeb42d824 100644 (file)
@@ -146,6 +146,12 @@ struct ResourceDefinition
   //! if the resource is a cluster:
   //! 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;
+
+  //! Predefined working directory on the resource
+  string working_directory;
 };
 
 //! exception thrown if a computer is not found in the catalog
index d4faed75c3df3f66f1b2161962a5e65cd6940075..73ac4ece0f88959028a9946b764a71fa20e9dcef 100755 (executable)
@@ -69,6 +69,8 @@ SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& resources_list): _reso
   test_user_commands = "userCommands";
   test_use = "use";
   test_members = "members";
+  test_is_cluster_head = "isClusterHead";
+  test_working_directory = "workingDirectory";
 }
 
 //=============================================================================
@@ -596,6 +598,36 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser
     xmlFree(nb_of_proc_per_node);
   }
 
+  if (xmlHasProp(machine_descr, (const xmlChar*)test_is_cluster_head))
+  {
+    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.is_cluster_head = true;
+    }
+    else
+    {
+      resource.is_cluster_head = false;
+    }
+    xmlFree(is_cluster_head);
+  }
+  else
+  {
+    resource.is_cluster_head = false;
+  }
+
+  if (xmlHasProp(machine_descr, (const xmlChar*)test_working_directory))
+  {
+    xmlChar* working_directory = xmlGetProp(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;
   while(aCurSubNode != NULL)
@@ -672,6 +704,11 @@ void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc)
     xmlNewProp(node,
                BAD_CAST test_cluster_internal_protocol,
                BAD_CAST ParserResourcesType::protocolToString((*iter).second.ClusterInternalProtocol).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)
     {
index cb8fe088c95730d6d9c8b890dd34c8017becb94e..dc171024d6badff41444fe8d5404981d8526dbab 100755 (executable)
@@ -89,6 +89,8 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesCatalog_Handler
     const char *test_user_commands;
     const char *test_use;
     const char *test_members;
+    const char *test_is_cluster_head;
+    const char *test_working_directory;
 
   };
 
index 0dd68beac8cfc8c82dbf229e4ca5261da3b03bc7..13583cd2caef42b698a8e4101cc4ba866a12e023 100644 (file)
@@ -188,7 +188,9 @@ void ParserResourcesType::Print()
     "use : " << use << std::endl <<
     "NbOfProc : " << nbOfProc << std::endl <<
     "Modules : " << std::endl <<
-    "Components : " << 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;
@@ -283,6 +285,8 @@ void ParserResourcesType::Clear()
   use = "";
   ClusterMembersList.clear();
   nbOfProc = 1;
+  is_cluster_head = false;
+  working_directory = "";
 
   DataForSort._Name = "";
   DataForSort._nbOfNodes = 1;
index cb6fb79e6dc45271c56e7cb87360b186492a6771..1885a8e3ce9c693b95452900c71f055077dfeca5 100755 (executable)
@@ -108,6 +108,8 @@ struct RESOURCESMANAGER_EXPORT ParserResourcesType
   std::string use;
   std::list<ParserResourcesClusterMembersType> ClusterMembersList;
   unsigned int nbOfProc;
+  bool is_cluster_head;
+  std::string working_directory;
 
   void Print();
   void Clear();
index 0a4e5598a42847b9d507389ea1ef07b7179ed7ce..090b2d3530c8e9bd400f18b2a16e49bc7f7b0e6a 100644 (file)
@@ -226,6 +226,8 @@ SALOME_ResourcesManager::GetResourceDefinition(const char * name)
   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->working_directory = CORBA::string_dup(resource.working_directory.c_str());
 
   if( resource.mpi == lam )
     p_ptr->mpiImpl = "lam";
@@ -273,6 +275,8 @@ SALOME_ResourcesManager::AddResource(const Engines::ResourceDefinition& new_reso
   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")
@@ -372,10 +376,10 @@ SALOME_ResourcesManager::AddResource(const Engines::ResourceDefinition& new_reso
   }
 }
 
-void 
+void
 SALOME_ResourcesManager::RemoveResource(const char * resource_name,
-                                       CORBA::Boolean write,
-                                       const char * xml_file)
+                                        CORBA::Boolean write,
+                                        const char * xml_file)
 {
   _rm.DeleteResourceInCatalog(resource_name);
   if (write)
@@ -431,7 +435,7 @@ SALOME_ResourcesManager::getMachineFile(std::string resource_name,
 
       // Creating machine file
       machine_file_name = tmpnam(NULL);
-         std::ofstream machine_file(machine_file_name.c_str(), std::ios_base::out);
+      std::ofstream machine_file(machine_file_name.c_str(), std::ios_base::out);
 
       CORBA::Long machine_number = 0;
       std::list<std::string>::iterator it = list_of_machines.begin();
@@ -493,20 +497,20 @@ SALOME_ResourcesManager::getMachineFile(std::string resource_name,
       }
       else if (resource.mpi == openmpi)
       {
-       // Creating machine file
-       machine_file_name = tmpnam(NULL);
-       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 = 
-         resource.ClusterMembersList.begin();
-       while (cluster_it != resource.ClusterMembersList.end())
-       {
-         unsigned int number_of_proc = (*cluster_it).DataForSort._nbOfNodes * 
-           (*cluster_it).DataForSort._nbOfProcPerNode;
-         machine_file << (*cluster_it).HostName << " slots=" << number_of_proc << std::endl;
-         cluster_it++;
-       }
+        // Creating machine file
+        machine_file_name = tmpnam(NULL);
+        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 =
+          resource.ClusterMembersList.begin();
+        while (cluster_it != resource.ClusterMembersList.end())
+        {
+          unsigned int number_of_proc = (*cluster_it).DataForSort._nbOfNodes *
+            (*cluster_it).DataForSort._nbOfProcPerNode;
+          machine_file << (*cluster_it).HostName << " slots=" << number_of_proc << std::endl;
+          cluster_it++;
+        }
       }
       else if (resource.mpi == nompi)
       {