Commit def088d4 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[trac810] Provide a notification on virtual config

The notification is used even when the config is not checked by remote
config. So we send it out in case of virtual module as well, but don't
wait for the answer.
parent 4578fa11
......@@ -322,12 +322,19 @@ class ConfigManager:
data.merge(conf_part[module_name], cmd)
use_part = conf_part[module_name]
# The command to send
update_cmd = ccsession.create_command(ccsession.COMMAND_CONFIG_UPDATE,
if module_name in self.virtual_modules:
# The module is virtual, so call it to get the answer
error = self.virtual_modules[module_name](use_part)
if error is None:
answer = ccsession.create_answer(0)
# OK, it is successful, send the notify, but don't wait
# for answer
seq =, module_name)
answer = ccsession.create_answer(1, error)
# Make sure just a validating plugin don't kill the whole manager
......@@ -336,9 +343,7 @@ class ConfigManager:
answer = ccsession.create_answer(1, "Exception: " + str(excp))
# Real module, send it over the wire to it
# send out changed info
update_cmd = ccsession.create_command(
ccsession.COMMAND_CONFIG_UPDATE, use_part)
# send out changed info and wait for answer
seq =, module_name)
# replace 'our' answer with that of the module
......@@ -353,9 +353,8 @@ class TestConfigManager(unittest.TestCase):
# Register our virtual module, check_test)
# The fake session will throw now if it is touched, as there's no
# message or answer ready. Handy, we don't need any code about it
# to check explicitly.
# The fake session will throw now if it tries to read a response.
# Handy, we don't need to find a complicated way to check for it.
result =
{'item1': value})
......@@ -363,6 +362,17 @@ class TestConfigManager(unittest.TestCase):
# With correct data
self.assertEqual(self.called_with['item1'], value)
self.assertEqual(result, {'result': expectedResult})
if expectedResult[0] == 0:
# Check it provided the correct notification
self.assertEqual(len(self.fake_session.message_queue), 1)
self.assertEqual({'command': [ 'config_update',
{'item1': value}]},
self.fake_session.get_message('Spec2', None))
# and the queue should now be empty again
self.assertEqual(len(self.fake_session.message_queue), 0)
# It shouldn't send anything on error
self.assertEqual(len(self.fake_session.message_queue), 0)
# Success
single_test(5, lambda: None, [0])
Markdown is supported
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