PathConfig => MixConfig
This commit is contained in:
parent
4f4ecfd3a8
commit
f83937a143
|
@ -0,0 +1,1112 @@
|
||||||
|
from .autopath import do_autopath
|
||||||
|
do_autopath()
|
||||||
|
|
||||||
|
from py.test import raises
|
||||||
|
|
||||||
|
from tiramisu.setting import groups, owners
|
||||||
|
from tiramisu import IntOption, StrOption, NetworkOption, NetmaskOption, \
|
||||||
|
OptionDescription, MasterSlaves, Config, GroupConfig, MixConfig, \
|
||||||
|
Params, ParamOption, ParamValue
|
||||||
|
from tiramisu.error import ConfigError, ConflictError, PropertiesOptionError, SlaveError, APIError
|
||||||
|
from tiramisu.storage import list_sessions
|
||||||
|
|
||||||
|
owners.addowner('mix1')
|
||||||
|
owners.addowner('mix2')
|
||||||
|
|
||||||
|
|
||||||
|
def teardown_function(function):
|
||||||
|
assert list_sessions() == [], 'session list is not empty when leaving "{}"'.format(function.__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def return_value(value=None):
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def raise_exception():
|
||||||
|
raise Exception('test')
|
||||||
|
|
||||||
|
|
||||||
|
def make_description():
|
||||||
|
i1 = IntOption('i1', '')
|
||||||
|
i2 = IntOption('i2', '', default=1)
|
||||||
|
i3 = IntOption('i3', '')
|
||||||
|
i4 = IntOption('i4', '', default=2)
|
||||||
|
i5 = IntOption('i5', '', default=[2], multi=True)
|
||||||
|
i6 = IntOption('i6', '', properties=('disabled',))
|
||||||
|
od1 = OptionDescription('od1', '', [i1, i2, i3, i4, i5, i6])
|
||||||
|
od2 = OptionDescription('od2', '', [od1])
|
||||||
|
return od2
|
||||||
|
|
||||||
|
|
||||||
|
def make_description1():
|
||||||
|
i1 = IntOption('i1', '')
|
||||||
|
i2 = IntOption('i2', '', default=1)
|
||||||
|
i3 = IntOption('i3', '')
|
||||||
|
i4 = IntOption('i4', '', default=2)
|
||||||
|
i5 = IntOption('i5', '', default=[2], multi=True)
|
||||||
|
i6 = IntOption('i6', '', properties=('disabled',))
|
||||||
|
od1 = OptionDescription('od1', '', [i1, i2, i3, i4, i5, i6])
|
||||||
|
od2 = OptionDescription('od2', '', [od1])
|
||||||
|
return od2
|
||||||
|
|
||||||
|
|
||||||
|
def make_description2():
|
||||||
|
i1 = IntOption('i1', '')
|
||||||
|
i2 = IntOption('i2', '', default=1)
|
||||||
|
i3 = IntOption('i3', '')
|
||||||
|
i4 = IntOption('i4', '', default=2)
|
||||||
|
i5 = IntOption('i5', '', default=[2], multi=True)
|
||||||
|
i6 = IntOption('i6', '', properties=('disabled',))
|
||||||
|
od1 = OptionDescription('od1', '', [i1, i2, i3, i4, i5, i6])
|
||||||
|
od2 = OptionDescription('od2', '', [od1])
|
||||||
|
return od2
|
||||||
|
|
||||||
|
|
||||||
|
def make_description3():
|
||||||
|
i1 = IntOption('i1', '')
|
||||||
|
i2 = IntOption('i2', '', default=1)
|
||||||
|
i3 = IntOption('i3', '')
|
||||||
|
i4 = IntOption('i4', '', default=2)
|
||||||
|
i5 = IntOption('i5', '', default=[2], multi=True)
|
||||||
|
i6 = IntOption('i6', '', properties=('disabled',))
|
||||||
|
od1 = OptionDescription('od1', '', [i1, i2, i3, i4, i5, i6])
|
||||||
|
od2 = OptionDescription('od2', '', [od1])
|
||||||
|
return od2
|
||||||
|
|
||||||
|
|
||||||
|
def make_mixconfig(double=False):
|
||||||
|
od1 = make_description()
|
||||||
|
od2 = make_description1()
|
||||||
|
od3 = make_description2()
|
||||||
|
conf1 = Config(od1, session_id='conf1')
|
||||||
|
conf2 = Config(od2, session_id='conf2')
|
||||||
|
mix = MixConfig(od3, [conf1, conf2], session_id='mix')
|
||||||
|
if double:
|
||||||
|
od4 = make_description3()
|
||||||
|
mix.owner.set(owners.mix2)
|
||||||
|
mix = MixConfig(od4, [mix], session_id='doublemix')
|
||||||
|
mix.property.read_write()
|
||||||
|
mix.owner.set(owners.mix1)
|
||||||
|
return mix
|
||||||
|
|
||||||
|
|
||||||
|
def test_unknown_config():
|
||||||
|
mix = make_mixconfig()
|
||||||
|
raises(ConfigError, "mix.config('unknown')")
|
||||||
|
|
||||||
|
|
||||||
|
def test_none():
|
||||||
|
mix = make_mixconfig()
|
||||||
|
assert mix.option('od1.i3').value.get() is mix.config('conf1').option('od1.i3').value.get() is mix.config('conf2').option('od1.i3').value.get() is None
|
||||||
|
assert mix.option('od1.i3').owner.get() is mix.config('conf1').option('od1.i3').owner.get() is mix.config('conf2').option('od1.i3').owner.get() is owners.default
|
||||||
|
#
|
||||||
|
mix.option('od1.i3').value.set(3)
|
||||||
|
assert mix.option('od1.i3').value.get() == mix.config('conf1').option('od1.i3').value.get() == mix.config('conf2').option('od1.i3').value.get() == 3
|
||||||
|
assert mix.option('od1.i3').owner.get() is mix.config('conf1').option('od1.i3').owner.get() is mix.config('conf2').option('od1.i3').owner.get() is owners.mix1
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('od1.i3').value.set(2)
|
||||||
|
assert mix.option('od1.i3').value.get() == mix.config('conf2').option('od1.i3').value.get() == 3
|
||||||
|
assert mix.config('conf1').option('od1.i3').value.get() == 2
|
||||||
|
assert mix.option('od1.i3').owner.get() is mix.config('conf2').option('od1.i3').owner.get() is owners.mix1
|
||||||
|
assert mix.config('conf1').option('od1.i3').owner.get() is owners.user
|
||||||
|
#
|
||||||
|
mix.option('od1.i3').value.set(4)
|
||||||
|
assert mix.option('od1.i3').value.get() == mix.config('conf2').option('od1.i3').value.get() == 4
|
||||||
|
assert mix.config('conf1').option('od1.i3').value.get() == 2
|
||||||
|
assert mix.option('od1.i3').owner.get() is mix.config('conf2').option('od1.i3').owner.get() is owners.mix1
|
||||||
|
assert mix.config('conf1').option('od1.i3').owner.get() is owners.user
|
||||||
|
#
|
||||||
|
mix.option('od1.i3').value.reset()
|
||||||
|
assert mix.option('od1.i3').value.get() is mix.config('conf2').option('od1.i3').value.get() is None
|
||||||
|
assert mix.config('conf1').option('od1.i3').value.get() == 2
|
||||||
|
assert mix.option('od1.i3').owner.get() is mix.config('conf2').option('od1.i3').owner.get() is owners.default
|
||||||
|
assert mix.config('conf1').option('od1.i3').owner.get() is owners.user
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('od1.i3').value.reset()
|
||||||
|
assert mix.option('od1.i3').value.get() is mix.config('conf1').option('od1.i3').value.get() is mix.config('conf2').option('od1.i3').value.get() is None
|
||||||
|
assert mix.option('od1.i3').owner.get() is mix.config('conf1').option('od1.i3').owner.get() is mix.config('conf2').option('od1.i3').owner.get() is owners.default
|
||||||
|
#
|
||||||
|
assert mix.config(None).config.name() == mix.config.name()
|
||||||
|
|
||||||
|
|
||||||
|
def test_reset():
|
||||||
|
mix = make_mixconfig()
|
||||||
|
assert mix.option('od1.i2').value.get() == 1
|
||||||
|
mix.option('od1.i2').value.set(2)
|
||||||
|
mix.config('conf1').option('od1.i2').value.set(3)
|
||||||
|
assert mix.option('od1.i2').value.get() == 2
|
||||||
|
assert mix.config('conf1').option('od1.i2').value.get() == 3
|
||||||
|
assert mix.config('conf2').option('od1.i2').value.get() == 2
|
||||||
|
mix.config.reset()
|
||||||
|
assert mix.option('od1.i2').value.get() == 1
|
||||||
|
assert mix.config('conf1').option('od1.i2').value.get() == 3
|
||||||
|
assert mix.config('conf2').option('od1.i2').value.get() == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_default():
|
||||||
|
mix = make_mixconfig()
|
||||||
|
assert mix.option('od1.i2').value.get() == mix.config('conf1').option('od1.i2').value.get() == mix.config('conf2').option('od1.i2').value.get() == 1
|
||||||
|
assert mix.option('od1.i2').owner.get() is mix.config('conf1').option('od1.i2').owner.get() is mix.config('conf2').option('od1.i2').owner.get() is owners.default
|
||||||
|
#
|
||||||
|
mix.option('od1.i2').value.set(3)
|
||||||
|
assert mix.option('od1.i2').value.get() == mix.config('conf1').option('od1.i2').value.get() == mix.config('conf2').option('od1.i2').value.get() == 3
|
||||||
|
assert mix.option('od1.i2').owner.get() is mix.config('conf1').option('od1.i2').owner.get() is mix.config('conf2').option('od1.i2').owner.get() is owners.mix1
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('od1.i2').value.set(2)
|
||||||
|
assert mix.option('od1.i2').value.get() == mix.config('conf2').option('od1.i2').value.get() == 3
|
||||||
|
assert mix.config('conf1').option('od1.i2').value.get() == 2
|
||||||
|
assert mix.option('od1.i2').owner.get() is mix.config('conf2').option('od1.i2').owner.get() is owners.mix1
|
||||||
|
assert mix.config('conf1').option('od1.i2').owner.get() is owners.user
|
||||||
|
#
|
||||||
|
mix.option('od1.i2').value.set(4)
|
||||||
|
assert mix.option('od1.i2').value.get() == mix.config('conf2').option('od1.i2').value.get() == 4
|
||||||
|
assert mix.config('conf1').option('od1.i2').value.get() == 2
|
||||||
|
assert mix.option('od1.i2').owner.get() is mix.config('conf2').option('od1.i2').owner.get() is owners.mix1
|
||||||
|
assert mix.config('conf1').option('od1.i2').owner.get() is owners.user
|
||||||
|
#
|
||||||
|
mix.option('od1.i2').value.reset()
|
||||||
|
assert mix.option('od1.i2').value.get() == mix.config('conf2').option('od1.i2').value.get() == 1
|
||||||
|
assert mix.config('conf1').option('od1.i2').value.get() == 2
|
||||||
|
assert mix.option('od1.i2').owner.get() is mix.config('conf2').option('od1.i2').owner.get() is owners.default
|
||||||
|
assert mix.config('conf1').option('od1.i2').owner.get() is owners.user
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('od1.i2').value.reset()
|
||||||
|
assert mix.option('od1.i2').value.get() == mix.config('conf1').option('od1.i2').value.get() == mix.config('conf2').option('od1.i2').value.get() == 1
|
||||||
|
assert mix.option('od1.i2').owner.get() is mix.config('conf1').option('od1.i2').owner.get() is mix.config('conf2').option('od1.i2').owner.get() is owners.default
|
||||||
|
|
||||||
|
|
||||||
|
def test_contexts():
|
||||||
|
mix = make_mixconfig()
|
||||||
|
errors = mix.value.set('od1.i2', 6, only_config=True)
|
||||||
|
assert mix.option('od1.i2').value.get() == 1
|
||||||
|
assert mix.option('od1.i2').owner.get() == owners.default
|
||||||
|
assert mix.config('conf1').option('od1.i2').value.get() == mix.config('conf1').option('od1.i2').value.get() == 6
|
||||||
|
assert mix.config('conf1').option('od1.i2').owner.get() == mix.config('conf1').option('od1.i2').owner.get() is owners.user
|
||||||
|
assert len(errors) == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_find():
|
||||||
|
mix = make_mixconfig()
|
||||||
|
ret = list(mix.option.find('i2'))
|
||||||
|
assert len(ret) == 1
|
||||||
|
assert 1 == ret[0].value.get()
|
||||||
|
assert 1 == mix.option.find('i2', first=True).value.get()
|
||||||
|
assert mix.value.dict() == {'od1.i4': 2, 'od1.i1': None, 'od1.i3': None,
|
||||||
|
'od1.i2': 1, 'od1.i5': [2]}
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_mix():
|
||||||
|
mix = make_mixconfig(double=True)
|
||||||
|
assert mix.option('od1.i2').value.get() == mix.config('mix').option('od1.i2').value.get() == mix.config('mix.conf1').option('od1.i2').value.get() == mix.config('mix.conf2').option('od1.i2').value.get() == 1
|
||||||
|
assert mix.option('od1.i2').owner.get() is mix.config('mix').option('od1.i2').owner.get() is mix.config('mix.conf1').option('od1.i2').owner.get() is mix.config('mix.conf2').option('od1.i2').owner.get() is owners.default
|
||||||
|
#
|
||||||
|
mix.option('od1.i2').value.set(3)
|
||||||
|
assert mix.option('od1.i2').value.get() == mix.config('mix').option('od1.i2').value.get() == mix.config('mix.conf1').option('od1.i2').value.get() == mix.config('mix.conf2').option('od1.i2').value.get() == 3
|
||||||
|
assert mix.option('od1.i2').owner.get() is mix.config('mix').option('od1.i2').owner.get() is mix.config('mix.conf1').option('od1.i2').owner.get() is mix.config('mix.conf2').option('od1.i2').owner.get() is owners.mix1
|
||||||
|
#
|
||||||
|
mix.config('mix.conf1').option('od1.i2').value.set(2)
|
||||||
|
assert mix.option('od1.i2').value.get() == mix.config('mix').option('od1.i2').value.get() == mix.config('mix.conf2').option('od1.i2').value.get() == 3
|
||||||
|
assert mix.config('mix.conf1').option('od1.i2').value.get() == 2
|
||||||
|
assert mix.option('od1.i2').owner.get() is mix.config('mix').option('od1.i2').owner.get() is mix.config('mix.conf2').option('od1.i2').owner.get() is owners.mix1
|
||||||
|
assert mix.config('mix.conf1').option('od1.i2').owner.get() is owners.user
|
||||||
|
#
|
||||||
|
mix.config('mix').option('od1.i2').value.set(4)
|
||||||
|
assert mix.option('od1.i2').value.get() == 3
|
||||||
|
assert mix.config('mix').option('od1.i2').value.get() == mix.config('mix.conf2').option('od1.i2').value.get() == 4
|
||||||
|
assert mix.config('mix.conf1').option('od1.i2').value.get() == 2
|
||||||
|
assert mix.option('od1.i2').owner.get() is owners.mix1
|
||||||
|
assert mix.config('mix').option('od1.i2').owner.get() is mix.config('mix.conf2').option('od1.i2').owner.get() is owners.mix2
|
||||||
|
assert mix.config('mix.conf1').option('od1.i2').owner.get() is owners.user
|
||||||
|
#
|
||||||
|
mix.config('mix').option('od1.i2').value.reset()
|
||||||
|
assert mix.option('od1.i2').value.get() == mix.config('mix').option('od1.i2').value.get() == mix.config('mix.conf2').option('od1.i2').value.get() == 3
|
||||||
|
assert mix.config('mix.conf1').option('od1.i2').value.get() == 2
|
||||||
|
assert mix.option('od1.i2').owner.get() is mix.config('mix').option('od1.i2').owner.get() is mix.config('mix.conf2').option('od1.i2').owner.get() is owners.mix1
|
||||||
|
assert mix.config('mix.conf1').option('od1.i2').owner.get() is owners.user
|
||||||
|
#
|
||||||
|
mix.option('od1.i2').value.reset()
|
||||||
|
assert mix.option('od1.i2').value.get() == mix.config('mix').option('od1.i2').value.get() == mix.config('mix.conf2').option('od1.i2').value.get() == 1
|
||||||
|
assert mix.config('mix.conf1').option('od1.i2').value.get() == 2
|
||||||
|
assert mix.option('od1.i2').owner.get() is mix.config('mix').option('od1.i2').owner.get() is mix.config('mix.conf2').option('od1.i2').owner.get() is owners.default
|
||||||
|
assert mix.config('mix.conf1').option('od1.i2').owner.get() is owners.user
|
||||||
|
#
|
||||||
|
mix.config('mix.conf1').option('od1.i2').value.reset()
|
||||||
|
assert mix.option('od1.i2').value.get() == mix.config('mix').option('od1.i2').value.get() == mix.config('mix.conf1').option('od1.i2').value.get() == mix.config('mix.conf2').option('od1.i2').value.get() == 1
|
||||||
|
assert mix.option('od1.i2').owner.get() is mix.config('mix').option('od1.i2').owner.get() is mix.config('mix.conf1').option('od1.i2').owner.get() is mix.config('mix.conf2').option('od1.i2').owner.get() is owners.default
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_mix_set():
|
||||||
|
mix = make_mixconfig(double=True)
|
||||||
|
errors1 = mix.value.set('od1.i1', 7, only_config=True)
|
||||||
|
errors2 = mix.value.set('od1.i6', 7, only_config=True)
|
||||||
|
assert len(errors1) == 0
|
||||||
|
assert len(errors2) == 2
|
||||||
|
conf1 = mix.config('mix.conf1')._config_bag.context
|
||||||
|
conf2 = mix.config('mix.conf2')._config_bag.context
|
||||||
|
assert mix.config('mix.conf1').option('od1.i1').value.get() == mix.config('mix.conf2').option('od1.i1').value.get() == 7
|
||||||
|
#
|
||||||
|
dconfigs = []
|
||||||
|
for conf in mix.config.find('i1', value=7).config.list():
|
||||||
|
dconfigs.append(conf._config_bag.context)
|
||||||
|
assert [conf1, conf2] == dconfigs
|
||||||
|
mix.config('mix.conf1').option('od1.i1').value.set(8)
|
||||||
|
#
|
||||||
|
dconfigs = []
|
||||||
|
for conf in mix.config.find('i1').config.list():
|
||||||
|
dconfigs.append(conf._config_bag.context)
|
||||||
|
assert [conf1, conf2] == dconfigs
|
||||||
|
assert conf2 == list(mix.config.find('i1', value=7).config.list())[0]._config_bag.context
|
||||||
|
assert conf1 == list(mix.config.find('i1', value=8).config.list())[0]._config_bag.context
|
||||||
|
#
|
||||||
|
dconfigs = []
|
||||||
|
for conf in mix.config.find('i5', value=2).config.list():
|
||||||
|
dconfigs.append(conf._config_bag.context)
|
||||||
|
assert [conf1, conf2] == dconfigs
|
||||||
|
#
|
||||||
|
raises(AttributeError, "mix.config.find('i1', value=10)")
|
||||||
|
raises(AttributeError, "mix.config.find('not', value=10)")
|
||||||
|
raises(AttributeError, "mix.config.find('i6')")
|
||||||
|
raises(ValueError, "mix.value.set('od1.i6', 7, only_config=True, force_default=True)")
|
||||||
|
raises(ValueError, "mix.value.set('od1.i6', 7, only_config=True, force_default_if_same=True)")
|
||||||
|
raises(ValueError, "mix.value.set('od1.i6', 7, only_config=True, force_dont_change_value=True)")
|
||||||
|
|
||||||
|
|
||||||
|
def test_not_mix():
|
||||||
|
i1 = IntOption('i1', '')
|
||||||
|
od1 = OptionDescription('od1', '', [i1])
|
||||||
|
od2 = OptionDescription('od2', '', [od1])
|
||||||
|
conf1 = Config(od2, session_id='conf1')
|
||||||
|
conf2 = Config(od2, session_id='conf2')
|
||||||
|
conf3 = Config(od2)
|
||||||
|
conf4 = Config(od2, session_id='conf4')
|
||||||
|
raises(TypeError, "GroupConfig(conf1)")
|
||||||
|
#same name
|
||||||
|
#raises(ConflictError, "GroupConfig([conf2, conf4], session_id='conf2')")
|
||||||
|
raises(ConflictError, "GroupConfig([conf2, conf2], session_id='conf8')")
|
||||||
|
grp = GroupConfig([conf1, conf2])
|
||||||
|
raises(APIError, "grp.option('od1.i1').value.get()")
|
||||||
|
conf1, conf2 = grp.config.list()
|
||||||
|
errors = grp.value.set('od1.i1', 7)
|
||||||
|
assert len(errors) == 0
|
||||||
|
assert grp.config('conf1').option('od1.i1').value.get() == grp.config('conf2').option('od1.i1').value.get() == 7
|
||||||
|
assert grp.config('conf1').option('od1.i1').owner.get() is grp.config('conf2').option('od1.i1').owner.get() is owners.user
|
||||||
|
grp.option('od1.i1').value.reset()
|
||||||
|
assert grp.config('conf1').option('od1.i1').owner.get() is grp.config('conf2').option('od1.i1').owner.get() is owners.default
|
||||||
|
|
||||||
|
|
||||||
|
def test_group_find_firsts():
|
||||||
|
i1 = IntOption('i1', '')
|
||||||
|
od1 = OptionDescription('od1', '', [i1])
|
||||||
|
od2 = OptionDescription('od2', '', [od1])
|
||||||
|
conf1 = Config(od2, session_id='conf1')
|
||||||
|
conf2 = Config(od2, session_id='conf2')
|
||||||
|
grp = GroupConfig([conf1, conf2])
|
||||||
|
itr = grp.config.find('i1').config.list()
|
||||||
|
conf1._config_bag.context == next(itr)._config_bag.context
|
||||||
|
conf2._config_bag.context == next(itr)._config_bag.context
|
||||||
|
try:
|
||||||
|
next(itr)
|
||||||
|
except StopIteration:
|
||||||
|
pass
|
||||||
|
except:
|
||||||
|
raise Exception('no')
|
||||||
|
else:
|
||||||
|
raise Exception('no')
|
||||||
|
|
||||||
|
|
||||||
|
def test_group_group():
|
||||||
|
i1 = IntOption('i1', '')
|
||||||
|
od1 = OptionDescription('od1', '', [i1])
|
||||||
|
od2 = OptionDescription('od2', '', [od1])
|
||||||
|
conf1 = Config(od2, session_id='conf9')
|
||||||
|
conf2 = Config(od2, session_id='conf10')
|
||||||
|
grp = GroupConfig([conf1, conf2], 'grp')
|
||||||
|
grp2 = GroupConfig([grp])
|
||||||
|
errors = grp2.value.set('od1.i1', 2)
|
||||||
|
assert len(errors) == 0
|
||||||
|
assert grp2.config('grp.conf9').option('od1.i1').value.get() == 2
|
||||||
|
assert grp2.config('grp.conf9').option('od1.i1').owner.get() is owners.user
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_unconsistent():
|
||||||
|
i1 = IntOption('i1', '')
|
||||||
|
i2 = IntOption('i2', '', default=1)
|
||||||
|
i3 = IntOption('i3', '')
|
||||||
|
i4 = IntOption('i4', '', default=2)
|
||||||
|
od1 = OptionDescription('od1', '', [i1, i2, i3, i4])
|
||||||
|
od2 = OptionDescription('od2', '', [od1])
|
||||||
|
od3 = OptionDescription('od3', '', [od1])
|
||||||
|
conf1 = Config(od2, session_id='conf1')
|
||||||
|
conf2 = Config(od2, session_id='conf2')
|
||||||
|
conf3 = Config(od2, session_id='conf3')
|
||||||
|
conf4 = Config(od3, session_id='conf4')
|
||||||
|
mix = MixConfig(od2, [conf1, conf2])
|
||||||
|
mix.owner.set(owners.mix1)
|
||||||
|
raises(TypeError, 'MixConfig(od2, "string")')
|
||||||
|
# same descr but conf1 already in mix
|
||||||
|
raises(ValueError, "MixConfig(od2, [conf1, conf3])")
|
||||||
|
# not same descr
|
||||||
|
MixConfig(od2, [conf3, conf4])
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_master_slaves():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od = OptionDescription('root', '', [interface1])
|
||||||
|
conf1 = Config(od, session_id='conf1')
|
||||||
|
conf2 = Config(od, session_id='conf2')
|
||||||
|
mix = MixConfig(od, [conf1, conf2])
|
||||||
|
mix.property.read_only()
|
||||||
|
itr = mix.config.find('ip_admin_eth0').config.list()
|
||||||
|
assert conf1._config_bag.context == next(itr)._config_bag.context
|
||||||
|
assert conf2._config_bag.context == next(itr)._config_bag.context
|
||||||
|
itr = mix.config.find('netmask_admin_eth0').config.list()
|
||||||
|
assert conf1._config_bag.context == next(itr)._config_bag.context
|
||||||
|
assert conf2._config_bag.context == next(itr)._config_bag.context
|
||||||
|
mix.property.read_write()
|
||||||
|
raises(AttributeError, "mix.config.find('netmask_admin_eth0')")
|
||||||
|
itr = mix.unrestraint.config.find('netmask_admin_eth0').config.list()
|
||||||
|
assert conf1._config_bag.context == next(itr)._config_bag.context
|
||||||
|
assert conf2._config_bag.context == next(itr)._config_bag.context
|
||||||
|
mix.property.read_only()
|
||||||
|
itr = mix.config.find('netmask_admin_eth0').config.list()
|
||||||
|
assert conf1._config_bag.context == next(itr)._config_bag.context
|
||||||
|
assert conf2._config_bag.context == next(itr)._config_bag.context
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_master_slaves_value2():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od = OptionDescription('root', '', [interface1])
|
||||||
|
conf1 = Config(od, session_id='conf1')
|
||||||
|
conf2 = Config(od, session_id='conf2')
|
||||||
|
mix = MixConfig(od, [conf1, conf2], session_id="mix")
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.8'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||||
|
#FIXME devrait raise ! assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0', 0).value.get() == None
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
||||||
|
#
|
||||||
|
mix.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||||
|
mix.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.255.0'
|
||||||
|
mix.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.0.0'
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_master_slaves_value_default():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True)
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od = OptionDescription('root', '', [interface1])
|
||||||
|
conf1 = Config(od, session_id='conf1')
|
||||||
|
conf2 = Config(od, session_id='conf2')
|
||||||
|
mix = MixConfig(od, [conf1, conf2])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||||
|
#
|
||||||
|
mix.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||||
|
#
|
||||||
|
mix.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.255.0'
|
||||||
|
#
|
||||||
|
mix.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.0.0'
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_master_slaves_owners():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od = OptionDescription('root', '', [interface1])
|
||||||
|
conf1 = Config(od, session_id='conf1')
|
||||||
|
conf2 = Config(od, session_id='conf2')
|
||||||
|
mix = MixConfig(od, [conf1, conf2])
|
||||||
|
mix.owner.set(owners.mix1)
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||||
|
raises(SlaveError, "mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()")
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.user
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||||
|
#
|
||||||
|
mix.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.mix1
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()
|
||||||
|
#
|
||||||
|
mix.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.mix1
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.mix1
|
||||||
|
#
|
||||||
|
mix.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.mix1
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.mix1
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.user
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.default
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_force_default():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od = OptionDescription('root', '', [interface1])
|
||||||
|
conf1 = Config(od, session_id='conf1')
|
||||||
|
conf2 = Config(od, session_id='conf2')
|
||||||
|
mix = MixConfig(od, [conf1, conf2])
|
||||||
|
mix.property.read_write()
|
||||||
|
mix.owner.set('mix1')
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
#
|
||||||
|
errors = mix.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.1'])
|
||||||
|
assert len(errors) == 0
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
|
#
|
||||||
|
errors = mix.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.3'])
|
||||||
|
assert len(errors) == 0
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
||||||
|
#
|
||||||
|
errors = mix.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default=True)
|
||||||
|
assert len(errors) == 0
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_force_dont_change_value():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od = OptionDescription('root', '', [interface1])
|
||||||
|
conf1 = Config(od, session_id='conf1')
|
||||||
|
conf2 = Config(od, session_id='conf2')
|
||||||
|
mix = MixConfig(od, [conf1, conf2])
|
||||||
|
mix.property.read_write()
|
||||||
|
mix.owner.set('mix1')
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||||
|
errors = mix.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_dont_change_value=True)
|
||||||
|
assert len(errors) == 0
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_force_default_if_same():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od = OptionDescription('root', '', [interface1])
|
||||||
|
conf1 = Config(od, session_id='conf1')
|
||||||
|
conf2 = Config(od, session_id='conf2')
|
||||||
|
mix = MixConfig(od, [conf1, conf2])
|
||||||
|
mix.property.read_write()
|
||||||
|
mix.owner.set('mix1')
|
||||||
|
#
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||||
|
errors = mix.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True)
|
||||||
|
assert len(errors) == 0
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.mix1
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.mix1
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.3'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.mix1
|
||||||
|
errors = mix.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True)
|
||||||
|
assert len(errors) == 0
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.mix1
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_force_default_if_same_and_dont_change():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od = OptionDescription('root', '', [interface1])
|
||||||
|
conf1 = Config(od, session_id='conf1')
|
||||||
|
conf2 = Config(od, session_id='conf2')
|
||||||
|
mix = MixConfig(od, [conf1, conf2])
|
||||||
|
mix.property.read_write()
|
||||||
|
mix.owner.set('mix1')
|
||||||
|
#
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||||
|
errors = mix.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True, force_dont_change_value=True)
|
||||||
|
assert len(errors) == 0
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.mix1
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
#
|
||||||
|
mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.3'])
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
errors = mix.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True, force_dont_change_value=True)
|
||||||
|
assert len(errors) == 0
|
||||||
|
assert mix.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
assert mix.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
assert mix.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_force_default_and_dont_change():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od = OptionDescription('root', '', [interface1])
|
||||||
|
conf1 = Config(od, session_id='rconf1')
|
||||||
|
conf2 = Config(od, session_id='rconf2')
|
||||||
|
mix = MixConfig(od, [conf1, conf2])
|
||||||
|
mix.property.read_write()
|
||||||
|
mix.owner.set('mix1')
|
||||||
|
raises(ValueError, "mix.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default=True, force_dont_change_value=True)")
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_properties_mix():
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
||||||
|
netmask_admin_eth0.impl_add_consistency('network_netmask', ip_admin_eth0)
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od = OptionDescription('root', '', [interface1])
|
||||||
|
conf1 = Config(od, session_id='conf1')
|
||||||
|
conf2 = Config(od, session_id='conf2')
|
||||||
|
conf1.property.read_write()
|
||||||
|
conf2.property.read_write()
|
||||||
|
mix = MixConfig(od, [conf1, conf2])
|
||||||
|
mix.property.read_write()
|
||||||
|
assert mix.config('conf1').value.dict() == {}
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_exception_mix():
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, callback=raise_exception)
|
||||||
|
netmask_admin_eth0.impl_add_consistency('network_netmask', ip_admin_eth0)
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od = OptionDescription('root', '', [interface1])
|
||||||
|
conf1 = Config(od, session_id='conf1')
|
||||||
|
conf2 = Config(od, session_id='conf2')
|
||||||
|
mix = MixConfig(od, [conf1, conf2])
|
||||||
|
mix.property.read_write()
|
||||||
|
raises(Exception, "conf1.make_dict()")
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_callback():
|
||||||
|
val1 = StrOption('val1', "", 'val')
|
||||||
|
val2 = StrOption('val2', "", callback=return_value, callback_params=Params(ParamOption(val1)))
|
||||||
|
val3 = StrOption('val3', "", callback=return_value, callback_params=Params(ParamValue('yes')))
|
||||||
|
val4 = StrOption('val4', "", callback=return_value, callback_params=Params(kwargs={'value': ParamOption(val1)}))
|
||||||
|
val5 = StrOption('val5', "", callback=return_value, callback_params=Params(kwargs={'value': ParamValue('yes')}))
|
||||||
|
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5])
|
||||||
|
cfg = Config(maconfig, session_id='cfg')
|
||||||
|
mix = MixConfig(maconfig, [cfg])
|
||||||
|
mix.property.read_write()
|
||||||
|
assert mix.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'val', 'val1': 'val', 'val5': 'yes', 'val4': 'val'}
|
||||||
|
mix.config('cfg').option('val1').value.set('new')
|
||||||
|
assert mix.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
||||||
|
mix.config('cfg').option('val1').value.reset()
|
||||||
|
mix.option('val1').value.set('new')
|
||||||
|
assert mix.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
||||||
|
mix.config('cfg').option('val4').value.set('new1')
|
||||||
|
assert mix.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
||||||
|
mix.config('cfg').option('val4').value.reset()
|
||||||
|
mix.option('val4').value.set('new1')
|
||||||
|
assert mix.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
||||||
|
mix.option('val4').value.reset()
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_callback_slave():
|
||||||
|
val = StrOption('val', "", default='val')
|
||||||
|
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val)))
|
||||||
|
val3 = StrOption('val2', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)))
|
||||||
|
val4 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)))
|
||||||
|
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||||
|
od = OptionDescription('root', '', [interface1])
|
||||||
|
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||||
|
cfg = Config(maconfig, session_id='cfg1')
|
||||||
|
mix = MixConfig(maconfig, [cfg])
|
||||||
|
mix.property.read_write()
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||||
|
mix.config('cfg1').option('val').value.set('val1')
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
||||||
|
mix.config('cfg1').option('val').value.reset()
|
||||||
|
mix.option('val').value.set('val1')
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
||||||
|
mix.option('val').value.reset()
|
||||||
|
mix.config('cfg1').option('val1.val2', 0).value.set('val2')
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||||
|
mix.config('cfg1').option('val1.val2', 0).value.reset()
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||||
|
mix.option('val1.val2', 0).value.set('val2')
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||||
|
mix.config('cfg1').option('val1.val3', 0).value.set('val6')
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val6'], 'val': 'val'}
|
||||||
|
mix.option('val1.val2', 0).value.reset()
|
||||||
|
mix.config('cfg1').option('val1.val3', 0).value.reset()
|
||||||
|
mix.config('cfg1').option('val1.val1').value.set(['val3'])
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||||
|
mix.config('cfg1').option('val1.val1').value.reset()
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||||
|
mix.option('val1.val1').value.set(['val3'])
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||||
|
mix.config('cfg1').option('val1.val2', 0).value.set('val2')
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||||
|
mix.option('val1.val1').value.set(['val3', 'rah'])
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
||||||
|
mix.option('val1.val1').value.pop(1)
|
||||||
|
mix.option('val1.val1').value.set(['val4'])
|
||||||
|
assert mix.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val4'], 'val1.val3': ['val4'], 'val': 'val'}
|
||||||
|
|
||||||
|
|
||||||
|
def test_meta_reset():
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od0 = OptionDescription('root', '', [interface1])
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od1 = OptionDescription('root', '', [interface1])
|
||||||
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||||
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||||
|
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
od2 = OptionDescription('root', '', [interface1])
|
||||||
|
conf1 = Config(od0, session_id='conf1')
|
||||||
|
conf2 = Config(od1, session_id='conf2')
|
||||||
|
meta = MixConfig(od2, [conf1, conf2])
|
||||||
|
meta.property.read_write()
|
||||||
|
meta.owner.set('mix1')
|
||||||
|
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('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.1'])
|
||||||
|
assert len(errors) == 0
|
||||||
|
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.1']
|
||||||
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
||||||
|
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('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||||
|
meta.value.reset('ip_admin_eth0.ip_admin_eth0')
|
||||||
|
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('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_properties_mix_copy():
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
||||||
|
interface0 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
||||||
|
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
||||||
|
interface2 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
conf1 = Config(interface0, session_id='conf1')
|
||||||
|
conf2 = Config(interface1, session_id='conf2')
|
||||||
|
conf1.property.read_write()
|
||||||
|
conf2.property.read_write()
|
||||||
|
mix = MixConfig(interface2, [conf1, conf2], session_id='mix1')
|
||||||
|
mix.property.read_write()
|
||||||
|
|
||||||
|
conf3 = mix.config('conf1').config.copy(session_id='conf3')
|
||||||
|
mix2 = conf3.config.metaconfig()
|
||||||
|
assert mix.config.name() == mix2.config.name()
|
||||||
|
|
||||||
|
assert mix.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
assert mix.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
assert mix.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
mix.option('ip_admin_eth0').value.set(['192.168.1.2'])
|
||||||
|
assert mix.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
||||||
|
assert mix.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
||||||
|
assert mix.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
||||||
|
ret = mix.value.set('ip_admin_eth0', ['192.168.1.3'], force_default_if_same=True)
|
||||||
|
assert mix.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
||||||
|
assert mix.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
||||||
|
assert mix.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_properties_mix_deepcopy():
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True,
|
||||||
|
properties=('disabled',))
|
||||||
|
interface0 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True,
|
||||||
|
properties=('disabled',))
|
||||||
|
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True,
|
||||||
|
properties=('disabled',))
|
||||||
|
interface2 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
conf1 = Config(interface0, session_id='conf1')
|
||||||
|
conf2 = Config(interface1, session_id='conf2')
|
||||||
|
conf1.property.read_write()
|
||||||
|
conf2.property.read_write()
|
||||||
|
mix = MixConfig(interface2, [conf1, conf2])
|
||||||
|
mix.permissive.set(frozenset({'hidden'}))
|
||||||
|
mix.property.read_write()
|
||||||
|
|
||||||
|
mix2 = mix.config('conf1').config.deepcopy(session_id='conf3')
|
||||||
|
assert mix != mix2
|
||||||
|
assert mix.permissive.get() == mix2.permissive.get()
|
||||||
|
|
||||||
|
assert mix.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
assert mix.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
assert mix2.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
mix.option('ip_admin_eth0').value.set(['192.168.1.2'])
|
||||||
|
assert mix.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
||||||
|
assert mix.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
||||||
|
assert mix2.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
mix.value.set('ip_admin_eth0', ['192.168.1.3'], force_default_if_same=True)
|
||||||
|
assert mix.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
||||||
|
assert mix.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
||||||
|
assert mix2.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_properties_submix_deepcopy():
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True,
|
||||||
|
properties=('disabled',))
|
||||||
|
interface0 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True,
|
||||||
|
properties=('disabled',))
|
||||||
|
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True,
|
||||||
|
properties=('disabled',))
|
||||||
|
interface2 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
conf1 = Config(interface0, session_id='conf1')
|
||||||
|
conf1.property.read_write()
|
||||||
|
mix1 = MixConfig(interface1, [conf1], session_id='mix1')
|
||||||
|
mix2 = MixConfig(interface2, [mix1], session_id='mix2')
|
||||||
|
mix_copy = conf1.config.deepcopy(session_id='conf2',
|
||||||
|
metaconfig_prefix='copy_')
|
||||||
|
assert mix_copy.config.name() == 'copy_mix2'
|
||||||
|
assert mix_copy.config('copy_mix1').config.name() == 'copy_mix1'
|
||||||
|
assert mix_copy.config('copy_mix1').config('conf2').config.name() == 'conf2'
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_properties_submix_deepcopy_owner():
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip")
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth1', "mask")
|
||||||
|
interface0 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth1', "ip")
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask")
|
||||||
|
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip")
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask")
|
||||||
|
interface2 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
conf1 = Config(interface0, session_id='conf1')
|
||||||
|
conf1.owner.set('conf1_user')
|
||||||
|
conf1.property.read_write()
|
||||||
|
mix1 = MixConfig(interface1, [conf1], session_id='mix1')
|
||||||
|
mix1.owner.set('mix1_user')
|
||||||
|
mix2 = MixConfig(interface2, [mix1], session_id='mix2')
|
||||||
|
mix2.owner.set('mix2_user')
|
||||||
|
#
|
||||||
|
conf1.option('ip_admin_eth0').value.set('192.168.0.1')
|
||||||
|
assert conf1.option('ip_admin_eth0').owner.get() == 'conf1_user'
|
||||||
|
mix2.option('ip_admin_eth0').value.set('192.168.0.3')
|
||||||
|
assert mix2.option('ip_admin_eth0').owner.get() == 'mix2_user'
|
||||||
|
#
|
||||||
|
mix2_copy = conf1.config.deepcopy(session_id='conf2',
|
||||||
|
metaconfig_prefix='copy_')
|
||||||
|
mix2_copy.option('netmask_admin_eth0').value.set('255.255.255.255')
|
||||||
|
assert mix2_copy.option('ip_admin_eth0').value.get() == '192.168.0.3'
|
||||||
|
assert mix2_copy.option('ip_admin_eth0').owner.get() == 'mix2_user'
|
||||||
|
assert mix2_copy.option('netmask_admin_eth0').owner.get() == 'mix2_user'
|
||||||
|
#
|
||||||
|
mix1_copy = mix2_copy.config('copy_mix1')
|
||||||
|
mix1_copy.option('netmask_admin_eth0').value.set('255.255.255.255')
|
||||||
|
#
|
||||||
|
conf2 = mix1_copy.config('conf2')
|
||||||
|
conf2.owner.set('conf2_user')
|
||||||
|
conf2.option('netmask_admin_eth1').value.set('255.255.255.255')
|
||||||
|
assert conf2.option('netmask_admin_eth1').owner.get() == 'conf2_user'
|
||||||
|
assert conf2.option('ip_admin_eth0').value.get() == '192.168.0.1'
|
||||||
|
assert conf2.option('ip_admin_eth0').owner.get() == 'conf1_user'
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_properties_mix_set_value():
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth1', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
||||||
|
interface0 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth1', "mask", multi=True, properties=('disabled',))
|
||||||
|
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||||
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
||||||
|
interface2 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
conf1 = Config(interface0, session_id='conf1')
|
||||||
|
conf2 = Config(interface1, session_id='conf2')
|
||||||
|
conf1.property.read_write()
|
||||||
|
conf2.property.read_write()
|
||||||
|
mix = MixConfig(interface2, [conf1, conf2])
|
||||||
|
mix.property.read_write()
|
||||||
|
assert mix.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
ret = mix.value.set('netmask_admin_eth0', ['255.255.255.255'], only_config=True)
|
||||||
|
assert len(ret) == 2
|
||||||
|
assert isinstance(ret[0], PropertiesOptionError)
|
||||||
|
assert isinstance(ret[1], AttributeError)
|
||||||
|
del ret[1]
|
||||||
|
del ret[0]
|
||||||
|
del ret
|
||||||
|
ret = mix.value.set('netmask_admin_eth0', ['255.255.255.255'], force_default=True)
|
||||||
|
assert len(ret) == 2
|
||||||
|
assert isinstance(ret[0], AttributeError)
|
||||||
|
assert isinstance(ret[1], PropertiesOptionError)
|
||||||
|
del ret[1]
|
||||||
|
del ret[0]
|
||||||
|
del ret
|
||||||
|
ret = mix.value.set('netmask_admin_eth0', ['255.255.255.255'], force_dont_change_value=True)
|
||||||
|
assert len(ret) == 3
|
||||||
|
assert isinstance(ret[0], PropertiesOptionError)
|
||||||
|
assert isinstance(ret[1], AttributeError)
|
||||||
|
assert isinstance(ret[2], PropertiesOptionError)
|
||||||
|
del ret[2]
|
||||||
|
del ret[1]
|
||||||
|
del ret[0]
|
||||||
|
del ret
|
||||||
|
ret = mix.value.set('netmask_admin_eth0', ['255.255.255.255'], force_default_if_same=True)
|
||||||
|
assert len(ret) == 2
|
||||||
|
assert isinstance(ret[0], AttributeError)
|
||||||
|
assert isinstance(ret[1], PropertiesOptionError)
|
||||||
|
del ret[1]
|
||||||
|
del ret[0]
|
||||||
|
del ret
|
||||||
|
ret = mix.value.set('ip_admin_eth0', '255.255.255.255', only_config=True)
|
||||||
|
assert len(ret) == 2
|
||||||
|
assert isinstance(ret[0], AttributeError)
|
||||||
|
assert isinstance(ret[1], ValueError)
|
||||||
|
del ret[1]
|
||||||
|
del ret[0]
|
||||||
|
del ret
|
||||||
|
ret = mix.value.set('ip_admin_eth0', '255.255.255.255', force_default=True)
|
||||||
|
assert len(ret) == 2
|
||||||
|
assert isinstance(ret[0], AttributeError)
|
||||||
|
assert isinstance(ret[1], ValueError)
|
||||||
|
del ret[1]
|
||||||
|
del ret[0]
|
||||||
|
del ret
|
||||||
|
ret = mix.value.set('ip_admin_eth0', '255.255.255.255', force_dont_change_value=True)
|
||||||
|
assert len(ret) == 2
|
||||||
|
assert isinstance(ret[0], AttributeError)
|
||||||
|
assert isinstance(ret[1], ValueError)
|
||||||
|
del ret[1]
|
||||||
|
del ret[0]
|
||||||
|
del ret
|
||||||
|
ret = mix.value.set('ip_admin_eth0', '255.255.255.255', force_default_if_same=True)
|
||||||
|
assert len(ret) == 2
|
||||||
|
assert isinstance(ret[0], AttributeError)
|
||||||
|
assert isinstance(ret[1], ValueError)
|
||||||
|
del ret[1]
|
||||||
|
del ret[0]
|
||||||
|
del ret
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_different_default():
|
||||||
|
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()
|
||||||
|
mix = MixConfig(interface2, [conf1, conf2], session_id='submix1')
|
||||||
|
mix = MixConfig(interface3, [mix], session_id='submix2')
|
||||||
|
mix = MixConfig(interface4, [mix])
|
||||||
|
mix.property.read_write()
|
||||||
|
#
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.6']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.4'], 'ip_admin_eth1': ['192.168.1.5']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.3']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.2']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
#
|
||||||
|
mix.option('ip_admin_eth0').value.set(['192.168.1.7'])
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.7'], 'ip_admin_eth1': ['192.168.1.5']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.3']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.2']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
#
|
||||||
|
mix.config('submix2').option('ip_admin_eth0').value.set(['192.168.1.8'])
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.8'], 'ip_admin_eth1': ['192.168.1.5']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.3']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.2']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.8']}
|
||||||
|
#
|
||||||
|
raises(AttributeError, "mix.config('submix2.submix1').option('ip_admin_eth0').value.set(['192.168.1.9'])")
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.8'], 'ip_admin_eth1': ['192.168.1.5']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.3']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.2']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.8']}
|
||||||
|
#
|
||||||
|
raises(AttributeError, "mix.config('submix2.submix1.conf2').option('ip_admin_eth0').value.set(['192.168.1.9'])")
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.8'], 'ip_admin_eth1': ['192.168.1.5']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.3']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.2']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.8']}
|
||||||
|
#
|
||||||
|
mix.config('submix2.submix1.conf1').option('ip_admin_eth0').value.set(['192.168.1.9'])
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.8'], 'ip_admin_eth1': ['192.168.1.5']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.3']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.2']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.9']}
|
||||||
|
#
|
||||||
|
raises(AttributeError, "mix.option('ip_admin_eth1').value.set(['192.168.1.10'])")
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.8'], 'ip_admin_eth1': ['192.168.1.5']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.3']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.2']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.9']}
|
||||||
|
#
|
||||||
|
mix.config('submix2').option('ip_admin_eth1').value.set(['192.168.1.10'])
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.8'], 'ip_admin_eth1': ['192.168.1.10']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.10']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.10']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.9']}
|
||||||
|
#
|
||||||
|
mix.config('submix2.submix1').option('ip_admin_eth1').value.set(['192.168.1.11'])
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.8'], 'ip_admin_eth1': ['192.168.1.10']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.11']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.11']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.9']}
|
||||||
|
#
|
||||||
|
mix.config('submix2.submix1.conf2').option('ip_admin_eth1').value.set(['192.168.1.12'])
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.8'], 'ip_admin_eth1': ['192.168.1.10']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.11']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.12']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.9']}
|
||||||
|
#
|
||||||
|
raises(AttributeError, "mix.config('submix2.submix1.conf1').option('ip_admin_eth1').value.set(['192.168.1.13'])")
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.8'], 'ip_admin_eth1': ['192.168.1.10']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.11']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.12']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.9']}
|
||||||
|
|
||||||
|
|
||||||
|
def test_mix_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()
|
||||||
|
mix = MixConfig(interface2, [conf1, conf2], session_id='submix1')
|
||||||
|
mix = MixConfig(interface3, [mix], session_id='submix2')
|
||||||
|
mix = MixConfig(interface4, [mix])
|
||||||
|
mix.property.read_write()
|
||||||
|
#
|
||||||
|
mix.option('ip_admin_eth0').value.set(['192.168.1.7'])
|
||||||
|
mix.config('submix2').option('ip_admin_eth0').value.set(['192.168.1.8'])
|
||||||
|
mix.config('submix2').option('ip_admin_eth1').value.set(['192.168.1.10'])
|
||||||
|
mix.config('submix2.submix1').option('ip_admin_eth1').value.set(['192.168.1.11'])
|
||||||
|
mix.config('submix2.submix1.conf2').option('ip_admin_eth1').value.set(['192.168.1.12'])
|
||||||
|
mix.config('submix2.submix1.conf1').option('ip_admin_eth0').value.set(['192.168.1.9'])
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.8'], 'ip_admin_eth1': ['192.168.1.10']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.11']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.12']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.9']}
|
||||||
|
#
|
||||||
|
mix.value.reset('ip_admin_eth0')
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.6']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.4'], 'ip_admin_eth1': ['192.168.1.10']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.11']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.12']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||||
|
#
|
||||||
|
mix.value.reset('ip_admin_eth1')
|
||||||
|
assert mix.value.dict() == {'ip_admin_eth0': ['192.168.1.6']}
|
||||||
|
assert mix.config('submix2').value.dict() == {'ip_admin_eth0': ['192.168.1.4'], 'ip_admin_eth1': ['192.168.1.5']}
|
||||||
|
assert mix.config('submix2.submix1').value.dict() == {'ip_admin_eth1': ['192.168.1.3']}
|
||||||
|
assert mix.config('submix2.submix1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.2']}
|
||||||
|
assert mix.config('submix2.submix1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
@ -1,1112 +0,0 @@
|
||||||
from .autopath import do_autopath
|
|
||||||
do_autopath()
|
|
||||||
|
|
||||||
from py.test import raises
|
|
||||||
|
|
||||||
from tiramisu.setting import groups, owners
|
|
||||||
from tiramisu import IntOption, StrOption, NetworkOption, NetmaskOption, \
|
|
||||||
OptionDescription, MasterSlaves, Config, GroupConfig, PathConfig, \
|
|
||||||
Params, ParamOption, ParamValue
|
|
||||||
from tiramisu.error import ConfigError, ConflictError, PropertiesOptionError, SlaveError, APIError
|
|
||||||
from tiramisu.storage import list_sessions
|
|
||||||
|
|
||||||
owners.addowner('path1')
|
|
||||||
owners.addowner('path2')
|
|
||||||
|
|
||||||
|
|
||||||
def teardown_function(function):
|
|
||||||
assert list_sessions() == [], 'session list is not empty when leaving "{}"'.format(function.__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def return_value(value=None):
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
def raise_exception():
|
|
||||||
raise Exception('test')
|
|
||||||
|
|
||||||
|
|
||||||
def make_description():
|
|
||||||
i1 = IntOption('i1', '')
|
|
||||||
i2 = IntOption('i2', '', default=1)
|
|
||||||
i3 = IntOption('i3', '')
|
|
||||||
i4 = IntOption('i4', '', default=2)
|
|
||||||
i5 = IntOption('i5', '', default=[2], multi=True)
|
|
||||||
i6 = IntOption('i6', '', properties=('disabled',))
|
|
||||||
od1 = OptionDescription('od1', '', [i1, i2, i3, i4, i5, i6])
|
|
||||||
od2 = OptionDescription('od2', '', [od1])
|
|
||||||
return od2
|
|
||||||
|
|
||||||
|
|
||||||
def make_description1():
|
|
||||||
i1 = IntOption('i1', '')
|
|
||||||
i2 = IntOption('i2', '', default=1)
|
|
||||||
i3 = IntOption('i3', '')
|
|
||||||
i4 = IntOption('i4', '', default=2)
|
|
||||||
i5 = IntOption('i5', '', default=[2], multi=True)
|
|
||||||
i6 = IntOption('i6', '', properties=('disabled',))
|
|
||||||
od1 = OptionDescription('od1', '', [i1, i2, i3, i4, i5, i6])
|
|
||||||
od2 = OptionDescription('od2', '', [od1])
|
|
||||||
return od2
|
|
||||||
|
|
||||||
|
|
||||||
def make_description2():
|
|
||||||
i1 = IntOption('i1', '')
|
|
||||||
i2 = IntOption('i2', '', default=1)
|
|
||||||
i3 = IntOption('i3', '')
|
|
||||||
i4 = IntOption('i4', '', default=2)
|
|
||||||
i5 = IntOption('i5', '', default=[2], multi=True)
|
|
||||||
i6 = IntOption('i6', '', properties=('disabled',))
|
|
||||||
od1 = OptionDescription('od1', '', [i1, i2, i3, i4, i5, i6])
|
|
||||||
od2 = OptionDescription('od2', '', [od1])
|
|
||||||
return od2
|
|
||||||
|
|
||||||
|
|
||||||
def make_description3():
|
|
||||||
i1 = IntOption('i1', '')
|
|
||||||
i2 = IntOption('i2', '', default=1)
|
|
||||||
i3 = IntOption('i3', '')
|
|
||||||
i4 = IntOption('i4', '', default=2)
|
|
||||||
i5 = IntOption('i5', '', default=[2], multi=True)
|
|
||||||
i6 = IntOption('i6', '', properties=('disabled',))
|
|
||||||
od1 = OptionDescription('od1', '', [i1, i2, i3, i4, i5, i6])
|
|
||||||
od2 = OptionDescription('od2', '', [od1])
|
|
||||||
return od2
|
|
||||||
|
|
||||||
|
|
||||||
def make_pathconfig(double=False):
|
|
||||||
od1 = make_description()
|
|
||||||
od2 = make_description1()
|
|
||||||
od3 = make_description2()
|
|
||||||
conf1 = Config(od1, session_id='conf1')
|
|
||||||
conf2 = Config(od2, session_id='conf2')
|
|
||||||
path = PathConfig(od3, [conf1, conf2], session_id='path')
|
|
||||||
if double:
|
|
||||||
od4 = make_description3()
|
|
||||||
path.owner.set(owners.path2)
|
|
||||||
path = PathConfig(od4, [path], session_id='doublepath')
|
|
||||||
path.property.read_write()
|
|
||||||
path.owner.set(owners.path1)
|
|
||||||
return path
|
|
||||||
|
|
||||||
|
|
||||||
def test_unknown_config():
|
|
||||||
path = make_pathconfig()
|
|
||||||
raises(ConfigError, "path.config('unknown')")
|
|
||||||
|
|
||||||
|
|
||||||
def test_none():
|
|
||||||
path = make_pathconfig()
|
|
||||||
assert path.option('od1.i3').value.get() is path.config('conf1').option('od1.i3').value.get() is path.config('conf2').option('od1.i3').value.get() is None
|
|
||||||
assert path.option('od1.i3').owner.get() is path.config('conf1').option('od1.i3').owner.get() is path.config('conf2').option('od1.i3').owner.get() is owners.default
|
|
||||||
#
|
|
||||||
path.option('od1.i3').value.set(3)
|
|
||||||
assert path.option('od1.i3').value.get() == path.config('conf1').option('od1.i3').value.get() == path.config('conf2').option('od1.i3').value.get() == 3
|
|
||||||
assert path.option('od1.i3').owner.get() is path.config('conf1').option('od1.i3').owner.get() is path.config('conf2').option('od1.i3').owner.get() is owners.path1
|
|
||||||
#
|
|
||||||
path.config('conf1').option('od1.i3').value.set(2)
|
|
||||||
assert path.option('od1.i3').value.get() == path.config('conf2').option('od1.i3').value.get() == 3
|
|
||||||
assert path.config('conf1').option('od1.i3').value.get() == 2
|
|
||||||
assert path.option('od1.i3').owner.get() is path.config('conf2').option('od1.i3').owner.get() is owners.path1
|
|
||||||
assert path.config('conf1').option('od1.i3').owner.get() is owners.user
|
|
||||||
#
|
|
||||||
path.option('od1.i3').value.set(4)
|
|
||||||
assert path.option('od1.i3').value.get() == path.config('conf2').option('od1.i3').value.get() == 4
|
|
||||||
assert path.config('conf1').option('od1.i3').value.get() == 2
|
|
||||||
assert path.option('od1.i3').owner.get() is path.config('conf2').option('od1.i3').owner.get() is owners.path1
|
|
||||||
assert path.config('conf1').option('od1.i3').owner.get() is owners.user
|
|
||||||
#
|
|
||||||
path.option('od1.i3').value.reset()
|
|
||||||
assert path.option('od1.i3').value.get() is path.config('conf2').option('od1.i3').value.get() is None
|
|
||||||
assert path.config('conf1').option('od1.i3').value.get() == 2
|
|
||||||
assert path.option('od1.i3').owner.get() is path.config('conf2').option('od1.i3').owner.get() is owners.default
|
|
||||||
assert path.config('conf1').option('od1.i3').owner.get() is owners.user
|
|
||||||
#
|
|
||||||
path.config('conf1').option('od1.i3').value.reset()
|
|
||||||
assert path.option('od1.i3').value.get() is path.config('conf1').option('od1.i3').value.get() is path.config('conf2').option('od1.i3').value.get() is None
|
|
||||||
assert path.option('od1.i3').owner.get() is path.config('conf1').option('od1.i3').owner.get() is path.config('conf2').option('od1.i3').owner.get() is owners.default
|
|
||||||
#
|
|
||||||
assert path.config(None).config.name() == path.config.name()
|
|
||||||
|
|
||||||
|
|
||||||
def test_reset():
|
|
||||||
path = make_pathconfig()
|
|
||||||
assert path.option('od1.i2').value.get() == 1
|
|
||||||
path.option('od1.i2').value.set(2)
|
|
||||||
path.config('conf1').option('od1.i2').value.set(3)
|
|
||||||
assert path.option('od1.i2').value.get() == 2
|
|
||||||
assert path.config('conf1').option('od1.i2').value.get() == 3
|
|
||||||
assert path.config('conf2').option('od1.i2').value.get() == 2
|
|
||||||
path.config.reset()
|
|
||||||
assert path.option('od1.i2').value.get() == 1
|
|
||||||
assert path.config('conf1').option('od1.i2').value.get() == 3
|
|
||||||
assert path.config('conf2').option('od1.i2').value.get() == 1
|
|
||||||
|
|
||||||
|
|
||||||
def test_default():
|
|
||||||
path = make_pathconfig()
|
|
||||||
assert path.option('od1.i2').value.get() == path.config('conf1').option('od1.i2').value.get() == path.config('conf2').option('od1.i2').value.get() == 1
|
|
||||||
assert path.option('od1.i2').owner.get() is path.config('conf1').option('od1.i2').owner.get() is path.config('conf2').option('od1.i2').owner.get() is owners.default
|
|
||||||
#
|
|
||||||
path.option('od1.i2').value.set(3)
|
|
||||||
assert path.option('od1.i2').value.get() == path.config('conf1').option('od1.i2').value.get() == path.config('conf2').option('od1.i2').value.get() == 3
|
|
||||||
assert path.option('od1.i2').owner.get() is path.config('conf1').option('od1.i2').owner.get() is path.config('conf2').option('od1.i2').owner.get() is owners.path1
|
|
||||||
#
|
|
||||||
path.config('conf1').option('od1.i2').value.set(2)
|
|
||||||
assert path.option('od1.i2').value.get() == path.config('conf2').option('od1.i2').value.get() == 3
|
|
||||||
assert path.config('conf1').option('od1.i2').value.get() == 2
|
|
||||||
assert path.option('od1.i2').owner.get() is path.config('conf2').option('od1.i2').owner.get() is owners.path1
|
|
||||||
assert path.config('conf1').option('od1.i2').owner.get() is owners.user
|
|
||||||
#
|
|
||||||
path.option('od1.i2').value.set(4)
|
|
||||||
assert path.option('od1.i2').value.get() == path.config('conf2').option('od1.i2').value.get() == 4
|
|
||||||
assert path.config('conf1').option('od1.i2').value.get() == 2
|
|
||||||
assert path.option('od1.i2').owner.get() is path.config('conf2').option('od1.i2').owner.get() is owners.path1
|
|
||||||
assert path.config('conf1').option('od1.i2').owner.get() is owners.user
|
|
||||||
#
|
|
||||||
path.option('od1.i2').value.reset()
|
|
||||||
assert path.option('od1.i2').value.get() == path.config('conf2').option('od1.i2').value.get() == 1
|
|
||||||
assert path.config('conf1').option('od1.i2').value.get() == 2
|
|
||||||
assert path.option('od1.i2').owner.get() is path.config('conf2').option('od1.i2').owner.get() is owners.default
|
|
||||||
assert path.config('conf1').option('od1.i2').owner.get() is owners.user
|
|
||||||
#
|
|
||||||
path.config('conf1').option('od1.i2').value.reset()
|
|
||||||
assert path.option('od1.i2').value.get() == path.config('conf1').option('od1.i2').value.get() == path.config('conf2').option('od1.i2').value.get() == 1
|
|
||||||
assert path.option('od1.i2').owner.get() is path.config('conf1').option('od1.i2').owner.get() is path.config('conf2').option('od1.i2').owner.get() is owners.default
|
|
||||||
|
|
||||||
|
|
||||||
def test_contexts():
|
|
||||||
path = make_pathconfig()
|
|
||||||
errors = path.value.set('od1.i2', 6, only_config=True)
|
|
||||||
assert path.option('od1.i2').value.get() == 1
|
|
||||||
assert path.option('od1.i2').owner.get() == owners.default
|
|
||||||
assert path.config('conf1').option('od1.i2').value.get() == path.config('conf1').option('od1.i2').value.get() == 6
|
|
||||||
assert path.config('conf1').option('od1.i2').owner.get() == path.config('conf1').option('od1.i2').owner.get() is owners.user
|
|
||||||
assert len(errors) == 0
|
|
||||||
|
|
||||||
|
|
||||||
def test_find():
|
|
||||||
path = make_pathconfig()
|
|
||||||
ret = list(path.option.find('i2'))
|
|
||||||
assert len(ret) == 1
|
|
||||||
assert 1 == ret[0].value.get()
|
|
||||||
assert 1 == path.option.find('i2', first=True).value.get()
|
|
||||||
assert path.value.dict() == {'od1.i4': 2, 'od1.i1': None, 'od1.i3': None,
|
|
||||||
'od1.i2': 1, 'od1.i5': [2]}
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_path():
|
|
||||||
path = make_pathconfig(double=True)
|
|
||||||
assert path.option('od1.i2').value.get() == path.config('path').option('od1.i2').value.get() == path.config('path.conf1').option('od1.i2').value.get() == path.config('path.conf2').option('od1.i2').value.get() == 1
|
|
||||||
assert path.option('od1.i2').owner.get() is path.config('path').option('od1.i2').owner.get() is path.config('path.conf1').option('od1.i2').owner.get() is path.config('path.conf2').option('od1.i2').owner.get() is owners.default
|
|
||||||
#
|
|
||||||
path.option('od1.i2').value.set(3)
|
|
||||||
assert path.option('od1.i2').value.get() == path.config('path').option('od1.i2').value.get() == path.config('path.conf1').option('od1.i2').value.get() == path.config('path.conf2').option('od1.i2').value.get() == 3
|
|
||||||
assert path.option('od1.i2').owner.get() is path.config('path').option('od1.i2').owner.get() is path.config('path.conf1').option('od1.i2').owner.get() is path.config('path.conf2').option('od1.i2').owner.get() is owners.path1
|
|
||||||
#
|
|
||||||
path.config('path.conf1').option('od1.i2').value.set(2)
|
|
||||||
assert path.option('od1.i2').value.get() == path.config('path').option('od1.i2').value.get() == path.config('path.conf2').option('od1.i2').value.get() == 3
|
|
||||||
assert path.config('path.conf1').option('od1.i2').value.get() == 2
|
|
||||||
assert path.option('od1.i2').owner.get() is path.config('path').option('od1.i2').owner.get() is path.config('path.conf2').option('od1.i2').owner.get() is owners.path1
|
|
||||||
assert path.config('path.conf1').option('od1.i2').owner.get() is owners.user
|
|
||||||
#
|
|
||||||
path.config('path').option('od1.i2').value.set(4)
|
|
||||||
assert path.option('od1.i2').value.get() == 3
|
|
||||||
assert path.config('path').option('od1.i2').value.get() == path.config('path.conf2').option('od1.i2').value.get() == 4
|
|
||||||
assert path.config('path.conf1').option('od1.i2').value.get() == 2
|
|
||||||
assert path.option('od1.i2').owner.get() is owners.path1
|
|
||||||
assert path.config('path').option('od1.i2').owner.get() is path.config('path.conf2').option('od1.i2').owner.get() is owners.path2
|
|
||||||
assert path.config('path.conf1').option('od1.i2').owner.get() is owners.user
|
|
||||||
#
|
|
||||||
path.config('path').option('od1.i2').value.reset()
|
|
||||||
assert path.option('od1.i2').value.get() == path.config('path').option('od1.i2').value.get() == path.config('path.conf2').option('od1.i2').value.get() == 3
|
|
||||||
assert path.config('path.conf1').option('od1.i2').value.get() == 2
|
|
||||||
assert path.option('od1.i2').owner.get() is path.config('path').option('od1.i2').owner.get() is path.config('path.conf2').option('od1.i2').owner.get() is owners.path1
|
|
||||||
assert path.config('path.conf1').option('od1.i2').owner.get() is owners.user
|
|
||||||
#
|
|
||||||
path.option('od1.i2').value.reset()
|
|
||||||
assert path.option('od1.i2').value.get() == path.config('path').option('od1.i2').value.get() == path.config('path.conf2').option('od1.i2').value.get() == 1
|
|
||||||
assert path.config('path.conf1').option('od1.i2').value.get() == 2
|
|
||||||
assert path.option('od1.i2').owner.get() is path.config('path').option('od1.i2').owner.get() is path.config('path.conf2').option('od1.i2').owner.get() is owners.default
|
|
||||||
assert path.config('path.conf1').option('od1.i2').owner.get() is owners.user
|
|
||||||
#
|
|
||||||
path.config('path.conf1').option('od1.i2').value.reset()
|
|
||||||
assert path.option('od1.i2').value.get() == path.config('path').option('od1.i2').value.get() == path.config('path.conf1').option('od1.i2').value.get() == path.config('path.conf2').option('od1.i2').value.get() == 1
|
|
||||||
assert path.option('od1.i2').owner.get() is path.config('path').option('od1.i2').owner.get() is path.config('path.conf1').option('od1.i2').owner.get() is path.config('path.conf2').option('od1.i2').owner.get() is owners.default
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_path_set():
|
|
||||||
path = make_pathconfig(double=True)
|
|
||||||
errors1 = path.value.set('od1.i1', 7, only_config=True)
|
|
||||||
errors2 = path.value.set('od1.i6', 7, only_config=True)
|
|
||||||
assert len(errors1) == 0
|
|
||||||
assert len(errors2) == 2
|
|
||||||
conf1 = path.config('path.conf1')._config_bag.context
|
|
||||||
conf2 = path.config('path.conf2')._config_bag.context
|
|
||||||
assert path.config('path.conf1').option('od1.i1').value.get() == path.config('path.conf2').option('od1.i1').value.get() == 7
|
|
||||||
#
|
|
||||||
dconfigs = []
|
|
||||||
for conf in path.config.find('i1', value=7).config.list():
|
|
||||||
dconfigs.append(conf._config_bag.context)
|
|
||||||
assert [conf1, conf2] == dconfigs
|
|
||||||
path.config('path.conf1').option('od1.i1').value.set(8)
|
|
||||||
#
|
|
||||||
dconfigs = []
|
|
||||||
for conf in path.config.find('i1').config.list():
|
|
||||||
dconfigs.append(conf._config_bag.context)
|
|
||||||
assert [conf1, conf2] == dconfigs
|
|
||||||
assert conf2 == list(path.config.find('i1', value=7).config.list())[0]._config_bag.context
|
|
||||||
assert conf1 == list(path.config.find('i1', value=8).config.list())[0]._config_bag.context
|
|
||||||
#
|
|
||||||
dconfigs = []
|
|
||||||
for conf in path.config.find('i5', value=2).config.list():
|
|
||||||
dconfigs.append(conf._config_bag.context)
|
|
||||||
assert [conf1, conf2] == dconfigs
|
|
||||||
#
|
|
||||||
raises(AttributeError, "path.config.find('i1', value=10)")
|
|
||||||
raises(AttributeError, "path.config.find('not', value=10)")
|
|
||||||
raises(AttributeError, "path.config.find('i6')")
|
|
||||||
raises(ValueError, "path.value.set('od1.i6', 7, only_config=True, force_default=True)")
|
|
||||||
raises(ValueError, "path.value.set('od1.i6', 7, only_config=True, force_default_if_same=True)")
|
|
||||||
raises(ValueError, "path.value.set('od1.i6', 7, only_config=True, force_dont_change_value=True)")
|
|
||||||
|
|
||||||
|
|
||||||
def test_not_path():
|
|
||||||
i1 = IntOption('i1', '')
|
|
||||||
od1 = OptionDescription('od1', '', [i1])
|
|
||||||
od2 = OptionDescription('od2', '', [od1])
|
|
||||||
conf1 = Config(od2, session_id='conf1')
|
|
||||||
conf2 = Config(od2, session_id='conf2')
|
|
||||||
conf3 = Config(od2)
|
|
||||||
conf4 = Config(od2, session_id='conf4')
|
|
||||||
raises(TypeError, "GroupConfig(conf1)")
|
|
||||||
#same name
|
|
||||||
#raises(ConflictError, "GroupConfig([conf2, conf4], session_id='conf2')")
|
|
||||||
raises(ConflictError, "GroupConfig([conf2, conf2], session_id='conf8')")
|
|
||||||
grp = GroupConfig([conf1, conf2])
|
|
||||||
raises(APIError, "grp.option('od1.i1').value.get()")
|
|
||||||
conf1, conf2 = grp.config.list()
|
|
||||||
errors = grp.value.set('od1.i1', 7)
|
|
||||||
assert len(errors) == 0
|
|
||||||
assert grp.config('conf1').option('od1.i1').value.get() == grp.config('conf2').option('od1.i1').value.get() == 7
|
|
||||||
assert grp.config('conf1').option('od1.i1').owner.get() is grp.config('conf2').option('od1.i1').owner.get() is owners.user
|
|
||||||
grp.option('od1.i1').value.reset()
|
|
||||||
assert grp.config('conf1').option('od1.i1').owner.get() is grp.config('conf2').option('od1.i1').owner.get() is owners.default
|
|
||||||
|
|
||||||
|
|
||||||
def test_group_find_firsts():
|
|
||||||
i1 = IntOption('i1', '')
|
|
||||||
od1 = OptionDescription('od1', '', [i1])
|
|
||||||
od2 = OptionDescription('od2', '', [od1])
|
|
||||||
conf1 = Config(od2, session_id='conf1')
|
|
||||||
conf2 = Config(od2, session_id='conf2')
|
|
||||||
grp = GroupConfig([conf1, conf2])
|
|
||||||
itr = grp.config.find('i1').config.list()
|
|
||||||
conf1._config_bag.context == next(itr)._config_bag.context
|
|
||||||
conf2._config_bag.context == next(itr)._config_bag.context
|
|
||||||
try:
|
|
||||||
next(itr)
|
|
||||||
except StopIteration:
|
|
||||||
pass
|
|
||||||
except:
|
|
||||||
raise Exception('no')
|
|
||||||
else:
|
|
||||||
raise Exception('no')
|
|
||||||
|
|
||||||
|
|
||||||
def test_group_group():
|
|
||||||
i1 = IntOption('i1', '')
|
|
||||||
od1 = OptionDescription('od1', '', [i1])
|
|
||||||
od2 = OptionDescription('od2', '', [od1])
|
|
||||||
conf1 = Config(od2, session_id='conf9')
|
|
||||||
conf2 = Config(od2, session_id='conf10')
|
|
||||||
grp = GroupConfig([conf1, conf2], 'grp')
|
|
||||||
grp2 = GroupConfig([grp])
|
|
||||||
errors = grp2.value.set('od1.i1', 2)
|
|
||||||
assert len(errors) == 0
|
|
||||||
assert grp2.config('grp.conf9').option('od1.i1').value.get() == 2
|
|
||||||
assert grp2.config('grp.conf9').option('od1.i1').owner.get() is owners.user
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_unconsistent():
|
|
||||||
i1 = IntOption('i1', '')
|
|
||||||
i2 = IntOption('i2', '', default=1)
|
|
||||||
i3 = IntOption('i3', '')
|
|
||||||
i4 = IntOption('i4', '', default=2)
|
|
||||||
od1 = OptionDescription('od1', '', [i1, i2, i3, i4])
|
|
||||||
od2 = OptionDescription('od2', '', [od1])
|
|
||||||
od3 = OptionDescription('od3', '', [od1])
|
|
||||||
conf1 = Config(od2, session_id='conf1')
|
|
||||||
conf2 = Config(od2, session_id='conf2')
|
|
||||||
conf3 = Config(od2, session_id='conf3')
|
|
||||||
conf4 = Config(od3, session_id='conf4')
|
|
||||||
path = PathConfig(od2, [conf1, conf2])
|
|
||||||
path.owner.set(owners.path1)
|
|
||||||
raises(TypeError, 'PathConfig(od2, "string")')
|
|
||||||
# same descr but conf1 already in path
|
|
||||||
raises(ValueError, "PathConfig(od2, [conf1, conf3])")
|
|
||||||
# not same descr
|
|
||||||
PathConfig(od2, [conf3, conf4])
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_master_slaves():
|
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od = OptionDescription('root', '', [interface1])
|
|
||||||
conf1 = Config(od, session_id='conf1')
|
|
||||||
conf2 = Config(od, session_id='conf2')
|
|
||||||
path = PathConfig(od, [conf1, conf2])
|
|
||||||
path.property.read_only()
|
|
||||||
itr = path.config.find('ip_admin_eth0').config.list()
|
|
||||||
assert conf1._config_bag.context == next(itr)._config_bag.context
|
|
||||||
assert conf2._config_bag.context == next(itr)._config_bag.context
|
|
||||||
itr = path.config.find('netmask_admin_eth0').config.list()
|
|
||||||
assert conf1._config_bag.context == next(itr)._config_bag.context
|
|
||||||
assert conf2._config_bag.context == next(itr)._config_bag.context
|
|
||||||
path.property.read_write()
|
|
||||||
raises(AttributeError, "path.config.find('netmask_admin_eth0')")
|
|
||||||
itr = path.unrestraint.config.find('netmask_admin_eth0').config.list()
|
|
||||||
assert conf1._config_bag.context == next(itr)._config_bag.context
|
|
||||||
assert conf2._config_bag.context == next(itr)._config_bag.context
|
|
||||||
path.property.read_only()
|
|
||||||
itr = path.config.find('netmask_admin_eth0').config.list()
|
|
||||||
assert conf1._config_bag.context == next(itr)._config_bag.context
|
|
||||||
assert conf2._config_bag.context == next(itr)._config_bag.context
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_master_slaves_value2():
|
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od = OptionDescription('root', '', [interface1])
|
|
||||||
conf1 = Config(od, session_id='conf1')
|
|
||||||
conf2 = Config(od, session_id='conf2')
|
|
||||||
path = PathConfig(od, [conf1, conf2], session_id="path")
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.8'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
|
||||||
#FIXME devrait raise ! assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0', 0).value.get() == None
|
|
||||||
#
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
|
||||||
#
|
|
||||||
path.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
|
||||||
path.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.255.0'
|
|
||||||
path.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.0.0'
|
|
||||||
#
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_master_slaves_value_default():
|
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True)
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od = OptionDescription('root', '', [interface1])
|
|
||||||
conf1 = Config(od, session_id='conf1')
|
|
||||||
conf2 = Config(od, session_id='conf2')
|
|
||||||
path = PathConfig(od, [conf1, conf2])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
|
||||||
#
|
|
||||||
path.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
|
||||||
#
|
|
||||||
path.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.255.0'
|
|
||||||
#
|
|
||||||
path.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.0.0'
|
|
||||||
#
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_master_slaves_owners():
|
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od = OptionDescription('root', '', [interface1])
|
|
||||||
conf1 = Config(od, session_id='conf1')
|
|
||||||
conf2 = Config(od, session_id='conf2')
|
|
||||||
path = PathConfig(od, [conf1, conf2])
|
|
||||||
path.owner.set(owners.path1)
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
|
||||||
raises(SlaveError, "path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()")
|
|
||||||
#
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.user
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()
|
|
||||||
#
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
|
||||||
#
|
|
||||||
path.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.path1
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()
|
|
||||||
#
|
|
||||||
path.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.path1
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.path1
|
|
||||||
#
|
|
||||||
path.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.path1
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.path1
|
|
||||||
#
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.user
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.default
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_force_default():
|
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od = OptionDescription('root', '', [interface1])
|
|
||||||
conf1 = Config(od, session_id='conf1')
|
|
||||||
conf2 = Config(od, session_id='conf2')
|
|
||||||
path = PathConfig(od, [conf1, conf2])
|
|
||||||
path.property.read_write()
|
|
||||||
path.owner.set('path1')
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
#
|
|
||||||
errors = path.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.1'])
|
|
||||||
assert len(errors) == 0
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
||||||
#
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
||||||
#
|
|
||||||
errors = path.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.3'])
|
|
||||||
assert len(errors) == 0
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
|
||||||
#
|
|
||||||
errors = path.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default=True)
|
|
||||||
assert len(errors) == 0
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_force_dont_change_value():
|
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od = OptionDescription('root', '', [interface1])
|
|
||||||
conf1 = Config(od, session_id='conf1')
|
|
||||||
conf2 = Config(od, session_id='conf2')
|
|
||||||
path = PathConfig(od, [conf1, conf2])
|
|
||||||
path.property.read_write()
|
|
||||||
path.owner.set('path1')
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
|
||||||
errors = path.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_dont_change_value=True)
|
|
||||||
assert len(errors) == 0
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_force_default_if_same():
|
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od = OptionDescription('root', '', [interface1])
|
|
||||||
conf1 = Config(od, session_id='conf1')
|
|
||||||
conf2 = Config(od, session_id='conf2')
|
|
||||||
path = PathConfig(od, [conf1, conf2])
|
|
||||||
path.property.read_write()
|
|
||||||
path.owner.set('path1')
|
|
||||||
#
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
#
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
|
||||||
errors = path.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True)
|
|
||||||
assert len(errors) == 0
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.path1
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.path1
|
|
||||||
#
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.3'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.path1
|
|
||||||
errors = path.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True)
|
|
||||||
assert len(errors) == 0
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.path1
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_force_default_if_same_and_dont_change():
|
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od = OptionDescription('root', '', [interface1])
|
|
||||||
conf1 = Config(od, session_id='conf1')
|
|
||||||
conf2 = Config(od, session_id='conf2')
|
|
||||||
path = PathConfig(od, [conf1, conf2])
|
|
||||||
path.property.read_write()
|
|
||||||
path.owner.set('path1')
|
|
||||||
#
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
#
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
|
||||||
errors = path.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True, force_dont_change_value=True)
|
|
||||||
assert len(errors) == 0
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.path1
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
||||||
#
|
|
||||||
path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.3'])
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
||||||
errors = path.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True, force_dont_change_value=True)
|
|
||||||
assert len(errors) == 0
|
|
||||||
assert path.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
assert path.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
||||||
assert path.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_force_default_and_dont_change():
|
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od = OptionDescription('root', '', [interface1])
|
|
||||||
conf1 = Config(od, session_id='rconf1')
|
|
||||||
conf2 = Config(od, session_id='rconf2')
|
|
||||||
path = PathConfig(od, [conf1, conf2])
|
|
||||||
path.property.read_write()
|
|
||||||
path.owner.set('path1')
|
|
||||||
raises(ValueError, "path.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default=True, force_dont_change_value=True)")
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_properties_path():
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
|
||||||
netmask_admin_eth0.impl_add_consistency('network_netmask', ip_admin_eth0)
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od = OptionDescription('root', '', [interface1])
|
|
||||||
conf1 = Config(od, session_id='conf1')
|
|
||||||
conf2 = Config(od, session_id='conf2')
|
|
||||||
conf1.property.read_write()
|
|
||||||
conf2.property.read_write()
|
|
||||||
path = PathConfig(od, [conf1, conf2])
|
|
||||||
path.property.read_write()
|
|
||||||
assert path.config('conf1').value.dict() == {}
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_exception_path():
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, callback=raise_exception)
|
|
||||||
netmask_admin_eth0.impl_add_consistency('network_netmask', ip_admin_eth0)
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od = OptionDescription('root', '', [interface1])
|
|
||||||
conf1 = Config(od, session_id='conf1')
|
|
||||||
conf2 = Config(od, session_id='conf2')
|
|
||||||
path = PathConfig(od, [conf1, conf2])
|
|
||||||
path.property.read_write()
|
|
||||||
raises(Exception, "conf1.make_dict()")
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_callback():
|
|
||||||
val1 = StrOption('val1', "", 'val')
|
|
||||||
val2 = StrOption('val2', "", callback=return_value, callback_params=Params(ParamOption(val1)))
|
|
||||||
val3 = StrOption('val3', "", callback=return_value, callback_params=Params(ParamValue('yes')))
|
|
||||||
val4 = StrOption('val4', "", callback=return_value, callback_params=Params(kwargs={'value': ParamOption(val1)}))
|
|
||||||
val5 = StrOption('val5', "", callback=return_value, callback_params=Params(kwargs={'value': ParamValue('yes')}))
|
|
||||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5])
|
|
||||||
cfg = Config(maconfig, session_id='cfg')
|
|
||||||
path = PathConfig(maconfig, [cfg])
|
|
||||||
path.property.read_write()
|
|
||||||
assert path.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'val', 'val1': 'val', 'val5': 'yes', 'val4': 'val'}
|
|
||||||
path.config('cfg').option('val1').value.set('new')
|
|
||||||
assert path.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
|
||||||
path.config('cfg').option('val1').value.reset()
|
|
||||||
path.option('val1').value.set('new')
|
|
||||||
assert path.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
|
||||||
path.config('cfg').option('val4').value.set('new1')
|
|
||||||
assert path.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
|
||||||
path.config('cfg').option('val4').value.reset()
|
|
||||||
path.option('val4').value.set('new1')
|
|
||||||
assert path.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
|
||||||
path.option('val4').value.reset()
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_callback_slave():
|
|
||||||
val = StrOption('val', "", default='val')
|
|
||||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val)))
|
|
||||||
val3 = StrOption('val2', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)))
|
|
||||||
val4 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)))
|
|
||||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
|
||||||
od = OptionDescription('root', '', [interface1])
|
|
||||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
|
||||||
cfg = Config(maconfig, session_id='cfg1')
|
|
||||||
path = PathConfig(maconfig, [cfg])
|
|
||||||
path.property.read_write()
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
|
||||||
path.config('cfg1').option('val').value.set('val1')
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
|
||||||
path.config('cfg1').option('val').value.reset()
|
|
||||||
path.option('val').value.set('val1')
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
|
||||||
path.option('val').value.reset()
|
|
||||||
path.config('cfg1').option('val1.val2', 0).value.set('val2')
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
|
||||||
path.config('cfg1').option('val1.val2', 0).value.reset()
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
|
||||||
path.option('val1.val2', 0).value.set('val2')
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
|
||||||
path.config('cfg1').option('val1.val3', 0).value.set('val6')
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val6'], 'val': 'val'}
|
|
||||||
path.option('val1.val2', 0).value.reset()
|
|
||||||
path.config('cfg1').option('val1.val3', 0).value.reset()
|
|
||||||
path.config('cfg1').option('val1.val1').value.set(['val3'])
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
|
||||||
path.config('cfg1').option('val1.val1').value.reset()
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
|
||||||
path.option('val1.val1').value.set(['val3'])
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
|
||||||
path.config('cfg1').option('val1.val2', 0).value.set('val2')
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
|
||||||
path.option('val1.val1').value.set(['val3', 'rah'])
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
|
||||||
path.option('val1.val1').value.pop(1)
|
|
||||||
path.option('val1.val1').value.set(['val4'])
|
|
||||||
assert path.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val4'], 'val1.val3': ['val4'], 'val': 'val'}
|
|
||||||
|
|
||||||
|
|
||||||
def test_meta_reset():
|
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od0 = OptionDescription('root', '', [interface1])
|
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od1 = OptionDescription('root', '', [interface1])
|
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
||||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
|
||||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
od2 = OptionDescription('root', '', [interface1])
|
|
||||||
conf1 = Config(od0, session_id='conf1')
|
|
||||||
conf2 = Config(od1, session_id='conf2')
|
|
||||||
meta = PathConfig(od2, [conf1, conf2])
|
|
||||||
meta.property.read_write()
|
|
||||||
meta.owner.set('path1')
|
|
||||||
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('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.1'])
|
|
||||||
assert len(errors) == 0
|
|
||||||
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.1']
|
|
||||||
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
||||||
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
|
||||||
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('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
||||||
meta.value.reset('ip_admin_eth0.ip_admin_eth0')
|
|
||||||
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('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_properties_path_copy():
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
|
||||||
interface0 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
|
||||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
|
||||||
interface2 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
conf1 = Config(interface0, session_id='conf1')
|
|
||||||
conf2 = Config(interface1, session_id='conf2')
|
|
||||||
conf1.property.read_write()
|
|
||||||
conf2.property.read_write()
|
|
||||||
path = PathConfig(interface2, [conf1, conf2], session_id='path1')
|
|
||||||
path.property.read_write()
|
|
||||||
|
|
||||||
conf3 = path.config('conf1').config.copy(session_id='conf3')
|
|
||||||
path2 = conf3.config.metaconfig()
|
|
||||||
assert path.config.name() == path2.config.name()
|
|
||||||
|
|
||||||
assert path.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
||||||
assert path.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
||||||
assert path.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
||||||
path.option('ip_admin_eth0').value.set(['192.168.1.2'])
|
|
||||||
assert path.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
|
||||||
assert path.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
|
||||||
assert path.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
|
||||||
ret = path.value.set('ip_admin_eth0', ['192.168.1.3'], force_default_if_same=True)
|
|
||||||
assert path.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
|
||||||
assert path.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
|
||||||
assert path.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_properties_path_deepcopy():
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True,
|
|
||||||
properties=('disabled',))
|
|
||||||
interface0 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True,
|
|
||||||
properties=('disabled',))
|
|
||||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True,
|
|
||||||
properties=('disabled',))
|
|
||||||
interface2 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
conf1 = Config(interface0, session_id='conf1')
|
|
||||||
conf2 = Config(interface1, session_id='conf2')
|
|
||||||
conf1.property.read_write()
|
|
||||||
conf2.property.read_write()
|
|
||||||
path = PathConfig(interface2, [conf1, conf2])
|
|
||||||
path.permissive.set(frozenset({'hidden'}))
|
|
||||||
path.property.read_write()
|
|
||||||
|
|
||||||
path2 = path.config('conf1').config.deepcopy(session_id='conf3')
|
|
||||||
assert path != path2
|
|
||||||
assert path.permissive.get() == path2.permissive.get()
|
|
||||||
|
|
||||||
assert path.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
||||||
assert path.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
||||||
assert path2.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
||||||
path.option('ip_admin_eth0').value.set(['192.168.1.2'])
|
|
||||||
assert path.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
|
||||||
assert path.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
|
||||||
assert path2.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
||||||
path.value.set('ip_admin_eth0', ['192.168.1.3'], force_default_if_same=True)
|
|
||||||
assert path.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
|
||||||
assert path.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
|
||||||
assert path2.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_properties_subpath_deepcopy():
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True,
|
|
||||||
properties=('disabled',))
|
|
||||||
interface0 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True,
|
|
||||||
properties=('disabled',))
|
|
||||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True,
|
|
||||||
properties=('disabled',))
|
|
||||||
interface2 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
conf1 = Config(interface0, session_id='conf1')
|
|
||||||
conf1.property.read_write()
|
|
||||||
path1 = PathConfig(interface1, [conf1], session_id='path1')
|
|
||||||
path2 = PathConfig(interface2, [path1], session_id='path2')
|
|
||||||
path_copy = conf1.config.deepcopy(session_id='conf2',
|
|
||||||
metaconfig_prefix='copy_')
|
|
||||||
assert path_copy.config.name() == 'copy_path2'
|
|
||||||
assert path_copy.config('copy_path1').config.name() == 'copy_path1'
|
|
||||||
assert path_copy.config('copy_path1').config('conf2').config.name() == 'conf2'
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_properties_subpath_deepcopy_owner():
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip")
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth1', "mask")
|
|
||||||
interface0 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth1', "ip")
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask")
|
|
||||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip")
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask")
|
|
||||||
interface2 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
conf1 = Config(interface0, session_id='conf1')
|
|
||||||
conf1.owner.set('conf1_user')
|
|
||||||
conf1.property.read_write()
|
|
||||||
path1 = PathConfig(interface1, [conf1], session_id='path1')
|
|
||||||
path1.owner.set('path1_user')
|
|
||||||
path2 = PathConfig(interface2, [path1], session_id='path2')
|
|
||||||
path2.owner.set('path2_user')
|
|
||||||
#
|
|
||||||
conf1.option('ip_admin_eth0').value.set('192.168.0.1')
|
|
||||||
assert conf1.option('ip_admin_eth0').owner.get() == 'conf1_user'
|
|
||||||
path2.option('ip_admin_eth0').value.set('192.168.0.3')
|
|
||||||
assert path2.option('ip_admin_eth0').owner.get() == 'path2_user'
|
|
||||||
#
|
|
||||||
path2_copy = conf1.config.deepcopy(session_id='conf2',
|
|
||||||
metaconfig_prefix='copy_')
|
|
||||||
path2_copy.option('netmask_admin_eth0').value.set('255.255.255.255')
|
|
||||||
assert path2_copy.option('ip_admin_eth0').value.get() == '192.168.0.3'
|
|
||||||
assert path2_copy.option('ip_admin_eth0').owner.get() == 'path2_user'
|
|
||||||
assert path2_copy.option('netmask_admin_eth0').owner.get() == 'path2_user'
|
|
||||||
#
|
|
||||||
path1_copy = path2_copy.config('copy_path1')
|
|
||||||
path1_copy.option('netmask_admin_eth0').value.set('255.255.255.255')
|
|
||||||
#
|
|
||||||
conf2 = path1_copy.config('conf2')
|
|
||||||
conf2.owner.set('conf2_user')
|
|
||||||
conf2.option('netmask_admin_eth1').value.set('255.255.255.255')
|
|
||||||
assert conf2.option('netmask_admin_eth1').owner.get() == 'conf2_user'
|
|
||||||
assert conf2.option('ip_admin_eth0').value.get() == '192.168.0.1'
|
|
||||||
assert conf2.option('ip_admin_eth0').owner.get() == 'conf1_user'
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_properties_path_set_value():
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth1', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
|
||||||
interface0 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth1', "mask", multi=True, properties=('disabled',))
|
|
||||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
||||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
|
||||||
interface2 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
||||||
conf1 = Config(interface0, session_id='conf1')
|
|
||||||
conf2 = Config(interface1, session_id='conf2')
|
|
||||||
conf1.property.read_write()
|
|
||||||
conf2.property.read_write()
|
|
||||||
path = PathConfig(interface2, [conf1, conf2])
|
|
||||||
path.property.read_write()
|
|
||||||
assert path.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
||||||
ret = path.value.set('netmask_admin_eth0', ['255.255.255.255'], only_config=True)
|
|
||||||
assert len(ret) == 2
|
|
||||||
assert isinstance(ret[0], PropertiesOptionError)
|
|
||||||
assert isinstance(ret[1], AttributeError)
|
|
||||||
del ret[1]
|
|
||||||
del ret[0]
|
|
||||||
del ret
|
|
||||||
ret = path.value.set('netmask_admin_eth0', ['255.255.255.255'], force_default=True)
|
|
||||||
assert len(ret) == 2
|
|
||||||
assert isinstance(ret[0], AttributeError)
|
|
||||||
assert isinstance(ret[1], PropertiesOptionError)
|
|
||||||
del ret[1]
|
|
||||||
del ret[0]
|
|
||||||
del ret
|
|
||||||
ret = path.value.set('netmask_admin_eth0', ['255.255.255.255'], force_dont_change_value=True)
|
|
||||||
assert len(ret) == 3
|
|
||||||
assert isinstance(ret[0], PropertiesOptionError)
|
|
||||||
assert isinstance(ret[1], AttributeError)
|
|
||||||
assert isinstance(ret[2], PropertiesOptionError)
|
|
||||||
del ret[2]
|
|
||||||
del ret[1]
|
|
||||||
del ret[0]
|
|
||||||
del ret
|
|
||||||
ret = path.value.set('netmask_admin_eth0', ['255.255.255.255'], force_default_if_same=True)
|
|
||||||
assert len(ret) == 2
|
|
||||||
assert isinstance(ret[0], AttributeError)
|
|
||||||
assert isinstance(ret[1], PropertiesOptionError)
|
|
||||||
del ret[1]
|
|
||||||
del ret[0]
|
|
||||||
del ret
|
|
||||||
ret = path.value.set('ip_admin_eth0', '255.255.255.255', only_config=True)
|
|
||||||
assert len(ret) == 2
|
|
||||||
assert isinstance(ret[0], AttributeError)
|
|
||||||
assert isinstance(ret[1], ValueError)
|
|
||||||
del ret[1]
|
|
||||||
del ret[0]
|
|
||||||
del ret
|
|
||||||
ret = path.value.set('ip_admin_eth0', '255.255.255.255', force_default=True)
|
|
||||||
assert len(ret) == 2
|
|
||||||
assert isinstance(ret[0], AttributeError)
|
|
||||||
assert isinstance(ret[1], ValueError)
|
|
||||||
del ret[1]
|
|
||||||
del ret[0]
|
|
||||||
del ret
|
|
||||||
ret = path.value.set('ip_admin_eth0', '255.255.255.255', force_dont_change_value=True)
|
|
||||||
assert len(ret) == 2
|
|
||||||
assert isinstance(ret[0], AttributeError)
|
|
||||||
assert isinstance(ret[1], ValueError)
|
|
||||||
del ret[1]
|
|
||||||
del ret[0]
|
|
||||||
del ret
|
|
||||||
ret = path.value.set('ip_admin_eth0', '255.255.255.255', force_default_if_same=True)
|
|
||||||
assert len(ret) == 2
|
|
||||||
assert isinstance(ret[0], AttributeError)
|
|
||||||
assert isinstance(ret[1], ValueError)
|
|
||||||
del ret[1]
|
|
||||||
del ret[0]
|
|
||||||
del ret
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_different_default():
|
|
||||||
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()
|
|
||||||
#
|
|
||||||
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']}
|
|
||||||
#
|
|
||||||
path.option('ip_admin_eth0').value.set(['192.168.1.7'])
|
|
||||||
assert path.value.dict() == {'ip_admin_eth0': ['192.168.1.7']}
|
|
||||||
assert path.config('subpath2').value.dict() == {'ip_admin_eth0': ['192.168.1.7'], '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.7']}
|
|
||||||
#
|
|
||||||
path.config('subpath2').option('ip_admin_eth0').value.set(['192.168.1.8'])
|
|
||||||
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.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.8']}
|
|
||||||
#
|
|
||||||
raises(AttributeError, "path.config('subpath2.subpath1').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.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.8']}
|
|
||||||
#
|
|
||||||
raises(AttributeError, "path.config('subpath2.subpath1.conf2').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.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.8']}
|
|
||||||
#
|
|
||||||
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.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.9']}
|
|
||||||
#
|
|
||||||
raises(AttributeError, "path.option('ip_admin_eth1').value.set(['192.168.1.10'])")
|
|
||||||
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.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.9']}
|
|
||||||
#
|
|
||||||
path.config('subpath2').option('ip_admin_eth1').value.set(['192.168.1.10'])
|
|
||||||
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.10']}
|
|
||||||
assert path.config('subpath2.subpath1.conf2').value.dict() == {'ip_admin_eth1': ['192.168.1.10']}
|
|
||||||
assert path.config('subpath2.subpath1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.9']}
|
|
||||||
#
|
|
||||||
path.config('subpath2.subpath1').option('ip_admin_eth1').value.set(['192.168.1.11'])
|
|
||||||
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.11']}
|
|
||||||
assert path.config('subpath2.subpath1.conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.9']}
|
|
||||||
#
|
|
||||||
path.config('subpath2.subpath1.conf2').option('ip_admin_eth1').value.set(['192.168.1.12'])
|
|
||||||
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']}
|
|
||||||
#
|
|
||||||
raises(AttributeError, "path.config('subpath2.subpath1.conf1').option('ip_admin_eth1').value.set(['192.168.1.13'])")
|
|
||||||
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']}
|
|
||||||
|
|
||||||
|
|
||||||
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']}
|
|
|
@ -15,7 +15,7 @@
|
||||||
from .function import Params, ParamOption, ParamValue, ParamContext
|
from .function import Params, ParamOption, ParamValue, ParamContext
|
||||||
from .option import *
|
from .option import *
|
||||||
from .error import APIError
|
from .error import APIError
|
||||||
from .api import Config, MetaConfig, GroupConfig, PathConfig
|
from .api import Config, MetaConfig, GroupConfig, MixConfig
|
||||||
from .option import __all__ as all_options
|
from .option import __all__ as all_options
|
||||||
from .setting import owners, undefined
|
from .setting import owners, undefined
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ allfuncs = ['Params',
|
||||||
'ParamValue',
|
'ParamValue',
|
||||||
'ParamContext',
|
'ParamContext',
|
||||||
'MetaConfig',
|
'MetaConfig',
|
||||||
'PathConfig',
|
'MixConfig',
|
||||||
'GroupConfig',
|
'GroupConfig',
|
||||||
'Config',
|
'Config',
|
||||||
'APIError',
|
'APIError',
|
||||||
|
|
|
@ -22,7 +22,7 @@ from typing import List, Any, Optional, Callable, Union, Dict
|
||||||
from .error import APIError, ConfigError, SlaveError, PropertiesOptionError
|
from .error import APIError, ConfigError, SlaveError, PropertiesOptionError
|
||||||
from .i18n import _
|
from .i18n import _
|
||||||
from .setting import ConfigBag, OptionBag, owners, groups, Undefined, undefined, FORBIDDEN_SET_PROPERTIES
|
from .setting import ConfigBag, OptionBag, owners, groups, Undefined, undefined, FORBIDDEN_SET_PROPERTIES
|
||||||
from .config import KernelConfig, SubConfig, KernelGroupConfig, KernelMetaConfig, KernelPathConfig
|
from .config import KernelConfig, SubConfig, KernelGroupConfig, KernelMetaConfig, KernelMixConfig
|
||||||
from .option import ChoiceOption, OptionDescription
|
from .option import ChoiceOption, OptionDescription
|
||||||
|
|
||||||
|
|
||||||
|
@ -1140,8 +1140,8 @@ class _TiramisuContextGroupConfig(TiramisuContext):
|
||||||
return Config(config)
|
return Config(config)
|
||||||
|
|
||||||
|
|
||||||
class _TiramisuContextPathConfig(_TiramisuContextGroupConfig, _TiramisuContextConfigReset):
|
class _TiramisuContextMixConfig(_TiramisuContextGroupConfig, _TiramisuContextConfigReset):
|
||||||
"""Actions to PathConfig"""
|
"""Actions to MixConfig"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -1193,8 +1193,8 @@ class TiramisuAPI(TiramisuHelp):
|
||||||
config = _TiramisuContextGroupConfig
|
config = _TiramisuContextGroupConfig
|
||||||
elif config_type == 'meta':
|
elif config_type == 'meta':
|
||||||
config = _TiramisuContextMetaConfig
|
config = _TiramisuContextMetaConfig
|
||||||
elif config_type == 'path':
|
elif config_type == 'mix':
|
||||||
config = _TiramisuContextPathConfig
|
config = _TiramisuContextMixConfig
|
||||||
else:
|
else:
|
||||||
config = _TiramisuContextConfig
|
config = _TiramisuContextConfig
|
||||||
return config(self._config_bag)
|
return config(self._config_bag)
|
||||||
|
@ -1267,7 +1267,7 @@ class MetaConfig(TiramisuAPI):
|
||||||
super().__init__(config)
|
super().__init__(config)
|
||||||
|
|
||||||
|
|
||||||
class PathConfig(TiramisuAPI):
|
class MixConfig(TiramisuAPI):
|
||||||
"""MetaConfig object that enables us to handle the sub configuration's options"""
|
"""MetaConfig object that enables us to handle the sub configuration's options"""
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
optiondescription: OptionDescription,
|
optiondescription: OptionDescription,
|
||||||
|
@ -1281,7 +1281,7 @@ class PathConfig(TiramisuAPI):
|
||||||
else:
|
else:
|
||||||
_children.append(child)
|
_children.append(child)
|
||||||
|
|
||||||
config = KernelPathConfig(optiondescription,
|
config = KernelMixConfig(optiondescription,
|
||||||
_children,
|
_children,
|
||||||
session_id=session_id,
|
session_id=session_id,
|
||||||
persistent=persistent)
|
persistent=persistent)
|
||||||
|
|
|
@ -671,7 +671,7 @@ class _CommonConfig(SubConfig):
|
||||||
metaconfig_prefix=None,
|
metaconfig_prefix=None,
|
||||||
child=None,
|
child=None,
|
||||||
deep=False):
|
deep=False):
|
||||||
assert isinstance(self, (KernelConfig, KernelPathConfig)), _('cannot duplicate {}').format(self.__class__.__name__)
|
assert isinstance(self, (KernelConfig, KernelMixConfig)), _('cannot duplicate {}').format(self.__class__.__name__)
|
||||||
if isinstance(self, KernelConfig):
|
if isinstance(self, KernelConfig):
|
||||||
duplicated_config = KernelConfig(self._impl_descr,
|
duplicated_config = KernelConfig(self._impl_descr,
|
||||||
_duplicate=True,
|
_duplicate=True,
|
||||||
|
@ -812,7 +812,7 @@ class KernelGroupConfig(_CommonConfig):
|
||||||
resetted_opts=None):
|
resetted_opts=None):
|
||||||
if resetted_opts is None:
|
if resetted_opts is None:
|
||||||
resetted_opts = []
|
resetted_opts = []
|
||||||
if isinstance(self, KernelPathConfig):
|
if isinstance(self, KernelMixConfig):
|
||||||
super().cfgimpl_reset_cache(option_bag,
|
super().cfgimpl_reset_cache(option_bag,
|
||||||
resetted_opts=copy(resetted_opts))
|
resetted_opts=copy(resetted_opts))
|
||||||
for child in self._impl_children:
|
for child in self._impl_children:
|
||||||
|
@ -889,7 +889,7 @@ class KernelGroupConfig(_CommonConfig):
|
||||||
#so search only one time the option for all children
|
#so search only one time the option for all children
|
||||||
if bypath is undefined and byname is not None and \
|
if bypath is undefined and byname is not None and \
|
||||||
isinstance(self,
|
isinstance(self,
|
||||||
KernelPathConfig):
|
KernelMixConfig):
|
||||||
bypath = next(self.find(bytype=None,
|
bypath = next(self.find(bytype=None,
|
||||||
byvalue=undefined,
|
byvalue=undefined,
|
||||||
byname=byname,
|
byname=byname,
|
||||||
|
@ -959,9 +959,9 @@ class KernelGroupConfig(_CommonConfig):
|
||||||
raise ConfigError(_('unknown config "{}"').format(name))
|
raise ConfigError(_('unknown config "{}"').format(name))
|
||||||
|
|
||||||
|
|
||||||
class KernelPathConfig(KernelGroupConfig):
|
class KernelMixConfig(KernelGroupConfig):
|
||||||
__slots__ = tuple()
|
__slots__ = tuple()
|
||||||
impl_type = 'path'
|
impl_type = 'mix'
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
optiondescription,
|
optiondescription,
|
||||||
|
@ -1147,7 +1147,7 @@ class KernelPathConfig(KernelGroupConfig):
|
||||||
_commit=False)
|
_commit=False)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
if isinstance(child, KernelPathConfig):
|
if isinstance(child, KernelMixConfig):
|
||||||
child.reset(path,
|
child.reset(path,
|
||||||
False,
|
False,
|
||||||
rconfig_bag,
|
rconfig_bag,
|
||||||
|
@ -1160,7 +1160,7 @@ class KernelPathConfig(KernelGroupConfig):
|
||||||
self.cfgimpl_get_values()._p_.commit()
|
self.cfgimpl_get_values()._p_.commit()
|
||||||
|
|
||||||
|
|
||||||
class KernelMetaConfig(KernelPathConfig):
|
class KernelMetaConfig(KernelMixConfig):
|
||||||
__slots__ = tuple()
|
__slots__ = tuple()
|
||||||
impl_type = 'meta'
|
impl_type = 'meta'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue