Commit f1488332 authored by Petr Pudlak's avatar Petr Pudlak
Browse files

Support for a read-only detached copy of the configuration



The detached configuration doesn't do any kind of locking or
communication with WConfd, it just holds a static snapshot of the
configuration.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 95b9e1dd
......@@ -3087,6 +3087,14 @@ class ConfigWriter(object):
"""
return self._ConfigData().HasAnyDiskOfType(dev_type)
@_ConfigSync(shared=1)
def GetDetachedConfig(self):
"""Returns a detached version of a ConfigManager, which represents
a read-only snapshot of the configuration at this particular time.
"""
return DetachedConfig(self._ConfigData())
@_ConfigSync()
def Update(self, target, feedback_fn, ec_id=None):
"""Notify function to be called after updates.
......@@ -3424,3 +3432,22 @@ class ConfigWriter(object):
"""
if not self._offline:
self._wconfd.FlushConfig()
class DetachedConfig(ConfigWriter):
def __init__(self, config_data):
super(DetachedConfig, self).__init__(self, offline=True)
self._SetConfigData(config_data)
@staticmethod
def _WriteCallError():
raise errors.ProgrammerError("DetachedConfig supports only read-only"
" operations")
def _OpenConfig(self, shared):
if not shared:
DetachedConfig._WriteCallError()
def _CloseConfig(self, save):
if save:
DetachedConfig._WriteCallError()
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