3 #log files localization
5 import os, commands, sys, re, string, socket
6 from Utils_Identity import getShortHostName
8 if sys.platform == "win32":
9 # temporarily using home directory for Namning Service logs
10 # to be replaced with TEMP later...
11 os.environ["BaseDir"]=os.environ["HOME"]
13 os.environ["BaseDir"]="/tmp"
15 os.environ["Username"]=os.environ["USER"]
17 # kill OmniNames if exists
19 #killall -q -9 omniNames
25 os.mkdir(os.environ["BaseDir"] + "/logs")
26 os.chmod(os.environ["BaseDir"] + "/logs", 0777)
28 #print "Can't create " + os.environ["BaseDir"] + "/logs"
31 upath = os.environ["BaseDir"] + "/logs/" + os.environ["Username"]
36 #print "Can't create " + upath
39 #os.system("touch " + upath + "/dummy")
40 for fname in os.listdir(upath):
42 os.remove(upath + "/" + fname)
45 #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
47 print "Name Service... "
48 #hname=os.environ["HOST"] #commands.getoutput("hostname")
49 if sys.platform == "win32":
50 hname=getShortHostName()
52 hname=socket.gethostname()
56 f=open(os.environ["OMNIORB_CONFIG"])
57 ss=re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
60 aPort=re.findall("\d+", ss[0])[0]
62 #aSedCommand="s/.*NameService=corbaname::" + hname + ":\([[:digit:]]*\)/\1/"
63 #print "sed command = ", aSedCommand
64 #aPort = commands.getoutput("sed -e\"" + aSedCommand + "\"" + os.environ["OMNIORB_CONFIG"])
67 if sys.platform == "win32":
69 #command = ['omniNames -start ' , aPort , ' -logdir ' , '\"' + upath + '\"']
70 #os.system("start omniNames -start " + aPort + " -logdir " + "\"" + upath + "\"" )
71 command = "start omniNames -start " + aPort + " -logdir " + "\"" + upath + "\""
73 pid = win32pm.spawnpid( string.join(command, " "), -nc )
74 process_id[pid]=command
76 os.system("omniNames -start " + aPort + " -logdir " + upath + " &")
79 print "to list contexts and objects bound int the context with the specified name : showNS "
81 # In LifeCycleCORBA, FactoryServer is started with rsh on the requested
82 # computer if this Container does not exist. Default is localhost.
83 # Others Containers are started with start_impl method of FactoryServer Container.
84 # For using rsh it is necessary to have in the ${HOME} directory a .rhosts file
85 # Warning : on RedHat the file /etc/hosts contains by default a line like :
86 # 127.0.0.1 bordolex bordolex.paris1.matra-dtv.fr localhost.localdomain localhost
87 # (bordolex is the station name). omniNames on bordolex will be accessible from other
88 # computers only if the computer name is removed on that line like :
89 # 127.0.0.1 bordolex.paris1.matra-dtv.fr localhost.localdomain localhost
91 # To start dynamically Containers on several computers you need to
92 # put in the ${OMNIORB_CONFIG} file a computer name instead of "localhost"
93 # example : ORBInitRef NameService=corbaname::dm2s0017
95 # If you need to use several omniNames running on the same computer, you have to :
96 #1. put in your ${OMNIORB_CONFIG} file a computer name and port number
97 # example : ORBInitRef NameService=corbaname::dm2s0017:1515
98 #2. start omninames with this port number in runNS.sh
99 # example : omniNames -start 1515 -logdir ${BaseDir}/logs/${Username} &