3 import sys, os, re, socket
6 from Utils_Identity import getShortHostName
8 # -----------------------------------------------------------------------------
10 class NamingServer(Server):
12 USER=os.getenv('USER')
15 #os.system("mkdir -m 777 -p /tmp/logs")
16 LOGDIR="/tmp/logs/" + USER
19 if sys.platform == "win32":
20 # temporarily using home directory for Namning Service logs
21 # to be replaced with TEMP later...
22 os.environ["BaseDir"]=os.environ["HOME"]
24 os.environ["BaseDir"]="/tmp"
27 os.mkdir(os.environ["BaseDir"] + "/logs")
28 os.chmod(os.environ["BaseDir"] + "/logs", 0777)
30 #print "Can't create " + os.environ["BaseDir"] + "/logs"
33 upath = os.environ["BaseDir"] + "/logs/";
34 if sys.platform == "win32":
35 upath += os.environ["Username"];
37 upath += os.environ["USER"];
42 #print "Can't create " + upath
45 #os.system("touch " + upath + "/dummy")
46 for fname in os.listdir(upath):
48 os.remove(upath + "/" + fname)
51 #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
53 print "Name Service... "
54 #hname=os.environ["HOST"] #commands.getoutput("hostname")
55 if sys.platform == "win32":
56 hname=getShortHostName();
58 hname = socket.gethostname();
62 f=open(os.environ["OMNIORB_CONFIG"])
63 ss=re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
69 #aPort=(ss.join().split(':'))[2];
70 #aPort=re.findall("\d+", ss[0])[0]
72 #aSedCommand="s/.*NameService=corbaname::" + hname + ":\([[:digit:]]*\)/\1/"
73 #print "sed command = ", aSedCommand
74 #aPort = commands.getoutput("sed -e\"" + aSedCommand + "\"" + os.environ["OMNIORB_CONFIG"])
76 if sys.platform == "win32":
77 #print "start omniNames -start " + aPort + " -logdir " + upath
78 self.CMD=['omniNames -start ' , aPort , ' -logdir ' , '\"' + upath + '\"']
79 #os.system("start omniNames -start " + aPort + " -logdir " + upath)
81 #self.CMD=['omniNames -start ' , aPort , ' -logdir ' , upath , ' &']
82 self.CMD=['omniNames','-start' , aPort, '-logdir' , upath ]
83 #os.system("omniNames -start " + aPort + " -logdir " + upath + " &")
86 print "to list contexts and objects bound int the context with the specified name : showNS "
91 if sys.platform == "win32":
92 env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("PATH")]
94 env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")]
95 self.CMD=['xterm', '-e']+ env_ld_library_path + ['python']
99 # In LifeCycleCORBA, FactoryServer is started with rsh on the requested
100 # computer if this Container does not exist. Default is localhost.
101 # Others Containers are started with start_impl method of FactoryServer Container.
102 # For using rsh it is necessary to have in the ${HOME} directory a .rhosts file
103 # Warning : on RedHat the file /etc/hosts contains by default a line like :
104 # 127.0.0.1 bordolex bordolex.paris1.matra-dtv.fr localhost.localdomain localhost
105 # (bordolex is the station name). omniNames on bordolex will be accessible from other
106 # computers only if the computer name is removed on that line like :
107 # 127.0.0.1 bordolex.paris1.matra-dtv.fr localhost.localdomain localhost
109 # To start dynamically Containers on several computers you need to
110 # put in the ${OMNIORB_CONFIG} file a computer name instead of "localhost"
111 # example : ORBInitRef NameService=corbaname::dm2s0017
113 # If you need to use several omniNames running on the same computer, you have to :
114 #1. put in your ${OMNIORB_CONFIG} file a computer name and port number
115 # example : ORBInitRef NameService=corbaname::dm2s0017:1515
116 #2. start omninames with this port number like in orbmodile.py
117 # example : omniNames -start 1515 -logdir ${BaseDir}/logs/${Username} &