From: Naoki Kambe Date: Thu, 19 Jul 2012 09:12:24 +0000 (+0900) Subject: [2136] added update of 'poll-interval' X-Git-Tag: trac2351_base~112^2~52 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=397d4b7bd07b56f73b5d627dc0982efdf246385c;p=thirdparty%2Fkea.git [2136] added update of 'poll-interval' --- diff --git a/src/bin/stats/stats.py.in b/src/bin/stats/stats.py.in index 431b856255..6ccacbc57e 100755 --- a/src/bin/stats/stats.py.in +++ b/src/bin/stats/stats.py.in @@ -144,6 +144,7 @@ class Stats: self.callbacks[name] = Callback(command=callback, kwargs=kwargs) except AttributeError: raise StatsError(STATS_UNKNOWN_COMMAND_IN_SPEC, cmd["command_name"]) + self.config = {} self.mccs.start() # setup my config self.config = dict([ @@ -203,7 +204,11 @@ class Stats: """ logger.debug(DBG_STATS_MESSAGING, STATS_RECEIVED_NEW_CONFIG, new_config) - # do nothing currently + # update to new config + if new_config and type(new_config) is dict: + # backup old config + self.old_config = self.config.copy() + self.config.update(new_config) return isc.config.create_answer(0) def command_handler(self, command, kwargs): diff --git a/src/bin/stats/tests/b10-stats_test.py b/src/bin/stats/tests/b10-stats_test.py index 8ea09ac5a8..bec05cf8c9 100644 --- a/src/bin/stats/tests/b10-stats_test.py +++ b/src/bin/stats/tests/b10-stats_test.py @@ -1,4 +1,4 @@ -# Copyright (C) 2010, 2011 Internet Systems Consortium. +# Copyright (C) 2010, 2011, 2012 Internet Systems Consortium. # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -227,9 +227,11 @@ class TestStats(unittest.TestCase): self.stats_server = ThreadingServerManager(MyStats) self.stats = self.stats_server.server self.stats_server.run() - # config_handler - self.assertEqual(self.stats.config_handler({'foo':'bar'}), + # test updating poll-interval + self.assertEqual(self.stats.config['poll-interval'], 60) + self.assertEqual(self.stats.config_handler({'poll-interval': 120}), isc.config.create_answer(0)) + self.assertEqual(self.stats.config['poll-interval'], 120) # command_handler self.base.boss.server._started.wait()