]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
allow salome_init to point to origin cm,rm,dsm and esm in salome.salome_init() launch...
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 23 Aug 2021 09:43:47 +0000 (11:43 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 23 Aug 2021 09:43:47 +0000 (11:43 +0200)
src/Basics/KernelBasis.cxx
src/Basics/KernelBasis.hxx
src/Basics/KernelBasis.i
src/Container/SALOME_Container_No_NS_Serv.cxx
src/KERNEL_PY/__init__.py

index b634f7265e21203ec3ebd605c421141b0457ea97..73612dc6f5cb1be24184e0df480150ddc5071e24 100644 (file)
@@ -21,6 +21,9 @@
 
 static bool DEFAULT_SSL_MODE = false;
 
+// IOR of SALOME_Embedded_NamingService servant
+static std::string IOR_OF_EMBEDDED_NS;
+
 bool getSSLMode()
 {
   return DEFAULT_SSL_MODE;
@@ -30,3 +33,13 @@ void setSSLMode(bool sslMode)
 {
   DEFAULT_SSL_MODE = sslMode;
 }
+
+std::string BASICS_EXPORT getIOROfEmbeddedNS()
+{
+  return IOR_OF_EMBEDDED_NS;
+}
+
+void BASICS_EXPORT setIOROfEmbeddedNS(const std::string& ior)
+{
+  IOR_OF_EMBEDDED_NS = ior;
+}
index 184fb99879f03b00b9fe270421fde0e002387547..710106ff3266a95ba35a383226bc0d4f269e6703 100644 (file)
 
 #include "SALOME_Basics.hxx"
 
+#include <string>
+
 bool BASICS_EXPORT getSSLMode();
 void BASICS_EXPORT setSSLMode(bool sslMode);
+
+std::string BASICS_EXPORT getIOROfEmbeddedNS();
+void BASICS_EXPORT setIOROfEmbeddedNS(const std::string& ior);
index 44b2e221ab61cf47b124772e2135922051ea227f..d2cdbfc1374d8e3312992e9752ceaa5a155e55db 100644 (file)
 #include "KernelBasis.hxx"
 %}
 
+%include "std_string.i"
+
 bool getSSLMode();
 void setSSLMode(bool sslMode);
+
+std::string getIOROfEmbeddedNS();
+void setIOROfEmbeddedNS(const std::string& ior);
index 6d801845016b3830651142e8a5233ab31b3b3207..37818df899bc1cb985875cb5b9dcc8d65a959672 100644 (file)
 #include "SALOME_Embedded_NamingService_Client.hxx"
 #include "Utils_SALOME_Exception.hxx"
 #include "SALOME_KernelORB.hxx"
+#include "KernelBasis.hxx"
 
 int main(int argc, char* argv[])
 {
   if(argc<3)
     THROW_SALOME_EXCEPTION( "SALOME_Container_No_NS_Serv : requires 2 input arguments <containerName> <IOR of Engines::EmbeddedNamingService>" );
   CORBA::ORB_ptr orb(KERNEL::getORB());
-  CORBA::Object_var ns_serv_obj_base = orb->string_to_object(argv[2]);
+  std::string IOROfEmbeddedNamingService(argv[2]);
+  setIOROfEmbeddedNS(IOROfEmbeddedNamingService);
+  CORBA::Object_var ns_serv_obj_base = orb->string_to_object(IOROfEmbeddedNamingService.c_str());
   if( CORBA::is_nil(ns_serv_obj_base) )
     THROW_SALOME_EXCEPTION( "SALOME_Container_No_NS_Serv : argument 2 is NOT a valid IOR" );
   Engines::EmbeddedNamingService_var ns_serv_obj = Engines::EmbeddedNamingService::_narrow(ns_serv_obj_base);
index 0c06b1cfdd35132d617846b9eecfa89062a89567..d0d611d8ea75bf7ce3d94fb5cb5659adf98684d3 100644 (file)
@@ -171,17 +171,22 @@ __EMB_SERVANT_ENV_VAR_NAME = "SALOME_EMB_SERVANT"
 def standalone():
     import os
     os.environ[__EMB_SERVANT_ENV_VAR_NAME] = "1"
+    import KernelBasis
+    KernelBasis.setSSLMode(True)
 
 def salome_init(path=None, embedded=False):
     import os
+    import KernelBasis
     if __EMB_SERVANT_ENV_VAR_NAME in os.environ:
-        salome_init_without_session()
-    else:
-        import KernelBasis
-        if KernelBasis.getSSLMode():
+        KernelBasis.setSSLMode(True)
+    #
+    if KernelBasis.getSSLMode():
+        if KernelBasis.getIOROfEmbeddedNS() == "":
             salome_init_without_session()
         else:
-            salome_init_with_session(path, embedded)
+            salome_init_without_session_attached()
+    else:
+        salome_init_with_session(path, embedded)
 
 class StandAloneLifecyle:
     def __init__(self, containerManager, resourcesManager):
@@ -203,8 +208,8 @@ class StandAloneLifecyle:
     def getResourcesManager(self):
       return self._rm
 
-def salome_init_without_session():
-    global lcc,naming_service,myStudy,orb,modulcat,sg,cm,dsm,esm
+def salome_init_without_session_common():
+    global lcc,naming_service,myStudy,orb,modulcat,sg
     import KernelBasis
     KernelBasis.setSSLMode(True)
     import KernelDS
@@ -215,23 +220,48 @@ def salome_init_without_session():
     import SALOME_ModuleCatalog
     from salome_kernel import list_of_catalogs_regarding_environement
     modulcat = KernelModuleCatalog.myModuleCatalog( list_of_catalogs_regarding_environement() )
-    import KernelLauncher
-    from NamingService import NamingService
-    cm = KernelLauncher.myContainerManager()
-    lcc = StandAloneLifecyle(cm, KernelLauncher.myResourcesManager())
-    # activate poaManager to accept co-localized CORBA calls.
+    #
     poa = orb.resolve_initial_references("RootPOA")
     poaManager = poa._get_the_POAManager()
     poaManager.activate()
     sg = SalomeOutsideGUI()
     salome_study_init_without_session()
+    #
+    from NamingService import NamingService
     naming_service = NamingService()
+
+def salome_init_without_session():
+    salome_init_without_session_common()
+    global lcc,cm,dsm,esm
+    import KernelLauncher
+    cm = KernelLauncher.myContainerManager()
+    lcc = StandAloneLifecyle(cm, KernelLauncher.myResourcesManager())
+    # activate poaManager to accept co-localized CORBA calls.
     from KernelSDS import GetDSMInstance
     import sys
     dsm = GetDSMInstance(sys.argv)
     # esm inherits from SALOME_CPythonHelper singleton already initialized by GetDSMInstance
     # esm inherits also from SALOME_ResourcesManager creation/initialization (concerning SingleThreadPOA POA) when KernelLauncher.GetContainerManager() has been called
     esm = KernelLauncher.GetExternalServer()
+    
+def salome_init_without_session_attached():
+    """
+    Configuration SSL inside a python interpretor launched in the SALOME_Container_No_NS_Serv.
+    In this configuration, 
+    """
+    salome_init_without_session_common()
+    global lcc,cm,dsm,esm
+    import CORBA
+    orb=CORBA.ORB_init([''])
+    import Engines
+    import KernelBasis
+    nsAbroad = orb.string_to_object( KernelBasis.getIOROfEmbeddedNS() )
+    import SALOME
+    cm = orb.string_to_object( nsAbroad.Resolve("/ContainerManager").decode() )
+    rm = orb.string_to_object( nsAbroad.Resolve("/ResourcesManager").decode() )
+    lcc = StandAloneLifecyle(cm,rm)
+    dsm = orb.string_to_object( nsAbroad.Resolve("/DataServerManager").decode() )
+    esm = orb.string_to_object( nsAbroad.Resolve("/ExternalServers").decode() )
 
 def salome_init_with_session(path=None, embedded=False):
     """