Commit 9d00b71c authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2676] Convert ZoneMgr to use the rpc_call

Just a plain conversion.
parent 2b0ef32a
...@@ -41,23 +41,16 @@ TEST_SQLITE3_DBFILE = os.getenv("TESTDATAOBJDIR") + '/initdb.file' ...@@ -41,23 +41,16 @@ TEST_SQLITE3_DBFILE = os.getenv("TESTDATAOBJDIR") + '/initdb.file'
class ZonemgrTestException(Exception): class ZonemgrTestException(Exception):
pass pass
class MySession():
def __init__(self):
pass
def group_sendmsg(self, msg, module_name):
if module_name not in ("Auth", "Xfrin"):
raise ZonemgrTestException("module name not exist")
def group_recvmsg(self, nonblock, seq):
return None, None
class FakeCCSession(isc.config.ConfigData, MockModuleCCSession): class FakeCCSession(isc.config.ConfigData, MockModuleCCSession):
def __init__(self): def __init__(self):
module_spec = isc.config.module_spec_from_file(SPECFILE_LOCATION) module_spec = isc.config.module_spec_from_file(SPECFILE_LOCATION)
ConfigData.__init__(self, module_spec) ConfigData.__init__(self, module_spec)
MockModuleCCSession.__init__(self) MockModuleCCSession.__init__(self)
def rpc_call(self, command, module, instance="*", to="*", params=None):
if module not in ("Auth", "Xfrin"):
raise ZonemgrTestException("module name not exist")
def get_remote_config_value(self, module_name, identifier): def get_remote_config_value(self, module_name, identifier):
if module_name == "Auth" and identifier == "database_file": if module_name == "Auth" and identifier == "database_file":
return TEST_SQLITE3_DBFILE, False return TEST_SQLITE3_DBFILE, False
...@@ -84,7 +77,7 @@ class MyZonemgrRefresh(ZonemgrRefresh): ...@@ -84,7 +77,7 @@ class MyZonemgrRefresh(ZonemgrRefresh):
return None return None
sqlite3_ds.get_zone_soa = get_zone_soa sqlite3_ds.get_zone_soa = get_zone_soa
ZonemgrRefresh.__init__(self, MySession(), TEST_SQLITE3_DBFILE, ZonemgrRefresh.__init__(self, None, TEST_SQLITE3_DBFILE,
self._slave_socket, FakeCCSession()) self._slave_socket, FakeCCSession())
current_time = time.time() current_time = time.time()
self._zonemgr_refresh_info = { self._zonemgr_refresh_info = {
...@@ -619,7 +612,6 @@ class MyZonemgr(Zonemgr): ...@@ -619,7 +612,6 @@ class MyZonemgr(Zonemgr):
self._db_file = TEST_SQLITE3_DBFILE self._db_file = TEST_SQLITE3_DBFILE
self._zone_refresh = None self._zone_refresh = None
self._shutdown_event = threading.Event() self._shutdown_event = threading.Event()
self._cc = MySession()
self._module_cc = FakeCCSession() self._module_cc = FakeCCSession()
self._config_data = { self._config_data = {
"lowerbound_refresh" : 10, "lowerbound_refresh" : 10,
......
...@@ -105,6 +105,7 @@ class ZonemgrRefresh: ...@@ -105,6 +105,7 @@ class ZonemgrRefresh:
def __init__(self, cc, db_file, slave_socket, module_cc_session): def __init__(self, cc, db_file, slave_socket, module_cc_session):
self._cc = cc self._cc = cc
self._mccs = module_cc_session
self._check_sock = slave_socket self._check_sock = slave_socket
self._db_file = db_file self._db_file = db_file
self._zonemgr_refresh_info = {} self._zonemgr_refresh_info = {}
...@@ -277,15 +278,12 @@ class ZonemgrRefresh: ...@@ -277,15 +278,12 @@ class ZonemgrRefresh:
def _send_command(self, module_name, command_name, params): def _send_command(self, module_name, command_name, params):
"""Send command between modules.""" """Send command between modules."""
msg = create_command(command_name, params)
try: try:
seq = self._cc.group_sendmsg(msg, module_name) self._mccs.rpc_call(command_name, module_name, params=params)
try: except socket.error: # FIXME: WTF?
answer, env = self._cc.group_recvmsg(False, seq)
except isc.cc.session.SessionTimeout:
pass # for now we just ignore the failure
except socket.error:
logger.error(ZONEMGR_SEND_FAIL, module_name) logger.error(ZONEMGR_SEND_FAIL, module_name)
except (isc.cc.session.SessionTimeout, isc.config.RPCError):
pass # for now we just ignore the failure
def _find_need_do_refresh_zone(self): def _find_need_do_refresh_zone(self):
"""Find the first zone need do refresh, if no zone need """Find the first zone need do refresh, if no zone need
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment