reset for pathconfig
This commit is contained in:
parent
b27d283341
commit
4f4ecfd3a8
|
@ -746,7 +746,7 @@ def test_meta_reset():
|
||||||
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
||||||
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
meta.option('ip_admin_eth0.ip_admin_eth0').value.reset(children=True)
|
meta.value.reset('ip_admin_eth0.ip_admin_eth0')
|
||||||
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
|
|
@ -746,7 +746,7 @@ def test_meta_reset():
|
||||||
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
||||||
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
meta.option('ip_admin_eth0.ip_admin_eth0').value.reset(children=True)
|
meta.value.reset('ip_admin_eth0.ip_admin_eth0')
|
||||||
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
@ -986,11 +986,12 @@ def test_path_different_default():
|
||||||
path = PathConfig(interface3, [path], session_id='subpath2')
|
path = PathConfig(interface3, [path], session_id='subpath2')
|
||||||
path = PathConfig(interface4, [path])
|
path = PathConfig(interface4, [path])
|
||||||
path.property.read_write()
|
path.property.read_write()
|
||||||
path.value.dict() == {'ip_admin_eth0': ['192.168.1.6']}
|
#
|
||||||
path.config('subpath2').value.dict() == {'ip_admin_eth0': ['192.168.1.4'], 'ip_admin_eth1': ['192.168.1.5']}
|
assert path.value.dict() == {'ip_admin_eth0': ['192.168.1.6']}
|
||||||
path.config('subpath2.subpath1').value.dict() == {'ip_admin_eth1': ['192.168.1.3']}
|
assert path.config('subpath2').value.dict() == {'ip_admin_eth0': ['192.168.1.4'], 'ip_admin_eth1': ['192.168.1.5']}
|
||||||
path.config('subpath2.subpath1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.2']}
|
assert path.config('subpath2.subpath1').value.dict() == {'ip_admin_eth1': ['192.168.1.3']}
|
||||||
path.config('subpath2.subpath1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
assert path.config('subpath2.subpath1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.2']}
|
||||||
|
assert path.config('subpath2.subpath1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
#
|
#
|
||||||
path.option('ip_admin_eth0').value.set(['192.168.1.7'])
|
path.option('ip_admin_eth0').value.set(['192.168.1.7'])
|
||||||
assert path.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
assert path.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
@ -1061,3 +1062,51 @@ def test_path_different_default():
|
||||||
assert path.config('subpath2.subpath1').value.dict() == {'ip_admin_eth1': ['192.168.1.11']}
|
assert path.config('subpath2.subpath1').value.dict() == {'ip_admin_eth1': ['192.168.1.11']}
|
||||||
assert path.config('subpath2.subpath1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.12']}
|
assert path.config('subpath2.subpath1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.12']}
|
||||||
assert path.config('subpath2.subpath1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.9']}
|
assert path.config('subpath2.subpath1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.9']}
|
||||||
|
|
||||||
|
|
||||||
|
def test_path_different_default_reset():
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
interface0 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth1', "ip", multi=True, default=['192.168.1.2'])
|
||||||
|
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth1', "ip", multi=True, default=['192.168.1.3'])
|
||||||
|
interface2 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.4'])
|
||||||
|
ip_admin_eth1 = NetworkOption('ip_admin_eth1', "ip", multi=True, default=['192.168.1.5'])
|
||||||
|
interface3 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, ip_admin_eth1])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.6'])
|
||||||
|
interface4 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0])
|
||||||
|
conf1 = Config(interface0, session_id='conf1')
|
||||||
|
conf1.property.read_write()
|
||||||
|
conf2 = Config(interface1, session_id='conf2')
|
||||||
|
conf2.property.read_write()
|
||||||
|
path = PathConfig(interface2, [conf1, conf2], session_id='subpath1')
|
||||||
|
path = PathConfig(interface3, [path], session_id='subpath2')
|
||||||
|
path = PathConfig(interface4, [path])
|
||||||
|
path.property.read_write()
|
||||||
|
#
|
||||||
|
path.option('ip_admin_eth0').value.set(['192.168.1.7'])
|
||||||
|
path.config('subpath2').option('ip_admin_eth0').value.set(['192.168.1.8'])
|
||||||
|
path.config('subpath2').option('ip_admin_eth1').value.set(['192.168.1.10'])
|
||||||
|
path.config('subpath2.subpath1').option('ip_admin_eth1').value.set(['192.168.1.11'])
|
||||||
|
path.config('subpath2.subpath1.conf2').option('ip_admin_eth1').value.set(['192.168.1.12'])
|
||||||
|
path.config('subpath2.subpath1.conf1').option('ip_admin_eth0').value.set(['192.168.1.9'])
|
||||||
|
assert path.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
assert path.config('subpath2').value.dict() == {'ip_admin_eth0': ['192.168.1.8'], 'ip_admin_eth1': ['192.168.1.10']}
|
||||||
|
assert path.config('subpath2.subpath1').value.dict() == {'ip_admin_eth1': ['192.168.1.11']}
|
||||||
|
assert path.config('subpath2.subpath1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.12']}
|
||||||
|
assert path.config('subpath2.subpath1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.9']}
|
||||||
|
#
|
||||||
|
path.value.reset('ip_admin_eth0')
|
||||||
|
assert path.value.dict() == {'ip_admin_eth0': ['192.168.1.6']}
|
||||||
|
assert path.config('subpath2').value.dict() == {'ip_admin_eth0': ['192.168.1.4'], 'ip_admin_eth1': ['192.168.1.10']}
|
||||||
|
assert path.config('subpath2.subpath1').value.dict() == {'ip_admin_eth1': ['192.168.1.11']}
|
||||||
|
assert path.config('subpath2.subpath1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.12']}
|
||||||
|
assert path.config('subpath2.subpath1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
#
|
||||||
|
path.value.reset('ip_admin_eth1')
|
||||||
|
assert path.value.dict() == {'ip_admin_eth0': ['192.168.1.6']}
|
||||||
|
assert path.config('subpath2').value.dict() == {'ip_admin_eth0': ['192.168.1.4'], 'ip_admin_eth1': ['192.168.1.5']}
|
||||||
|
assert path.config('subpath2.subpath1').value.dict() == {'ip_admin_eth1': ['192.168.1.3']}
|
||||||
|
assert path.config('subpath2.subpath1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.2']}
|
||||||
|
assert path.config('subpath2.subpath1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
|
|
@ -36,6 +36,7 @@ def test_delete_not_persisten():
|
||||||
o = OptionDescription('od', '', [b])
|
o = OptionDescription('od', '', [b])
|
||||||
try:
|
try:
|
||||||
Config(o, session_id='test_persistent', persistent=True)
|
Config(o, session_id='test_persistent', persistent=True)
|
||||||
|
delete_session('test_persistent')
|
||||||
except:
|
except:
|
||||||
c = Config(o, session_id='not_test_persistent')
|
c = Config(o, session_id='not_test_persistent')
|
||||||
assert 'not_test_persistent' in list_sessions()
|
assert 'not_test_persistent' in list_sessions()
|
||||||
|
|
|
@ -451,20 +451,6 @@ class _TiramisuOptionValueMaster:
|
||||||
return self._length
|
return self._length
|
||||||
|
|
||||||
|
|
||||||
class _TiramisuOptionValueMeta:
|
|
||||||
def reset(self,
|
|
||||||
itself: bool=True,
|
|
||||||
children: bool=False):
|
|
||||||
"""Reset value"""
|
|
||||||
if children:
|
|
||||||
config_bag = self._option_bag.config_bag
|
|
||||||
config_bag.context.reset(self._option_bag.path,
|
|
||||||
config_bag)
|
|
||||||
if itself:
|
|
||||||
self._test_slave_index()
|
|
||||||
self._subconfig.delattr(self._option_bag)
|
|
||||||
|
|
||||||
|
|
||||||
class _TiramisuOptionValueGroup:
|
class _TiramisuOptionValueGroup:
|
||||||
def reset(self):
|
def reset(self):
|
||||||
"""Reset value"""
|
"""Reset value"""
|
||||||
|
@ -537,9 +523,6 @@ class TiramisuOptionValue(CommonTiramisuOption):
|
||||||
types.append(_TiramisuOptionValueMaster)
|
types.append(_TiramisuOptionValueMaster)
|
||||||
elif option.impl_is_master_slaves('slave'):
|
elif option.impl_is_master_slaves('slave'):
|
||||||
types.append(_TiramisuOptionValueSlave)
|
types.append(_TiramisuOptionValueSlave)
|
||||||
if option_bag.config_bag.context.impl_type in ('meta', 'path'):
|
|
||||||
# only if not an optiondescription
|
|
||||||
types.insert(0, _TiramisuOptionValueMeta)
|
|
||||||
if option_bag.config_bag.context.impl_type == 'group':
|
if option_bag.config_bag.context.impl_type == 'group':
|
||||||
types.append(_TiramisuOptionValueGroup)
|
types.append(_TiramisuOptionValueGroup)
|
||||||
new_type_dict = {'_allow_optiondescription': cls._allow_optiondescription,
|
new_type_dict = {'_allow_optiondescription': cls._allow_optiondescription,
|
||||||
|
@ -800,6 +783,14 @@ class TiramisuContextValue(TiramisuContext):
|
||||||
self._config_bag,
|
self._config_bag,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
|
def reset(self,
|
||||||
|
path: str,
|
||||||
|
only_children: bool=False):
|
||||||
|
"""Reset value"""
|
||||||
|
self._config_bag.context.reset(path,
|
||||||
|
only_children,
|
||||||
|
self._config_bag)
|
||||||
|
|
||||||
def dict(self,
|
def dict(self,
|
||||||
flatten=False,
|
flatten=False,
|
||||||
withvalue=undefined,
|
withvalue=undefined,
|
||||||
|
|
|
@ -244,15 +244,18 @@ class SubConfig(object):
|
||||||
_commit)
|
_commit)
|
||||||
|
|
||||||
def delattr(self,
|
def delattr(self,
|
||||||
option_bag):
|
option_bag,
|
||||||
|
_commit=True):
|
||||||
option = option_bag.option
|
option = option_bag.option
|
||||||
if option.impl_is_symlinkoption():
|
if option.impl_is_symlinkoption():
|
||||||
raise TypeError(_("can't delete a SymLinkOption"))
|
raise TypeError(_("can't delete a SymLinkOption"))
|
||||||
values = self.cfgimpl_get_values()
|
values = self.cfgimpl_get_values()
|
||||||
if option_bag.index is not None:
|
if option_bag.index is not None:
|
||||||
values.reset_slave(option_bag)
|
values.reset_slave(option_bag,
|
||||||
|
_commit)
|
||||||
else:
|
else:
|
||||||
values.reset(option_bag)
|
values.reset(option_bag,
|
||||||
|
_commit)
|
||||||
|
|
||||||
def _get_subpath(self, name):
|
def _get_subpath(self, name):
|
||||||
if self._impl_path is None:
|
if self._impl_path is None:
|
||||||
|
@ -827,9 +830,10 @@ class KernelGroupConfig(_CommonConfig):
|
||||||
"""
|
"""
|
||||||
ret = []
|
ret = []
|
||||||
if self.impl_type == 'group':
|
if self.impl_type == 'group':
|
||||||
|
# No value so cannot commit only one time
|
||||||
commit = True
|
commit = True
|
||||||
else:
|
else:
|
||||||
#Commit only one time
|
# Commit only one time
|
||||||
commit = False
|
commit = False
|
||||||
for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
cconfig_bag = config_bag.copy()
|
cconfig_bag = config_bag.copy()
|
||||||
|
@ -928,7 +932,8 @@ class KernelGroupConfig(_CommonConfig):
|
||||||
return self._impl_name
|
return self._impl_name
|
||||||
|
|
||||||
def reset(self,
|
def reset(self,
|
||||||
path):
|
path,
|
||||||
|
_commit=True):
|
||||||
for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
config_bag = ConfigBag(child)
|
config_bag = ConfigBag(child)
|
||||||
config_bag.remove_validation()
|
config_bag.remove_validation()
|
||||||
|
@ -944,7 +949,7 @@ class KernelGroupConfig(_CommonConfig):
|
||||||
config_bag)
|
config_bag)
|
||||||
option_bag.config_bag.context = child
|
option_bag.config_bag.context = child
|
||||||
child.cfgimpl_get_values().reset(option_bag,
|
child.cfgimpl_get_values().reset(option_bag,
|
||||||
_commit=True)
|
_commit=_commit)
|
||||||
|
|
||||||
def getconfig(self,
|
def getconfig(self,
|
||||||
name):
|
name):
|
||||||
|
@ -1015,23 +1020,37 @@ class KernelPathConfig(KernelGroupConfig):
|
||||||
only_config=only_config,
|
only_config=only_config,
|
||||||
_commit=_commit)
|
_commit=_commit)
|
||||||
ret = []
|
ret = []
|
||||||
|
subconfig, name = self.cfgimpl_get_home_by_path(path,
|
||||||
|
config_bag)
|
||||||
|
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||||
|
config_bag,
|
||||||
|
self.cfgimpl_get_path())
|
||||||
|
option_bag = OptionBag()
|
||||||
|
option_bag.set_option(option,
|
||||||
|
path,
|
||||||
|
index,
|
||||||
|
config_bag)
|
||||||
if force_default or force_default_if_same or force_dont_change_value:
|
if force_default or force_default_if_same or force_dont_change_value:
|
||||||
if force_default and force_dont_change_value:
|
if force_default and force_dont_change_value:
|
||||||
raise ValueError(_('force_default and force_dont_change_value'
|
raise ValueError(_('force_default and force_dont_change_value'
|
||||||
' cannot be set together'))
|
' cannot be set together'))
|
||||||
#opt = self.cfgimpl_get_description().impl_get_opt_by_path(path,
|
|
||||||
# config_bag)
|
|
||||||
for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
cconfig_bag = config_bag.copy()
|
cconfig_bag = config_bag.copy()
|
||||||
cconfig_bag.context = child
|
cconfig_bag.context = child
|
||||||
try:
|
try:
|
||||||
|
if self.impl_type == 'meta':
|
||||||
|
moption_bag = option_bag
|
||||||
|
del moption_bag.properties
|
||||||
|
del moption_bag.permissives
|
||||||
|
moption_bag.config_bag = cconfig_bag
|
||||||
|
else:
|
||||||
subconfig, name = child.cfgimpl_get_home_by_path(path,
|
subconfig, name = child.cfgimpl_get_home_by_path(path,
|
||||||
cconfig_bag)
|
cconfig_bag)
|
||||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||||
cconfig_bag,
|
cconfig_bag,
|
||||||
child.cfgimpl_get_path())
|
child.cfgimpl_get_path())
|
||||||
option_bag = OptionBag()
|
moption_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
moption_bag.set_option(option,
|
||||||
path,
|
path,
|
||||||
index,
|
index,
|
||||||
cconfig_bag)
|
cconfig_bag)
|
||||||
|
@ -1040,17 +1059,17 @@ class KernelPathConfig(KernelGroupConfig):
|
||||||
child_value = undefined
|
child_value = undefined
|
||||||
else:
|
else:
|
||||||
child_value = child.getattr(name,
|
child_value = child.getattr(name,
|
||||||
option_bag)
|
moption_bag)
|
||||||
if force_default or (force_default_if_same and value == child_value):
|
if force_default or (force_default_if_same and value == child_value):
|
||||||
child.cfgimpl_get_values().reset(option_bag,
|
child.cfgimpl_get_values().reset(moption_bag,
|
||||||
_commit=False)
|
_commit=False)
|
||||||
continue
|
continue
|
||||||
if force_dont_change_value:
|
if force_dont_change_value:
|
||||||
child_value = child.getattr(name,
|
child_value = child.getattr(name,
|
||||||
option_bag)
|
moption_bag)
|
||||||
if value != child_value:
|
if value != child_value:
|
||||||
child.setattr(child_value,
|
child.setattr(child_value,
|
||||||
option_bag,
|
moption_bag,
|
||||||
_commit=False)
|
_commit=False)
|
||||||
except PropertiesOptionError as err:
|
except PropertiesOptionError as err:
|
||||||
ret.append(PropertiesOptionError(err._option_bag,
|
ret.append(PropertiesOptionError(err._option_bag,
|
||||||
|
@ -1064,16 +1083,10 @@ class KernelPathConfig(KernelGroupConfig):
|
||||||
ret.append(err)
|
ret.append(err)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subconfig, name = self.cfgimpl_get_home_by_path(path,
|
if self.impl_type == 'meta':
|
||||||
config_bag)
|
del option_bag.properties
|
||||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
del option_bag.permissives
|
||||||
config_bag,
|
option_bag.config_bag = config_bag
|
||||||
self.cfgimpl_get_path())
|
|
||||||
option_bag = OptionBag()
|
|
||||||
option_bag.set_option(option,
|
|
||||||
path,
|
|
||||||
index,
|
|
||||||
config_bag)
|
|
||||||
self.setattr(value,
|
self.setattr(value,
|
||||||
option_bag,
|
option_bag,
|
||||||
_commit=False)
|
_commit=False)
|
||||||
|
@ -1083,9 +1096,12 @@ class KernelPathConfig(KernelGroupConfig):
|
||||||
|
|
||||||
def reset(self,
|
def reset(self,
|
||||||
path,
|
path,
|
||||||
config_bag):
|
only_children,
|
||||||
|
config_bag,
|
||||||
|
commit=True):
|
||||||
rconfig_bag = config_bag.copy()
|
rconfig_bag = config_bag.copy()
|
||||||
rconfig_bag.remove_validation()
|
rconfig_bag.remove_validation()
|
||||||
|
if self.impl_type == 'meta':
|
||||||
subconfig, name = self.cfgimpl_get_home_by_path(path,
|
subconfig, name = self.cfgimpl_get_home_by_path(path,
|
||||||
config_bag)
|
config_bag)
|
||||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||||
|
@ -1094,11 +1110,54 @@ class KernelPathConfig(KernelGroupConfig):
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
path,
|
path,
|
||||||
option,
|
None,
|
||||||
rconfig_bag)
|
rconfig_bag)
|
||||||
|
elif not only_children:
|
||||||
|
try:
|
||||||
|
subconfig, name = self.cfgimpl_get_home_by_path(path,
|
||||||
|
config_bag)
|
||||||
|
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||||
|
config_bag,
|
||||||
|
subconfig.cfgimpl_get_path())
|
||||||
|
option_bag = OptionBag()
|
||||||
|
option_bag.set_option(option,
|
||||||
|
path,
|
||||||
|
None,
|
||||||
|
rconfig_bag)
|
||||||
|
except AttributeError:
|
||||||
|
only_children = True
|
||||||
for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
option_bag.config_bag.context = child
|
rconfig_bag.context = child
|
||||||
child.cfgimpl_get_values().reset(option_bag)
|
try:
|
||||||
|
if self.impl_type == 'meta':
|
||||||
|
moption_bag = option_bag
|
||||||
|
moption_bag.config_bag = rconfig_bag
|
||||||
|
else:
|
||||||
|
subconfig, name = child.cfgimpl_get_home_by_path(path,
|
||||||
|
rconfig_bag)
|
||||||
|
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||||
|
rconfig_bag,
|
||||||
|
child.cfgimpl_get_path())
|
||||||
|
moption_bag = OptionBag()
|
||||||
|
moption_bag.set_option(option,
|
||||||
|
path,
|
||||||
|
None,
|
||||||
|
rconfig_bag)
|
||||||
|
child.cfgimpl_get_values().reset(moption_bag,
|
||||||
|
_commit=False)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
if isinstance(child, KernelPathConfig):
|
||||||
|
child.reset(path,
|
||||||
|
False,
|
||||||
|
rconfig_bag,
|
||||||
|
commit=False)
|
||||||
|
if not only_children:
|
||||||
|
option_bag.config_bag = config_bag
|
||||||
|
self.cfgimpl_get_values().reset(option_bag,
|
||||||
|
_commit=False)
|
||||||
|
if commit:
|
||||||
|
self.cfgimpl_get_values()._p_.commit()
|
||||||
|
|
||||||
|
|
||||||
class KernelMetaConfig(KernelPathConfig):
|
class KernelMetaConfig(KernelPathConfig):
|
||||||
|
|
|
@ -169,7 +169,8 @@ class MasterSlaves(OptionDescription):
|
||||||
validate_meta=False):
|
validate_meta=False):
|
||||||
if slavelen > index:
|
if slavelen > index:
|
||||||
values._p_.resetvalue_index(slave_path,
|
values._p_.resetvalue_index(slave_path,
|
||||||
index)
|
index,
|
||||||
|
True)
|
||||||
if slavelen > index + 1:
|
if slavelen > index + 1:
|
||||||
for idx in range(index + 1, slavelen):
|
for idx in range(index + 1, slavelen):
|
||||||
if values._p_.hasvalue(slave_path, idx):
|
if values._p_.hasvalue(slave_path, idx):
|
||||||
|
|
|
@ -156,7 +156,7 @@ class OptionBag:
|
||||||
raise KeyError('unknown key {} for OptionBag'.format(key)) # pragma: no cover
|
raise KeyError('unknown key {} for OptionBag'.format(key)) # pragma: no cover
|
||||||
|
|
||||||
def __delattr__(self, key):
|
def __delattr__(self, key):
|
||||||
if key == 'properties':
|
if key in ['properties', 'permissives']:
|
||||||
return
|
return
|
||||||
raise KeyError('unknown key {} for ConfigBag'.format(key)) # pragma: no cover
|
raise KeyError('unknown key {} for ConfigBag'.format(key)) # pragma: no cover
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,10 @@ class Values(Cache):
|
||||||
values[1] = tuple(values_idx)
|
values[1] = tuple(values_idx)
|
||||||
self._values = tuple(values)
|
self._values = tuple(values)
|
||||||
|
|
||||||
def resetvalue_index(self, path, index):
|
def resetvalue_index(self,
|
||||||
|
path,
|
||||||
|
index,
|
||||||
|
commit):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print('resetvalue_index', path, index, id(self))
|
print('resetvalue_index', path, index, id(self))
|
||||||
def _resetvalue(nb):
|
def _resetvalue(nb):
|
||||||
|
|
|
@ -445,13 +445,11 @@ class Values(object):
|
||||||
else:
|
else:
|
||||||
self._p_.resetvalue(option_bag.path,
|
self._p_.resetvalue(option_bag.path,
|
||||||
_commit)
|
_commit)
|
||||||
if not opt.impl_is_master_slaves('master'):
|
|
||||||
# if master, already reset behind
|
|
||||||
pass
|
|
||||||
context.cfgimpl_reset_cache(option_bag)
|
context.cfgimpl_reset_cache(option_bag)
|
||||||
|
|
||||||
def reset_slave(self,
|
def reset_slave(self,
|
||||||
option_bag):
|
option_bag,
|
||||||
|
_commit=True):
|
||||||
|
|
||||||
if self._p_.hasvalue(option_bag.path, index=option_bag.index):
|
if self._p_.hasvalue(option_bag.path, index=option_bag.index):
|
||||||
context = option_bag.config_bag.context
|
context = option_bag.config_bag.context
|
||||||
|
@ -467,7 +465,9 @@ class Values(object):
|
||||||
value = fake_value.getdefaultvalue(soption_bag)
|
value = fake_value.getdefaultvalue(soption_bag)
|
||||||
fake_value.setvalue_validation(value,
|
fake_value.setvalue_validation(value,
|
||||||
soption_bag)
|
soption_bag)
|
||||||
self._p_.resetvalue_index(option_bag.path, option_bag.index)
|
self._p_.resetvalue_index(option_bag.path,
|
||||||
|
option_bag.index,
|
||||||
|
_commit)
|
||||||
context.cfgimpl_reset_cache(option_bag)
|
context.cfgimpl_reset_cache(option_bag)
|
||||||
|
|
||||||
def reset_master(self,
|
def reset_master(self,
|
||||||
|
|
Loading…
Reference in New Issue