DBG_PROCESS = logger.DBGLVL_TRACE_BASIC
DBG_COMMANDS = logger.DBGLVL_TRACE_DETAIL
-# Messages sent over the unix domain socket to indicate if it is followed by a real socket
+# Messages sent over the unix domain socket to indicate if it is followed by a
+# real socket
CREATOR_SOCKET_OK = b"1\n"
CREATOR_SOCKET_UNAVAILABLE = b"0\n"
verbose=False, nokill=False, setuid=None, setgid=None,
username=None, cmdctl_port=None, wait_time=10):
"""
- Initialize the Init of BIND. This is a singleton (only one can run).
+ Initialize the Init of BIND. This is a singleton (only one can
+ run).
The msgq_socket_file specifies the UNIX domain socket file that the
msgq process listens on. If verbose is True, then b10-init reports
self.component_config = {}
# Some time in future, it may happen that a single component has
# multple processes (like a pipeline-like component). If so happens,
- # name "components" may be inappropriate. But as the code isn't probably
- # completely ready for it, we leave it at components for now. We also
- # want to support multiple instances of a single component. If it turns
- # out that we'll have a single component with multiple same processes
- # or if we start multiple components with the same configuration (we do
- # this now, but it might change) is an open question.
+ # name "components" may be inappropriate. But as the code isn't
+ # probably completely ready for it, we leave it at components for
+ # now. We also want to support multiple instances of a single
+ # component. If it turns out that we'll have a single component with
+ # multiple same processes or if we start multiple components with the
+ # same configuration (we do this now, but it might change) is an open
+ # question.
self.components = {}
# Simply list of components that died and need to wait for a
# restart. Components manage their own restart schedule now
def command_handler(self, command, args):
logger.debug(DBG_COMMANDS, BIND10_RECEIVED_COMMAND, command)
- answer = isc.config.ccsession.create_answer(1, "command not implemented")
+ answer = isc.config.ccsession.create_answer(1,
+ "command not implemented")
if type(command) != str:
answer = isc.config.ccsession.create_answer(1, "bad command")
else:
if pid is None:
logger.debug(DBG_PROCESS, BIND10_STARTED_PROCESS, self.curproc)
else:
- logger.debug(DBG_PROCESS, BIND10_STARTED_PROCESS_PID, self.curproc, pid)
+ logger.debug(DBG_PROCESS, BIND10_STARTED_PROCESS_PID, self.curproc,
+ pid)
def process_running(self, msg, who):
"""
if msgq_proc.process:
msgq_proc.process.kill()
logger.error(BIND10_CONNECTING_TO_CC_FAIL)
- raise CChannelConnectError("Unable to connect to c-channel after 5 seconds")
+ raise CChannelConnectError("Unable to connect to c-channel " +
+ "after 5 seconds")
# try to connect, and if we can't wait a short while
try:
except isc.cc.session.SessionError:
time.sleep(0.1)
- # Subscribe to the message queue. The only messages we expect to receive
- # on this channel are once relating to process startup.
+ # Subscribe to the message queue. The only messages we expect to
+ # receive on this channel are once relating to process startup.
if self.cc_session is not None:
self.cc_session.group_subscribe("Init")
def wait_msgq(self):
"""
- Wait for the message queue to fully start. It does so only after the
- config manager connects to it. We know it is ready when it starts
- answering commands.
+ Wait for the message queue to fully start. It does so only after
+ the config manager connects to it. We know it is ready when it
+ starts answering commands.
We don't add a specific command for it here, an error response is
as good as positive one to know it is alive.
while time_remaining > 0 and retry:
try:
self.ccs.rpc_call('AreYouThere?', 'Msgq')
- # We don't expect this to succeed. If it does, it's programmer error
+ # We don't expect this to succeed. If it does, it's programmer
+ # error
raise Exception("Non-existing RPC call succeeded")
except isc.config.RPCRecipientMissing:
retry = True # Not there yet
# time to wait can be set on the command line.
time_remaining = self.wait_time
msg, env = self.cc_session.group_recvmsg()
- while time_remaining > 0 and not self.process_running(msg, "ConfigManager"):
+ while time_remaining > 0 and not self.process_running(msg,
+ "ConfigManager"):
logger.debug(DBG_PROCESS, BIND10_WAIT_CFGMGR)
time.sleep(1)
time_remaining = time_remaining - 1
msg, env = self.cc_session.group_recvmsg()
if not self.process_running(msg, "ConfigManager"):
- raise ProcessStartError("Configuration manager process has not started")
+ raise ProcessStartError("Configuration manager process has not " +
+ "started")
return bind_cfgd
# A couple of utility methods for starting processes...
- def start_process(self, name, args, c_channel_env, port=None, address=None):
+ def start_process(self, name, args, c_channel_env, port=None,
+ address=None):
"""
Given a set of command arguments, start the process and output
appropriate log messages. If the start is successful, the process
# The next few methods start up the rest of the BIND-10 processes.
# Although many of these methods are little more than a call to
- # start_simple, they are retained (a) for testing reasons and (b) as a place
- # where modifications can be made if the process start-up sequence changes
- # for a given process.
+ # start_simple, they are retained (a) for testing reasons and (b) as a
+ # place where modifications can be made if the process start-up sequence
+ # changes for a given process.
def start_auth(self):
"""
try:
self.cc_session = isc.cc.Session(self.msgq_socket_file)
logger.fatal(BIND10_MSGQ_ALREADY_RUNNING)
- return "b10-msgq already running, or socket file not cleaned , cannot start"
+ return "b10-msgq already running, or socket file not cleaned , " +\
+ "cannot start"
except isc.cc.session.SessionError:
# this is the case we want, where the msgq is not running
pass
def set_creator(self, creator):
"""
- Registeres a socket creator into the b10-init. The socket creator is not
- used directly, but through a cache. The cache is created in this
+ Registeres a socket creator into the b10-init. The socket creator is
+ not used directly, but through a cache. The cache is created in this
method.
If called more than once, it raises a ValueError.
parser = Parser(version=VERSION)
parser.add_option("-m", "--msgq-socket-file", dest="msgq_socket_file",
type="string", default=None,
- help="UNIX domain socket file the b10-msgq daemon will use")
+ help="UNIX domain socket file the b10-msgq daemon " +
+ "will use")
parser.add_option("-i", "--no-kill", action="store_true", dest="nokill",
- default=False, help="do not send SIGTERM and SIGKILL signals to modules during shutdown")
+ default=False,
+ help="do not send SIGTERM and SIGKILL signals to " +
+ "modules during shutdown")
parser.add_option("-u", "--user", dest="user", type="string", default=None,
help="Change user after startup (must run as root)")
parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
default=None,
help="file to dump the PID of the BIND 10 process")
parser.add_option("-w", "--wait", dest="wait_time", type="int",
- default=10, help="Time (in seconds) to wait for config manager to start up")
+ default=10,
+ help="Time (in seconds) to wait for config manager to "
+ "start up")
(options, args) = parser.parse_args(args)