Ticket #242: bind10_trac242.patch

File bind10_trac242.patch, 4.5 KB (added by jelte, 9 years ago)
  • src/lib/python/isc/config/ccsession.py

     
    150150
    151151        self._remote_module_configs = {}
    152152
     153    def __del__(self):
     154        for module_name in self._remote_module_configs:
     155            self._session.group_unsubscribe(module_name)
     156
    153157    def start(self):
    154158        """Send the specification for this module to the configuration
    155159           manager, and request the current non-default configuration.
     
    244248        self._session.group_subscribe(module_name);
    245249
    246250        # Get the current config for that module now
    247         seq = self._session.group_sendmsg({ "command": [ "get_config", { "module_name": module_name } ] }, "ConfigManager")
     251        seq = self._session.group_sendmsg(create_command(COMMAND_GET_CONFIG, { "module_name": module_name }), "ConfigManager")
    248252        answer, env = self._session.group_recvmsg(False, seq)
    249253        if answer:
    250254            rcode, value = parse_answer(answer)
     
    259263    def remove_remote_config(self, module_name):
    260264        """Removes the remote configuration access for this module"""
    261265        if module_name in self._remote_module_configs:
     266            self._session.group_unsubscribe(module_name)
    262267            del self._remote_module_configs[module_name]
    263268
    264269    def get_remote_config_value(self, module_name, identifier):
     
    280285    def __request_config(self):
    281286        """Asks the configuration manager for the current configuration, and call the config handler if set.
    282287           Raises a ModuleCCSessionError if there is no answer from the configuration manager"""
    283         seq = self._session.group_sendmsg({ "command": [ "get_config", { "module_name": self._module_name } ] }, "ConfigManager")
     288        seq = self._session.group_sendmsg(create_command(COMMAND_GET_CONFIG, { "module_name": self._module_name }), "ConfigManager")
    284289        answer, env = self._session.group_recvmsg(False, seq)
    285290        if answer:
    286291            rcode, value = parse_answer(answer)
  • src/lib/python/isc/config/tests/ccsession_test.py

     
    352352
    353353        self.assertRaises(ModuleCCSessionError, mccs.get_remote_config_value, "Spec2", "item1")
    354354
     355        self.assertFalse("Spec2" in fake_session.subscriptions)
    355356        rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
     357        self.assertTrue("Spec2" in fake_session.subscriptions)
    356358        self.assertEqual("Spec2", rmodname)
    357359        self.assertRaises(isc.cc.data.DataNotFoundError, mccs.get_remote_config_value, rmodname, "asdf")
    358360        value, default = mccs.get_remote_config_value(rmodname, "item1")
     
    360362        self.assertEqual(True, default)
    361363
    362364        mccs.remove_remote_config(rmodname)
     365        self.assertFalse("Spec2" in fake_session.subscriptions)
    363366        self.assertRaises(ModuleCCSessionError, mccs.get_remote_config_value, "Spec2", "item1")
     367
     368        # test if unsubscription is alse sent when object is deleted
     369        rmodname = mccs.add_remote_config(self.spec_file("spec2.spec"))
     370        self.assertTrue("Spec2" in fake_session.subscriptions)
     371        mccs = None
     372        self.assertFalse("Spec2" in fake_session.subscriptions)
     373       
    364374   
    365375class fakeUIConn():
    366376    def __init__(self):
  • src/lib/python/isc/config/tests/unittest_fakesession.py

     
    1616        if instance_name:
    1717            self.subscriptions[group_name].append(instance_name)
    1818           
     19    def group_unsubscribe(self, group_name, instance_name = None):
     20        if group_name in self.subscriptions:
     21            if instance_name:
     22                if len(self.subscriptions[group_name]) > 1:
     23                    del self.subscriptions[group_name][instance_name]
     24                else:
     25                    del self.subscriptions[group_name]
     26            else:
     27                del self.subscriptions[group_name]
     28           
    1929
    2030    def has_subscription(self, group_name, instance_name = None):
    2131        if group_name in self.subscriptions: