]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
End of moving Odyssee in SSL mode
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 15 Sep 2021 06:06:27 +0000 (08:06 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 15 Sep 2021 06:06:27 +0000 (08:06 +0200)
bin/ORBConfigFile.py
bin/salome_utils.py
src/KERNEL_PY/__init__.py

index a11b9afb63775a42957e4a59c25ecf02efb2a33e..b390bd146515949fdea167ed25f9b43091379b22 100755 (executable)
@@ -39,6 +39,40 @@ def readORBConfigFile(filename):
   return host, port
 #
 
+def fillOrbConfigFileNoNS(prefix,orbdata):
+  GIOP_MaxMsgSize = 2097152000  # 2 GBytes
+  orbdata.append("%sgiopMaxMsgSize = %s # 2 GBytes"%(prefix,GIOP_MaxMsgSize))
+  orbdata.append("%straceLevel = 0 # critical errors only"%(prefix))
+  orbdata.append("%smaxGIOPConnectionPerServer = 500 # to allow containers parallel launch"%(prefix))
+  orbdata.append("%snativeCharCodeSet = UTF-8"%(prefix))
+  return GIOP_MaxMsgSize
+
+
+def getPrefix():
+  from omniORB import CORBA
+  prefix = "" if CORBA.ORB_ID == "omniORB4" else "ORB"
+  return prefix
+  
+def writeORBConfigFileSSL(path, kwargs={}):
+  from salome_utils import generateFileName
+  omniorb_config = generateFileName(path, prefix="omniORB",
+                                    extension="cfg",
+                                    hidden=True,
+                                    with_hostname=True,
+                                    **kwargs)
+  import os
+  os.environ['OMNIORB_CONFIG'] = omniorb_config
+  prefix = getPrefix()
+
+  orbdata = []
+  GIOP_MaxMsgSize = fillOrbConfigFileNoNS(prefix,orbdata)
+  orbdata.append("")
+
+  with open(omniorb_config, "w") as f:
+    f.write("\n".join(orbdata))
+    
+  return [ omniorb_config, GIOP_MaxMsgSize ]
+
 # IMPORTANT NOTE: do not add any print call (cf. note at the bottom of the file)
 def writeORBConfigFile(path, host, port, kwargs={}):
 
@@ -54,17 +88,11 @@ def writeORBConfigFile(path, host, port, kwargs={}):
   os.environ['NSPORT'] = "%s"%(port)
   os.environ['NSHOST'] = "%s"%(host)
 
-  from omniORB import CORBA
-  prefix = "" if CORBA.ORB_ID == "omniORB4" else "ORB"
-
-  GIOP_MaxMsgSize = 2097152000  # 2 GBytes
+  prefix = getPrefix()
 
   orbdata = []
   orbdata.append("%sInitRef = NameService=corbaname::%s:%s"%(prefix,host,port))
-  orbdata.append("%sgiopMaxMsgSize = %s # 2 GBytes"%(prefix,GIOP_MaxMsgSize))
-  orbdata.append("%straceLevel = 0 # critical errors only"%(prefix))
-  orbdata.append("%smaxGIOPConnectionPerServer = 500 # to allow containers parallel launch"%(prefix))
-  orbdata.append("%snativeCharCodeSet = UTF-8"%(prefix))
+  GIOP_MaxMsgSize = fillOrbConfigFileNoNS(prefix,orbdata)
 
   orbdata.append("")
 
index 33fc6320ab91424db678545cd680cf3e4b2f2f7d..114793af0a476801849fb2e91fc588c24d8a455c 100644 (file)
@@ -170,6 +170,9 @@ def getAppName():
     """
     return os.getenv('APPNAME', 'SALOME') # 'SALOME' is default user name
 
+def getPid():
+    return os.getpid()
+
 # ---
 
 def getPortNumber(use_default=True):
@@ -246,6 +249,7 @@ def generateFileName(path, prefix=None, suffix=None, extension=None,
     - with_hostname : use host name:
     - with_port : use port number:
     - with_app      : use application name:
+    - with_pid      : use current pid
 
     Any of these keyword arguments can accept either explicit string value,
     or `True` to automatically deduce value from current configuration.
@@ -270,6 +274,7 @@ def generateFileName(path, prefix=None, suffix=None, extension=None,
     _with_kwarg('with_hostname', getShortHostName)
     _with_kwarg('with_port', getPortNumber)
     _with_kwarg('with_app', getAppName)
+    _with_kwarg('with_pid', getPid)
     _with_str(suffix)
 
     # raise an exception if file name is empty
index 1a3af63bc0ff42dd0466e37812257129037bcc90..ad8f52425290c391da1687a5cb6c3e8323bba9b1 100644 (file)
@@ -209,6 +209,20 @@ class StandAloneLifecyle:
       return self._rm
 
 def salome_init_without_session_common(path=None, embedded=False):
+    from ORBConfigFile import writeORBConfigFileSSL
+    OMNIORB_USER_PATH = "OMNIORB_USER_PATH"
+    def RemoveOmniorbConfigFile():
+        import os
+        if "OMNIORB_CONFIG" in os.environ:
+            fileToRemove = os.environ["OMNIORB_CONFIG"]
+            if os.path.exists(fileToRemove):
+                os.unlink(fileToRemove)
+
+    if OMNIORB_USER_PATH in os.environ:
+        import atexit
+        writeORBConfigFileSSL(os.environ[OMNIORB_USER_PATH],kwargs={"with_pid":True})
+        atexit.register(RemoveOmniorbConfigFile)
+
     global lcc,naming_service,myStudy,orb,modulcat,sg
     import KernelBasis
     KernelBasis.setSSLMode(True)