Parcourir la source

[2136] added update of 'poll-interval'

Naoki Kambe il y a 12 ans
Parent
commit
397d4b7bd0
2 fichiers modifiés avec 11 ajouts et 4 suppressions
  1. 6 1
      src/bin/stats/stats.py.in
  2. 5 3
      src/bin/stats/tests/b10-stats_test.py

+ 6 - 1
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):

+ 5 - 3
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()