if ( strlen( MyParams.ContainerName ) ) {
_FullContainerName = _FullHostName + "/" + string( (char * ) MyParams.ContainerName ) ;
_ContainerObject = _NamingService->Resolve( _FullContainerName.c_str() ) ;
- MESSAGE( "Manager_i::FindContainers NamingService->Resolve( " << _FullContainerName << ")" ) ;
+ MESSAGE( "Manager_i::FindContainers NamingService->Resolve( " << _FullContainerName << " )" ) ;
if ( !CORBA::is_nil( _ContainerObject ) ) {
_EnginesContainer = Engines::Container::_narrow( _ContainerObject ) ;
if ( _EnginesContainer->type() == MyParams.ContainerType ) {
if ( _ListOfContainers->length() ) {
_EnginesContainer = Engines::Container::_nil() ;
int i ;
- for ( i = 0 ; i < _ListOfContainers->length() && CORBA::is_nil( _EnginesContainer ) ; i++ ) {
+ for ( i = 0 ; i < _ListOfContainers->length() && ( ( _StartContainer && CORBA::is_nil( _EnginesContainer ) ) || !_StartContainer ) ; i++ ) {
_FullHostName = "/Containers/" ;
char * aHostName = _ListOfContainers[ i ]->machineName() ;
_HostName = string( aHostName ) ;
aContainerName = strrchr( aContainerName , '/' ) + 1 ;
_ContainerName = string( aContainerName ) ;
_FullContainerName = _FullHostName + "/" + _ContainerName ;
- MESSAGE( "Manager_i::FindOrStartContainerLocked Container " << _FullContainerName << " searched Component "
- << _ComponentName << " " << aContainerName << " " << _ContainerName ) ;
+ MESSAGE( "Manager_i::FindOrStartContainerLocked Container " << i << " " << _FullContainerName
+ << " searched Component '" << _ComponentName << "'" ) ;
if ( strlen( _ComponentName.c_str() ) ) {
_FullComponentName = _FullContainerName + "/" + _ComponentName ;
MESSAGE( "Manager_i::FindOrStartContainerLocked Component " << _FullComponentName ) ;
}
}
if ( CORBA::is_nil( _EnginesContainer ) && _StartContainer ) {
- StartContainer( myParams ) ;
+ if ( _ListOfContainers->length() ) {
+ _EnginesContainer = _ListOfContainers[ 0 ] ;
+ }
+ else {
+ StartContainer( myParams ) ;
+ }
}
return Engines::Container::_duplicate( _EnginesContainer ) ;
}
Engines::Component_ptr Manager_i::FindComponent( const Containers::MachineParameters & myParams ,
const char * ComponentName ) {
+ _StartContainer = false ;
+ return Find_Component( myParams , ComponentName ) ;
+}
+
+Engines::Component_ptr Manager_i::Find_Component( const Containers::MachineParameters & myParams ,
+ const char * ComponentName ) {
Containers::MachineParameters MyParams = (Containers::MachineParameters & ) myParams ;
if ( strcmp( MyParams.HostName ,"localhost" ) == 0 ) {
MyParams.HostName = GetHostname().c_str() ;
}
MESSAGE( "FindComponent HostName " << MyParams.HostName << " ContainerName " << MyParams.ContainerName
<< " ComponentName " << ComponentName ) ;
- _StartContainer = false ;
FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
if ( CORBA::is_nil( _EnginesComponent ) ) {
MESSAGE( "FindComponent ComponentName " << ComponentName << " NOT found" ) ;
}
MESSAGE( "MutexManager pthread_mutex_locked" ) ;
try {
- EnginesComponent = FindComponent( MyParams , ComponentName ) ;
+ _StartContainer = true ;
+ EnginesComponent = Find_Component( MyParams , ComponentName ) ;
if ( CORBA::is_nil( EnginesComponent ) ) {
- _StartContainer = true ;
- aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
+ MESSAGE("Component not found " << _ComponentName ) ;
+// aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
}
else {
- aContainer = _EnginesContainer ;
+ MESSAGE("Component was found " << _ComponentName ) ;
}
+ aContainer = _EnginesContainer ;
}
catch ( ... ) {
MESSAGE(" catch") ;
}
MESSAGE( "MutexManager pthread_mutex_locked" ) ;
try {
- EnginesComponent = FindComponent( MyParams , ComponentName ) ;
+ _StartContainer = true ;
+ EnginesComponent = Find_Component( MyParams , ComponentName ) ;
if ( CORBA::is_nil( EnginesComponent ) ) {
- MESSAGE("Component not found " << _ComponentName << " --> FindOrStartContainerLocked" ) ;
- _StartContainer = true ;
- aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
+ MESSAGE("Component not found " << _ComponentName ) ;
+// aContainer = FindOrStartContainerLocked( (Containers::MachineParameters & ) MyParams , ComponentName ) ;
}
else {
- aContainer = _EnginesContainer ;
+ MESSAGE("Component was found " << _ComponentName ) ;
}
+ aContainer = _EnginesContainer ;
}
catch ( ... ) {
MESSAGE(" catch") ;
ListOfComputers = MyResourcesMgr.GetComputers( DefaultParams )
print ''
-print 'ListOfComputers',len( ListOfComputers ),'computers found'
if len( ListOfComputers ) > 0 :
print "Error",len( ListOfComputers ),"Computers found"
i = 0
ComputerParameters( ListOfComputers[i].Parameters() )
ComputerEnvironement( ListOfComputers[i].Environment() )
i = i + 1
+else :
+ print 'ListOfComputers',len( ListOfComputers ),'computers found Ok'
aComputer = MyResourcesMgr.SelectComputer( DefaultParams )
if aComputer is None :
if len( Containers ) == 0 :
print len( Containers ),"found Error"
+
+
DefaultParams.Memory = 0
DefaultParams.ContainerName = ''
+ContainerParameters( DefaultParams )
+
DefaultParams.ContainerType = Engines.Undefined
Containers = MyContainersMgr.FindContainers( DefaultParams )
i = 0
print "Container running on",Containers[ i ]._get_machineName(),"with name",Containers[ i ]._get_name(),"and type",Containers[ i ].type()
i = i + 1
+aContainer = MyContainersMgr.FindContainer( DefaultParams )
+print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainers.type()
+
+aContainer = MyContainersMgr.FindContainer( 'FactoryServer' ) )
+print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainers.type()
+
+aContainer = MyContainersMgr.FindContainer( 'localhost/FactoryServer' ) )
+print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainers.type()
+
DefaultParams.ContainerType = Engines.Cpp
Containers = MyContainersMgr.FindContainers( DefaultParams )
i = 0
DefaultParams.ContainerType = Engines.Cpp
DefaultParams.ContainerName = 'FactoryServer'
FactoryServerAddComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "AddComponent" )
-FactoryServerAddComponent._get_instanceName()
-FactoryServerAddComponent._get_interfaceName()
+print FactoryServerAddComponent.GetContainerRef()._get_name(),FactoryServerAddComponent._get_instanceName(),FactoryServerAddComponent._get_interfaceName()
+
+DefaultParams.ContainerType = Engines.Undefined
+DefaultParams.ContainerName = ''
+
+ContainerParameters( DefaultParams )
AddComponent = MyContainersMgr.FindComponent( DefaultParams , 'AddComponent' )
-AddComponent._get_instanceName()
-AddComponent._get_interfaceName()
+print AddComponent.GetContainerRef()._get_name(),AddComponent._get_instanceName(),AddComponent._get_interfaceName()
ListOfAddComponent = MyContainersMgr.FindComponents( DefaultParams , 'AddComponent' )
i = 0
while i < len( ListOfAddComponent ) :
- print ListOfAddComponent[ i ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName()
+ print ListOfAddComponent[ i ].GetContainerRef()._get_name(),ListOfAddComponent[ i ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName()
i = i + 1
-MyContainersMgr.FindOrLoad_Component( DefaultParams , "AddComponent" )
+aSameAddComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "AddComponent" )
+print aSameAddComponent.GetContainerRef()._get_name(),aSameAddComponent._get_instanceName(),aSameAddComponent._get_interfaceName()
+
ListOfAddComponent = MyContainersMgr.FindComponents( DefaultParams , 'AddComponent' )
i = 0
while i < len( ListOfAddComponent ) :
- print ListOfAddComponent[ i ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName()
+ print ListOfAddComponent[ i ].GetContainerRef()._get_name(),ListOfAddComponent[ i ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName()
i = i + 1
+ContainerParameters( DefaultParams )
+
FactoryServeSubComponent = MyContainersMgr.FindOrLoad_Component( DefaultParams , "SubComponent" )
ListOfComponents = MyContainersMgr.FindComponents( DefaultParams , '' )
i = 0
while i < len( ListOfComponents ) :
- print ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName()
+ print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName()
i = i + 1
DefaultParams.ContainerName = 'SuperVisionContainer'
ListOfAddComponent = MyContainersMgr.FindComponents( DefaultParams , 'AddComponent' )
i = 0
while i < len( ListOfAddComponent ) :
- print ListOfAddComponent[ i ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName()
+ print ListOfAddComponent[ i ].GetContainerRef()._get_name(),ListOfAddComponent[ i ]._get_instanceName(),ListOfAddComponent[ i ]._get_interfaceName()
i = i + 1
ListOfComponents = MyContainersMgr.FindComponents( DefaultParams , '' )
i = 0
while i < len( ListOfComponents ) :
- print ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName()
+ print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName()
i = i + 1
from LifeCycleCORBA import *
orb = CORBA.ORB_init([''], CORBA.ORB_ID)
lcc = LifeCycleCORBA( orb )
-DefaultParams.ContainerName = 'SuperVisionContainer'
lccMulComponent = lcc.FindOrLoadComponent( 'SuperVisionContainer' , "MulComponent" )
-DefaultParams.ContainerName = 'DivComponentContainer'
+print lccMulComponent.GetContainerRef()._get_name(),lccMulComponent._get_instanceName(),lccMulComponent._get_interfaceName()
lccDivComponent = lcc.FindOrLoadComponent( 'DivComponentContainer' , "DivComponent" )
+print lccDivComponent.GetContainerRef()._get_name(),lccDivComponent._get_instanceName(),lccDivComponent._get_interfaceName()
+
+
+DefaultParams = lcc.Parameters()
+
+DefaultParams.ContainerName = 'SuperVisionContainer'
+
+lccAddComponent = lcc.FindOrLoadComponent( DefaultParams , "AddComponent" )
+print lccAddComponent.GetContainerRef()._get_name(),lccAddComponent._get_instanceName(),lccAddComponent._get_interfaceName()
+
+DefaultParams.ContainerName = 'SubComponentContainer'
+
+lccSubComponent = lcc.FindOrLoadComponent( DefaultParams , "SubComponent" )
+print lccSubComponent.GetContainerRef()._get_name(),lccSubComponent._get_instanceName(),lccSubComponent._get_interfaceName()
+
+aContainer = lcc.FindContainer( DefaultParams )
+print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type()
+
+aContainer = lcc.FindContainer( 'FactoryServer' )
+print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type()
+
+aContainer = lcc.FindContainer( 'localhost/FactoryServer' )
+print "Container running on",aContainer._get_machineName(),"with name",aContainer._get_name(),"and type",aContainer.type()
+
+ContainerParameters( DefaultParams )
+
+DefaultParams.ContainerName = ''
+
+ListOfContainers = lcc.FindContainers( DefaultParams )
+i = 0
+while i < len( ListOfContainers ) :
+ print "Container running on",ListOfContainers[ i ]._get_machineName(),"with name",ListOfContainers[ i ]._get_name(),"and type",ListOfContainers[ i ].type()
+ i = i + 1
+
+ListOfComponents = lcc.FindComponents( DefaultParams , '' )
+i = 0
+while i < len( ListOfComponents ) :
+ print ListOfComponents[ i ].GetContainerRef()._get_name(),ListOfComponents[ i ]._get_instanceName(),ListOfComponents[ i ]._get_interfaceName()
+ i = i + 1
+
+
+aComponent = lcc.FindComponent( DefaultParams , 'SubComponent' )
+print aComponent.GetContainerRef()._get_name(),aComponent._get_instanceName(),aComponent._get_interfaceName()
+
+lccMulComponent = lcc.FindOrLoadComponent( DefaultParams , "MulComponent" )
+
+print lccMulComponent.GetContainerRef()._get_name(),lccMulComponent._get_instanceName(),lccMulComponent._get_interfaceName()
+
from SALOME_utilities import *
+import Resources
+import Containers
+
class LifeCycleCORBA:
_orb = None
_rootcontext = None
- _containerRootContext = None
- _catalog = None
-
+ #_containerRootContext = None
+ #_catalog = None
+ _containermgr = None
+
#-------------------------------------------------------------------------
def __init__(self, orb):
if self._rootContext is None:
MESSAGE( "Name Service Reference is invalid" )
- name = [CosNaming.NameComponent("Containers","dir")]
- try:
- self._containerRootContext = self._rootContext.bind_new_context(name)
+ #name = [CosNaming.NameComponent("Containers","dir")]
+ #try:
+ #self._containerRootContext = self._rootContext.bind_new_context(name)
- except CosNaming.NamingContext.AlreadyBound, ex:
- MESSAGE( "/Containers.dir Context already exists" )
- obj = self._rootContext.resolve(name)
- self._containerRootContext = obj._narrow(CosNaming.NamingContext)
- if self._containerRootContext is None:
- MESSAGE( "Containers.dir exists but it is not a NamingContext" )
+ #except CosNaming.NamingContext.AlreadyBound, ex:
+ #MESSAGE( "/Containers.dir Context already exists" )
+ #obj = self._rootContext.resolve(name)
+ #self._containerRootContext = obj._narrow(CosNaming.NamingContext)
+ #if self._containerRootContext is None:
+ #MESSAGE( "Containers.dir exists but it is not a NamingContext" )
+
+ #name = [CosNaming.NameComponent("Kernel","dir"),
+ #CosNaming.NameComponent("ModulCatalog","object")]
+ #try:
+ #obj = self._rootContext.resolve(name)
+ #except CosNaming.NamingContext.NotFound, ex:
+ #MESSAGE( "/Kernel.dir/ModulCatalog.object not found in Naming Service" )
name = [CosNaming.NameComponent("Kernel","dir"),
- CosNaming.NameComponent("ModulCatalog","object")]
+ CosNaming.NameComponent("ContainersManager","object")]
try:
obj = self._rootContext.resolve(name)
except CosNaming.NamingContext.NotFound, ex:
- MESSAGE( "/Kernel.dir/ModulCatalog.object not found in Naming Service" )
+ MESSAGE( "/Kernel.dir/ContainersManager.object not found in Naming Service" )
+
+ self._containermgr = obj._narrow( Containers.Manager )
+ self._containermgr.ping()
+
+ #self._catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog)
+ #if self._catalog is None:
+ #MESSAGE( "/Kernel.dir/ModulCatalog.object exists but is not a ModulCatalog" )
+
+ #-------------------------------------------------------------------------
+
+ def Parameters( self ):
+ return self._containermgr.Parameters()
- self._catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog)
- if self._catalog is None:
- MESSAGE( "/Kernel.dir/ModulCatalog.object exists but is not a ModulCatalog" )
#-------------------------------------------------------------------------
theComputer = os.getenv("HOSTNAME")
computerSplitName = theComputer.split('.')
theComputer = computerSplitName[0]
- MESSAGE( theComputer + theContainer )
+ MESSAGE( theComputer + '/' + theContainer )
return theComputer,theContainer
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
def FindContainer(self, containerName):
- theComputer,theContainer = self.ContainerName( containerName )
- name = [CosNaming.NameComponent(theComputer,"dir"),
- CosNaming.NameComponent(theContainer,"object")]
- obj = None
- try:
- obj = self._containerRootContext.resolve(name)
- MESSAGE( containerName + ".object found in Naming Service" )
+ try :
+ theComputer,theContainer = self.ContainerName( containerName )
+ MyParams = self._containermgr.Parameters()
+ MyParams.HostName = theComputer
+ MyParams.ContainerName = theContainer
+ if theContainer.find('Py') == -1 :
+ MyParams.ContainerType = Engines.Cpp
+ else :
+ MyParams.ContainerType = Engines.Python
+ except :
+ MyParams = containerName
+ container = self._containermgr.FindContainer( MyParams )
+ #name = [CosNaming.NameComponent(theComputer,"dir"),
+ # CosNaming.NameComponent(theContainer,"object")]
+ #obj = None
+ #try:
+ # obj = self._containerRootContext.resolve(name)
+ # MESSAGE( containerName + ".object found in Naming Service" )
- except CosNaming.NamingContext.NotFound, ex:
- MESSAGE( containerName + ".object not found in Naming Service" )
-
- if obj is None:
- container = None
- else:
- container = obj._narrow(Engines.Container)
- if container is None:
- MESSAGE( containerName + ".object exists but is not a Container" )
+ #except CosNaming.NamingContext.NotFound, ex:
+ # MESSAGE( containerName + ".object not found in Naming Service" )
+
+ #if obj is None:
+ # container = None
+ #else:
+ # container = obj._narrow(Engines.Container)
+ # if container is None:
+ # MESSAGE( containerName + ".object exists but is not a Container" )
return container
#-------------------------------------------------------------------------
- def FindOrStartContainer(self, theComputer , theContainer ):
- MESSAGE( "FindOrStartContainer" + theComputer + theContainer )
- aContainer = self.FindContainer( theComputer + "/" + theContainer )
- if aContainer is None :
- if (theContainer == "FactoryServer") | (theContainer == "FactoryServerPy") :
- if theComputer == os.getenv("HOSTNAME") :
- rshstr = ""
- else :
- rshstr = "rsh -n " + theComputer + " "
- path = self.ComputerPath( theComputer )
- if path != "" :
- rshstr = rshstr + path + "/../bin/"
- else :
- rshstr = rshstr + os.getenv( "SALOME_ROOT_DIR" ) + "/bin/"
- if theContainer == "FactoryServer" :
- rshstr = rshstr + "./runSession ./SALOME_Container "
- else :
- rshstr = rshstr + "./runSession ./SALOME_ContainerPy.py '"
- rshstr = rshstr + theContainer + " -"
- omniORBcfg = os.getenv( "OMNIORB_CONFIG" )
- file = os.open( omniORBcfg , os.O_RDONLY )
- ORBInitRef = os.read(file,132)
- if ORBInitRef[len(ORBInitRef)-1] == '\n' :
- ORBInitRef,bsn = ORBInitRef.split('\n')
- os.close( file )
- rshstr = rshstr + ORBInitRef
- if theContainer == "FactoryServerPy" :
- rshstr = rshstr + "'"
- rshstr = rshstr + " > /tmp/" + theContainer + "_"
- rshstr = rshstr + theComputer
- rshstr = rshstr + ".log 2>&1 &"
- os.system( rshstr )
- MESSAGE( "FindOrStartContainer" + rshstr + " done" )
- else :
- if theContainer.find('Py') == -1 :
- aContainer = self.FindContainer( theComputer + "/" + "FactoryServer" )
- else :
- aContainer = self.FindContainer( theComputer + "/" + "FactoryServerPy" )
- aContainer = aContainer.start_impl( theContainer )
-
- count = 21
- while aContainer is None :
- time.sleep(1)
- count = count - 1
- MESSAGE( str(count) + ". Waiting for " + theComputer + "/" + theContainer )
- aContainer = self.FindContainer( theComputer + "/" + theContainer )
- if count == 0 :
- return aContainer
+ def FindContainers( self , MyParams ) :
+ if MyParams.HostName == 'localhost' :
+ MyParams.HostName = os.getenv("HOSTNAME")
+ return self._containermgr.FindContainers( MyParams )
+
+
+ #-------------------------------------------------------------------------
+
+ def FindComponent( self , MyParams , ComponentName ) :
+ if MyParams.HostName == 'localhost' :
+ MyParams.HostName = os.getenv("HOSTNAME")
+ return self._containermgr.FindComponent( MyParams , ComponentName )
+
+
+ #-------------------------------------------------------------------------
+
+ def FindComponents( self , MyParams , ComponentName ) :
+ if MyParams.HostName == 'localhost' :
+ MyParams.HostName = os.getenv("HOSTNAME")
+ return self._containermgr.FindComponents( MyParams , ComponentName )
+
+
+ #-------------------------------------------------------------------------
+
+ #def FindOrStartContainer(self, theComputer , theContainer ):
+ #MESSAGE( "FindOrStartContainer" + theComputer + theContainer )
+ #aContainer = self.FindContainer( theComputer + "/" + theContainer )
+ #if aContainer is None :
+ #if (theContainer == "FactoryServer") | (theContainer == "FactoryServerPy") :
+ #if theComputer == os.getenv("HOSTNAME") :
+ #rshstr = ""
+ #else :
+ #rshstr = "rsh -n " + theComputer + " "
+ #path = self.ComputerPath( theComputer )
+ #if path != "" :
+ #rshstr = rshstr + path + "/../bin/"
+ #else :
+ #rshstr = rshstr + os.getenv( "SALOME_ROOT_DIR" ) + "/bin/"
+ #if theContainer == "FactoryServer" :
+ #rshstr = rshstr + "./runSession ./SALOME_Container "
+ #else :
+ #rshstr = rshstr + "./runSession ./SALOME_ContainerPy.py '"
+ #rshstr = rshstr + theContainer + " -"
+ #omniORBcfg = os.getenv( "OMNIORB_CONFIG" )
+ #file = os.open( omniORBcfg , os.O_RDONLY )
+ #ORBInitRef = os.read(file,132)
+ #if ORBInitRef[len(ORBInitRef)-1] == '\n' :
+ #ORBInitRef,bsn = ORBInitRef.split('\n')
+ #os.close( file )
+ #rshstr = rshstr + ORBInitRef
+ #if theContainer == "FactoryServerPy" :
+ #rshstr = rshstr + "'"
+ #rshstr = rshstr + " > /tmp/" + theContainer + "_"
+ #rshstr = rshstr + theComputer
+ #rshstr = rshstr + ".log 2>&1 &"
+ #os.system( rshstr )
+ #MESSAGE( "FindOrStartContainer" + rshstr + " done" )
+ #else :
+ #if theContainer.find('Py') == -1 :
+ #aContainer = self.FindContainer( theComputer + "/" + "FactoryServer" )
+ #aContainerType = Engines.Cpp
+ #else :
+ #aContainer = self.FindContainer( theComputer + "/" + "FactoryServerPy" )
+ #aContainerType = Engines.Python
+ #aContainer = aContainer.start_impl( theContainer , aContainerType )
+
+ #count = 21
+ #while aContainer is None :
+ #time.sleep(1)
+ #count = count - 1
+ #MESSAGE( str(count) + ". Waiting for " + theComputer + "/" + theContainer )
+ #aContainer = self.FindContainer( theComputer + "/" + theContainer )
+ #if count == 0 :
+ #return aContainer
- return aContainer
+ #return aContainer
#os.system("rsh -n dm2s0017 /export/home/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515")
#-------------------------------------------------------------------------
def FindOrLoadComponent(self, containerName, componentName):
- theComputer,theContainer = self.ContainerName( containerName )
- name = [CosNaming.NameComponent(theComputer,"dir"),
- CosNaming.NameComponent(theContainer,"dir"),
- CosNaming.NameComponent(componentName,"object")]
- try:
- obj = self._containerRootContext.resolve(name)
- except CosNaming.NamingContext.NotFound, ex:
- MESSAGE( "component " + componentName + " not found, trying to load" )
- container = self.FindContainer(theComputer + "/" + theContainer)
- if container is None:
- MESSAGE( "container " + theComputer + "/" + theContainer + " not found in Naming Service, trying to start" )
- if (theContainer != "FactoryServer") & (theContainer != "FactoryServerPy") :
- if theContainer.find('Py') == -1 :
- theFactorycontainer = "FactoryServer"
- else :
- theFactorycontainer = "FactoryServerPy"
- Factorycontainer = self.FindContainer(theComputer + "/" + theFactorycontainer)
- if Factorycontainer is None:
- MESSAGE( "container " + theComputer + "/" + theFactorycontainer + " not found in Naming Service, trying to start" )
- Factorycontainer = self.FindOrStartContainer(theComputer,theFactorycontainer)
- else:
- Factorycontainer = self.FindOrStartContainer(theComputer,theContainer)
- if Factorycontainer != None :
- container = self.FindOrStartContainer(theComputer,theContainer)
-
- if container != None:
- compoinfo = self._catalog.GetComponent(componentName)
- if compoinfo is None:
- MESSAGE( "component " + componentName + " not found in Module Catalog" )
- else:
- try:
- machineName = theComputer
- path = compoinfo.GetPathPrefix(machineName) + "/"
- except SALOME_ModuleCatalog.NotFound, ex:
- MESSAGE( "machine " + machineName + " not found in Module Catalog" )
- MESSAGE( "trying localhost" )
- try:
- path = compoinfo.GetPathPrefix("localhost") + "/"
- except SALOME_ModuleCatalog.NotFound, ex:
- path = ""
- implementation = path + "lib" + componentName + "Engine.so"
- MESSAGE( "Trying to load " + implementation )
- try:
- component = container.load_impl(componentName, implementation)
- MESSAGE( "component " + component._get_instanceName() + " launched !" )
- return component
- except:
- MESSAGE( "component " + componentName + " NOT launched !" )
-
- else:
- try:
- component = obj._narrow(Engines.Component)
- if component is None:
- MESSAGE( componentName + " is not a component !" )
- else:
- MESSAGE( "component " + component._get_instanceName() + " found !" )
- return component
- except:
- MESSAGE( componentName + " failure" )
- return None
+
+ try :
+ theComputer,theContainer = self.ContainerName( containerName )
+ MyParams = self._containermgr.Parameters()
+ MyParams.HostName = theComputer
+ MyParams.ContainerName = theContainer
+ if theContainer.find('Py') == -1 :
+ MyParams.ContainerType = Engines.Cpp
+ else :
+ MyParams.ContainerType = Engines.Python
+ except :
+ MyParams = containerName
+ return self._containermgr.FindOrLoad_Component( MyParams , componentName )
+ #name = [CosNaming.NameComponent(theComputer,"dir"),
+ #CosNaming.NameComponent(theContainer,"dir"),
+ #CosNaming.NameComponent(componentName,"object")]
+ #try:
+ #obj = self._containerRootContext.resolve(name)
+ #except CosNaming.NamingContext.NotFound, ex:
+ #MESSAGE( "component " + componentName + " not found, trying to load" )
+ #container = self.FindContainer(theComputer + "/" + theContainer)
+ #if container is None:
+ #MESSAGE( "container " + theComputer + "/" + theContainer + " not found in Naming Service, trying to start" )
+ #if (theContainer != "FactoryServer") & (theContainer != "FactoryServerPy") :
+ #if theContainer.find('Py') == -1 :
+ #theFactorycontainer = "FactoryServer"
+ #else :
+ #theFactorycontainer = "FactoryServerPy"
+ #Factorycontainer = self.FindContainer(theComputer + "/" + theFactorycontainer)
+ #if Factorycontainer is None:
+ #MESSAGE( "container " + theComputer + "/" + theFactorycontainer + " not found in Naming Service, trying to start" )
+ #Factorycontainer = self.FindOrStartContainer(theComputer,theFactorycontainer)
+ #else:
+ #Factorycontainer = self.FindOrStartContainer(theComputer,theContainer)
+ #if Factorycontainer != None :
+ #container = self.FindOrStartContainer(theComputer,theContainer)
+
+ #if container != None:
+ #compoinfo = self._catalog.GetComponent(componentName)
+ #if compoinfo is None:
+ #MESSAGE( "component " + componentName + " not found in Module Catalog" )
+ #else:
+ #try:
+ #machineName = theComputer
+ #path = compoinfo.GetPathPrefix(machineName) + "/"
+ #except SALOME_ModuleCatalog.NotFound, ex:
+ #MESSAGE( "machine " + machineName + " not found in Module Catalog" )
+ #MESSAGE( "trying localhost" )
+ #try:
+ #path = compoinfo.GetPathPrefix("localhost") + "/"
+ #except SALOME_ModuleCatalog.NotFound, ex:
+ #path = ""
+ #implementation = path + "lib" + componentName + "Engine.so"
+ #MESSAGE( "Trying to load " + implementation )
+ #try:
+ #component = container.load_impl(componentName, implementation)
+ #MESSAGE( "component " + component._get_instanceName() + " launched !" )
+ #return component
+ #except:
+ #MESSAGE( "component " + componentName + " NOT launched !" )
+
+ #else:
+ #try:
+ #component = obj._narrow(Engines.Component)
+ #if component is None:
+ #MESSAGE( componentName + " is not a component !" )
+ #else:
+ #MESSAGE( "component " + component._get_instanceName() + " found !" )
+ #return component
+ #except:
+ #MESSAGE( componentName + " failure" )
+ #return None