import SALOME
session=clt.waitNS("/Kernel/Session",SALOME.Session)
+ from Utils_Identity import getShortHostName
+
if os.getenv("HOSTNAME") == None:
if os.getenv("HOST") == None:
- os.environ["HOSTNAME"]="localhost"
+ os.environ["HOSTNAME"]=getShortHostName()
else:
os.environ["HOSTNAME"]=os.getenv("HOST")
- theComputer = os.getenv("HOSTNAME")
- computerSplitName = theComputer.split('.')
- theComputer = computerSplitName[0]
+ theComputer = getShortHostName()
#
# Lancement Container C++ local,
self._Executed = 0
naming_service = SALOME_NamingServicePy_i(self._orb)
- myMachine=string.split(os.getenv( "HOSTNAME" ),'.')
- Component_path = "/Containers/" + myMachine[0] + "/" + self._containerName + "/" + self._interfaceName
+ myMachine=getShortHostName()
+ Component_path = "/Containers/" + myMachine + "/" + self._containerName + "/" + self._interfaceName
MESSAGE( 'SALOME_ComponentPy_i Register' + str( Component_path ) )
naming_service.Register(self._this(), Component_path)
from SALOME_ComponentPy import *
from SALOME_utilities import *
+from Utils_Identity import getShortHostName
#=============================================================================
self._poa = poa
self._containerName = containerName
- myMachine=string.split(os.getenv( "HOSTNAME" ),'.')
+ myMachine=getShortHostName()
naming_service = SALOME_NamingServicePy_i(self._orb)
self._naming_service = naming_service
- Container_path = "/Containers/" + myMachine[0] + "/" + self._containerName
+ Container_path = "/Containers/" + myMachine + "/" + self._containerName
MESSAGE( str(Container_path) )
naming_service.Register(self._this(), Container_path)
def start_impl(self, ContainerName):
MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) )
- myMachine=string.split(os.getenv( "HOSTNAME" ),'.')
- theContainer = "/Containers/" + myMachine[0] + "/" + ContainerName
+ myMachine=getShortHostName()
+ theContainer = "/Containers/" + myMachine + "/" + ContainerName
try:
obj = self._naming_service.Resolve(theContainer)
except :
import SALOME_ModuleCatalog
from SALOME_utilities import *
+from Utils_Identity import getShortHostName
class LifeCycleCORBA:
_orb = None
theComputer = ""
theContainer = containerName
if theComputer == "" :
- theComputer = os.getenv("HOSTNAME")
+ theComputer = getShortHostName()
if theComputer == "localhost" :
- theComputer = os.getenv("HOSTNAME")
+ theComputer = getShortHostName()
computerSplitName = theComputer.split('.')
theComputer = computerSplitName[0]
MESSAGE( theComputer + theContainer )
aContainer = self.FindContainer( theComputer + "/" + theContainer )
if aContainer is None :
if (theContainer == "FactoryServer") | (theContainer == "FactoryServerPy") :
- myMachine=string.split(os.getenv( "HOSTNAME" ),'.')
- if theComputer == myMachine[0] :
+ myMachine=getShortHostName()
+ if theComputer == myMachine :
rshstr = ""
else :
rshstr = "rsh -n " + theComputer + " "
#==============================================================================
from LifeCycleCORBA import *
+from Utils_Identity import getShortHostName
class MPILifeCycleCORBA(LifeCycleCORBA):
#-------------------------------------------------------------------------
aMPIContainer = self.FindContainer( theComputer + "/" + theMPIContainer )
if aMPIContainer is None :
if (theMPIContainerRoot == "MPIFactoryServer") | (theMPIContainerRoot == "MPIFactoryServerPy") :
- if theComputer == os.getenv("HOSTNAME") :
+ if theComputer == getShortHostName() :
rshstr = ""
else :
rshstr = "rsh -n " + theComputer + " "
from omniORB import CORBA
import CosNaming
import Engines
+from Utils_Identity import getShortHostName
#initialise the ORB
sys.exit(1)
#resolve the name /Containers.dir/FactoryServerPy.object
-myMachine=string.split(os.getenv( "HOSTNAME" ),'.')
-machineName= myMachine[0]
+machineName= getShortHostName()
containerName = "FactoryServerPy"
name = [CosNaming.NameComponent("Containers","dir"),
CosNaming.NameComponent(machineName,"dir"),
import socket
import pwd
import time
+import string
+
+def getShortHostName():
+ """
+ gives Hostname without domain extension.
+ SALOME naming service needs short Hostnames (without domain extension).
+ HOSTNAME is not allways defined in environment,
+ socket.gethostname() gives short or complete Hostname, depending on
+ defined aliases.
+ """
+ return string.split(socket.gethostname(),'.')[0]
class Identity:
def __init__(self,name):
self._name = name
self._pid = os.getpid()
- self._machine = os.getenv( "HOSTNAME" )
+ self._machine = socket.gethostname()
self._adip = socket.gethostbyname(self._machine) # IP adress
self._uid = os.getuid()
list = pwd.getpwuid(self._uid)