|
@@ -32,7 +32,8 @@ import isc.util.cio.socketsession
|
|
|
import isc.server_common.tsig_keyring
|
|
|
from isc.server_common.dns_tcp import DNSTCPContext
|
|
|
from isc.datasrc import DataSourceClient
|
|
|
-from isc.server_common.auth_command import auth_loadzone_command
|
|
|
+from isc.server_common.auth_command import AUTH_LOADZONE_COMMAND, \
|
|
|
+ auth_loadzone_params
|
|
|
import select
|
|
|
import time
|
|
|
import errno
|
|
@@ -544,42 +545,38 @@ class DDNSServer:
|
|
|
def __notify_start_forwarder(self):
|
|
|
'''Notify auth that DDNS Update messages can now be forwarded'''
|
|
|
try:
|
|
|
- seq = self._cc._session.group_sendmsg(create_command(
|
|
|
- "start_ddns_forwarder"), AUTH_MODULE_NAME)
|
|
|
- answer, _ = self._cc._session.group_recvmsg(False, seq)
|
|
|
- rcode, error_msg = parse_answer(answer)
|
|
|
- if rcode != 0:
|
|
|
- logger.error(DDNS_START_FORWARDER_ERROR, error_msg)
|
|
|
- except (SessionTimeout, SessionError, ProtocolError) as ex:
|
|
|
+ self._cc.rpc_call("start_ddns_forwarder", AUTH_MODULE_NAME)
|
|
|
+ except (SessionTimeout, SessionError, ProtocolError,
|
|
|
+ RPCRecipientMissing) as ex:
|
|
|
logger.error(DDNS_START_FORWARDER_FAIL, ex)
|
|
|
+ except RPCError as e:
|
|
|
+ logger.error(DDNS_START_FORWARDER_ERROR, e)
|
|
|
|
|
|
def __notify_stop_forwarder(self):
|
|
|
'''Notify auth that DDNS Update messages should no longer be forwarded.
|
|
|
|
|
|
'''
|
|
|
try:
|
|
|
- seq = self._cc._session.group_sendmsg(create_command(
|
|
|
- "stop_ddns_forwarder"), AUTH_MODULE_NAME)
|
|
|
- answer, _ = self._cc._session.group_recvmsg(False, seq)
|
|
|
- rcode, error_msg = parse_answer(answer)
|
|
|
- if rcode != 0:
|
|
|
- logger.error(DDNS_STOP_FORWARDER_ERROR, error_msg)
|
|
|
- except (SessionTimeout, SessionError, ProtocolError) as ex:
|
|
|
+ self._cc.rpc_call("stop_ddns_forwarder", AUTH_MODULE_NAME)
|
|
|
+ except (SessionTimeout, SessionError, ProtocolError,
|
|
|
+ RPCRecipientMissing) as ex:
|
|
|
logger.error(DDNS_STOP_FORWARDER_FAIL, ex)
|
|
|
+ except RPCError as e:
|
|
|
+ logger.error(DDNS_STOP_FORWARDER_ERROR, e)
|
|
|
|
|
|
def __notify_auth(self, zname, zclass):
|
|
|
'''Notify auth of the update, if necessary.'''
|
|
|
- msg = auth_loadzone_command(self._cc, zname, zclass)
|
|
|
- if msg is not None:
|
|
|
- self.__notify_update(AUTH_MODULE_NAME, msg, zname, zclass)
|
|
|
+ self.__notify_update(AUTH_MODULE_NAME, AUTH_LOADZONE_COMMAND,
|
|
|
+ auth_loadzone_params(zname, zclass), zname,
|
|
|
+ zclass)
|
|
|
|
|
|
def __notify_xfrout(self, zname, zclass):
|
|
|
'''Notify xfrout of the update.'''
|
|
|
param = {'zone_name': zname.to_text(), 'zone_class': zclass.to_text()}
|
|
|
- msg = create_command('notify', param)
|
|
|
- self.__notify_update(XFROUT_MODULE_NAME, msg, zname, zclass)
|
|
|
+ self.__notify_update(XFROUT_MODULE_NAME, 'notify', param, zname,
|
|
|
+ zclass)
|
|
|
|
|
|
- def __notify_update(self, modname, msg, zname, zclass):
|
|
|
+ def __notify_update(self, modname, command, params, zname, zclass):
|
|
|
'''Notify other module of the update.
|
|
|
|
|
|
Note that we use blocking communication here. While the internal
|
|
@@ -590,27 +587,17 @@ class DDNSServer:
|
|
|
For a longer term we'll need to switch to asynchronous communication,
|
|
|
but for now we rely on the blocking operation.
|
|
|
|
|
|
- Note also that we directly refer to the "protected" member of
|
|
|
- ccsession (_cc._session) rather than creating a separate channel.
|
|
|
- It's probably not the best practice, but hopefully we can introduce
|
|
|
- a cleaner way when we support asynchronous communication.
|
|
|
- At the moment we prefer the brevity with the use of internal channel
|
|
|
- of the cc session.
|
|
|
-
|
|
|
'''
|
|
|
try:
|
|
|
- seq = self._cc._session.group_sendmsg(msg, modname)
|
|
|
- answer, _ = self._cc._session.group_recvmsg(False, seq)
|
|
|
- rcode, error_msg = parse_answer(answer)
|
|
|
- except (SessionTimeout, SessionError, ProtocolError) as ex:
|
|
|
- rcode = 1
|
|
|
- error_msg = str(ex)
|
|
|
- if rcode == 0:
|
|
|
+ # FIXME? Is really rpc_call the correct one? What if there are more
|
|
|
+ # than one recipient of the given kind? What if none? We need to
|
|
|
+ # think of some kind of notification/broadcast mechanism.
|
|
|
+ self._cc.rpc_call(command, modname, params=params)
|
|
|
logger.debug(TRACE_BASIC, DDNS_UPDATE_NOTIFY, modname,
|
|
|
ZoneFormatter(zname, zclass))
|
|
|
- else:
|
|
|
+ except (SessionTimeout, SessionError, ProtocolError, RPCError) as ex:
|
|
|
logger.error(DDNS_UPDATE_NOTIFY_FAIL, modname,
|
|
|
- ZoneFormatter(zname, zclass), error_msg)
|
|
|
+ ZoneFormatter(zname, zclass), ex)
|
|
|
|
|
|
def handle_session(self, fileno):
|
|
|
"""Handle incoming session on the socket with given fileno.
|