From: rahuel Date: Thu, 4 Nov 2004 15:06:36 +0000 (+0000) Subject: ContainersManager/ResourcesManager X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a817e94fcfa44b13900ee31915c5d4df5f6a1cbd;p=modules%2Fkernel.git ContainersManager/ResourcesManager Portability on Alpha_OSF(CCRT) --- diff --git a/bin/killSalome.py b/bin/killSalome.py index 814420dfa..e149ac31c 100755 --- a/bin/killSalome.py +++ b/bin/killSalome.py @@ -10,6 +10,31 @@ process_id={} # def killSalome(): + print "arret du serveur ContainersManager ==> arret des containers" + import os + import sys + import string + from omniORB import CORBA + import CosNaming + import SALOME + import Engines + import Containers + try : + orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) + obj = orb.resolve_initial_references("NameService") + rootContext = obj._narrow(CosNaming.NamingContext) + if rootContext is None: + print "Name Service Reference is invalid" + else : + name = [CosNaming.NameComponent("Kernel","dir"), + CosNaming.NameComponent("ContainersManager","object")] + obj = rootContext.resolve( name ) + MyContainersMgr = obj._narrow(Containers.Manager) + print "MyContainersMgr.ping :",MyContainersMgr.ping() + MyContainersMgr.destroy() + except : + print "Cannot destroy the ContainersManager" + print "arret des serveurs SALOME" for pid, cmd in process_id.items(): print "arret du process %s : %s"% (pid, cmd[0]) @@ -17,13 +42,12 @@ def killSalome(): os.kill(pid,signal.SIGKILL) except: print " ------------------ process %s : %s inexistant"% (pid, cmd[0]) - print "arret du naming service" - os.system("killall -9 omniNames") + #CCRTprint "arret du naming service" + #CCRTos.system("killall -9 omniNames") # ----------------------------------------------------------------------------- filedict='/tmp/'+os.getenv('USER')+'_SALOME_pidict' -#filedict='/tmp/'+os.getlogin()+'_SALOME_pidict' try: fpid=open(filedict, 'r') except: diff --git a/bin/orbmodule.py b/bin/orbmodule.py index 1154b0101..8ac737fa2 100755 --- a/bin/orbmodule.py +++ b/bin/orbmodule.py @@ -13,9 +13,9 @@ class Server: def run(self): commande=self.XTERM+self.CMD - print commande - ier=os.system(commande) - if ier:print "Commande failed" + print commande,"NOT DONE" + #CCRTier=os.system(commande) + #CCRTif ier:print "Commande failed" # ----------------------------------------------------------------------------- @@ -26,7 +26,9 @@ class NamingServer(Server): USER='anonymous' LOGDIR="/tmp/logs/" + USER os.system("mkdir -m 777 -p " + LOGDIR) - CMD="runNS.sh > " + LOGDIR + "/salomeNS.log 2>&1" + #CCRTCMD="runNS.sh > " + LOGDIR + "/salomeNS.log 2>&1" + #CCRTCMD="runNS.sh > " + LOGDIR + "/salomeNS.log" + #print "NamingServer(Server)",CMD # ----------------------------------------------------------------------------- @@ -45,6 +47,7 @@ class client: obj = self.orb.resolve_initial_references("NameService") try: self.rootContext = obj._narrow(CosNaming.NamingContext) + print "Naming Service exists but perhaps on an other host (Alpha-OSF(CCRT) !", return except CORBA.COMM_FAILURE: self.rootContext = None @@ -70,7 +73,7 @@ class client: if self.rootContext is None: print "Failed to narrow the root naming context" sys.exit(1) - print " found in %s seconds " % ((ncount-1)*delta) + print "Naming Service found in %s seconds " % ((ncount-1)*delta) # -------------------------------------------------------------------------- diff --git a/bin/runSalome.py b/bin/runSalome.py index d8f148c90..8333594ae 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -22,15 +22,44 @@ usage="""USAGE: runSalome.py [options] # def killSalome(): + print "arret du serveur ContainersManager ==> arret des containers" + import os + import sys + import string + from omniORB import CORBA + import CosNaming + import Engines + import Resources + import Containers + try : + orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) + obj = orb.resolve_initial_references("NameService") + rootContext = obj._narrow(CosNaming.NamingContext) + if rootContext is None: + print "Name Service Reference is invalid" + else : + name = [CosNaming.NameComponent("Kernel","dir"), + CosNaming.NameComponent("ContainersManager","object")] + obj = rootContext.resolve( name ) + MyContainersMgr = obj._narrow(Containers.Manager) + print "MyContainersMgr.ping :" + MyContainersMgr.ping() + print "MyContainersMgr.destroy :" + MyContainersMgr.destroy() + print "MyContainersMgr destroyed" + except : + print "Cannot destroy the ContainersManager" + print "arret des serveurs SALOME" for pid, cmd in process_id.items(): print "arret du process %s : %s"% (pid, cmd[0]) try: - os.kill(pid,signal.SIGKILL) + os.kill(pid,signal.SIGKILL) except: print " ------------------ process %s : %s inexistant"% (pid, cmd[0]) - print "arret du naming service" - os.system("killall -9 omniNames") + #CCRTprint "arret du naming service" + #CCRT killall ne marche pas ... + #CCRTos.system("killall -9 omniNames") # ----------------------------------------------------------------------------- # @@ -165,6 +194,13 @@ class Server: pid = os.spawnvp(os.P_NOWAIT, args[0], args) process_id[pid]=self.CMD +class omniNamesServer(Server): + os.system( 'mkdir -m 775 /tmp/logs' ) + os.system( 'mkdir /tmp/logs/${LOGNAME}' ) + os.system( 'touch /tmp/logs/${LOGNAME}/dummy' ) + os.system( 'rm -f /tmp/logs/${LOGNAME}/omninames* /tmp/logs/${LOGNAME}/dummy /tmp/logs/${LOGNAME}/*.log' ) + CMD=['omniNames','-start','-logdir','/tmp/logs/'+os.getenv('LOGNAME')] + class CatalogServer(Server): SCMD1=['SALOME_ModuleCatalog_Server','-common'] SCMD2=['-personal','${HOME}/Salome/resources/CatalogModulePersonnel.xml'] @@ -184,14 +220,24 @@ class SalomeDSServer(Server): class RegistryServer(Server): CMD=['SALOME_Registry_Server', '--salome_session','theSession'] -class ContainerCPPServer(Server): - CMD=['SALOME_Container','FactoryServer','-ORBInitRef','NameService=corbaname::localhost'] +class ResourcesServer(Server): + CMD=['ResourcesManager_Server','-common',os.getenv('KERNEL_ROOT_DIR')+'/share/salome/resources/ResourcesCatalog.xml','-ORBInitRef','NameService=corbaname::localhost'] + +class ContainersServer(Server): + CMD=['ContainersManager_Server','-ORBInitRef','NameService=corbaname::localhost'] + +class ContainerServer( Server) : + def Params( self , HostName , ContainerName , ContainerType ) : + self.CMD=['startContainer.py',str(with_xterm),HostName,ContainerName,ContainerType,'localhost','0'] -class ContainerPYServer(Server): - CMD=['SALOME_ContainerPy.py','FactoryServerPy','-ORBInitRef','NameService=corbaname::localhost'] +#class ContainerCPPServer(Server): + #CMD=['SALOME_Container','FactoryServer','-ORBInitRef','NameService=corbaname::localhost'] -class ContainerSUPERVServer(Server): - CMD=['SALOME_Container','SuperVisionContainer','-ORBInitRef','NameService=corbaname::localhost'] +#class ContainerPYServer(Server): + #CMD=['SALOME_ContainerPy.py','FactoryServerPy','-ORBInitRef','NameService=corbaname::localhost'] + +#class ContainerSUPERVServer(Server): + #CMD=['SALOME_Container','SuperVisionContainer','-ORBInitRef','NameService=corbaname::localhost'] class LoggerServer(Server): CMD=['SALOME_Logger_Server', 'logger.log'] @@ -324,6 +370,12 @@ def startSalome(): if with_gui: SessionLoader().run() + # + # Lancement omniNames + # + + omniNamesServer().run() + # # Initialisation ORB et Naming Service # @@ -388,14 +440,16 @@ def startSalome(): # Lancement Session Server # - SessionServer().run() + if with_gui: + SessionServer().run() # # Attente de la disponibilité du Session Server dans le Naming Service # - import SALOME - session=clt.waitNS("/Kernel/Session",SALOME.Session) + if with_gui: + import SALOME + session=clt.waitNS("/Kernel/Session",SALOME.Session) if os.getenv("HOSTNAME") == None: if os.getenv("HOST") == None: @@ -406,12 +460,48 @@ def startSalome(): theComputer = os.getenv("HOSTNAME") computerSplitName = theComputer.split('.') theComputer = computerSplitName[0] + #CCRT + import socket + #theComputerAddr = socket.gethostbyname( theComputer ) + #print "theComputer :",theComputer,theComputerAddr,"HOSTNAME",os.getenv("HOSTNAME") + #theComputer = theComputerAddr + print "theComputer :",theComputer,socket.gethostbyname( theComputer ),"HOSTNAME",os.getenv("HOSTNAME") + import Engines + import Resources + import Containers + + # + # Lancement ResourcesManager Server + # + + ResourcesServer().run() + + # + # Attente de la disponibilité du ResourcesServer dans le Naming Service + # + + session=clt.waitNS("/Kernel/ResourcesManager",Resources.Manager) + + # + # Lancement ContainersManager Server + # + + ContainersServer().run() + + # + # Attente de la disponibilité du ContainersManager dans le Naming Service + # + + MyContainersMgr = clt.waitNS("/Kernel/ContainersManager",Containers.Manager) + # # Lancement Container C++ local # if with_container_cpp: - ContainerCPPServer().run() + FactoryServer = ContainerServer() + FactoryServer.Params( theComputer , 'FactoryServer' , 'Engines.CppContainer' ) + FactoryServer.run() # # Attente de la disponibilité du Container C++ local dans le Naming Service @@ -424,13 +514,16 @@ def startSalome(): # if with_container_python: - ContainerPYServer().run() + FactoryServerPy = ContainerServer() + FactoryServerPy.Params( theComputer , 'FactoryServerPy' , 'Engines.PythonContainer' ) + FactoryServerPy.run() # # Attente de la disponibilité du Container Python local dans le Naming Service # - clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy") + FactoryServerPy = clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy") + FactoryServerPy.ping() if with_container_superv: @@ -438,8 +531,9 @@ def startSalome(): # Lancement Container Supervision local # - ContainerSUPERVServer().run() - + SuperVisionContainer = ContainerServer() + SuperVisionContainer.Params( theComputer , 'SuperVisionContainer' , 'Engines.CppContainer' ) + SuperVisionContainer.run() # # Attente de la disponibilité du Container Supervision local dans le Naming Service # diff --git a/bin/startContainer.py b/bin/startContainer.py new file mode 100755 index 000000000..7aceb7d2c --- /dev/null +++ b/bin/startContainer.py @@ -0,0 +1,83 @@ +#! /usr/bin/env python +# +# SALOME startContainer : implementation of container and engine for Kernel +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : startContainer.py +# Author : Jean Rahuel, CEA +# Module : SALOME +# $Header: + +import os +import sys +import string +from omniORB import CORBA, PortableServer +import Containers +import Engines +from SALOME_NamingServicePy import * + +if sys.argv[1] == '--help' : + print 'USAGE : startContainer.py with_xterm HostName ContainerName ContainerType NSHostName NSHostPort' + print ' ContainerType : Engines.CppContainer or Engines.PythonContainer' + sys.exit(0) + +orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) + +naming_service = SALOME_NamingServicePy_i(orb) + +MyContainersMgr = naming_service.Resolve("/Kernel/ContainersManager") +DefaultParams = MyContainersMgr.Parameters() +DefaultParams.with_xterm = int( sys.argv[1] ) +DefaultParams.HostName = sys.argv[2] +DefaultParams.ContainerName = sys.argv[3] +if sys.argv[4] == 'Engines.CppContainer' : + DefaultParams.ContainerType = Engines.CppContainer +elif sys.argv[4] == 'Engines.PythonContainer' : + DefaultParams.ContainerType = Engines.PythonContainer +else : + DefaultParams.ContainerType = Engines.UndefinedContainerType +DefaultParams.NsHostName = sys.argv[5] +DefaultParams.NsPort = int( sys.argv[6] ) + +#print "startContainer Parameters :" +#print "with_xterm :",DefaultParams.with_xterm +#print "Os :",DefaultParams.Os +#print "Memory :",DefaultParams.Memory +#print "CpuClock :",DefaultParams.CpuClock +#print "NbProc :",DefaultParams.NbProc +#print "NbNode :",DefaultParams.NbNode +#print "HostName :",DefaultParams.HostName +#print "ContainerName :",DefaultParams.ContainerName +#print "ContainerType :",DefaultParams.ContainerType +#print "NsHostName :",DefaultParams.NsHostName +#print "NsPort :",DefaultParams.NsPort + +aContainer = MyContainersMgr.FindOrStartContainer( DefaultParams ) + +if aContainer != None : + aContainer.ping() +else : + print "startContainer failed" + + +