Browse Source

closer to goodness: undoing default port numbers set in __init__() methods and elsewhere

git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1554 e5f2f494-b856-4b98-b285-d166d9295462
Michael Graff 15 years ago
parent
commit
c712cf814d
3 changed files with 24 additions and 11 deletions
  1. 9 6
      src/bin/bind10/bind10.py.in
  2. 14 4
      src/bin/msgq/msgq.py.in
  3. 1 1
      src/lib/python/isc/cc/session.py

+ 9 - 6
src/bin/bind10/bind10.py.in

@@ -118,7 +118,6 @@ class ProcessInfo:
             spawn_env['PYTHON_EXEC'] = os.environ['PYTHON_EXEC']
             spawn_env['PYTHON_EXEC'] = os.environ['PYTHON_EXEC']
         if 'PYTHONPATH' in os.environ:
         if 'PYTHONPATH' in os.environ:
             spawn_env['PYTHONPATH'] = os.environ['PYTHONPATH']
             spawn_env['PYTHONPATH'] = os.environ['PYTHONPATH']
-        spawn_env['ISC_MSGQ_PORT'] = self.c_channel_port
         self.process = subprocess.Popen(self.args,
         self.process = subprocess.Popen(self.args,
                                         stdin=subprocess.PIPE,
                                         stdin=subprocess.PIPE,
                                         stdout=spawn_stdout,
                                         stdout=spawn_stdout,
@@ -216,7 +215,7 @@ class BoB:
             sys.stdout.write("Starting msgq using port %d\n" % 
             sys.stdout.write("Starting msgq using port %d\n" % 
                              self.c_channel_port)
                              self.c_channel_port)
         try:
         try:
-            c_channel = ProcessInfo("msgq", "msgq", c_channel_env, True)
+            c_channel = ProcessInfo("msgq", ["msgq"], c_channel_env, True)
         except Exception as e:
         except Exception as e:
             return "Unable to start msgq; " + str(e)
             return "Unable to start msgq; " + str(e)
         self.processes[c_channel.pid] = c_channel
         self.processes[c_channel.pid] = c_channel
@@ -241,7 +240,8 @@ class BoB:
         if self.verbose:
         if self.verbose:
             sys.stdout.write("Starting b10-cfgmgr\n")
             sys.stdout.write("Starting b10-cfgmgr\n")
         try:
         try:
-            bind_cfgd = ProcessInfo("b10-cfgmgr", "b10-cfgmgr")
+            bind_cfgd = ProcessInfo("b10-cfgmgr", ["b10-cfgmgr"],
+                                    { 'ISC_MSGQ_PORT': str(self.c_channel_port)})
         except Exception as e:
         except Exception as e:
             c_channel.process.kill()
             c_channel.process.kill()
             return "Unable to start b10-cfgmgr; " + str(e)
             return "Unable to start b10-cfgmgr; " + str(e)
@@ -269,7 +269,8 @@ class BoB:
                              self.auth_port)
                              self.auth_port)
             authargs += ['-v']
             authargs += ['-v']
         try:
         try:
-            auth = ProcessInfo("b10-auth", authargs)
+            auth = ProcessInfo("b10-auth", authargs,
+                               { 'ISC_MSGQ_PORT': str(self.c_channel_port)})
         except Exception as e:
         except Exception as e:
             c_channel.process.kill()
             c_channel.process.kill()
             bind_cfgd.process.kill()
             bind_cfgd.process.kill()
@@ -282,7 +283,8 @@ class BoB:
         if self.verbose:
         if self.verbose:
             sys.stdout.write("Starting b10-xfrin\n")
             sys.stdout.write("Starting b10-xfrin\n")
         try:
         try:
-            xfrind = ProcessInfo("b10-xfrin", ['b10-xfrin'])
+            xfrind = ProcessInfo("b10-xfrin", ['b10-xfrin'],
+                                 { 'ISC_MSGQ_PORT': str(self.c_channel_port)})
         except Exception as e:
         except Exception as e:
             c_channel.process.kill()
             c_channel.process.kill()
             bind_cfgd.process.kill()
             bind_cfgd.process.kill()
@@ -297,7 +299,8 @@ class BoB:
         if self.verbose:
         if self.verbose:
             sys.stdout.write("Starting b10-cmdctl on port 8080\n")
             sys.stdout.write("Starting b10-cmdctl on port 8080\n")
         try:
         try:
-            cmd_ctrld = ProcessInfo("b10-cmdctl", ['b10-cmdctl'])
+            cmd_ctrld = ProcessInfo("b10-cmdctl", ['b10-cmdctl'],
+                                    { 'ISC_MSGQ_PORT': str(self.c_channel_port)})
         except Exception as e:
         except Exception as e:
             c_channel.process.kill()
             c_channel.process.kill()
             bind_cfgd.process.kill()
             bind_cfgd.process.kill()

+ 14 - 4
src/bin/msgq/msgq.py.in

@@ -71,15 +71,25 @@ class SubscriptionManager:
 
 
 class MsgQ:
 class MsgQ:
     """Message Queue class."""
     """Message Queue class."""
-    def __init__(self, c_channel_port=9912, verbose=False):
+    def __init__(self, port=0, verbose=False):
         """Initialize the MsgQ master.
         """Initialize the MsgQ master.
         
         
-        The c_channel_port specifies the TCP/IP port that the msgq
+        The port specifies the TCP/IP port that the msgq
         process listens on. If verbose is True, then the MsgQ reports
         process listens on. If verbose is True, then the MsgQ reports
         what it is doing.
         what it is doing.
         """
         """
+
+        if port == 0:
+	        if 'ISC_MSGQ_PORT' in os.environ:
+	            port = int(os.environ["ISC_MSGQ_PORT"])
+	        else:
+	            port = 9912
+
+
+        print(port)
+
         self.verbose = verbose
         self.verbose = verbose
-        self.c_channel_port = c_channel_port
+        self.c_channel_port = port
         self.poller = None
         self.poller = None
         self.kqueue = None
         self.kqueue = None
         self.runnable = False
         self.runnable = False
@@ -365,7 +375,7 @@ if __name__ == "__main__":
     parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
     parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
                       help="display more about what is going on")
                       help="display more about what is going on")
     parser.add_option("-m", "--msgq-port", dest="msgq_port", type="string",
     parser.add_option("-m", "--msgq-port", dest="msgq_port", type="string",
-                      action="callback", callback=check_port, default="9912",
+                      action="callback", callback=check_port, default="0",
                       help="port the msgq daemon will use")
                       help="port the msgq daemon will use")
     (options, args) = parser.parse_args()
     (options, args) = parser.parse_args()
 
 

+ 1 - 1
src/lib/python/isc/cc/session.py

@@ -35,7 +35,7 @@ class Session:
         self._queue = []
         self._queue = []
 
 
         if port == 0:
         if port == 0:
-	        if 'B10_FROM_SOURCE' in os.environ:
+	        if 'ISC_MSGQ_PORT' in os.environ:
 	            port = int(os.environ["ISC_MSGQ_PORT"])
 	            port = int(os.environ["ISC_MSGQ_PORT"])
 	        else:
 	        else:
 	            port = 9912
 	            port = 9912