summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJelte Jansen <jelte@isc.org>2010-06-03 16:53:45 +0200
committerJelte Jansen <jelte@isc.org>2010-06-03 16:53:45 +0200
commit60f6071643cb3afc1825c90b1181f5cfa86ab906 (patch)
tree57076ed7537eded90c33a09bf35434d08ba7c99c
parentpythonic style fix: (diff)
downloadkea-60f6071643cb3afc1825c90b1181f5cfa86ab906.tar.xz
kea-60f6071643cb3afc1825c90b1181f5cfa86ab906.zip
changes from http://bind10.isc.org/ticket/227 (unnamed prints), looked at by Jeremy and Evan
git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@2073 e5f2f494-b856-4b98-b285-d166d9295462
-rw-r--r--src/bin/bind10/bind10.py.in40
-rw-r--r--src/bin/cfgmgr/b10-cfgmgr.py.in2
-rw-r--r--src/bin/cmdctl/cmdctl.py.in4
-rw-r--r--src/bin/msgq/msgq.py.in35
-rw-r--r--src/bin/xfrin/xfrin.py.in8
-rw-r--r--src/bin/xfrout/xfrout.py.in2
-rw-r--r--src/lib/cc/session.cc1
-rw-r--r--src/lib/python/isc/config/config_data.py1
8 files changed, 45 insertions, 48 deletions
diff --git a/src/bin/bind10/bind10.py.in b/src/bin/bind10/bind10.py.in
index 47cdfec154..040f14bce1 100644
--- a/src/bin/bind10/bind10.py.in
+++ b/src/bin/bind10/bind10.py.in
@@ -210,7 +210,7 @@ class BoB:
if self.msgq_socket_file is not None:
c_channel_env["BIND10_MSGQ_SOCKET_FILE"] = self.msgq_socket_file
if self.verbose:
- sys.stdout.write("Checking for already running b10-msgq\n")
+ sys.stdout.write("[bind10] Checking for already running b10-msgq\n")
# try to connect, and if we can't wait a short while
try:
self.cc_session = isc.cc.Session(self.msgq_socket_file)
@@ -222,7 +222,7 @@ class BoB:
# start the c-channel daemon
if self.verbose:
if self.msgq_socket_file:
- sys.stdout.write("Starting b10-msgq\n")
+ sys.stdout.write("[bind10] Starting b10-msgq\n")
try:
c_channel = ProcessInfo("b10-msgq", ["b10-msgq"], c_channel_env,
True, not self.verbose)
@@ -230,7 +230,7 @@ class BoB:
return "Unable to start b10-msgq; " + str(e)
self.processes[c_channel.pid] = c_channel
if self.verbose:
- sys.stdout.write("Started b10-msgq (PID %d)\n" % c_channel.pid)
+ sys.stdout.write("[bind10] Started b10-msgq (PID %d)\n" % c_channel.pid)
# now connect to the c-channel
cc_connect_start = time.time()
@@ -276,7 +276,7 @@ class BoB:
# be processed properly.
xfrout_args = ['b10-xfrout']
if self.verbose:
- sys.stdout.write("Starting b10-xfrout\n")
+ sys.stdout.write("[bind10] Starting b10-xfrout\n")
xfrout_args += ['-v']
try:
xfrout = ProcessInfo("b10-xfrout", xfrout_args,
@@ -287,13 +287,13 @@ class BoB:
return "Unable to start b10-xfrout; " + str(e)
self.processes[xfrout.pid] = xfrout
if self.verbose:
- sys.stdout.write("Started b10-xfrout (PID %d)\n" % xfrout.pid)
+ sys.stdout.write("[bind10] Started b10-xfrout (PID %d)\n" % xfrout.pid)
# start b10-auth
# XXX: this must be read from the configuration manager in the future
authargs = ['b10-auth', '-p', str(self.auth_port)]
if self.verbose:
- sys.stdout.write("Starting b10-auth using port %d\n" %
+ sys.stdout.write("[bind10] Starting b10-auth using port %d\n" %
self.auth_port)
authargs += ['-v']
try:
@@ -306,12 +306,12 @@ class BoB:
return "Unable to start b10-auth; " + str(e)
self.processes[auth.pid] = auth
if self.verbose:
- sys.stdout.write("Started b10-auth (PID %d)\n" % auth.pid)
+ sys.stdout.write("[bind10] Started b10-auth (PID %d)\n" % auth.pid)
# start b10-xfrin
xfrin_args = ['b10-xfrin']
if self.verbose:
- sys.stdout.write("Starting b10-xfrin\n")
+ sys.stdout.write("[bind10] Starting b10-xfrin\n")
xfrin_args += ['-v']
try:
xfrind = ProcessInfo("b10-xfrin", xfrin_args,
@@ -324,13 +324,13 @@ class BoB:
return "Unable to start b10-xfrin; " + str(e)
self.processes[xfrind.pid] = xfrind
if self.verbose:
- sys.stdout.write("Started b10-xfrin (PID %d)\n" % xfrind.pid)
+ sys.stdout.write("[bind10] Started b10-xfrin (PID %d)\n" % xfrind.pid)
# start the b10-cmdctl
# XXX: we hardcode port 8080
cmdctl_args = ['b10-cmdctl']
if self.verbose:
- sys.stdout.write("Starting b10-cmdctl on port 8080\n")
+ sys.stdout.write("[bind10] Starting b10-cmdctl on port 8080\n")
cmdctl_args += ['-v']
try:
cmd_ctrld = ProcessInfo("b10-cmdctl", cmdctl_args,
@@ -344,7 +344,7 @@ class BoB:
return "Unable to start b10-cmdctl; " + str(e)
self.processes[cmd_ctrld.pid] = cmd_ctrld
if self.verbose:
- sys.stdout.write("Started b10-cmdctl (PID %d)\n" % cmd_ctrld.pid)
+ sys.stdout.write("[bind10] Started b10-cmdctl (PID %d)\n" % cmd_ctrld.pid)
self.runnable = True
@@ -367,7 +367,7 @@ class BoB:
def shutdown(self):
"""Stop the BoB instance."""
if self.verbose:
- sys.stdout.write("Stopping the server.\n")
+ sys.stdout.write("[bind10] Stopping the server.\n")
# first try using the BIND 10 request to stop
try:
self.stop_all_processes()
@@ -380,7 +380,7 @@ class BoB:
processes_to_stop = list(self.processes.values())
for proc_info in processes_to_stop:
if self.verbose:
- sys.stdout.write("Sending SIGTERM to %s (PID %d).\n" %
+ sys.stdout.write("[bind10] Sending SIGTERM to %s (PID %d).\n" %
(proc_info.name, proc_info.pid))
try:
proc_info.process.terminate()
@@ -396,7 +396,7 @@ class BoB:
processes_to_stop = list(self.processes.values())
for proc_info in processes_to_stop:
if self.verbose:
- sys.stdout.write("Sending SIGKILL to %s (PID %d).\n" %
+ sys.stdout.write("[bind10] Sending SIGKILL to %s (PID %d).\n" %
(proc_info.name, proc_info.pid))
try:
proc_info.process.kill()
@@ -405,7 +405,7 @@ class BoB:
# finally exited)
pass
if self.verbose:
- sys.stdout.write("All processes ended, server done.\n")
+ sys.stdout.write("[bind10] All processes ended, server done.\n")
def reap_children(self):
"""Check to see if any of our child processes have exited,
@@ -424,15 +424,15 @@ class BoB:
proc_info.restart_schedule.set_run_stop_time()
self.dead_processes[proc_info.pid] = proc_info
if self.verbose:
- sys.stdout.write("Process %s (PID %d) died.\n" %
+ sys.stdout.write("[bind10] Process %s (PID %d) died.\n" %
(proc_info.name, proc_info.pid))
if proc_info.name == "b10-msgq":
if self.verbose and self.runnable:
sys.stdout.write(
- "The b10-msgq process died, shutting down.\n")
+ "[bind10] The b10-msgq process died, shutting down.\n")
self.runnable = False
else:
- sys.stdout.write("Unknown child pid %d exited.\n" % pid)
+ sys.stdout.write("[bind10] Unknown child pid %d exited.\n" % pid)
def restart_processes(self):
"""Restart any dead processes."""
@@ -546,7 +546,7 @@ def main():
options.verbose)
startup_result = boss_of_bind.startup()
if startup_result:
- sys.stderr.write("Error on startup: %s\n" % startup_result)
+ sys.stderr.write("[bind10] Error on startup: %s\n" % startup_result)
sys.exit(1)
# In our main loop, we check for dead processes or messages
@@ -572,7 +572,7 @@ def main():
if err.args[0] == errno.EINTR:
(rlist, wlist, xlist) = ([], [], [])
else:
- sys.stderr.write("Error with select(); %s\n" % err)
+ sys.stderr.write("[bind10] Error with select(); %s\n" % err)
break
for fd in rlist + xlist:
diff --git a/src/bin/cfgmgr/b10-cfgmgr.py.in b/src/bin/cfgmgr/b10-cfgmgr.py.in
index b09a793037..563bbcdf7e 100644
--- a/src/bin/cfgmgr/b10-cfgmgr.py.in
+++ b/src/bin/cfgmgr/b10-cfgmgr.py.in
@@ -50,6 +50,6 @@ if __name__ == "__main__":
print("[b10-cfgmgr] Error creating config manager, "
"is the command channel daemon running?")
except KeyboardInterrupt as kie:
- print("Got ctrl-c, exit")
+ print("[b10-cfgmgr] Interrupted, exiting")
if cm:
cm.write_config()
diff --git a/src/bin/cmdctl/cmdctl.py.in b/src/bin/cmdctl/cmdctl.py.in
index 23cd28fc9f..4e5a73351d 100644
--- a/src/bin/cmdctl/cmdctl.py.in
+++ b/src/bin/cmdctl/cmdctl.py.in
@@ -312,7 +312,7 @@ class CommandControl():
return 1, {'error': errstr}
def log_info(self, msg):
- sys.stdout.write(msg)
+ sys.stdout.write("[b10-cmdctl] %s\n" % str(msg))
class SecureHTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
'''Make the server address can be reused.'''
@@ -400,7 +400,7 @@ class SecureHTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
return self.cmdctrl.send_command_with_check(module_name, command_name, params)
def log_info(self, msg):
- sys.stdout.write(msg)
+ sys.stdout.write("[b10-cmdctl] %s\n" % str(msg))
httpd = None
diff --git a/src/bin/msgq/msgq.py.in b/src/bin/msgq/msgq.py.in
index 65a7b2ae33..df6995b400 100644
--- a/src/bin/msgq/msgq.py.in
+++ b/src/bin/msgq/msgq.py.in
@@ -47,11 +47,11 @@ class SubscriptionManager:
"""Add a subscription."""
target = ( group, instance )
if target in self.subscriptions:
- print("Appending to existing target")
+ print("[b10-msgq] Appending to existing target")
if socket not in self.subscriptions[target]:
self.subscriptions[target].append(socket)
else:
- print("Creating new target")
+ print("[b10-msgq] Creating new target")
self.subscriptions[target] = [ socket ]
def unsubscribe(self, group, instance, socket):
@@ -168,14 +168,16 @@ class MsgQ:
self.setup_listener()
if self.verbose:
- sys.stdout.write("Listening\n")
+ sys.stdout.write("[b10-msgq] Listening\n")
self.runnable = True
def process_accept(self):
"""Process an accept on the listening socket."""
newsocket, ipaddr = self.listen_socket.accept()
- sys.stderr.write("Connection\n")
+ # TODO: When we have logging, we might want
+ # to add a debug message here that a new connection
+ # was made
self.sockets[newsocket.fileno()] = newsocket
lname = self.newlname()
self.lnames[lname] = newsocket
@@ -189,9 +191,9 @@ class MsgQ:
"""Process a read on a socket."""
sock = self.sockets[fd]
if sock == None:
- sys.stderr.write("Got read on Strange Socket fd %d\n" % fd)
+ sys.stderr.write("[b10-msgq] Got read on Strange Socket fd %d\n" % fd)
return
-# sys.stderr.write("Got read on fd %d\n" %fd)
+# sys.stderr.write("[b10-msgq] Got read on fd %d\n" %fd)
self.process_packet(fd, sock)
def kill_socket(self, fd, sock):
@@ -203,7 +205,7 @@ class MsgQ:
del self.lnames[lname]
sock.close()
self.sockets[fd] = None
- sys.stderr.write("Closing socket fd %d\n" % fd)
+ sys.stderr.write("[b10-msgq] Closing socket fd %d\n" % fd)
def getbytes(self, fd, sock, length):
"""Get exactly the requested bytes, or raise an exception if
@@ -243,14 +245,14 @@ class MsgQ:
routing, data = self.read_packet(fd, sock)
except MsgQReceiveError as err:
self.kill_socket(fd, sock)
- sys.stderr.write("Receive error: %s\n" % err)
+ sys.stderr.write("[b10-msgq] Receive error: %s\n" % err)
return
try:
routingmsg = isc.cc.message.from_wire(routing)
except DecodeError as err:
self.kill_socket(fd, sock)
- sys.stderr.write("Routing decode error: %s\n" % err)
+ sys.stderr.write("[b10-msgq] Routing decode error: %s\n" % err)
return
# sys.stdout.write("\t" + pprint.pformat(routingmsg) + "\n")
@@ -261,8 +263,9 @@ class MsgQ:
def process_command(self, fd, sock, routing, data):
"""Process a single command. This will split out into one of the
other functions."""
- print("[XX] got command: ")
- print(routing)
+ # TODO: A print statement got removed here (one that prints the
+ # routing envelope). When we have logging with multiple levels,
+ # we might want to re-add that on a high debug verbosity.
cmd = routing["type"]
if cmd == 'send':
self.process_command_send(sock, routing, data)
@@ -273,7 +276,7 @@ class MsgQ:
elif cmd == 'getlname':
self.process_command_getlname(sock, routing, data)
else:
- sys.stderr.write("Invalid command: %s\n" % cmd)
+ sys.stderr.write("[b10-msgq] Invalid command: %s\n" % cmd)
def preparemsg(self, env, msg = None):
if type(env) == dict:
@@ -358,7 +361,7 @@ class MsgQ:
if err.args[0] == errno.EINTR:
events = []
else:
- sys.stderr.write("Error with poll(): %s\n" % err)
+ sys.stderr.write("[b10-msgq] Error with poll(): %s\n" % err)
break
for (fd, event) in events:
if fd == self.listen_socket.fileno():
@@ -384,7 +387,7 @@ class MsgQ:
def shutdown(self):
"""Stop the MsgQ master."""
if self.verbose:
- sys.stdout.write("Stopping the server.\n")
+ sys.stdout.write("[b10-msgq] Stopping the server.\n")
self.listen_socket.close()
if os.path.exists(self.socket_file):
os.remove(self.socket_file)
@@ -420,13 +423,13 @@ if __name__ == "__main__":
# Announce startup.
if options.verbose:
- sys.stdout.write("MsgQ %s\n" % __version__)
+ sys.stdout.write("[b10-msgq] MsgQ %s\n" % __version__)
msgq = MsgQ(options.msgq_socket_file, options.verbose)
setup_result = msgq.setup()
if setup_result:
- sys.stderr.write("Error on startup: %s\n" % setup_result)
+ sys.stderr.write("[b10-msgq] Error on startup: %s\n" % setup_result)
sys.exit(1)
try:
diff --git a/src/bin/xfrin/xfrin.py.in b/src/bin/xfrin/xfrin.py.in
index afc330a1d9..c0fd69916e 100644
--- a/src/bin/xfrin/xfrin.py.in
+++ b/src/bin/xfrin/xfrin.py.in
@@ -55,9 +55,7 @@ XFRIN_FAIL = 1
DEFAULT_MASTER_PORT = '53'
def log_error(msg):
- sys.stderr.write("[b10-xfrin] ")
- sys.stderr.write(str(msg))
- sys.stderr.write('\n')
+ sys.stderr.write("[b10-xfrin] %s\n" % str(msg))
class XfrinException(Exception):
pass
@@ -319,9 +317,7 @@ class XfrinConnection(asyncore.dispatcher):
def log_msg(self, msg):
if self._verbose:
- sys.stdout.write('[b10-xfrin] ')
- sys.stdout.write(str(msg))
- sys.stdout.write('\n')
+ sys.stdout.write('[b10-xfrin] %s\n' % str(msg))
def process_xfrin(xfrin_recorder, zone_name, rrclass, db_file,
diff --git a/src/bin/xfrout/xfrout.py.in b/src/bin/xfrout/xfrout.py.in
index 9f6e72918f..af1506ec69 100644
--- a/src/bin/xfrout/xfrout.py.in
+++ b/src/bin/xfrout/xfrout.py.in
@@ -176,7 +176,7 @@ class XfroutSession(BaseRequestHandler):
self.log_msg("transfer of '%s/IN': AXFR end" % zone_name)
except Exception as err:
if verbose_mode:
- sys.stderr.write(str(err))
+ sys.stderr.write("[b10-xfrout] %s\n" % str(err))
self.server.decrease_transfers_counter()
return
diff --git a/src/lib/cc/session.cc b/src/lib/cc/session.cc
index 5ee6409b6f..66bc2717ab 100644
--- a/src/lib/cc/session.cc
+++ b/src/lib/cc/session.cc
@@ -321,7 +321,6 @@ Session::establish(const char* socket_file) {
recvmsg(routing, msg, false);
impl_->lname_ = msg->get("lname")->stringValue();
- cout << "My local name is: " << impl_->lname_ << endl;
// At this point there's no risk of resource leak.
session_holder.clear();
diff --git a/src/lib/python/isc/config/config_data.py b/src/lib/python/isc/config/config_data.py
index 47dad26329..f18980158c 100644
--- a/src/lib/python/isc/config/config_data.py
+++ b/src/lib/python/isc/config/config_data.py
@@ -427,7 +427,6 @@ class MultiConfigData:
else:
entry['default'] = False
result.append(entry)
- #print(spec)
return result
def set_value(self, identifier, value):