master/slaves => leader/followers
This commit is contained in:
parent
b9ae1ec656
commit
c3f968dbde
35 changed files with 923 additions and 1031 deletions
|
@ -9,9 +9,9 @@ from collections import OrderedDict
|
|||
from .autopath import do_autopath
|
||||
do_autopath()
|
||||
from tiramisu import Config, MetaConfig, \
|
||||
StrOption, SymLinkOption, OptionDescription, MasterSlaves, DynOptionDescription, \
|
||||
StrOption, SymLinkOption, OptionDescription, Leadership, DynOptionDescription, \
|
||||
submulti, undefined, owners, Params, ParamOption
|
||||
from tiramisu.error import PropertiesOptionError, APIError, ConfigError, SlaveError
|
||||
from tiramisu.error import PropertiesOptionError, APIError, ConfigError, LeadershipError
|
||||
ICON = u'\u2937'
|
||||
|
||||
OPTIONS_TYPE = {'str': {'type': str,
|
||||
|
@ -73,18 +73,18 @@ def autocheck(func):
|
|||
def _autocheck_default_value(cfg, path, conf, **kwargs):
|
||||
"""set and get values
|
||||
"""
|
||||
# check if is a multi, a master or a slave
|
||||
# check if is a multi, a leader or a follower
|
||||
multi = cfg.unrestraint.option(path).option.ismulti()
|
||||
submulti_ = cfg.unrestraint.option(path).option.issubmulti()
|
||||
isslave = cfg.unrestraint.option(path).option.isslave()
|
||||
isfollower = cfg.unrestraint.option(path).option.isfollower()
|
||||
|
||||
# set default value (different if value is multi or not)
|
||||
empty_value = kwargs['default']
|
||||
|
||||
# test default value (should be empty)
|
||||
# cannot test for slave (we cannot get all values for a slave)
|
||||
# cannot test for follower (we cannot get all values for a follower)
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert cfg.config(conf).option(path).value.get() == empty_value
|
||||
assert cfg.config(conf).forcepermissive.option(path).value.get() == empty_value
|
||||
|
@ -113,26 +113,26 @@ def _set_value(cfg, pathwrite, conf, **kwargs):
|
|||
set_permissive = kwargs.get('set_permissive', True)
|
||||
multi = cfg.unrestraint.option(pathwrite).option.ismulti()
|
||||
submulti_ = cfg.unrestraint.option(pathwrite).option.issubmulti()
|
||||
ismaster = cfg.unrestraint.option(pathwrite).option.ismaster()
|
||||
isslave = cfg.unrestraint.option(pathwrite).option.isslave()
|
||||
isleader = cfg.unrestraint.option(pathwrite).option.isleader()
|
||||
isfollower = cfg.unrestraint.option(pathwrite).option.isfollower()
|
||||
if not multi:
|
||||
first_value = FIRST_VALUE
|
||||
elif submulti_ is False:
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
first_value = LIST_FIRST_VALUE
|
||||
else:
|
||||
second_value = LIST_SECOND_VALUE[1]
|
||||
|
||||
else:
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
first_value = SUBLIST_FIRST_VALUE
|
||||
else:
|
||||
second_value = SUBLIST_SECOND_VALUE[1]
|
||||
|
||||
# for slave should have an index and good length
|
||||
# for master must append, not set
|
||||
# for follower should have an index and good length
|
||||
# for leader must append, not set
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
if ismaster:
|
||||
if isleader:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
raises(APIError, "cfg.config(conf).option(pathwrite, 0).value.set(first_value[0])")
|
||||
if not set_permissive:
|
||||
|
@ -148,7 +148,7 @@ def _set_value(cfg, pathwrite, conf, **kwargs):
|
|||
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathwrite).value.set([first_value[0]])")
|
||||
if len(first_value) > 1:
|
||||
raises(APIError, "cfg.config(conf).unrestraint.option(pathwrite).value.set(first_value[1])")
|
||||
elif isslave:
|
||||
elif isfollower:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
if not set_permissive:
|
||||
cfg.config(conf).option(pathwrite, 1).value.set(second_value)
|
||||
|
@ -179,10 +179,10 @@ def _set_value(cfg, pathwrite, conf, **kwargs):
|
|||
#FIXME raises(APIError, "cfg.config(conf).unrestraint.option(pathwrite).value.set(first_value)")
|
||||
|
||||
|
||||
def _getproperties(multi, isslave, kwargs):
|
||||
def _getproperties(multi, isfollower, kwargs):
|
||||
# define properties
|
||||
properties = copy(PROPERTIES_LIST)
|
||||
if multi and not isslave:
|
||||
if multi and not isfollower:
|
||||
default_props = ['empty']
|
||||
properties.append('empty')
|
||||
else:
|
||||
|
@ -195,7 +195,7 @@ def _getproperties(multi, isslave, kwargs):
|
|||
|
||||
|
||||
def _check_properties(cfg, mcfg, pathread, conf, kwargs, props_permissive, props):
|
||||
if not cfg.unrestraint.option(pathread).option.isslave():
|
||||
if not cfg.unrestraint.option(pathread).option.isfollower():
|
||||
if not kwargs.get('permissive_od', False):
|
||||
assert set(cfg.config(conf).option(pathread).property.get()) == set(props_permissive)
|
||||
assert set(cfg.config(conf).option(pathread).property.get()) == set(props)
|
||||
|
@ -229,13 +229,13 @@ def _check_properties(cfg, mcfg, pathread, conf, kwargs, props_permissive, props
|
|||
|
||||
|
||||
def _property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
# check if is a multi or a slave
|
||||
# check if is a multi or a follower
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
|
||||
# define properties
|
||||
properties = copy(PROPERTIES_LIST)
|
||||
if multi and not isslave:
|
||||
if multi and not isfollower:
|
||||
default_props = ['empty']
|
||||
properties.append('empty')
|
||||
else:
|
||||
|
@ -244,7 +244,7 @@ def _property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **
|
|||
if extra_properties:
|
||||
properties.extend(extra_properties)
|
||||
default_props.extend(extra_properties)
|
||||
default_props, properties = _getproperties(multi, isslave, kwargs)
|
||||
default_props, properties = _getproperties(multi, isfollower, kwargs)
|
||||
|
||||
if confwrite == confread:
|
||||
_check_properties(cfg, mcfg, pathread, confwrite, kwargs, default_props, default_props)
|
||||
|
@ -269,25 +269,25 @@ def _autocheck_get_value(cfg, pathread, conf, **kwargs):
|
|||
set_permissive = kwargs.get('set_permissive', True)
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
empty_value = kwargs['default']
|
||||
if not multi:
|
||||
first_value = FIRST_VALUE
|
||||
elif submulti_ is False:
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
first_value = LIST_FIRST_VALUE
|
||||
else:
|
||||
second_value = LIST_SECOND_VALUE[1]
|
||||
|
||||
else:
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
first_value = SUBLIST_FIRST_VALUE
|
||||
else:
|
||||
second_value = SUBLIST_SECOND_VALUE[1]
|
||||
|
||||
# get value after set value without permissive
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
if isslave:
|
||||
if isfollower:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert cfg.config(conf).option(pathread, 0).value.get() == empty_value
|
||||
assert cfg.config(conf).option(pathread, 1).value.get() == second_value
|
||||
|
@ -319,8 +319,8 @@ def _autocheck_get_value(cfg, pathread, conf, **kwargs):
|
|||
|
||||
|
||||
def _check_owner(cfg, pathread, conf, kwargs, owner, permissive_owner):
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
if not isslave:
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
if not isfollower:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert cfg.config(conf).option(pathread).owner.get() == owner
|
||||
assert cfg.config(conf).forcepermissive.option(pathread).owner.get() == owner
|
||||
|
@ -351,18 +351,18 @@ def autocheck_option_multi(cfg, mcfg, pathread, pathwrite, confread, confwrite,
|
|||
if not kwargs.get('permissive_od', False):
|
||||
cfg.option(pathread).option.ismulti()
|
||||
cfg.option(pathread).option.issubmulti()
|
||||
cfg.option(pathread).option.ismaster()
|
||||
cfg.option(pathread).option.isslave()
|
||||
cfg.option(pathread).option.isleader()
|
||||
cfg.option(pathread).option.isfollower()
|
||||
else:
|
||||
raises(PropertiesOptionError, "cfg.option(pathread).option.ismulti()")
|
||||
raises(PropertiesOptionError, "cfg.option(pathread).option.issubmulti()")
|
||||
raises(PropertiesOptionError, "cfg.option(pathread).option.ismaster()")
|
||||
raises(PropertiesOptionError, "cfg.option(pathread).option.isslave()")
|
||||
raises(PropertiesOptionError, "cfg.option(pathread).option.isleader()")
|
||||
raises(PropertiesOptionError, "cfg.option(pathread).option.isfollower()")
|
||||
|
||||
cfg.forcepermissive.option(pathread).option.ismulti()
|
||||
cfg.forcepermissive.option(pathread).option.issubmulti()
|
||||
cfg.forcepermissive.option(pathread).option.ismaster()
|
||||
cfg.forcepermissive.option(pathread).option.isslave()
|
||||
cfg.forcepermissive.option(pathread).option.isleader()
|
||||
cfg.forcepermissive.option(pathread).option.isfollower()
|
||||
|
||||
|
||||
|
||||
|
@ -370,10 +370,10 @@ def autocheck_option_multi(cfg, mcfg, pathread, pathwrite, confread, confwrite,
|
|||
def autocheck_default_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
"""check different value of owner when any value is set to this option
|
||||
"""
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
# check if owner is a string "default" and 'isdefault'
|
||||
def do(conf):
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert cfg.config(conf).option(pathread).owner.get() == 'default'
|
||||
assert cfg.config(conf).forcepermissive.option(pathread).owner.get() == 'default'
|
||||
|
@ -438,7 +438,7 @@ def autocheck_set_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k
|
|||
def autocheck_get_value_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
empty_value = kwargs['default']
|
||||
if not multi:
|
||||
|
@ -450,7 +450,7 @@ def autocheck_get_value_permissive(cfg, mcfg, pathread, pathwrite, confread, con
|
|||
|
||||
def do(conf):
|
||||
# get value after set value without permissive
|
||||
if isslave:
|
||||
if isfollower:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert cfg.config(conf).option(pathread, 0).value.get() == empty_value
|
||||
assert cfg.config(conf).forcepermissive.option(pathread, 0).value.get() == empty_value
|
||||
|
@ -504,9 +504,9 @@ def autocheck_get_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k
|
|||
|
||||
|
||||
@autocheck
|
||||
def autocheck_value_slave(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
if not isslave:
|
||||
def autocheck_value_follower(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
if not isfollower:
|
||||
return
|
||||
if kwargs.get('propertyerror', False):
|
||||
return
|
||||
|
@ -529,28 +529,28 @@ def autocheck_value_slave(cfg, mcfg, pathread, pathwrite, confread, confwrite, *
|
|||
value.append(cfg.forcepermissive.option(pathread, idx).value.get())
|
||||
|
||||
assert value == [empty_value, empty_value]
|
||||
# cannot access to a slave with index too high
|
||||
# cannot access to a follower with index too high
|
||||
if submulti_ is False:
|
||||
value = LIST_FIRST_VALUE[0]
|
||||
else:
|
||||
value = SUBLIST_FIRST_VALUE[0]
|
||||
|
||||
raises(SlaveError, "cfg.forcepermissive.option(pathread, length).value.get()")
|
||||
raises(SlaveError, "cfg.forcepermissive.option(pathread, length).value.set(value)")
|
||||
raises(SlaveError, "cfg.forcepermissive.option(pathread, length).value.reset()")
|
||||
raises(SlaveError, "cfg.forcepermissive.option(pathread, length).owner.get()")
|
||||
raises(SlaveError, "cfg.forcepermissive.option(pathread, length).owner.isdefault()")
|
||||
raises(SlaveError, "cfg.forcepermissive.option(pathread, length).property.get()")
|
||||
raises(SlaveError, "cfg.forcepermissive.option(pathread, length).owner.set('new_user')")
|
||||
raises(SlaveError, "cfg.forcepermissive.option(pathread, length).property.add('prop')")
|
||||
raises(LeadershipError, "cfg.forcepermissive.option(pathread, length).value.get()")
|
||||
raises(LeadershipError, "cfg.forcepermissive.option(pathread, length).value.set(value)")
|
||||
raises(LeadershipError, "cfg.forcepermissive.option(pathread, length).value.reset()")
|
||||
raises(LeadershipError, "cfg.forcepermissive.option(pathread, length).owner.get()")
|
||||
raises(LeadershipError, "cfg.forcepermissive.option(pathread, length).owner.isdefault()")
|
||||
raises(LeadershipError, "cfg.forcepermissive.option(pathread, length).property.get()")
|
||||
raises(LeadershipError, "cfg.forcepermissive.option(pathread, length).owner.set('new_user')")
|
||||
raises(LeadershipError, "cfg.forcepermissive.option(pathread, length).property.add('prop')")
|
||||
|
||||
|
||||
@autocheck
|
||||
def autocheck_reset_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
# check if is a multi, a master or a slave
|
||||
# check if is a multi, a leader or a follower
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
|
||||
# set default value (different if value is multi or not)
|
||||
if not multi:
|
||||
|
@ -567,7 +567,7 @@ def autocheck_reset_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, *
|
|||
|
||||
# reset value without permissive
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
cfg.config(confwrite).option(pathwrite).value.reset()
|
||||
#else:
|
||||
|
@ -580,7 +580,7 @@ def autocheck_reset_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, *
|
|||
|
||||
# get value after reset value without permissive
|
||||
def do(conf):
|
||||
if isslave:
|
||||
if isfollower:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert cfg.config(conf).option(pathread, 0).value.get() == empty_value
|
||||
assert cfg.config(conf).option(pathread, 1).value.get() == second_value[1]
|
||||
|
@ -602,111 +602,111 @@ def autocheck_reset_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, *
|
|||
|
||||
@autocheck
|
||||
def autocheck_append_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
ismaster = cfg.unrestraint.option(pathread).option.ismaster()
|
||||
isleader = cfg.unrestraint.option(pathread).option.isleader()
|
||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||
if not ismaster:
|
||||
if not isleader:
|
||||
return
|
||||
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
if not kwargs.get('propertyerror', False):
|
||||
master_value = cfg.config(confread).forcepermissive.option(pathread).value.get()
|
||||
len_value = len(master_value)
|
||||
master_value.append(undefined)
|
||||
leader_value = cfg.config(confread).forcepermissive.option(pathread).value.get()
|
||||
len_value = len(leader_value)
|
||||
leader_value.append(undefined)
|
||||
assert len(cfg.config(confread).forcepermissive.option(pathread).value.get()) == len_value
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.forcepermissive.config(confwrite).option(pathread).value.set(master_value)
|
||||
new_master_value = cfg.config(confread).forcepermissive.option(pathread).value.get()
|
||||
len_new = len(new_master_value)
|
||||
cfg.forcepermissive.config(confwrite).option(pathread).value.set(leader_value)
|
||||
new_leader_value = cfg.config(confread).forcepermissive.option(pathread).value.get()
|
||||
len_new = len(new_leader_value)
|
||||
assert len_value + 1 == len_new
|
||||
assert new_master_value[-1] == kwargs['default_multi']
|
||||
slave_path = pathread.rsplit('.', 1)[0]
|
||||
if slave_path.endswith('val1') or slave_path.endswith('val2'):
|
||||
slave_path += '.third' + slave_path[-4:]
|
||||
assert new_leader_value[-1] == kwargs['default_multi']
|
||||
follower_path = pathread.rsplit('.', 1)[0]
|
||||
if follower_path.endswith('val1') or follower_path.endswith('val2'):
|
||||
follower_path += '.third' + follower_path[-4:]
|
||||
else:
|
||||
slave_path += '.third'
|
||||
follower_path += '.third'
|
||||
for idx in range(len_new):
|
||||
assert cfg.config(confread).forcepermissive.option(slave_path, idx).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(follower_path, idx).value.get() == kwargs['default_multi']
|
||||
#
|
||||
if not submulti_:
|
||||
value = 'value'
|
||||
else:
|
||||
value = ['value']
|
||||
master_value.append(value)
|
||||
assert len(cfg.config(confread).forcepermissive.option(pathread).value.get()) == len(new_master_value)
|
||||
cfg.forcepermissive.config(confwrite).option(pathread).value.set(master_value)
|
||||
leader_value.append(value)
|
||||
assert len(cfg.config(confread).forcepermissive.option(pathread).value.get()) == len(new_leader_value)
|
||||
cfg.forcepermissive.config(confwrite).option(pathread).value.set(leader_value)
|
||||
assert cfg.config(confread).forcepermissive.option(pathread).value.get()[-1] == value
|
||||
|
||||
|
||||
@autocheck
|
||||
def autocheck_pop_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
ismaster = cfg.unrestraint.option(pathread).option.ismaster()
|
||||
isleader = cfg.unrestraint.option(pathread).option.isleader()
|
||||
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
|
||||
if not ismaster:
|
||||
if not isleader:
|
||||
return
|
||||
|
||||
if not kwargs.get('propertyerror', False):
|
||||
if not submulti_:
|
||||
values = ['value1', 'value2', 'value3', 'value4']
|
||||
slave_value = 'slave'
|
||||
follower_value = 'follower'
|
||||
else:
|
||||
values = [['value1'], ['value2'], ['value3'], ['value4']]
|
||||
slave_value = ['slave']
|
||||
slaves = [kwargs['default_multi'], slave_value, kwargs['default_multi'], kwargs['default_multi']]
|
||||
a_slave = pathwrite.rsplit('.', 1)[0]
|
||||
if a_slave.endswith('val1') or a_slave.endswith('val2'):
|
||||
a_slave += '.third' + a_slave[-4:]
|
||||
follower_value = ['follower']
|
||||
followers = [kwargs['default_multi'], follower_value, kwargs['default_multi'], kwargs['default_multi']]
|
||||
a_follower = pathwrite.rsplit('.', 1)[0]
|
||||
if a_follower.endswith('val1') or a_follower.endswith('val2'):
|
||||
a_follower += '.third' + a_follower[-4:]
|
||||
else:
|
||||
a_slave += '.third'
|
||||
a_follower += '.third'
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
cfg.forcepermissive.config(confwrite).option(pathread).value.set(values)
|
||||
cfg.forcepermissive.config(confwrite).option(a_slave, 1).value.set(slave_value)
|
||||
cfg.config(confread).forcepermissive.option(a_slave, 0).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_slave, 0).owner.isdefault() is True
|
||||
cfg.config(confread).forcepermissive.option(a_slave, 1).value.get() == slave_value
|
||||
assert cfg.config(confread).forcepermissive.option(a_slave, 1).owner.isdefault() is False
|
||||
cfg.config(confread).forcepermissive.option(a_slave, 2).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_slave, 2).owner.isdefault() is True
|
||||
cfg.config(confread).forcepermissive.option(a_slave, 3).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_slave, 3).owner.isdefault() is True
|
||||
cfg.forcepermissive.config(confwrite).option(a_follower, 1).value.set(follower_value)
|
||||
cfg.config(confread).forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_follower, 0).owner.isdefault() is True
|
||||
cfg.config(confread).forcepermissive.option(a_follower, 1).value.get() == follower_value
|
||||
assert cfg.config(confread).forcepermissive.option(a_follower, 1).owner.isdefault() is False
|
||||
cfg.config(confread).forcepermissive.option(a_follower, 2).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_follower, 2).owner.isdefault() is True
|
||||
cfg.config(confread).forcepermissive.option(a_follower, 3).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_follower, 3).owner.isdefault() is True
|
||||
#
|
||||
cfg.forcepermissive.config(confwrite).option(pathread).value.pop(3)
|
||||
cfg.config(confread).forcepermissive.option(a_slave, 0).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_slave, 0).owner.isdefault() is True
|
||||
cfg.config(confread).forcepermissive.option(a_slave, 1).value.get() == slave_value
|
||||
assert cfg.config(confread).forcepermissive.option(a_slave, 1).owner.isdefault() is False
|
||||
cfg.config(confread).forcepermissive.option(a_slave, 2).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_slave, 2).owner.isdefault() is True
|
||||
cfg.config(confread).forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_follower, 0).owner.isdefault() is True
|
||||
cfg.config(confread).forcepermissive.option(a_follower, 1).value.get() == follower_value
|
||||
assert cfg.config(confread).forcepermissive.option(a_follower, 1).owner.isdefault() is False
|
||||
cfg.config(confread).forcepermissive.option(a_follower, 2).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_follower, 2).owner.isdefault() is True
|
||||
#
|
||||
cfg.forcepermissive.config(confwrite).option(pathread).value.pop(0)
|
||||
cfg.config(confread).forcepermissive.option(a_slave, 0).value.get() == slave_value
|
||||
assert cfg.config(confread).forcepermissive.option(a_slave, 0).owner.isdefault() is False
|
||||
cfg.config(confread).forcepermissive.option(a_slave, 1).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_slave, 1).owner.isdefault() is True
|
||||
cfg.config(confread).forcepermissive.option(a_follower, 0).value.get() == follower_value
|
||||
assert cfg.config(confread).forcepermissive.option(a_follower, 0).owner.isdefault() is False
|
||||
cfg.config(confread).forcepermissive.option(a_follower, 1).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_follower, 1).owner.isdefault() is True
|
||||
#
|
||||
cfg.forcepermissive.config(confwrite).option(pathread).value.pop(0)
|
||||
cfg.config(confread).forcepermissive.option(a_slave, 0).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_slave, 0).owner.isdefault() is True
|
||||
cfg.config(confread).forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi']
|
||||
assert cfg.config(confread).forcepermissive.option(a_follower, 0).owner.isdefault() is True
|
||||
|
||||
|
||||
@autocheck
|
||||
def autocheck_reset_value_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
# check if is a multi, a master or a slave
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
# check if is a multi, a leader or a follower
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
# reset value with permissive
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
cfg.forcepermissive.config(confwrite).option(pathwrite).value.reset()
|
||||
else:
|
||||
cfg.forcepermissive.option(pathwrite, 1).value.reset()
|
||||
elif kwargs.get('permissive', False):
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
cfg.forcepermissive.config(confwrite).option(pathwrite).value.reset()
|
||||
else:
|
||||
cfg.forcepermissive.option(pathwrite, 1).value.reset()
|
||||
#FIXME else:
|
||||
# if not isslave:
|
||||
# if not isfollower:
|
||||
# raises(PropertiesOptionError, "cfg.forcepermissive.config(confwrite).option(pathwrite).value.reset()")
|
||||
# else:
|
||||
# raises(PropertiesOptionError, "cfg.forcepermissive.option(pathwrite, 1).value.reset()")
|
||||
|
@ -736,11 +736,11 @@ def autocheck_display(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwa
|
|||
def autocheck_property(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
"""get property from path
|
||||
"""
|
||||
# check if is a multi or a slave
|
||||
# check if is a multi or a follower
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
|
||||
default_props, properties = _getproperties(multi, isslave, kwargs)
|
||||
default_props, properties = _getproperties(multi, isfollower, kwargs)
|
||||
|
||||
if confread == confwrite:
|
||||
_check_properties(cfg, mcfg, pathread, confread, kwargs, default_props, default_props)
|
||||
|
@ -766,10 +766,10 @@ def autocheck_property_permissive(cfg, mcfg, pathread, pathwrite, confread, conf
|
|||
def autocheck_reset_property(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
"""check properties after set with permissive
|
||||
"""
|
||||
# check if is a multi or a slave
|
||||
# check if is a multi or a follower
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
default_props, properties = _getproperties(multi, isslave, kwargs)
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
default_props, properties = _getproperties(multi, isfollower, kwargs)
|
||||
|
||||
_property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||
|
||||
|
@ -784,10 +784,10 @@ def autocheck_reset_property(cfg, mcfg, pathread, pathwrite, confread, confwrite
|
|||
|
||||
@autocheck
|
||||
def autocheck_reset_property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
# check if is a multi or a slave
|
||||
# check if is a multi or a follower
|
||||
multi = cfg.unrestraint.option(pathread).option.ismulti()
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
default_props, properties = _getproperties(multi, isslave, kwargs)
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
default_props, properties = _getproperties(multi, isfollower, kwargs)
|
||||
|
||||
_property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||
|
||||
|
@ -816,11 +816,11 @@ def autocheck_owner_with_value(cfg, mcfg, pathread, pathwrite, confread, confwri
|
|||
|
||||
@autocheck
|
||||
def autocheck_default_owner_with_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
|
||||
# test if is default owner without permissive
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert cfg.config(confwrite).option(pathread).owner.isdefault() is False
|
||||
if confwrite != confread:
|
||||
|
@ -842,15 +842,15 @@ def autocheck_default_owner_with_value(cfg, mcfg, pathread, pathwrite, confread,
|
|||
|
||||
@autocheck
|
||||
def autocheck_default_owner_with_value_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
# check if is a isslave
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
# check if is a isfollower
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
|
||||
def do(conf):
|
||||
# test if is default owner with permissive
|
||||
if not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
assert cfg.config(conf).forcepermissive.option(pathread).owner.isdefault() is False
|
||||
else:
|
||||
assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.isdefault() is True
|
||||
|
@ -864,9 +864,9 @@ def autocheck_default_owner_with_value_permissive(cfg, mcfg, pathread, pathwrite
|
|||
|
||||
@autocheck
|
||||
def autocheck_set_owner_no_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
if not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
raises(ConfigError, "cfg.forcepermissive.config(confwrite).option(pathwrite).owner.set('new_user')")
|
||||
else:
|
||||
raises(ConfigError, "cfg.forcepermissive.option(pathwrite, 1).owner.set('new_user')")
|
||||
|
@ -875,12 +875,12 @@ def autocheck_set_owner_no_value(cfg, mcfg, pathread, pathwrite, confread, confw
|
|||
@autocheck
|
||||
def autocheck_set_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
# test set owner without permissive
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
|
||||
# set owner without permissive
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
cfg.config(confwrite).option(pathwrite).owner.set('new_user')
|
||||
raises(ValueError, "cfg.config(confwrite).option(pathwrite).owner.set('default')")
|
||||
|
@ -900,18 +900,18 @@ def autocheck_set_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k
|
|||
|
||||
@autocheck
|
||||
def autocheck_set_owner_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
isslave = cfg.unrestraint.option(pathread).option.isslave()
|
||||
isfollower = cfg.unrestraint.option(pathread).option.isfollower()
|
||||
|
||||
_set_value(cfg, pathwrite, confwrite, **kwargs)
|
||||
|
||||
# set owner with permissive
|
||||
if not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
if not isfollower:
|
||||
cfg.forcepermissive.config(confwrite).option(pathwrite).owner.set('new_user1')
|
||||
else:
|
||||
cfg.forcepermissive.option(pathwrite, 1).owner.set('new_user1')
|
||||
#FIXME else:
|
||||
# if not isslave:
|
||||
# if not isfollower:
|
||||
# raises(PropertiesOptionError,
|
||||
# "cfg.forcepermissive.config(confwrite).option(pathwrite).owner.set('new_user1')")
|
||||
# else:
|
||||
|
@ -1096,7 +1096,7 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
|||
kwargs['default'] = default_value
|
||||
|
||||
is_dyn = False
|
||||
is_master = False
|
||||
is_leader = False
|
||||
dyns = []
|
||||
has_value = False
|
||||
for cpath, options in paths_.items():
|
||||
|
@ -1107,8 +1107,8 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
|||
for dname in cpath.split('.')[:-1]:
|
||||
if options.get(dname, {}).get('dyn'):
|
||||
is_dyn = True
|
||||
if options.get(dname, {}).get('master'):
|
||||
is_master = True
|
||||
if options.get(dname, {}).get('leader'):
|
||||
is_leader = True
|
||||
else:
|
||||
dirname = ''
|
||||
name = cpath
|
||||
|
@ -1132,9 +1132,9 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
|||
dico_value[cpath + 'link'] = default_value
|
||||
|
||||
has_value = True
|
||||
isslave = False
|
||||
if '.' in path and is_master and not path.rsplit('.', 1)[1].startswith('first'):
|
||||
isslave = True
|
||||
isfollower = False
|
||||
if '.' in path and is_leader and not path.rsplit('.', 1)[1].startswith('first'):
|
||||
isfollower = True
|
||||
if not multi is submulti:
|
||||
kwargs['default'] = None
|
||||
if is_dyn and dyns:
|
||||
|
@ -1181,7 +1181,7 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
|||
if is_dyn:
|
||||
dico[cpath + 'extraoptconsistencyval1'] = value
|
||||
dico_value[cpath + 'extraoptconsistencyval1'] = value
|
||||
if is_master:
|
||||
if is_leader:
|
||||
spath = cpath.split('.')
|
||||
spath[-2] = spath[-2][:-1] + '2'
|
||||
spath[-3] = spath[-3][:-1] + '2'
|
||||
|
@ -1193,7 +1193,7 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
|||
else:
|
||||
dico[cpath + 'extraoptconsistency'] = value
|
||||
dico_value[cpath + 'extraoptconsistency'] = value
|
||||
if is_master:
|
||||
if is_leader:
|
||||
for cpath in list(paths_.keys())[len(dyns):]:
|
||||
if cpath.endswith('.first') or cpath.endswith('.firstval1') or cpath.endswith('.firstval2'):
|
||||
second_path = cpath.rsplit('.', 1)[0] + '.second'
|
||||
|
@ -1216,31 +1216,31 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
|||
dvalue = None
|
||||
#
|
||||
kwargs['default_multi'] = dvalue
|
||||
if isslave:
|
||||
if isfollower:
|
||||
kwargs['default'] = dvalue
|
||||
len_master = len(dico[cpath])
|
||||
len_leader = len(dico[cpath])
|
||||
if second_path in dico:
|
||||
dico[second_path] = [dvalue] * len_master
|
||||
dico[second_path] = [dvalue] * len_leader
|
||||
if symlink:
|
||||
dico[second_path + 'link'] = [dvalue] * len_master
|
||||
dico[second_path + 'link'] = [dvalue] * len_leader
|
||||
if third_path in dico:
|
||||
dico[third_path] = [dvalue] * len_master
|
||||
dico[third_path] = [dvalue] * len_leader
|
||||
if symlink:
|
||||
dico[third_path + 'link'] = [dvalue] * len_master
|
||||
dico[third_path + 'link'] = [dvalue] * len_leader
|
||||
if cons_path in dico:
|
||||
dico[cons_path] = [dvalue] * len_master
|
||||
dico[cons_path] = [dvalue] * len_leader
|
||||
#
|
||||
len_master = len(dico_value[cpath])
|
||||
len_leader = len(dico_value[cpath])
|
||||
if second_path in dico_value:
|
||||
dico_value[second_path] = [dvalue] * len_master
|
||||
dico_value[second_path] = [dvalue] * len_leader
|
||||
if symlink:
|
||||
dico_value[second_path + 'link'] = [dvalue] * len_master
|
||||
dico_value[second_path + 'link'] = [dvalue] * len_leader
|
||||
if third_path in dico_value:
|
||||
dico_value[third_path] = [dvalue] * len_master
|
||||
dico_value[third_path] = [dvalue] * len_leader
|
||||
if symlink:
|
||||
dico_value[third_path + 'link'] = [dvalue] * len_master
|
||||
dico_value[third_path + 'link'] = [dvalue] * len_leader
|
||||
if cons_path in dico_value:
|
||||
dico_value[cons_path] = [dvalue] * len_master
|
||||
dico_value[cons_path] = [dvalue] * len_leader
|
||||
return is_dyn, dico, dico_value
|
||||
if DISPLAY:
|
||||
text = u' {} launch tests for {}'.format(ICON, path)
|
||||
|
@ -1288,33 +1288,33 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
|||
else:
|
||||
ckwargs['owner'] = OWNER
|
||||
|
||||
if mcfg.unrestraint.option(path).option.isslave():
|
||||
if mcfg.unrestraint.option(path).option.isfollower():
|
||||
dirname = path.rsplit('.', 1)[0]
|
||||
master_path = dirname + '.first'
|
||||
master_path_2 = None
|
||||
leader_path = dirname + '.first'
|
||||
leader_path_2 = None
|
||||
if dirname.endswith('val1') or dirname.endswith('val2'):
|
||||
master_path += 'val1'
|
||||
master_path = master_path.replace('val2', 'val1')
|
||||
master_path_2 = master_path.replace('val1', 'val2')
|
||||
leader_path += 'val1'
|
||||
leader_path = leader_path.replace('val2', 'val1')
|
||||
leader_path_2 = leader_path.replace('val1', 'val2')
|
||||
if multi is submulti:
|
||||
value = SUBLIST_SECOND_VALUE
|
||||
else:
|
||||
value = LIST_SECOND_VALUE
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
mcfg.option(master_path).value.set(value)
|
||||
ckwargs['make_dict'][master_path] = value
|
||||
ckwargs['make_dict_value'][master_path] = value
|
||||
mcfg.option(leader_path).value.set(value)
|
||||
ckwargs['make_dict'][leader_path] = value
|
||||
ckwargs['make_dict_value'][leader_path] = value
|
||||
if symlink:
|
||||
ckwargs['make_dict'][master_path + 'link'] = value
|
||||
ckwargs['make_dict_value'][master_path + 'link'] = value
|
||||
if master_path_2:
|
||||
ckwargs['make_dict'][leader_path + 'link'] = value
|
||||
ckwargs['make_dict_value'][leader_path + 'link'] = value
|
||||
if leader_path_2:
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
mcfg.option(master_path_2).value.set(value)
|
||||
ckwargs['make_dict'][master_path_2] = value
|
||||
ckwargs['make_dict_value'][master_path_2] = value
|
||||
mcfg.option(leader_path_2).value.set(value)
|
||||
ckwargs['make_dict'][leader_path_2] = value
|
||||
ckwargs['make_dict_value'][leader_path_2] = value
|
||||
if symlink:
|
||||
ckwargs['make_dict'][master_path_2 + 'link'] = value
|
||||
ckwargs['make_dict_value'][master_path_2 + 'link'] = value
|
||||
ckwargs['make_dict'][leader_path_2 + 'link'] = value
|
||||
ckwargs['make_dict_value'][leader_path_2 + 'link'] = value
|
||||
if default_multi:
|
||||
if multi is not submulti:
|
||||
dvalue = SECOND_VALUE
|
||||
|
@ -1337,9 +1337,9 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
|||
ckwargs['make_dict'][npath + 'link'] = [dvalue] * len(value)
|
||||
ckwargs['make_dict_value'][npath + 'link'] = [dvalue] * len(value)
|
||||
if path == npath:
|
||||
ckwargs['make_dict_value'][npath][-1] = ckwargs['make_dict_value'][master_path][-1]
|
||||
ckwargs['make_dict_value'][npath][-1] = ckwargs['make_dict_value'][leader_path][-1]
|
||||
if symlink:
|
||||
ckwargs['make_dict_value'][npath + 'link'][-1] = ckwargs['make_dict_value'][master_path][-1]
|
||||
ckwargs['make_dict_value'][npath + 'link'][-1] = ckwargs['make_dict_value'][leader_path][-1]
|
||||
npath = ldirname + '.third' + suffix
|
||||
if npath in ckwargs['make_dict']:
|
||||
ckwargs['make_dict'][npath] = [dvalue] * len(value)
|
||||
|
@ -1348,9 +1348,9 @@ def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, c
|
|||
ckwargs['make_dict'][npath + 'link'] = [dvalue] * len(value)
|
||||
ckwargs['make_dict_value'][npath + 'link'] = [dvalue] * len(value)
|
||||
if path == npath:
|
||||
ckwargs['make_dict_value'][npath][-1] = ckwargs['make_dict_value'][master_path][-1]
|
||||
ckwargs['make_dict_value'][npath][-1] = ckwargs['make_dict_value'][leader_path][-1]
|
||||
if symlink:
|
||||
ckwargs['make_dict_value'][npath + 'link'][-1] = ckwargs['make_dict_value'][master_path][-1]
|
||||
ckwargs['make_dict_value'][npath + 'link'][-1] = ckwargs['make_dict_value'][leader_path][-1]
|
||||
npath = ldirname + '.extraoptconsistency' + suffix
|
||||
if npath in ckwargs['make_dict']:
|
||||
ckwargs['make_dict'][npath] = [dvalue] * len(value)
|
||||
|
@ -1416,12 +1416,12 @@ def make_conf(options, multi, default, default_multi, require, consistency, call
|
|||
weakrefs = []
|
||||
dyn = []
|
||||
goptions = []
|
||||
def make_option(path, option_infos, in_master, master):
|
||||
def make_option(path, option_infos, in_leader, leader):
|
||||
option_type = 'str'
|
||||
option_properties = []
|
||||
option_requires = []
|
||||
isslave = False
|
||||
if in_master and symlink:
|
||||
isfollower = False
|
||||
if in_leader and symlink:
|
||||
return None, None, None
|
||||
if option_infos is not None:
|
||||
if require:
|
||||
|
@ -1433,7 +1433,7 @@ def make_conf(options, multi, default, default_multi, require, consistency, call
|
|||
else:
|
||||
option_requires.append({'option': goptions[0], 'expected': None,
|
||||
'action': prop})
|
||||
isslave = option_infos.get('slave', False)
|
||||
isfollower = option_infos.get('follower', False)
|
||||
args = [path, "{}'s option".format(path)]
|
||||
kwargs = {}
|
||||
call_kwargs = {}
|
||||
|
@ -1450,7 +1450,7 @@ def make_conf(options, multi, default, default_multi, require, consistency, call
|
|||
kwargs['multi'] = multi
|
||||
if callback:
|
||||
call_kwargs['multi'] = multi
|
||||
if ((not in_master or master) and default) and path is not 'extraoptrequire' and not path.endswith('extraoptconsistency'):
|
||||
if ((not in_leader or leader) and default) and path is not 'extraoptrequire' and not path.endswith('extraoptconsistency'):
|
||||
if multi is False:
|
||||
value = FIRST_VALUE
|
||||
elif multi is True:
|
||||
|
@ -1506,10 +1506,10 @@ def make_conf(options, multi, default, default_multi, require, consistency, call
|
|||
for prop in PROPERTIES:
|
||||
if infos.get(prop, False) is True:
|
||||
properties.append(prop)
|
||||
if infos.get('master', False) is True:
|
||||
if infos.get('leader', False) is True:
|
||||
if not multi:
|
||||
return
|
||||
optiondescription = MasterSlaves
|
||||
optiondescription = Leadership
|
||||
if infos.get('dyn', False) is True:
|
||||
if symlink:
|
||||
return
|
||||
|
@ -1557,7 +1557,7 @@ def make_conf(options, multi, default, default_multi, require, consistency, call
|
|||
local_collect_options = local_collect_options[optiondescription]
|
||||
local_collect_options['properties'].update(option.get(optiondescription, {}))
|
||||
option_name = path.split('.')[-1]
|
||||
in_master = False
|
||||
in_leader = False
|
||||
if '.' in path:
|
||||
name_od = path.rsplit('.', 1)[0]
|
||||
if '.' in name_od:
|
||||
|
@ -1565,9 +1565,9 @@ def make_conf(options, multi, default, default_multi, require, consistency, call
|
|||
oddescr = collect_options.get(subod, {})
|
||||
else:
|
||||
oddescr = collect_options
|
||||
in_master = oddescr.get(name_od, {}).get('properties', {}).get('master')
|
||||
master = in_master and path.endswith('first')
|
||||
obj, objcall, sobj = make_option(option_name, option.get(option_name), in_master, master)
|
||||
in_leader = oddescr.get(name_od, {}).get('properties', {}).get('leader')
|
||||
leader = in_leader and path.endswith('first')
|
||||
obj, objcall, sobj = make_option(option_name, option.get(option_name), in_leader, leader)
|
||||
if obj is None:
|
||||
return None, None, None
|
||||
weakrefs.append(weakref.ref(obj))
|
||||
|
@ -1576,7 +1576,7 @@ def make_conf(options, multi, default, default_multi, require, consistency, call
|
|||
if sobj is not None:
|
||||
weakrefs.append(weakref.ref(sobj))
|
||||
if '.' in path:
|
||||
if master:
|
||||
if leader:
|
||||
local_collect_options.setdefault('options', []).insert(0, obj)
|
||||
else:
|
||||
local_collect_options.setdefault('options', []).append(obj)
|
||||
|
@ -1609,10 +1609,10 @@ DICT_PATHS = [
|
|||
OrderedDict([('subod.subsubod.first', {}),
|
||||
('subod.subsubod.second', {'second': {'disabled': True}}),
|
||||
('subod.subsubod.third', {'third': {'hidden': True}})]),
|
||||
# test a config with masterslaves
|
||||
OrderedDict([('odmaster.first', {'odmaster': {'master': True}}),
|
||||
('odmaster.second', {'odmaster': {'master': True}, 'second': {'disabled': True, 'slave': True}}),
|
||||
('odmaster.third', {'odmaster': {'master': True}, 'third': {'hidden': True, 'slave': True}})]),
|
||||
# test a config with leadership
|
||||
OrderedDict([('odleader.first', {'odleader': {'leader': True}}),
|
||||
('odleader.second', {'odleader': {'leader': True}, 'second': {'disabled': True, 'follower': True}}),
|
||||
('odleader.third', {'odleader': {'leader': True}, 'third': {'hidden': True, 'follower': True}})]),
|
||||
# test a config with dynoption
|
||||
OrderedDict([('subod.first', {'subod': {'dyn': True}}),
|
||||
('subod.second', {'second': {'disabled': True}}),
|
||||
|
@ -1647,10 +1647,10 @@ DICT_PATHS = [
|
|||
('subod.subsubodval2.firstval2', None),
|
||||
('subod.subsubodval2.secondval2', None),
|
||||
('subod.subsubodval2.thirdval2', None)]),
|
||||
# test a config with dyn subsubod with masterslave
|
||||
OrderedDict([('subod.subsubod.first', {'subod': {'dyn': True}, 'subsubod': {'master': True}}),
|
||||
('subod.subsubod.second', {'subod': {'dyn': True}, 'subsubod' : {'master': True}, 'second': {'disabled': True, 'slave': True}}),
|
||||
('subod.subsubod.third', {'subod': {'dyn': True}, 'subsubod': {'master': True}, 'third': {'hidden': True, 'slave': True}}),
|
||||
# test a config with dyn subsubod with leadership
|
||||
OrderedDict([('subod.subsubod.first', {'subod': {'dyn': True}, 'subsubod': {'leader': True}}),
|
||||
('subod.subsubod.second', {'subod': {'dyn': True}, 'subsubod' : {'leader': True}, 'second': {'disabled': True, 'follower': True}}),
|
||||
('subod.subsubod.third', {'subod': {'dyn': True}, 'subsubod': {'leader': True}, 'third': {'hidden': True, 'follower': True}}),
|
||||
('subodval1.subsubodval1.firstval1', None),
|
||||
('subodval1.subsubodval1.secondval1', None),
|
||||
('subodval1.subsubodval1.thirdval1', None),
|
||||
|
|
|
@ -8,7 +8,7 @@ do_autopath()
|
|||
from tiramisu import setting, value
|
||||
setting.expires_time = 1
|
||||
value.expires_time = 1
|
||||
from tiramisu.option import BoolOption, IPOption, IntOption, StrOption, OptionDescription, MasterSlaves
|
||||
from tiramisu.option import BoolOption, IPOption, IntOption, StrOption, OptionDescription, Leadership
|
||||
from tiramisu import Config
|
||||
from tiramisu.error import ConfigError, PropertiesOptionError
|
||||
from tiramisu.setting import groups
|
||||
|
@ -256,11 +256,10 @@ def test_cache_not_cache():
|
|||
assert 'u1' not in settings._p_.get_cached()
|
||||
|
||||
|
||||
def test_cache_master_slave():
|
||||
def test_cache_leadership():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.property.read_write()
|
||||
|
@ -419,11 +418,10 @@ def test_cache_callback():
|
|||
'val5': {None: (['yes', 'new4'], None)}})
|
||||
|
||||
|
||||
def test_cache_master_and_slaves_master():
|
||||
def test_cache_leader_and_followers():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.property.read_write()
|
||||
|
@ -495,11 +493,10 @@ def test_cache_master_and_slaves_master():
|
|||
# 'val1.val2': {0: (None, None), 1: ('oui', None)}}
|
||||
|
||||
|
||||
def test_cache_master_callback():
|
||||
def test_cache_leader_callback():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params=Params(kwargs={'value': ParamOption(val1)}))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.property.read_write()
|
||||
|
|
|
@ -35,8 +35,8 @@ def make_description():
|
|||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé")
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau")
|
||||
|
||||
master = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = OptionDescription('interface1', '', [master])
|
||||
leader = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = OptionDescription('interface1', '', [leader])
|
||||
interface1.impl_set_group_type(groups.family)
|
||||
|
||||
general = OptionDescription('general', '', [numero_etab, nom_machine,
|
||||
|
|
|
@ -8,7 +8,7 @@ from tiramisu import BoolOption, StrOption, ChoiceOption, IPOption, \
|
|||
NetworkOption, NetmaskOption, IntOption, FloatOption, \
|
||||
UnicodeOption, PortOption, BroadcastOption, DomainnameOption, \
|
||||
EmailOption, URLOption, UsernameOption, FilenameOption, SymLinkOption, \
|
||||
OptionDescription, DynOptionDescription, SynDynOption, submulti, MasterSlaves, \
|
||||
OptionDescription, DynOptionDescription, SynDynOption, submulti, Leadership, \
|
||||
Config, Params, ParamOption, ParamValue
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError, ConflictError
|
||||
from tiramisu.storage import list_sessions
|
||||
|
@ -930,10 +930,10 @@ def test_consistency_ip_in_network_dyndescription():
|
|||
cfg.option('dodval1.cval1').value.set('192.168.1.1')
|
||||
|
||||
|
||||
def test_masterslaves_dyndescription():
|
||||
def test_leadership_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -988,10 +988,10 @@ def test_masterslaves_dyndescription():
|
|||
assert api.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
||||
|
||||
|
||||
def test_masterslaves_default_multi_dyndescription():
|
||||
def test_leadership_default_multi_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, default_multi='no')
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -1011,12 +1011,12 @@ def test_masterslaves_default_multi_dyndescription():
|
|||
assert api.option('od.stval1.st1val1.st2val1', 0).owner.isdefault()
|
||||
assert api.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
||||
|
||||
def test_masterslaves_dyndescription_param():
|
||||
def test_leadership_dyndescription_param():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
odval = OptionDescription('odval1', '', [val1])
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od = OptionDescription('od', '', [st, odval])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -1071,10 +1071,10 @@ def test_masterslaves_dyndescription_param():
|
|||
assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default
|
||||
|
||||
|
||||
def test_masterslaves_default_multi_dyndescription():
|
||||
def test_leadership_default_multi_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, default_multi='no')
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -1095,7 +1095,7 @@ def test_masterslaves_default_multi_dyndescription():
|
|||
assert api.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
||||
|
||||
|
||||
def _test_masterslaves(cfg):
|
||||
def _test_leadership(cfg):
|
||||
owner = cfg.owner.get()
|
||||
cfg.option('od.val1.val1').value.set(['val1', 'val2'])
|
||||
cfg.option('od.val1.val2', 0).value.set('val1')
|
||||
|
@ -1149,24 +1149,24 @@ def _test_masterslaves(cfg):
|
|||
assert cfg.option('od.stval2.st1val2.st1val2').owner.get() == owners.default
|
||||
|
||||
|
||||
def test_masterslaves_dyndescription_param_master():
|
||||
def test_leadership_dyndescription_param_leader():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
odval = MasterSlaves('val1', '', [val1, val2])
|
||||
odval = Leadership('val1', '', [val1, val2])
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od = OptionDescription('od', '', [st, odval])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
_test_masterslaves(cfg)
|
||||
_test_leadership(cfg)
|
||||
|
||||
|
||||
def test_masterslaves_default_multi_dyndescription():
|
||||
def test_leadership_default_multi_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, default_multi='no')
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -1187,24 +1187,24 @@ def test_masterslaves_default_multi_dyndescription():
|
|||
assert api.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
||||
|
||||
|
||||
def test_masterslaves_dyndescription_param_slave():
|
||||
def test_leadership_dyndescription_param_follower():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
odval = MasterSlaves('val1', '', [val1, val2])
|
||||
odval = Leadership('val1', '', [val1, val2])
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list, callback_params=Params(ParamOption(val2)))
|
||||
od = OptionDescription('od', '', [st, odval])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
_test_masterslaves(cfg)
|
||||
_test_leadership(cfg)
|
||||
|
||||
|
||||
def test_masterslaves_default_multi_dyndescription():
|
||||
def test_leadership_default_multi_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, default_multi='no')
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -1225,10 +1225,10 @@ def test_masterslaves_default_multi_dyndescription():
|
|||
assert api.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
||||
|
||||
|
||||
def test_masterslaves_submulti_dyndescription():
|
||||
def test_leadership_submulti_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=submulti)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
std = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od1 = OptionDescription('od', '', [std])
|
||||
od2 = OptionDescription('od', '', [od1])
|
||||
|
@ -1257,53 +1257,10 @@ def test_masterslaves_submulti_dyndescription():
|
|||
assert api.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
||||
|
||||
|
||||
#FIXME DynOptionDescription cannot be MasterSlave
|
||||
#def test_masterslaves_consistency_ip_dyndescription():
|
||||
# neta = NetworkOption('net', '', multi=True)
|
||||
# maskb = NetmaskOption('mask', '', multi=True)
|
||||
# broadc = BroadcastOption('broad', '', multi=True)
|
||||
# maskb.impl_add_consistency('network_netmask', neta)
|
||||
# broadc.impl_add_consistency('broadcast', neta, maskb)
|
||||
# dod = DynOptionDescription('net', '', [neta, maskb, broadc], callback=return_list)
|
||||
# dod.impl_set_group_type(groups.master)
|
||||
# od1 = OptionDescription('od', '', [dod])
|
||||
# cfg = Config(od1)
|
||||
# api.option('netval1.netval1').value.set(['192.168.1.0'])
|
||||
# api.option('netval1.maskval1').value.set(['255.255.255.0'])
|
||||
# api.option('netval1.broadval1').value.set(['192.168.1.255'])
|
||||
#
|
||||
# api.option('netval1.netval1').value.set(['192.168.1.0', '192.168.2.128'])
|
||||
# api.option('netval1.maskval1').value.set(['255.255.255.0', '255.255.255.128'])
|
||||
# api.option('netval1.broadval1').value.set(['192.168.1.255', '192.168.2.255'])
|
||||
# #
|
||||
# assert cfg.netval1.netval1 == ['192.168.1.0', '192.168.2.128']
|
||||
# assert cfg.netval1.maskval1 == ['255.255.255.0', '255.255.255.128']
|
||||
# assert cfg.netval1.broadval1 == ['192.168.1.255', '192.168.2.255']
|
||||
# assert cfg.netval2.netval2 == []
|
||||
# assert cfg.netval2.maskval2 == []
|
||||
# assert cfg.netval2.broadval2 == []
|
||||
|
||||
|
||||
#def test_masterslaves_consistency_ip_dyndescription_propertyerror():
|
||||
# a = NetworkOption('net', '', multi=True)
|
||||
# b = NetmaskOption('mask', '', multi=True, properties=('mandatory',))
|
||||
# c = BroadcastOption('broad', '', multi=True)
|
||||
# b.impl_add_consistency('network_netmask', a)
|
||||
# c.impl_add_consistency('broadcast', a, b)
|
||||
# dod = DynOptionDescription('net', '', [a, b, c], callback=return_list)
|
||||
# dod.impl_set_group_type(groups.master)
|
||||
# od = OptionDescription('od', '', [dod])
|
||||
# cfg = Config(od)
|
||||
# api.property.read_write()
|
||||
# cfg.netval1.netval1 = ['192.168.1.0']
|
||||
# api.property.read_only()
|
||||
# raises(PropertiesOptionError, "cfg.netval1.netval1")
|
||||
|
||||
|
||||
def test_masterslaves_callback_dyndescription():
|
||||
def test_leadership_callback_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params=Params(kwargs={'value': ParamOption(st1)}))
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
st1 = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od1 = OptionDescription('od', '', [st1])
|
||||
od2 = OptionDescription('od', '', [od1])
|
||||
|
@ -1361,10 +1318,10 @@ def test_masterslaves_callback_dyndescription():
|
|||
assert api.option('od.stval1.st1val1.st2val1', 0).value.get() == 'yes'
|
||||
|
||||
|
||||
def test_masterslaves_callback_value_dyndescription():
|
||||
def test_leadership_callback_value_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params=Params(kwargs={'value': ParamValue('val')}))
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -1376,11 +1333,11 @@ def test_masterslaves_callback_value_dyndescription():
|
|||
assert api.option('od.stval1.st1val1.st2val1', 0).value.get() == 'val'
|
||||
|
||||
|
||||
def test_masterslaves_callback_nomulti_dyndescription():
|
||||
def test_leadership_callback_nomulti_dyndescription():
|
||||
v11 = StrOption('v1', '', "val")
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params=Params(ParamOption(v11)))
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
stt = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od1 = OptionDescription('od', '', [stt])
|
||||
od2 = OptionDescription('od', '', [od1, v11])
|
||||
|
@ -1391,11 +1348,11 @@ def test_masterslaves_callback_nomulti_dyndescription():
|
|||
assert api.option('od.stval1.st1val1.st2val1', 0).value.get() == 'val'
|
||||
|
||||
|
||||
def test_masterslaves_callback_samegroup_dyndescription():
|
||||
def test_leadership_callback_samegroup_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True)
|
||||
st3 = StrOption('st3', "", multi=True, callback=return_dynval, callback_params=Params(ParamOption(st2)))
|
||||
stm = MasterSlaves('st1', '', [st1, st2, st3])
|
||||
stm = Leadership('st1', '', [st1, st2, st3])
|
||||
stt = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od1 = OptionDescription('od', '', [stt])
|
||||
od2 = OptionDescription('od', '', [od1])
|
||||
|
|
|
@ -7,7 +7,7 @@ from py.test import raises
|
|||
|
||||
from tiramisu.setting import owners, groups
|
||||
from tiramisu import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription, SymLinkOption, MasterSlaves, Config, \
|
||||
StrOption, OptionDescription, SymLinkOption, Leadership, Config, \
|
||||
Params, ParamContext, ParamOption, ParamValue
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError
|
||||
from tiramisu.storage import list_sessions
|
||||
|
@ -178,25 +178,25 @@ def test_force_store_value_no_requirement():
|
|||
pass
|
||||
|
||||
|
||||
def test_force_store_value_masterslaves_slave():
|
||||
def test_force_store_value_leadership_follower():
|
||||
b = IntOption('int', 'Test int option', multi=True)
|
||||
c = StrOption('str', 'Test string option', multi=True, properties=('force_store_value',))
|
||||
descr = MasterSlaves("int", "", [b, c])
|
||||
descr = Leadership("int", "", [b, c])
|
||||
raises(ConfigError, "conf = Config(descr)")
|
||||
|
||||
|
||||
#def test_force_store_value_masterslaves():
|
||||
#def test_force_store_value_leadership():
|
||||
# b = IntOption('int', 'Test int option', multi=True, properties=('force_store_value',))
|
||||
# c = StrOption('str', 'Test string option', multi=True)
|
||||
# descr = MasterSlaves("int", "", [b, c])
|
||||
# descr = Leadership("int", "", [b, c])
|
||||
# api = Config(descr)
|
||||
# assert api.value.get() == {'int': ('forced', ())}
|
||||
|
||||
|
||||
def test_force_store_value_masterslaves_sub():
|
||||
def test_force_store_value_leadership_sub():
|
||||
b = IntOption('int', 'Test int option', multi=True, properties=('force_store_value',))
|
||||
c = StrOption('str', 'Test string option', multi=True)
|
||||
descr = MasterSlaves("int", "", [b, c])
|
||||
descr = Leadership("int", "", [b, c])
|
||||
odr = OptionDescription('odr', '', [descr])
|
||||
api = Config(odr)
|
||||
compare(api.value.exportation(), (('int.int',), (None,), (tuple(),), ('forced',)))
|
||||
|
|
|
@ -5,8 +5,8 @@ from py.test import raises
|
|||
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu import ChoiceOption, BoolOption, IntOption, IPOption, NetmaskOption, \
|
||||
StrOption, OptionDescription, MasterSlaves, Config
|
||||
from tiramisu.error import SlaveError, PropertiesOptionError, APIError, ConfigError
|
||||
StrOption, OptionDescription, Leadership, Config
|
||||
from tiramisu.error import LeadershipError, PropertiesOptionError, APIError, ConfigError
|
||||
from tiramisu.api import TIRAMISU_VERSION
|
||||
from tiramisu.storage import list_sessions
|
||||
|
||||
|
@ -46,8 +46,8 @@ def make_description():
|
|||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé")
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau")
|
||||
|
||||
master = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = OptionDescription('interface1', '', [master])
|
||||
leader = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = OptionDescription('interface1', '', [leader])
|
||||
interface1.impl_set_group_type(groups.family)
|
||||
|
||||
general = OptionDescription('general', '', [numero_etab, nom_machine,
|
||||
|
@ -206,59 +206,58 @@ def test_iter_not_group():
|
|||
raise Exception('must raise')
|
||||
|
||||
|
||||
def test_groups_with_master():
|
||||
def test_groups_with_leader():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
assert interface1.impl_get_group_type() == groups.leadership
|
||||
|
||||
|
||||
def test_groups_is_master():
|
||||
def test_groups_is_leader():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True, default_multi='value')
|
||||
interface1 = MasterSlaves('masterslaves', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('leadership', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
var = StrOption('var', "ip réseau autorisé", multi=True)
|
||||
od2 = OptionDescription('od2', '', [var])
|
||||
od1 = OptionDescription('od', '', [interface1, od2])
|
||||
api = Config(od1)
|
||||
assert not api.option('od2').option.ismasterslaves()
|
||||
assert api.option('masterslaves').option.ismasterslaves()
|
||||
assert not api.option('od2.var').option.ismaster()
|
||||
assert not api.option('od2.var').option.isslave()
|
||||
assert api.option('masterslaves.ip_admin_eth0').option.ismulti()
|
||||
assert api.option('masterslaves.netmask_admin_eth0').option.ismulti()
|
||||
assert not api.option('masterslaves.ip_admin_eth0').option.issubmulti()
|
||||
assert not api.option('masterslaves.netmask_admin_eth0').option.issubmulti()
|
||||
assert api.option('masterslaves.ip_admin_eth0').option.ismaster()
|
||||
assert not api.option('masterslaves.ip_admin_eth0').option.isslave()
|
||||
assert not api.option('masterslaves.netmask_admin_eth0').option.ismaster()
|
||||
assert api.option('masterslaves.netmask_admin_eth0').option.isslave()
|
||||
assert api.option('masterslaves.netmask_admin_eth0').option.path() == 'masterslaves.netmask_admin_eth0'
|
||||
assert api.option('masterslaves.netmask_admin_eth0').option.defaultmulti() == 'value'
|
||||
assert not api.option('od2').option.isleadership()
|
||||
assert api.option('leadership').option.isleadership()
|
||||
assert not api.option('od2.var').option.isleader()
|
||||
assert not api.option('od2.var').option.isfollower()
|
||||
assert api.option('leadership.ip_admin_eth0').option.ismulti()
|
||||
assert api.option('leadership.netmask_admin_eth0').option.ismulti()
|
||||
assert not api.option('leadership.ip_admin_eth0').option.issubmulti()
|
||||
assert not api.option('leadership.netmask_admin_eth0').option.issubmulti()
|
||||
assert api.option('leadership.ip_admin_eth0').option.isleader()
|
||||
assert not api.option('leadership.ip_admin_eth0').option.isfollower()
|
||||
assert not api.option('leadership.netmask_admin_eth0').option.isleader()
|
||||
assert api.option('leadership.netmask_admin_eth0').option.isfollower()
|
||||
assert api.option('leadership.netmask_admin_eth0').option.path() == 'leadership.netmask_admin_eth0'
|
||||
assert api.option('leadership.netmask_admin_eth0').option.defaultmulti() == 'value'
|
||||
|
||||
|
||||
if TIRAMISU_VERSION != 2:
|
||||
def test_groups_with_master_in_root():
|
||||
def test_groups_with_leader_in_root():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
raises(ConfigError, "Config(interface1)")
|
||||
|
||||
|
||||
def test_groups_with_master_in_config():
|
||||
def test_groups_with_leader_in_config():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od = OptionDescription('root', '', [interface1])
|
||||
Config(od)
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
assert interface1.impl_get_group_type() == groups.leadership
|
||||
|
||||
|
||||
def test_groups_with_master_make_dict():
|
||||
def test_groups_with_leader_make_dict():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od = OptionDescription('root', '', [interface1])
|
||||
api = Config(od)
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': []}
|
||||
|
@ -270,10 +269,10 @@ def test_groups_with_master_make_dict():
|
|||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['ip1', 'ip2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None]}
|
||||
|
||||
|
||||
def test_groups_with_master_hidden_in_config():
|
||||
def test_groups_with_leader_hidden_in_config():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, properties=('hidden',))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True, properties=('hidden',))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od = OptionDescription('root', '', [interface1])
|
||||
api = Config(od)
|
||||
api.property.read_write()
|
||||
|
@ -285,10 +284,10 @@ def test_groups_with_master_hidden_in_config():
|
|||
raises(PropertiesOptionError, "api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()")
|
||||
|
||||
|
||||
def test_groups_with_master_hidden_in_config2():
|
||||
def test_groups_with_leader_hidden_in_config2():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True, properties=('hidden',))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od = OptionDescription('root', '', [interface1])
|
||||
api = Config(od)
|
||||
api.property.read_write()
|
||||
|
@ -312,40 +311,39 @@ def test_groups_with_master_hidden_in_config2():
|
|||
assert api.forcepermissive.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() is None
|
||||
|
||||
|
||||
def test_groups_with_master_reset_empty():
|
||||
def test_groups_with_leader_reset_empty():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od_ = OptionDescription('root', '', [interface1])
|
||||
api = Config(od_)
|
||||
api.property.read_write()
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
||||
raises(SlaveError, "api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.reset()")
|
||||
raises(LeadershipError, "api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.reset()")
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.reset()
|
||||
|
||||
|
||||
def test_groups_with_master_reset_out_of_range():
|
||||
def test_groups_with_leader_reset_out_of_range():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od_ = OptionDescription('root', '', [interface1])
|
||||
api = Config(od_)
|
||||
api.property.read_write()
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||
api.forcepermissive.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.reset()
|
||||
raises(SlaveError, "api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.reset()")
|
||||
raises(LeadershipError, "api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.reset()")
|
||||
raises(IndexError, "api.option('ip_admin_eth0.ip_admin_eth0').value.pop(1)")
|
||||
|
||||
|
||||
def test_groups_with_master_hidden_in_config3():
|
||||
#if master is hidden, slave are hidden too
|
||||
def test_groups_with_leader_hidden_in_config3():
|
||||
#if leader is hidden, follower are hidden too
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, properties=('hidden',))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od = OptionDescription('root', '', [interface1])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
api = Config(od)
|
||||
api.property.read_write()
|
||||
api.permissive.set(frozenset(['hidden']))
|
||||
|
@ -364,11 +362,10 @@ def test_allowed_groups():
|
|||
raises(ValueError, "interface1.impl_set_group_type('toto')")
|
||||
|
||||
|
||||
def test_values_with_master_disabled_master():
|
||||
def test_values_with_leader_disabled_leader():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -381,30 +378,29 @@ def test_values_with_master_disabled_master():
|
|||
raises(PropertiesOptionError, "api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('192.168.230.145')")
|
||||
|
||||
|
||||
def test_sub_group_in_master_group():
|
||||
def test_sub_group_in_leader_group():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
subgroup = OptionDescription("subgroup", '', [])
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [subgroup, ip_admin_eth0, netmask_admin_eth0])")
|
||||
raises(ValueError, "Leadership('ip_admin_eth0', '', [subgroup, ip_admin_eth0, netmask_admin_eth0])")
|
||||
|
||||
|
||||
def test_group_always_has_multis():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau")
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
raises(ValueError, "Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
|
||||
|
||||
#____________________________________________________________
|
||||
def test_values_with_master_and_slaves():
|
||||
def test_values_with_leader_and_followers():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
owner = api.owner.get()
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
assert interface1.impl_get_group_type() == groups.leadership
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||
#
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(["192.168.230.145"])
|
||||
|
@ -417,16 +413,15 @@ def test_values_with_master_and_slaves():
|
|||
raises(APIError, "api.option('ip_admin_eth0.netmask_admin_eth0').value.pop(0)")
|
||||
|
||||
|
||||
def test_reset_values_with_master_and_slaves():
|
||||
def test_reset_values_with_leader_and_followers():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
owner = api.owner.get()
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
assert interface1.impl_get_group_type() == groups.leadership
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(["192.168.230.145"])
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').owner.get() == owner
|
||||
|
@ -441,17 +436,16 @@ def test_reset_values_with_master_and_slaves():
|
|||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
|
||||
|
||||
def test_reset_values_with_master_and_slaves_default_value():
|
||||
def test_reset_values_with_leader_and_followers_default_value():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, default=['192.168.230.145'])
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True, default=['255.255.255.0'])
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
raises(ValueError, "Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
|
||||
|
||||
def test_reset_values_with_master_and_slaves_default():
|
||||
def test_reset_values_with_leader_and_followers_default():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, default=['192.168.230.145'])
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -488,15 +482,14 @@ def test_reset_values_with_master_and_slaves_default():
|
|||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set(None)
|
||||
|
||||
|
||||
def test_values_with_master_and_slaves_slave():
|
||||
def test_values_with_leader_and_followers_follower():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
raises(SlaveError,
|
||||
raises(LeadershipError,
|
||||
"api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')")
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.230.145'])
|
||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
||||
|
@ -517,11 +510,10 @@ def test_values_with_master_and_slaves_slave():
|
|||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
|
||||
|
||||
def test_values_with_master_and_slaves_pop():
|
||||
def test_values_with_leader_and_followers_pop():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -537,11 +529,10 @@ def test_values_with_master_and_slaves_pop():
|
|||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.0.0'
|
||||
|
||||
|
||||
def test_values_with_master_and_slaves_master():
|
||||
def test_values_with_leader_and_followers_leader():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -550,7 +541,7 @@ def test_values_with_master_and_slaves_master():
|
|||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(["192.168.230.145", "192.168.230.145"])
|
||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
||||
api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.set('255.255.255.0')
|
||||
raises(SlaveError, "api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.230.145'])")
|
||||
raises(LeadershipError, "api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.230.145'])")
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.255.0'
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get() == '255.255.255.0'
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.pop(1)
|
||||
|
@ -560,10 +551,10 @@ def test_values_with_master_and_slaves_master():
|
|||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
|
||||
|
||||
def test_values_with_master_and_slaves_master_pop():
|
||||
def test_values_with_leader_and_followers_leader_pop():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -591,11 +582,10 @@ def test_values_with_master_and_slaves_master_pop():
|
|||
compare(api.value.exportation(), (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'), (None, (0,)), (('192.168.230.146', "192.168.230.145"), ('255.255.0.0',)), ('user', ('user',))))
|
||||
|
||||
|
||||
def test_values_with_master_owner():
|
||||
def test_values_with_leader_owner():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -608,11 +598,10 @@ def test_values_with_master_owner():
|
|||
assert api.option('ip_admin_eth0.ip_admin_eth0').owner.get() == owner
|
||||
|
||||
|
||||
def test_values_with_master_disabled():
|
||||
def test_values_with_leader_disabled():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -649,11 +638,10 @@ def test_multi_non_valid_value():
|
|||
raises(ValueError, "api.option('ip_admin_eth0').value.set([1])")
|
||||
|
||||
|
||||
def test_multi_master_default_slave():
|
||||
def test_multi_leader_default_follower():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", default_multi="255.255.255.0", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -661,11 +649,10 @@ def test_multi_master_default_slave():
|
|||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||
|
||||
|
||||
def test_groups_with_master_get_modified_value():
|
||||
def test_groups_with_leader_get_modified_value():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -679,11 +666,10 @@ def test_groups_with_master_get_modified_value():
|
|||
compare(api.value.exportation(), (('ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0',), (None, (0, 1)), (('192.168.1.1', '192.168.1.1'), ('255.255.255.255', '255.255.255.255')), ('user', ('user', 'user'))))
|
||||
|
||||
|
||||
def test_groups_with_master_importation():
|
||||
def test_groups_with_leader_importation():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -699,7 +685,7 @@ def test_groups_with_master_importation():
|
|||
def test_wrong_index():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od1 = OptionDescription('od', '', [interface1])
|
||||
maconfig = OptionDescription('toto', '', [od1])
|
||||
api = Config(maconfig)
|
||||
|
@ -713,57 +699,57 @@ def test_wrong_index():
|
|||
raises(APIError, "api.option('od', 0).option.get()")
|
||||
|
||||
|
||||
def test_without_master_or_slave():
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [])")
|
||||
def test_without_leader_or_follower():
|
||||
raises(ValueError, "Leadership('ip_admin_eth0', '', [])")
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0])")
|
||||
raises(ValueError, "Leadership('ip_admin_eth0', '', [ip_admin_eth0])")
|
||||
#empty optiondescription is allowed
|
||||
OptionDescription('ip_admin_eth0', '', [])
|
||||
|
||||
|
||||
def test_master_not_multi():
|
||||
def test_leader_not_multi():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé")
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
raises(ValueError, "Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
|
||||
|
||||
def test_slave_not_multi():
|
||||
def test_follower_not_multi():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau")
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
raises(ValueError, "Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
|
||||
|
||||
def test_slave_not_same():
|
||||
def test_follower_not_same():
|
||||
ip_admin_eth0 = IPOption('ip_admin_eth0', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface0 = MasterSlaves('interface0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface0 = Leadership('interface0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
ip_admin_eth1 = IPOption('ip_admin_eth1', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||
netmask_admin_eth1 = NetmaskOption('netmask_admin_eth1', "masque du sous-réseau", multi=True)
|
||||
netmask_admin_eth1.impl_add_consistency('ip_netmask', ip_admin_eth0)
|
||||
interface1 = MasterSlaves('interface1', '', [ip_admin_eth1, netmask_admin_eth1])
|
||||
interface1 = Leadership('interface1', '', [ip_admin_eth1, netmask_admin_eth1])
|
||||
od1 = OptionDescription('od', '', [interface0, interface1])
|
||||
maconfig = OptionDescription('toto', '', [od1])
|
||||
raises(ConfigError, "Config(maconfig)")
|
||||
|
||||
|
||||
def test_slave_not_same_not_equal():
|
||||
def test_follower_not_same_not_equal():
|
||||
ip_admin_eth0 = IPOption('ip_admin_eth0', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface0 = MasterSlaves('interface0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface0 = Leadership('interface0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
ip_admin_eth1 = IPOption('ip_admin_eth1', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||
netmask_admin_eth1 = NetmaskOption('netmask_admin_eth1', "masque du sous-réseau", multi=True)
|
||||
netmask_admin_eth1.impl_add_consistency('not_equal', netmask_admin_eth0)
|
||||
interface1 = MasterSlaves('interface1', '', [ip_admin_eth1, netmask_admin_eth1])
|
||||
interface1 = Leadership('interface1', '', [ip_admin_eth1, netmask_admin_eth1])
|
||||
od1 = OptionDescription('od', '', [interface0, interface1])
|
||||
maconfig = OptionDescription('toto', '', [od1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
||||
|
||||
def test_slave_force_store_value():
|
||||
def test_follower_force_store_value():
|
||||
ip_admin_eth0 = IPOption('ip_admin_eth0', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "masque du sous-réseau", multi=True, properties=('force_store_value',))
|
||||
interface0 = MasterSlaves('interface0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface0 = Leadership('interface0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od1 = OptionDescription('od', '', [interface0])
|
||||
maconfig = OptionDescription('toto', '', [od1])
|
||||
raises(ConfigError, "Config(maconfig)")
|
|
@ -6,7 +6,7 @@ from py.test import raises
|
|||
from tiramisu.api import TIRAMISU_VERSION
|
||||
from tiramisu import Config
|
||||
from tiramisu import IntOption, StrOption, UnicodeOption, OptionDescription, \
|
||||
SymLinkOption, MasterSlaves, undefined, Params, ParamOption
|
||||
SymLinkOption, Leadership, undefined, Params, ParamOption
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError
|
||||
from tiramisu.setting import groups
|
||||
from tiramisu.storage import list_sessions
|
||||
|
@ -407,37 +407,34 @@ def test_mandatory_warnings_frozen():
|
|||
assert set(api.value.mandatory()) == {'str', 'str1', 'unicode2', 'str3'}
|
||||
|
||||
|
||||
def test_mandatory_master():
|
||||
def test_mandatory_leader():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True,
|
||||
properties=('mandatory', ))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau",
|
||||
multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
descr = OptionDescription('o', '', [interface1])
|
||||
api = Config(descr)
|
||||
api.property.read_only()
|
||||
raises(PropertiesOptionError, "api.option('ip_admin_eth0.ip_admin_eth0').value.get()")
|
||||
|
||||
|
||||
def test_mandatory_warnings_master():
|
||||
def test_mandatory_warnings_leader():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True,
|
||||
properties=('mandatory', ))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau",
|
||||
multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
descr = OptionDescription('o', '', [interface1])
|
||||
api = Config(descr)
|
||||
assert list(api.value.mandatory()) == ['ip_admin_eth0.ip_admin_eth0']
|
||||
|
||||
|
||||
def test_mandatory_master_empty():
|
||||
def test_mandatory_leader_empty():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau",
|
||||
multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
descr = OptionDescription('o', '', [interface1])
|
||||
api = Config(descr)
|
||||
api.property.read_write()
|
||||
|
@ -475,12 +472,11 @@ def test_mandatory_master_empty():
|
|||
api.option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
||||
|
||||
|
||||
def test_mandatory_warnings_master_empty():
|
||||
def test_mandatory_warnings_leader_empty():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau",
|
||||
multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
descr = OptionDescription('o', '', [interface1])
|
||||
api = Config(descr)
|
||||
api.property.read_write()
|
||||
|
@ -500,12 +496,11 @@ def test_mandatory_warnings_master_empty():
|
|||
assert list(api.value.mandatory()) == []
|
||||
|
||||
|
||||
def test_mandatory_slave():
|
||||
def test_mandatory_follower():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau",
|
||||
multi=True, properties=('mandatory', ))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
descr = OptionDescription('o', '', [interface1])
|
||||
api = Config(descr)
|
||||
api.property.read_only()
|
||||
|
@ -530,12 +525,11 @@ def test_mandatory_slave():
|
|||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == 'ip'
|
||||
|
||||
|
||||
def test_mandatory_warnings_slave():
|
||||
def test_mandatory_warnings_follower():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau",
|
||||
multi=True, properties=('mandatory', ))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
descr = OptionDescription('o', '', [interface1])
|
||||
api = Config(descr)
|
||||
api.property.read_only()
|
||||
|
@ -597,32 +591,32 @@ def test_mandatory_warnings_requires():
|
|||
assert list(api.value.mandatory()) == ['str1', 'unicode2', 'str3']
|
||||
|
||||
|
||||
def test_mandatory_warnings_requires_masterslaves():
|
||||
def test_mandatory_warnings_requires_leadership():
|
||||
stroption = StrOption('str', 'Test string option', default="abc",
|
||||
properties=('mandatory', ))
|
||||
stroption1 = StrOption('str1', 'Test string option', multi=True)
|
||||
stroption2 = StrOption('str2', 'Test string option', multi=True, requires=[{'option': stroption, 'expected': 'yes', 'action': 'mandatory', 'transitive': False}])
|
||||
masterslave = MasterSlaves('master', 'masterslaves', [stroption1, stroption2])
|
||||
descr = OptionDescription('tiram', '', [stroption, masterslave])
|
||||
leadership = Leadership('leader', 'leadership', [stroption1, stroption2])
|
||||
descr = OptionDescription('tiram', '', [stroption, leadership])
|
||||
api = Config(descr)
|
||||
api.option('str').value.set('')
|
||||
api.option('master.str1').value.set(['str'])
|
||||
api.option('leader.str1').value.set(['str'])
|
||||
assert list(api.value.mandatory()) == ['str']
|
||||
api.option('str').value.set('yes')
|
||||
assert list(api.value.mandatory()) == ['master.str2']
|
||||
assert list(api.value.mandatory()) == ['leader.str2']
|
||||
|
||||
|
||||
def test_mandatory_warnings_requires_masterslaves_slave():
|
||||
def test_mandatory_warnings_requires_leadership_follower():
|
||||
stroption = StrOption('str', 'Test string option', multi=True)
|
||||
stroption1 = StrOption('str1', 'Test string option', multi=True)
|
||||
stroption2 = StrOption('str2', 'Test string option', multi=True, requires=[{'option': stroption1, 'expected': 'yes', 'action': 'mandatory', 'transitive': False}])
|
||||
masterslave = MasterSlaves('master', 'masterslaves', [stroption, stroption1, stroption2])
|
||||
descr = OptionDescription('tiram', '', [masterslave])
|
||||
leadership = Leadership('leader', 'leadership', [stroption, stroption1, stroption2])
|
||||
descr = OptionDescription('tiram', '', [leadership])
|
||||
api = Config(descr)
|
||||
api.option('master.str').value.set(['str'])
|
||||
api.option('leader.str').value.set(['str'])
|
||||
assert list(api.value.mandatory()) == []
|
||||
api.option('master.str1', 0).value.set('yes')
|
||||
assert list(api.value.mandatory()) == ['master.str2']
|
||||
api.option('leader.str1', 0).value.set('yes')
|
||||
assert list(api.value.mandatory()) == ['leader.str2']
|
||||
|
||||
|
||||
def test_mandatory_od_disabled():
|
||||
|
|
|
@ -4,9 +4,9 @@ do_autopath()
|
|||
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu import IntOption, StrOption, NetworkOption, NetmaskOption, BoolOption, ChoiceOption, \
|
||||
IPOption, OptionDescription, MasterSlaves, Config, GroupConfig, MetaConfig, \
|
||||
IPOption, OptionDescription, Leadership, Config, GroupConfig, MetaConfig, \
|
||||
Params, ParamOption, ParamValue
|
||||
from tiramisu.error import ConfigError, ConflictError, PropertiesOptionError, SlaveError, APIError
|
||||
from tiramisu.error import ConfigError, ConflictError, PropertiesOptionError, LeadershipError, APIError
|
||||
from tiramisu.storage import list_sessions
|
||||
|
||||
|
||||
|
@ -384,10 +384,10 @@ def test_meta_unconsistent():
|
|||
raises(ValueError, "MetaConfig([conf3, conf4])")
|
||||
|
||||
|
||||
def test_meta_master_slaves():
|
||||
def test_meta_leadership():
|
||||
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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -410,10 +410,10 @@ def test_meta_master_slaves():
|
|||
assert conf2._config_bag.context == next(itr)._config_bag.context
|
||||
|
||||
|
||||
def test_meta_master_slaves_value2():
|
||||
def test_meta_leadership_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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -435,10 +435,10 @@ def test_meta_master_slaves_value2():
|
|||
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||
|
||||
|
||||
def test_meta_master_slaves_value_default():
|
||||
def test_meta_leadership_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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -458,17 +458,17 @@ def test_meta_master_slaves_value_default():
|
|||
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||
|
||||
|
||||
def test_meta_master_slaves_owners():
|
||||
def test_meta_leadership_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])
|
||||
interface1 = Leadership('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')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.owner.set(owners.meta1)
|
||||
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||
raises(SlaveError, "meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()")
|
||||
raises(LeadershipError, "meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()")
|
||||
#
|
||||
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.user
|
||||
|
@ -497,7 +497,7 @@ def test_meta_master_slaves_owners():
|
|||
def test_meta_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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -535,7 +535,7 @@ def test_meta_force_default():
|
|||
def test_meta_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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -562,7 +562,7 @@ def test_meta_force_dont_change_value():
|
|||
def test_meta_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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -604,7 +604,7 @@ def test_meta_force_default_if_same():
|
|||
def test_meta_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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -646,7 +646,7 @@ def test_meta_force_default_if_same_and_dont_change():
|
|||
def test_meta_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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -660,7 +660,7 @@ def test_meta_properties_meta():
|
|||
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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -675,7 +675,7 @@ def test_meta_exception_meta():
|
|||
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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -728,12 +728,12 @@ def test_meta_callback():
|
|||
meta.option('val4').value.reset()
|
||||
|
||||
|
||||
def test_meta_callback_slave():
|
||||
def test_meta_callback_follower():
|
||||
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])
|
||||
interface1 = Leadership('val1', '', [val1, val3, val4])
|
||||
od = OptionDescription('root', '', [interface1])
|
||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||
cfg = Config(maconfig, session_id='cfg1')
|
||||
|
@ -774,7 +774,7 @@ def test_meta_callback_slave():
|
|||
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])
|
||||
interface1 = Leadership('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')
|
||||
|
|
|
@ -5,9 +5,9 @@ from py.test import raises
|
|||
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu import IntOption, StrOption, NetworkOption, NetmaskOption, \
|
||||
OptionDescription, MasterSlaves, Config, GroupConfig, MixConfig, \
|
||||
OptionDescription, Leadership, Config, GroupConfig, MixConfig, \
|
||||
Params, ParamOption, ParamValue
|
||||
from tiramisu.error import ConfigError, ConflictError, PropertiesOptionError, SlaveError, APIError
|
||||
from tiramisu.error import ConfigError, ConflictError, PropertiesOptionError, LeadershipError, APIError
|
||||
from tiramisu.storage import list_sessions
|
||||
|
||||
owners.addowner('mix1')
|
||||
|
@ -311,10 +311,10 @@ def test_mix_unconsistent():
|
|||
MixConfig(od2, [conf3, conf4])
|
||||
|
||||
|
||||
def test_mix_master_slaves():
|
||||
def test_mix_leadership():
|
||||
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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -337,10 +337,10 @@ def test_mix_master_slaves():
|
|||
assert conf2._config_bag.context == next(itr)._config_bag.context
|
||||
|
||||
|
||||
def test_mix_master_slaves_value2():
|
||||
def test_mix_leadership_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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -362,10 +362,10 @@ def test_mix_master_slaves_value2():
|
|||
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||
|
||||
|
||||
def test_mix_master_slaves_value_default():
|
||||
def test_mix_leadership_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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -385,17 +385,17 @@ def test_mix_master_slaves_value_default():
|
|||
assert mix.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||
|
||||
|
||||
def test_mix_master_slaves_owners():
|
||||
def test_mix_leadership_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])
|
||||
interface1 = Leadership('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()")
|
||||
raises(LeadershipError, "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
|
||||
|
@ -424,7 +424,7 @@ def test_mix_master_slaves_owners():
|
|||
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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -462,7 +462,7 @@ def test_mix_force_default():
|
|||
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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -489,7 +489,7 @@ def test_mix_force_dont_change_value():
|
|||
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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -531,7 +531,7 @@ def test_mix_force_default_if_same():
|
|||
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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -573,7 +573,7 @@ def test_mix_force_default_if_same_and_dont_change():
|
|||
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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -587,7 +587,7 @@ 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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -602,7 +602,7 @@ 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])
|
||||
interface1 = Leadership('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')
|
||||
|
@ -635,12 +635,12 @@ def test_mix_callback():
|
|||
mix.option('val4').value.reset()
|
||||
|
||||
|
||||
def test_mix_callback_slave():
|
||||
def test_mix_callback_follower():
|
||||
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])
|
||||
interface1 = Leadership('val1', '', [val1, val3, val4])
|
||||
od = OptionDescription('root', '', [interface1])
|
||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||
cfg = Config(maconfig, session_id='cfg1')
|
||||
|
@ -681,15 +681,15 @@ def test_mix_callback_slave():
|
|||
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])
|
||||
interface1 = Leadership('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])
|
||||
interface1 = Leadership('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])
|
||||
interface1 = Leadership('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')
|
||||
|
|
|
@ -195,10 +195,10 @@ def test_optiondescription_group_redefined():
|
|||
raises(ValueError, "od1.impl_set_group_type(groups.notfamily)")
|
||||
|
||||
|
||||
def test_optiondescription_group_masterslave():
|
||||
def test_optiondescription_group_leadership():
|
||||
i = IntOption('test', '')
|
||||
od1 = OptionDescription('od', '', [i])
|
||||
raises(ConfigError, "od1.impl_set_group_type(groups.master)")
|
||||
raises(ConfigError, "od1.impl_set_group_type(groups.leadership)")
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ from tiramisu import Config
|
|||
from tiramisu.config import KernelConfig
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription, SymLinkOption, IPOption, NetmaskOption, MasterSlaves, \
|
||||
StrOption, OptionDescription, SymLinkOption, IPOption, NetmaskOption, Leadership, \
|
||||
undefined, Params, ParamOption, ParamValue, ParamContext
|
||||
from tiramisu.api import TIRAMISU_VERSION
|
||||
from tiramisu.error import PropertiesOptionError, ConflictError, SlaveError, ConfigError
|
||||
from tiramisu.error import PropertiesOptionError, ConflictError, LeadershipError, ConfigError
|
||||
from tiramisu.i18n import _
|
||||
from tiramisu.storage import list_sessions
|
||||
|
||||
|
@ -502,11 +502,10 @@ def test_callback_multi_callback():
|
|||
assert api.option('val1.val1').value.get() == ['val1', 'val']
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master():
|
||||
def test_callback_leader_and_followers_leader():
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_val)
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -517,11 +516,10 @@ def test_callback_master_and_slaves_master():
|
|||
assert api.option('val1.val2', 1).value.get() == None
|
||||
|
||||
|
||||
def test_callback_slave():
|
||||
def test_callback_follower():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value3, callback_params=Params(ParamValue(['string', 'new'])))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -541,13 +539,12 @@ def test_callback_slave():
|
|||
assert api.option('val1.val2', 3).value.get() == None
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master2():
|
||||
def test_callback_leader_and_followers_leader2():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, default_multi='val2')
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val2)))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val3)))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2, val3, val4])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -557,13 +554,12 @@ def test_callback_master_and_slaves_master2():
|
|||
assert api.option('val1.val2', 0).value.get() == 'val2'
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master_mandatory():
|
||||
def test_callback_leader_and_followers_leader_mandatory():
|
||||
val = StrOption('val', "", default='val')
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params=Params(ParamOption(val)), properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_index, callback_params=Params(ParamOption(val1)), properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_index, callback_params=Params(ParamOption(val1)), properties=('mandatory',))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val3, val4])
|
||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_only()
|
||||
|
@ -579,14 +575,13 @@ def test_callback_master_and_slaves_master_mandatory():
|
|||
raises(PropertiesOptionError, "api.option('val1.val4', 1).value.get()")
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master_mandatory2():
|
||||
def test_callback_leader_and_followers_leader_mandatory2():
|
||||
val = StrOption('val', "", default='val')
|
||||
val_ = StrOption('val_', "", default='val_')
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_index, callback_params=Params(ParamOption(val), {'val2': ParamOption(val_)}), properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_index, callback_params=Params(ParamOption(val1), {'val2': ParamOption(val_)}), properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_index, callback_params=Params(ParamOption(val1), {'val2': ParamOption(val_)}), properties=('mandatory',))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val3, val4])
|
||||
maconfig = OptionDescription('rootconfig', '', [val, val_, interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_only()
|
||||
|
@ -608,14 +603,13 @@ def test_callback_master_and_slaves_master_mandatory2():
|
|||
assert api.option('val1.val1').value.get() == ['val', 'val_', 'val3']
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master_mandatory3():
|
||||
def test_callback_leader_and_followers_leader_mandatory3():
|
||||
val = StrOption('val', "", default='val')
|
||||
val_ = StrOption('val_', "", default='val_')
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params=Params(ParamOption(val), {'val': ParamOption(val_)}), properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)), properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)), properties=('mandatory',))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val3, val4])
|
||||
maconfig = OptionDescription('rootconfig', '', [val, val_, interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_only()
|
||||
|
@ -636,13 +630,12 @@ def test_callback_master_and_slaves_master_mandatory3():
|
|||
assert api.option('val1.val1').value.get() == ['val', 'val_', 'val3']
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master_mandatory4():
|
||||
def test_callback_leader_and_followers_leader_mandatory4():
|
||||
val = StrOption('val', "", default='val')
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params=Params(ParamOption(val)), properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)), properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)), properties=('mandatory',))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val3, val4])
|
||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_only()
|
||||
|
@ -660,26 +653,24 @@ def test_callback_master_and_slaves_master_mandatory4():
|
|||
assert api.option('val1.val4', 1).value.get() == 'val3'
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master3():
|
||||
def test_callback_leader_and_followers_leader3():
|
||||
val1 = StrOption('val1', "", multi=True, properties=('mandatory', 'empty'))
|
||||
val2 = StrOption('val2', "", multi=True, default_multi='val2', properties=('expert',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val2)))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val3)))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2, val3, val4])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
assert list(api.value.mandatory()) == ['val1.val1']
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master4():
|
||||
def test_callback_leader_and_followers_leader4():
|
||||
val1 = StrOption('val1', "", ['val1'], multi=True, properties=('mandatory',))
|
||||
val2 = StrOption('val2', "", multi=True, default_multi='val2', properties=('expert', 'mandatory'))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val2)))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val3)))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2, val3, val4])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -688,7 +679,7 @@ def test_callback_master_and_slaves_master4():
|
|||
assert list(api.value.mandatory()) == []
|
||||
|
||||
|
||||
def test_consistency_master_and_slaves_master_mandatory_transitive():
|
||||
def test_consistency_leader_and_followers_leader_mandatory_transitive():
|
||||
#default value
|
||||
val1 = IPOption('val1', "", ['192.168.0.1'], multi=True, properties=('mandatory',))
|
||||
val2 = NetmaskOption('val2', "", multi=True, default_multi='255.255.255.0', properties=('disabled', 'mandatory'))
|
||||
|
@ -697,8 +688,8 @@ def test_consistency_master_and_slaves_master_mandatory_transitive():
|
|||
val3 = IPOption('val3', "", multi=True, properties=('mandatory',))
|
||||
val4 = NetmaskOption('val4', "", multi=True, default_multi='255.255.255.0', properties=('disabled', 'mandatory'))
|
||||
val4.impl_add_consistency('ip_netmask', val3)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
interface2 = MasterSlaves('val3', '', [val3, val4])
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
interface2 = Leadership('val3', '', [val3, val4])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, interface2])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -712,7 +703,7 @@ def test_consistency_master_and_slaves_master_mandatory_transitive():
|
|||
assert list(api.value.mandatory()) == []
|
||||
|
||||
|
||||
def test_consistency_master_and_slaves_master_mandatory_non_transitive():
|
||||
def test_consistency_leader_and_followers_leader_mandatory_non_transitive():
|
||||
#no value
|
||||
val1 = IPOption('val1', "", multi=True, properties=('mandatory',))
|
||||
val2 = NetmaskOption('val2', "", multi=True, default_multi='255.255.255.0', properties=('disabled', 'mandatory'))
|
||||
|
@ -721,10 +712,8 @@ def test_consistency_master_and_slaves_master_mandatory_non_transitive():
|
|||
val3 = IPOption('val3', "", ['192.168.0.1'], multi=True, properties=('mandatory',))
|
||||
val4 = NetmaskOption('val4', "", multi=True, default_multi='255.255.255.0', properties=('disabled', 'mandatory'))
|
||||
val4.impl_add_consistency('ip_netmask', val3, transitive=False)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
interface2 = MasterSlaves('val3', '', [val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
#interface2.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
interface2 = Leadership('val3', '', [val3, val4])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, interface2])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -734,11 +723,10 @@ def test_consistency_master_and_slaves_master_mandatory_non_transitive():
|
|||
assert list(api.value.mandatory()) == ["val1.val1"]
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master_list():
|
||||
def test_callback_leader_and_followers_leader_list():
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_list)
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -759,24 +747,22 @@ def test_callback_master_and_slaves_master_list():
|
|||
assert api.option('val1.val2', 0).value.get() == None
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master_slave_list():
|
||||
def test_callback_leader_and_followers_leader_follower_list():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_list)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
assert api.option('val1.val1').value.get() == []
|
||||
api.option('val1.val1').value.set(['val1'])
|
||||
raises(SlaveError, "api.option('val1.val2', 0).value.get()")
|
||||
raises(LeadershipError, "api.option('val1.val2', 0).value.get()")
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_slave():
|
||||
def test_callback_leader_and_followers_follower():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_val)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -813,21 +799,20 @@ def test_callback_master_and_slaves_slave():
|
|||
assert api.option('val1.val2', 2).value.get() == 'val'
|
||||
|
||||
|
||||
def test_callback_master_and_slaves():
|
||||
def test_callback_leader_and_followers():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_val)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_slave_cal():
|
||||
def test_callback_leader_and_followers_follower_cal():
|
||||
val3 = StrOption('val3', "", multi=True)
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val3)))
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_val)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val3])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -847,12 +832,12 @@ def test_callback_master_and_slaves_slave_cal():
|
|||
assert api.option('val1.val2', 0).value.get() == 'val'
|
||||
assert api.option('val1.val2', 1).value.get() == 'val'
|
||||
assert api.option('val1.val1').value.get() == ['val1', 'val2']
|
||||
# len of slave is higher than master's one
|
||||
# len of follower is higher than leader's one
|
||||
api.option('val1.val2', 0).value.set('val1')
|
||||
api.option('val1.val2', 1).value.set('val2')
|
||||
api.option('val3').value.set(['val1'])
|
||||
assert api.option('val1.val1').value.get() == ['val1']
|
||||
raises(SlaveError, "api.option('val1.val2', 0).value.get()")
|
||||
raises(LeadershipError, "api.option('val1.val2', 0).value.get()")
|
||||
#
|
||||
api.option('val3').value.set(['val1', 'val2', 'val3'])
|
||||
assert api.option('val1.val2', 0).value.get() == 'val1'
|
||||
|
@ -860,12 +845,11 @@ def test_callback_master_and_slaves_slave_cal():
|
|||
assert api.option('val1.val2', 2).value.get() == 'val'
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master_disabled():
|
||||
def test_callback_leader_and_followers_leader_disabled():
|
||||
#properties must be transitive
|
||||
val1 = StrOption('val1', "", ['val1'], multi=True, properties=('disabled',))
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -874,12 +858,11 @@ def test_callback_master_and_slaves_master_disabled():
|
|||
raises(PropertiesOptionError, "api.option('val1.val2', 0).value.get()")
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master_callback_disabled():
|
||||
def test_callback_leader_and_followers_leader_callback_disabled():
|
||||
val0 = StrOption('val0', "", multi=True, properties=('disabled',))
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val0)))
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val0])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -891,11 +874,10 @@ def test_callback_master_and_slaves_master_callback_disabled():
|
|||
assert api.option('val1.val1').value.get() == []
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_slave_disabled():
|
||||
def test_callback_leader_and_followers_follower_disabled():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, properties=('disabled',))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -919,12 +901,11 @@ def test_callback_master_and_slaves_slave_disabled():
|
|||
assert api.option('val1.val2', 1).value.get() == 'no1'
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_slave_callback_disabled():
|
||||
def test_callback_leader_and_followers_follower_callback_disabled():
|
||||
val0 = StrOption('val0', "", multi=True, properties=('disabled',))
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val0)))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val0])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -939,28 +920,27 @@ def test_callback_master_and_slaves_slave_callback_disabled():
|
|||
api.option('val1.val1').value.pop(1)
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_value():
|
||||
def test_callback_leader_and_followers_value():
|
||||
val4 = StrOption('val4', '', multi=True, default=['val10', 'val11'])
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamValue('yes')))
|
||||
val5 = StrOption('val5', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val4)))
|
||||
val6 = StrOption('val6', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val5)))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2, val3, val5, val6])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2, val3, val5, val6])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val4])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
api.option('val4').value.get() == ['val10', 'val11']
|
||||
assert api.option('val1.val1').value.get() == []
|
||||
#raises(SlaveError, "cfg.val1.val1")
|
||||
#raises(SlaveError, "cfg.val1.val2")
|
||||
#raises(SlaveError, "cfg.val1.val3")
|
||||
#raises(SlaveError, "cfg.val1.val5")
|
||||
#raises(SlaveError, "cfg.val1.val6")
|
||||
#raises(LeadershipError, "cfg.val1.val1")
|
||||
#raises(LeadershipError, "cfg.val1.val2")
|
||||
#raises(LeadershipError, "cfg.val1.val3")
|
||||
#raises(LeadershipError, "cfg.val1.val5")
|
||||
#raises(LeadershipError, "cfg.val1.val6")
|
||||
#
|
||||
#default calculation has greater length
|
||||
#raises(SlaveError, "api.option('val1.val1').value.set(['val1']")
|
||||
#raises(LeadershipError, "api.option('val1.val1').value.set(['val1']")
|
||||
#
|
||||
api.option('val1.val1').value.set(['val1', 'val2'])
|
||||
assert api.option('val1.val1').value.get() == ['val1', 'val2']
|
||||
|
@ -968,10 +948,10 @@ def test_callback_master_and_slaves_value():
|
|||
assert api.option('val1.val2', 1).value.get() == 'val2'
|
||||
assert api.option('val1.val3', 0).value.get() == 'yes'
|
||||
assert api.option('val1.val3', 1).value.get() == 'yes'
|
||||
raises(SlaveError, "api.option('val1.val5', 0).value.get()")
|
||||
raises(SlaveError, "api.option('val1.val5', 1).value.get()")
|
||||
raises(SlaveError, "api.option('val1.val6', 0).value.get()")
|
||||
raises(SlaveError, "api.option('val1.val6', 1).value.get()")
|
||||
raises(LeadershipError, "api.option('val1.val5', 0).value.get()")
|
||||
raises(LeadershipError, "api.option('val1.val5', 1).value.get()")
|
||||
raises(LeadershipError, "api.option('val1.val6', 0).value.get()")
|
||||
raises(LeadershipError, "api.option('val1.val6', 1).value.get()")
|
||||
#
|
||||
api.option('val1.val1').value.set(['val1', 'val2', 'val3'])
|
||||
assert api.option('val1.val1').value.get() == ['val1', 'val2', 'val3']
|
||||
|
@ -981,8 +961,8 @@ def test_callback_master_and_slaves_value():
|
|||
assert api.option('val1.val3', 0).value.get() == 'yes'
|
||||
assert api.option('val1.val3', 1).value.get() == 'yes'
|
||||
assert api.option('val1.val3', 2).value.get() == 'yes'
|
||||
raises(SlaveError, "api.option('val1.val5', 2).value.get()")
|
||||
raises(SlaveError, "api.option('val1.val6', 2).value.get()")
|
||||
raises(LeadershipError, "api.option('val1.val5', 2).value.get()")
|
||||
raises(LeadershipError, "api.option('val1.val6', 2).value.get()")
|
||||
#
|
||||
api.option('val1.val1').value.pop(2)
|
||||
assert api.option('val1.val1').value.get() == ['val1', 'val2']
|
||||
|
@ -1011,10 +991,10 @@ def test_callback_master_and_slaves_value():
|
|||
assert api.option('val1.val3', 2).value.get() == 'yes'
|
||||
|
||||
|
||||
def test_callback_master():
|
||||
def test_callback_leader():
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value)
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val2)))
|
||||
raises(ValueError, "MasterSlaves('val1', '', [val1, val2])")
|
||||
raises(ValueError, "Leadership('val1', '', [val1, val2])")
|
||||
|
||||
|
||||
def test_callback_different_type():
|
||||
|
@ -1022,8 +1002,7 @@ def test_callback_different_type():
|
|||
val_ = IntOption('val_', "", default=3)
|
||||
val1 = IntOption('val1', "", multi=True)
|
||||
val2 = IntOption('val2', "", multi=True, callback=return_calc, callback_params=Params((ParamOption(val), ParamOption(val1)), {'k': ParamOption(val_)}))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val, val_])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -1181,11 +1160,10 @@ def test_callback_multi_list_params_key():
|
|||
assert api.option('val2.val2').value.get() == ['val', 'val']
|
||||
|
||||
|
||||
def test_masterslaves_callback_description():
|
||||
def test_leadership_callback_description():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_value, callback_params=Params(ParamOption(st1)))
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
stm = Leadership('st1', '', [st1, st2])
|
||||
st = OptionDescription('st', '', [stm])
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
|
|
@ -5,7 +5,7 @@ from py.test import raises
|
|||
|
||||
from tiramisu.setting import owners, groups
|
||||
from tiramisu import IPOption, NetworkOption, NetmaskOption, IntOption,\
|
||||
BroadcastOption, StrOption, SymLinkOption, OptionDescription, submulti, MasterSlaves,\
|
||||
BroadcastOption, StrOption, SymLinkOption, OptionDescription, submulti, Leadership,\
|
||||
Config, undefined, Params, ParamOption
|
||||
from tiramisu.error import ConfigError, ValueWarning, PropertiesOptionError
|
||||
from tiramisu.api import TIRAMISU_VERSION
|
||||
|
@ -264,7 +264,7 @@ def test_consistency_mix():
|
|||
b = IntOption('b', '', multi=True)
|
||||
c = IntOption('c', '', multi=True)
|
||||
d = IntOption('d', '', multi=True)
|
||||
od = MasterSlaves('c', '', [c, d])
|
||||
od = Leadership('c', '', [c, d])
|
||||
od2 = OptionDescription('a', '', [b, od])
|
||||
c.impl_add_consistency('not_equal', b, d)
|
||||
cfg = Config(od2)
|
||||
|
@ -295,10 +295,10 @@ def test_consistency_not_equal_default_submulti():
|
|||
raises(ConfigError, "a.impl_add_consistency('not_equal', b)")
|
||||
|
||||
|
||||
def test_consistency_not_equal_masterslave():
|
||||
def test_consistency_not_equal_leadership():
|
||||
a = IntOption('a', '', multi=True)
|
||||
b = IntOption('b', '', multi=True)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
od2 = OptionDescription('b', '', [od])
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
api = Config(od2)
|
||||
|
@ -313,27 +313,27 @@ def test_consistency_not_equal_masterslave():
|
|||
api.value.dict()
|
||||
|
||||
|
||||
def test_consistency_not_equal_masterslave_error_multi1():
|
||||
def test_consistency_not_equal_leadership_error_multi1():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = NetmaskOption('c', '', multi=True)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
od2 = OptionDescription('b', '', [od, c])
|
||||
c.impl_add_consistency('ip_netmask', a)
|
||||
raises(ConfigError, "Config(od2)")
|
||||
|
||||
|
||||
def test_consistency_not_equal_masterslave_error_multi2():
|
||||
def test_consistency_not_equal_leadership_error_multi2():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = IPOption('c', '', multi=True)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
od2 = OptionDescription('b', '', [od, c])
|
||||
b.impl_add_consistency('ip_netmask', c)
|
||||
raises(ConfigError, "Config(od2)")
|
||||
|
||||
|
||||
def test_consistency_ip_netmask_masterslave_error_not_master():
|
||||
def test_consistency_ip_netmask_leadership_error_not_leader():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
|
@ -342,34 +342,34 @@ def test_consistency_ip_netmask_masterslave_error_not_master():
|
|||
raises(ConfigError, "Config(od2)")
|
||||
|
||||
|
||||
def test_consistency_ip_netmask_masterslave_error_master_and_not():
|
||||
def test_consistency_ip_netmask_leadership_error_leader_and_not():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = IPOption('c', '', multi=True)
|
||||
d = NetmaskOption('d', '', multi=True)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
od2 = OptionDescription('c', '', [c, d])
|
||||
od3 = OptionDescription('b', '', [od, od2])
|
||||
d.impl_add_consistency('ip_netmask', a)
|
||||
raises(ConfigError, "Config(od3)")
|
||||
|
||||
|
||||
def test_consistency_ip_netmask_masterslave_error_othermaster():
|
||||
def test_consistency_ip_netmask_leadership_error_otherleader():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = IPOption('c', '', multi=True)
|
||||
d = NetmaskOption('d', '', multi=True)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od2 = MasterSlaves('c', '', [c, d])
|
||||
od = Leadership('a', '', [a, b])
|
||||
od2 = Leadership('c', '', [c, d])
|
||||
od3 = OptionDescription('b', '', [od, od2])
|
||||
d.impl_add_consistency('ip_netmask', a)
|
||||
raises(ConfigError, "Config(od2)")
|
||||
|
||||
|
||||
def test_consistency_not_equal_masterslaves_default():
|
||||
def test_consistency_not_equal_leadership_default():
|
||||
a = IntOption('a', '', multi=True)
|
||||
b = IntOption('b', '', multi=True, default_multi=1)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
od2 = OptionDescription('a', '', [od])
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
api = Config(od2)
|
||||
|
@ -423,10 +423,10 @@ def test_consistency_not_equal_multi_default2():
|
|||
a.impl_add_consistency('not_equal', b)
|
||||
|
||||
|
||||
def test_consistency_not_equal_master_default():
|
||||
def test_consistency_not_equal_leader_default():
|
||||
a = IntOption('a', '', multi=True, default=[2, 1])
|
||||
b = IntOption('b', '', multi=True, default_multi=1)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
od2 = OptionDescription('a', '', [od])
|
||||
api = Config(od2)
|
||||
|
@ -586,7 +586,7 @@ def test_consistency_ip_netmask_error_multi():
|
|||
def test_consistency_ip_netmask_multi():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
b.impl_add_consistency('ip_netmask', a)
|
||||
od2 = OptionDescription('od2', '', [od])
|
||||
api = Config(od2)
|
||||
|
@ -606,7 +606,7 @@ def test_consistency_ip_netmask_multi():
|
|||
def test_consistency_network_netmask_multi():
|
||||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
api = Config(od2)
|
||||
|
@ -618,10 +618,10 @@ def test_consistency_network_netmask_multi():
|
|||
raises(ValueError, "api.option('a.a').value.set(['192.168.1.1'])")
|
||||
|
||||
|
||||
def test_consistency_network_netmask_multi_slave_default_multi():
|
||||
def test_consistency_network_netmask_multi_follower_default_multi():
|
||||
a = NetworkOption('a', '', default_multi=u'192.168.1.0', multi=True, properties=('mandatory',))
|
||||
b = NetmaskOption('b', '', default_multi=u'255.255.255.0', multi=True, properties=('mandatory',))
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
od2 = OptionDescription('od2', '', [od])
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
api = Config(od2)
|
||||
|
@ -631,10 +631,10 @@ def test_consistency_network_netmask_multi_slave_default_multi():
|
|||
assert api.option('a.b', 0).value.get() == '255.255.255.0'
|
||||
|
||||
|
||||
def test_consistency_network_netmask_multi_slave_default():
|
||||
def test_consistency_network_netmask_multi_follower_default():
|
||||
a = NetworkOption('a', '', multi=True, properties=('mandatory',))
|
||||
b = NetmaskOption('b', '', default_multi=u'255.255.255.0', multi=True, properties=('mandatory',))
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
od2 = OptionDescription('od2', '', [od])
|
||||
api = Config(od2)
|
||||
|
@ -657,19 +657,19 @@ def return_netmask(*args, **kwargs):
|
|||
return u'255.255.255.0'
|
||||
|
||||
|
||||
def return_netmask2(master):
|
||||
if master is not None:
|
||||
if master.endswith('2.1'):
|
||||
def return_netmask2(leader):
|
||||
if leader is not None:
|
||||
if leader.endswith('2.1'):
|
||||
return u'255.255.255.0'
|
||||
if not master.endswith('.0'):
|
||||
if not leader.endswith('.0'):
|
||||
return u'255.255.255.255'
|
||||
return u'255.255.255.0'
|
||||
|
||||
|
||||
def test_consistency_network_netmask_multi_slave_callback():
|
||||
def test_consistency_network_netmask_multi_follower_callback():
|
||||
a = NetworkOption('a', '', multi=True, properties=('mandatory',))
|
||||
b = NetmaskOption('b', '', callback=return_netmask, multi=True, properties=('mandatory',))
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
od2 = OptionDescription('od2', '', [od])
|
||||
api = Config(od2)
|
||||
|
@ -688,10 +688,10 @@ def test_consistency_network_netmask_multi_slave_callback():
|
|||
api.option('a.a').value.set(['192.168.1.0', '192.168.1.1'])
|
||||
|
||||
|
||||
def test_consistency_network_netmask_multi_slave_callback_value():
|
||||
def test_consistency_network_netmask_multi_follower_callback_value():
|
||||
a = NetworkOption('a', '', multi=True, properties=('mandatory',))
|
||||
b = NetmaskOption('b', '', callback=return_netmask2, callback_params=Params(ParamOption(a)), multi=True, properties=('mandatory',))
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
od2 = OptionDescription('od2', '', [od])
|
||||
api = Config(od2)
|
||||
|
@ -712,10 +712,10 @@ def test_consistency_network_netmask_multi_slave_callback_value():
|
|||
api.option('a.b', 1).value.set('255.255.255.255')
|
||||
|
||||
|
||||
def test_consistency_ip_netmask_multi_master():
|
||||
def test_consistency_ip_netmask_multi_leader():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
b.impl_add_consistency('ip_netmask', a)
|
||||
od2 = OptionDescription('od2', '', [od])
|
||||
api = Config(od2)
|
||||
|
@ -730,10 +730,10 @@ def test_consistency_ip_netmask_multi_master():
|
|||
api.option('a.a').value.set(['192.168.1.2', '192.168.1.3'])
|
||||
|
||||
|
||||
def test_consistency_network_netmask_multi_master():
|
||||
def test_consistency_network_netmask_multi_leader():
|
||||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
od2 = OptionDescription('od2', '', [od])
|
||||
api = Config(od2)
|
||||
|
@ -749,7 +749,7 @@ def test_consistency_broadcast():
|
|||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = BroadcastOption('c', '', multi=True)
|
||||
od = MasterSlaves('a', '', [a, b, c])
|
||||
od = Leadership('a', '', [a, b, c])
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c.impl_add_consistency('broadcast', a, b)
|
||||
od2 = OptionDescription('od2', '', [od])
|
||||
|
@ -776,7 +776,7 @@ def test_consistency_broadcast_error():
|
|||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = BroadcastOption('c', '', multi=True)
|
||||
od = MasterSlaves('a', '', [a, b, c])
|
||||
od = Leadership('a', '', [a, b, c])
|
||||
od2 = OptionDescription('od2', '', [od])
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c.impl_add_consistency('broadcast', a)
|
||||
|
@ -825,7 +825,7 @@ def test_consistency_not_all():
|
|||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = BroadcastOption('c', '', multi=True)
|
||||
od = MasterSlaves('a', '', [a, b, c])
|
||||
od = Leadership('a', '', [a, b, c])
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
od2 = OptionDescription('od2', '', [od])
|
||||
api = Config(od2)
|
||||
|
@ -991,7 +991,7 @@ def test_consistency_warnings_error():
|
|||
def test_consistency_network_netmask_mandatory():
|
||||
a = NetworkOption('a', '', multi=True, properties=('mandatory',), default=[u'0.0.0.0'])
|
||||
b = NetmaskOption('b', '', multi=True, properties=('mandatory',), default_multi=u'0.0.0.0')
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
od = Leadership('a', '', [a, b])
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
od2 = OptionDescription('od2', '', [od])
|
||||
api = Config(od2)
|
||||
|
|
|
@ -7,7 +7,7 @@ from py.test import raises
|
|||
from tiramisu.setting import owners
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError
|
||||
from tiramisu import IntOption, FloatOption, StrOption, ChoiceOption, \
|
||||
BoolOption, OptionDescription, MasterSlaves, Config, undefined
|
||||
BoolOption, OptionDescription, Leadership, Config, undefined
|
||||
from tiramisu.storage import list_sessions
|
||||
|
||||
|
||||
|
@ -112,31 +112,31 @@ def test_force_default_on_freeze_multi():
|
|||
api.option('dummy1').property.add('frozen')
|
||||
|
||||
|
||||
def test_force_default_on_freeze_master():
|
||||
def test_force_default_on_freeze_leader():
|
||||
dummy1 = BoolOption('dummy1', 'Test int option', multi=True, properties=('force_default_on_freeze',))
|
||||
dummy2 = BoolOption('dummy2', 'Test string option', multi=True)
|
||||
descr = MasterSlaves("dummy1", "", [dummy1, dummy2])
|
||||
descr = Leadership("dummy1", "", [dummy1, dummy2])
|
||||
descr = OptionDescription("root", "", [descr])
|
||||
raises(ConfigError, "Config(descr)")
|
||||
|
||||
|
||||
def test_force_default_on_freeze_master_frozen():
|
||||
def test_force_default_on_freeze_leader_frozen():
|
||||
dummy1 = BoolOption('dummy1', 'Test int option', multi=True, properties=('force_default_on_freeze', 'frozen'))
|
||||
dummy2 = BoolOption('dummy2', 'Test string option', multi=True)
|
||||
descr = MasterSlaves("dummy1", "", [dummy1, dummy2])
|
||||
descr = Leadership("dummy1", "", [dummy1, dummy2])
|
||||
descr = OptionDescription("root", "", [descr])
|
||||
api = Config(descr)
|
||||
raises(ConfigError, "api.option('dummy1.dummy1').property.pop('frozen')")
|
||||
|
||||
|
||||
def test_force_default_on_freeze_slave():
|
||||
def test_force_default_on_freeze_follower():
|
||||
dummy1 = BoolOption('dummy1', 'Test int option', multi=True)
|
||||
dummy2 = BoolOption('dummy2', 'Test string option', multi=True, properties=('force_default_on_freeze',))
|
||||
descr = MasterSlaves("dummy1", "", [dummy1, dummy2])
|
||||
descr = Leadership("dummy1", "", [dummy1, dummy2])
|
||||
descr = OptionDescription("root", "", [descr])
|
||||
api = Config(descr)
|
||||
api.property.read_write()
|
||||
owners.addowner("frozenmultislave2")
|
||||
owners.addowner("frozenmultifollower2")
|
||||
api.option('dummy1.dummy1').value.set([True])
|
||||
api.option('dummy1.dummy2', 0).value.set(False)
|
||||
assert api.option('dummy1.dummy1').value.get() == [True]
|
||||
|
@ -149,7 +149,7 @@ def test_force_default_on_freeze_slave():
|
|||
assert api.option('dummy1.dummy2', 0).value.get() == None
|
||||
assert api.option('dummy1.dummy1').owner.get() == 'user'
|
||||
assert api.option('dummy1.dummy2', 0).owner.isdefault()
|
||||
raises(PropertiesOptionError, "api.option('dummy1.dummy2', 0).owner.set('frozenmultislave2')")
|
||||
raises(PropertiesOptionError, "api.option('dummy1.dummy2', 0).owner.set('frozenmultifollower2')")
|
||||
#
|
||||
api.option('dummy1.dummy2').property.pop('frozen')
|
||||
api.option('dummy1.dummy1').value.set([True, True])
|
||||
|
|
|
@ -5,7 +5,7 @@ from py.test import raises
|
|||
|
||||
from tiramisu.setting import owners, groups
|
||||
from tiramisu import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription, SymLinkOption, MasterSlaves, Config
|
||||
StrOption, OptionDescription, SymLinkOption, Leadership, Config
|
||||
from tiramisu.error import ConfigError, ConstError, PropertiesOptionError, APIError
|
||||
from tiramisu.storage import list_sessions
|
||||
|
||||
|
@ -165,10 +165,10 @@ def test_setowner_symlinkoption():
|
|||
raises(ConfigError, "api.option('tiramisu.symdummy').owner.set('user')")
|
||||
|
||||
|
||||
def test_owner_masterslaves():
|
||||
def test_owner_leadership():
|
||||
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
||||
c = StrOption('str', 'Test string option', multi=True)
|
||||
descr = MasterSlaves("int", "", [b, c])
|
||||
descr = Leadership("int", "", [b, c])
|
||||
od = OptionDescription('od', '', [descr])
|
||||
api = Config(od)
|
||||
raises(ConfigError, "api.option('int.str', 0).owner.set('user')")
|
||||
|
|
|
@ -8,7 +8,7 @@ from tiramisu.i18n import _
|
|||
from tiramisu.error import display_list, ConfigError
|
||||
from tiramisu.setting import owners, groups
|
||||
from tiramisu import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription, MasterSlaves, Config, undefined
|
||||
StrOption, OptionDescription, Leadership, Config, undefined
|
||||
from tiramisu.error import PropertiesOptionError
|
||||
from tiramisu.storage import list_sessions
|
||||
|
||||
|
@ -335,25 +335,25 @@ def test_multi_with_requires_that_is_multi_inverse():
|
|||
raises(ValueError, "Config(descr)")
|
||||
|
||||
|
||||
def test_multi_with_requires_that_is_masterslave():
|
||||
def test_multi_with_requires_that_is_leadership():
|
||||
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
||||
c = StrOption('str', 'Test string option', requires=[{'option': b, 'expected': 1, 'action': 'hidden'}], multi=True)
|
||||
descr = MasterSlaves("int", "", [b, c])
|
||||
descr = Leadership("int", "", [b, c])
|
||||
od = OptionDescription('root', '', [descr])
|
||||
Config(od)
|
||||
|
||||
|
||||
def test_multi_with_requires_that_is_masterslave_master():
|
||||
def test_multi_with_requires_that_is_leadership_leader():
|
||||
b = IntOption('int', 'Test int option', multi=True)
|
||||
c = StrOption('str', 'Test string option', requires=[{'option': b, 'expected': 1, 'action': 'hidden'}], multi=True)
|
||||
raises(ValueError, "MasterSlaves('str', '', [c, b])")
|
||||
raises(ValueError, "Leadership('str', '', [c, b])")
|
||||
|
||||
|
||||
def test_multi_with_requires_that_is_masterslave_slave():
|
||||
def test_multi_with_requires_that_is_leadership_follower():
|
||||
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
||||
c = StrOption('str', 'Test string option', multi=True)
|
||||
d = StrOption('str1', 'Test string option', requires=[{'option': c, 'expected': '1', 'action': 'hidden'}], multi=True)
|
||||
descr = MasterSlaves("int", "", [b, c, d])
|
||||
descr = Leadership("int", "", [b, c, d])
|
||||
descr2 = OptionDescription('od', '', [descr])
|
||||
api = Config(descr2)
|
||||
api.property.read_write()
|
||||
|
@ -375,11 +375,11 @@ def test_multi_with_requires_that_is_masterslave_slave():
|
|||
raises(PropertiesOptionError, "api.option('int.str1', 1).value.get()")
|
||||
|
||||
|
||||
def test_multi_with_requires_that_is_masterslave_slave_inverse():
|
||||
def test_multi_with_requires_that_is_leadership_follower_inverse():
|
||||
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
||||
c = StrOption('str', 'Test string option', multi=True)
|
||||
d = StrOption('str1', 'Test string option', requires=[{'option': c, 'expected': None, 'action': 'hidden', 'inverse': True}], multi=True)
|
||||
descr = MasterSlaves("int", "", [b, c, d])
|
||||
descr = Leadership("int", "", [b, c, d])
|
||||
descr2 = OptionDescription('od', '', [descr])
|
||||
api = Config(descr2)
|
||||
api.property.read_write()
|
||||
|
@ -401,15 +401,13 @@ def test_multi_with_requires_that_is_masterslave_slave_inverse():
|
|||
raises(PropertiesOptionError, "api.option('int.str1', 1).value.get()")
|
||||
|
||||
|
||||
def test_multi_with_requires_that_is_not_same_masterslave():
|
||||
def test_multi_with_requires_that_is_not_same_leadership():
|
||||
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
||||
c = StrOption('str', 'Test string option', requires=[{'option': b, 'expected': 1, 'action': 'hidden'}], multi=True)
|
||||
descr1 = MasterSlaves("int", "", [b, c])
|
||||
#descr1.impl_set_group_type(groups.master)
|
||||
descr1 = Leadership("int", "", [b, c])
|
||||
d = IntOption('int1', 'Test int option', default=[0], multi=True)
|
||||
e = StrOption('str', 'Test string option', requires=[{'option': b, 'expected': 1, 'action': 'hidden'}], multi=True)
|
||||
descr2 = MasterSlaves("int1", "", [d, e])
|
||||
#descr2.impl_set_group_type(groups.master)
|
||||
descr2 = Leadership("int1", "", [d, e])
|
||||
descr3 = OptionDescription('val', '', [descr1, descr2])
|
||||
descr3
|
||||
raises(ValueError, "Config(descr3)")
|
||||
|
|
|
@ -4,7 +4,7 @@ do_autopath()
|
|||
import warnings
|
||||
from py.test import raises
|
||||
|
||||
from tiramisu import BoolOption, StrOption, OptionDescription, MasterSlaves, Config, Params, ParamValue, ParamOption, ParamContext
|
||||
from tiramisu import BoolOption, StrOption, OptionDescription, Leadership, Config, Params, ParamValue, ParamOption, ParamContext
|
||||
from tiramisu.setting import groups
|
||||
from tiramisu.error import ValueWarning, ConfigError
|
||||
from tiramisu.i18n import _
|
||||
|
@ -153,33 +153,30 @@ def test_validator_params_value_values_index():
|
|||
api.option('opt1').value.set(['val1', 'val2'])
|
||||
|
||||
|
||||
def test_validator_params_value_values_master():
|
||||
def test_validator_params_value_values_leader():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip reseau autorise", multi=True, validator=value_values)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-reseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
api = Config(root)
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['val1', 'val2'])
|
||||
|
||||
|
||||
def test_validator_params_value_values_index_master():
|
||||
def test_validator_params_value_values_index_leader():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip reseau autorise", multi=True, validator=value_values_index)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-reseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
api = Config(root)
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['val1', 'val2'])
|
||||
|
||||
|
||||
def test_validator_params_value_values_slave():
|
||||
def test_validator_params_value_values_follower():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip reseau autorise", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-reseau", multi=True, validator=value_values)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
api = Config(root)
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
|
@ -189,11 +186,10 @@ def test_validator_params_value_values_slave():
|
|||
api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.set('val2')
|
||||
|
||||
|
||||
def test_validator_params_value_values_index_slave():
|
||||
def test_validator_params_value_values_index_follower():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip reseau autorise", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-reseau", multi=True, validator=value_values_index)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
api = Config(root)
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
|
@ -215,8 +211,7 @@ def test_validator_params_value_values_kwargs_empty():
|
|||
multi=True,
|
||||
validator=value_empty,
|
||||
validator_params=Params(ParamOption(v)))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
root = OptionDescription('root', '', [v, interface1])
|
||||
api = Config(root)
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['ip']
|
||||
|
@ -233,8 +228,7 @@ def test_validator_params_value_values_kwargs():
|
|||
multi=True,
|
||||
validator=value_values_auto,
|
||||
validator_params=Params(kwargs={'auto': ParamOption(v)}))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
root = OptionDescription('root', '', [v, interface1])
|
||||
api = Config(root)
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['ip']
|
||||
|
@ -250,8 +244,7 @@ def test_validator_params_value_values_kwargs_values():
|
|||
multi=True,
|
||||
validator=value_values_auto2,
|
||||
validator_params=Params(kwargs={'values': ParamOption(ip_admin_eth0)}))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
api = Config(root)
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
|
@ -268,8 +261,7 @@ def test_validator_params_value_values_kwargs2():
|
|||
multi=True,
|
||||
validator=value_values_index2,
|
||||
validator_params=Params(ParamValue(['val1']), {'index': ParamOption(ip_admin_eth0)}))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
api = Config(root)
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
|
@ -285,8 +277,7 @@ def test_validator_params_value_values_kwargs_index():
|
|||
multi=True,
|
||||
validator=value_values_index2,
|
||||
validator_params=Params(kwargs={'index': ParamOption(ip_admin_eth0)}))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
api = Config(root)
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
|
@ -439,14 +430,13 @@ def test_validator_warning_disabled():
|
|||
assert len(w) == 1
|
||||
|
||||
|
||||
def test_validator_warning_master_slave():
|
||||
def test_validator_warning_leadership():
|
||||
display_name_ip = "ip reseau autorise"
|
||||
display_name_netmask = "masque du sous-reseau"
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', display_name_ip, multi=True, validator=return_false, warnings_only=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', display_name_netmask, multi=True, validator=return_if_val, warnings_only=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
assert interface1.impl_get_group_type() == groups.leadership
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
api = Config(root)
|
||||
warnings.simplefilter("always", ValueWarning)
|
||||
|
@ -489,15 +479,14 @@ def test_validator_warning_master_slave():
|
|||
assert str(w[0].message) == msg_err.format('val', ip_admin_eth0._display_name, display_name_ip, 'test error return_false')
|
||||
|
||||
|
||||
def test_validator_slave_param():
|
||||
def test_validator_follower_param():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip reseau autorise", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0',
|
||||
"masque du sous-reseau",
|
||||
multi=True,
|
||||
validator=return_true,
|
||||
validator_params=Params(kwargs={'param': ParamOption(ip_admin_eth0)}))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
api = Config(root)
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
|
|
|
@ -8,7 +8,7 @@ from tiramisu.setting import groups
|
|||
from tiramisu import setting
|
||||
setting.expires_time = 1
|
||||
from tiramisu import IPOption, OptionDescription, BoolOption, IntOption, StrOption, \
|
||||
MasterSlaves, Config
|
||||
Leadership, Config
|
||||
from tiramisu.error import PropertiesOptionError, RequirementError
|
||||
from py.test import raises
|
||||
from tiramisu.storage import list_sessions, delete_session
|
||||
|
@ -956,11 +956,11 @@ def test_properties_conflict():
|
|||
raises(ValueError, "od1 = OptionDescription('service', '', [a], properties=('disabled',), requires=[{'option': a, 'expected': False, 'action': 'disabled'}])")
|
||||
|
||||
|
||||
def test_master_slave_requires():
|
||||
def test_leadership_requires():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True,
|
||||
requires=[{'option': ip_admin_eth0, 'expected': '192.168.1.1', 'action': 'disabled'}])
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -1006,46 +1006,46 @@ def test_master_slave_requires():
|
|||
del ret['ip_admin_eth0.netmask_admin_eth0']
|
||||
|
||||
|
||||
def test_master_slave_requires_both():
|
||||
def test_leadership_requires_both():
|
||||
ip_admin = StrOption('ip_admin_eth0', "ip réseau autorisé")
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True,
|
||||
requires=[{'option': ip_admin, 'expected': '192.168.1.1', 'action': 'disabled'}])
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
raises(RequirementError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0], requires=[{'option': ip_admin, 'expected': '192.168.1.1', 'action': 'disabled'}])")
|
||||
raises(RequirementError, "Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0], requires=[{'option': ip_admin, 'expected': '192.168.1.1', 'action': 'disabled'}])")
|
||||
|
||||
|
||||
def test_master_slave_requires_properties_invalid():
|
||||
def test_leadership_requires_properties_invalid():
|
||||
ip_admin = StrOption('ip_admin', "ip réseau autorisé")
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True,
|
||||
requires=[{'option': ip_admin_eth0, 'expected': '192.168.1.1', 'action': 'disabled'}])
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0], properties=('disabled',), requires=[{'option': ip_admin, 'expected': '192.168.1.1', 'action': 'disabled'}])")
|
||||
raises(ValueError, "Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0], properties=('disabled',), requires=[{'option': ip_admin, 'expected': '192.168.1.1', 'action': 'disabled'}])")
|
||||
|
||||
|
||||
def test_master_slave_requires_properties_invalid_2():
|
||||
def test_leadership_requires_properties_invalid_2():
|
||||
ip_admin = StrOption('ip_admin', "ip réseau autorisé")
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True,
|
||||
requires=[{'option': ip_admin, 'expected': '192.168.1.1', 'action': 'disabled'}])
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True,
|
||||
requires=[{'option': ip_admin_eth0, 'expected': '192.168.1.1', 'action': 'disabled'}])
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0], properties=('disabled',))")
|
||||
raises(ValueError, "Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0], properties=('disabled',))")
|
||||
|
||||
|
||||
def test_master_slave_requires_properties():
|
||||
def test_leadership_requires_properties():
|
||||
ip_admin = StrOption('ip_admin', "ip réseau autorisé")
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True,
|
||||
requires=[{'option': ip_admin_eth0, 'expected': '192.168.1.1', 'action': 'disabled'}])
|
||||
MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0], properties=('hidden',),
|
||||
Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0], properties=('hidden',),
|
||||
requires=[{'option': ip_admin, 'expected': '192.168.1.1', 'action': 'disabled'}])
|
||||
|
||||
|
||||
def test_master_slave_requires_master():
|
||||
def test_leadership_requires_leader():
|
||||
activate = BoolOption('activate', "Activer l'accès au réseau", True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True,
|
||||
requires=[{'option': activate, 'expected': False, 'action': 'disabled'}])
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [activate, interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -1068,11 +1068,11 @@ def test_master_slave_requires_master():
|
|||
assert api.value.dict() == {'activate': False}
|
||||
|
||||
|
||||
def test_master_slave_requires_masterslaves():
|
||||
def test_leadership_requires_leadership():
|
||||
activate = BoolOption('activate', "Activer l'accès au réseau", True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0],
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0],
|
||||
requires=[{'option': activate, 'expected': False, 'action': 'disabled'}])
|
||||
maconfig = OptionDescription('toto', '', [activate, interface1])
|
||||
api = Config(maconfig)
|
||||
|
@ -1096,13 +1096,12 @@ def test_master_slave_requires_masterslaves():
|
|||
assert api.value.dict() == {'activate': False}
|
||||
|
||||
|
||||
def test_master_slave_requires_no_master():
|
||||
def test_leadership_requires_no_leader():
|
||||
activate = BoolOption('activate', "Activer l'accès au réseau", True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True,
|
||||
requires=[{'option': activate, 'expected': False, 'action': 'disabled'}])
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [activate, interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
|
|
@ -109,10 +109,10 @@ def _diff_opt(opt1, opt2):
|
|||
assert v[1][key][i] == val2[idx][1][key][i]
|
||||
else:
|
||||
assert v[1] == val2[idx][1]
|
||||
elif attr == '_master_slaves':
|
||||
assert val1._p_._sm_getmaster().impl_getname() == val2._p_._sm_getmaster().impl_getname()
|
||||
sval1 = [opt.impl_getname() for opt in val1._p_._sm_getslaves()]
|
||||
sval2 = [opt.impl_getname() for opt in val2._p_._sm_getslaves()]
|
||||
elif attr == '_leadership':
|
||||
assert val1._p_._sm_get_leader().impl_getname() == val2._p_._sm_get_leader().impl_getname()
|
||||
sval1 = [opt.impl_getname() for opt in val1._p_._sm_get_followers()]
|
||||
sval2 = [opt.impl_getname() for opt in val2._p_._sm_get_followers()]
|
||||
assert sval1 == sval2
|
||||
elif attr == '_subdyn':
|
||||
try:
|
||||
|
@ -124,13 +124,13 @@ def _diff_opt(opt1, opt2):
|
|||
lst1 = []
|
||||
lst2 = []
|
||||
for idx, val in enumerate(val1):
|
||||
if isinstance(val, MasterSlaves):
|
||||
lst1.append(val._p_.master.impl_getname())
|
||||
if isinstance(val, Leadership):
|
||||
lst1.append(val._p_.leader.impl_getname())
|
||||
else:
|
||||
lst1.append(val.impl_getname())
|
||||
for idx, val in enumerate(val2):
|
||||
if isinstance(val, MasterSlaves):
|
||||
lst2.append(val._p_.master.impl_getname())
|
||||
if isinstance(val, Leadership):
|
||||
lst2.append(val._p_.leader.impl_getname())
|
||||
else:
|
||||
lst2.append(val.impl_getname())
|
||||
assert set(lst1) == set(lst2), '{} - {}'.format(lst1, lst2)
|
||||
|
|
|
@ -6,7 +6,7 @@ from py.test import raises
|
|||
|
||||
from tiramisu.error import ConfigError
|
||||
from tiramisu import Config
|
||||
from tiramisu.option import BoolOption, OptionDescription, MasterSlaves
|
||||
from tiramisu.option import BoolOption, OptionDescription, Leadership
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu.storage import list_sessions, delete_session
|
||||
|
||||
|
@ -174,11 +174,10 @@ def test_create_persistent_retrieve_owner():
|
|||
del c
|
||||
|
||||
|
||||
def test_create_persistent_retrieve_owner_masterslaves():
|
||||
def test_create_persistent_retrieve_owner_leadership():
|
||||
a = BoolOption('a', '', multi=True)
|
||||
b = BoolOption('b', '', multi=True)
|
||||
o = MasterSlaves('a', '', [a, b])
|
||||
#o.impl_set_group_type(groups.master)
|
||||
o = Leadership('a', '', [a, b])
|
||||
o1 = OptionDescription('a', '', [o])
|
||||
try:
|
||||
c = Config(o1, session_id='test_persistent', persistent=True)
|
||||
|
|
|
@ -6,9 +6,9 @@ from py.test import raises
|
|||
|
||||
from tiramisu.api import TIRAMISU_VERSION
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu import StrOption, IntOption, OptionDescription, submulti, MasterSlaves, Config, \
|
||||
from tiramisu import StrOption, IntOption, OptionDescription, submulti, Leadership, Config, \
|
||||
MetaConfig, undefined, Params, ParamOption
|
||||
from tiramisu.error import SlaveError
|
||||
from tiramisu.error import LeadershipError
|
||||
from tiramisu.storage import list_sessions
|
||||
|
||||
|
||||
|
@ -199,33 +199,31 @@ def test_callback_submulti_list_list():
|
|||
assert api.option('multi').owner.get() == owners.default
|
||||
|
||||
|
||||
def test_groups_with_master_submulti():
|
||||
def test_groups_with_leader_submulti():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=submulti)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
assert interface1.impl_get_group_type() == groups.leadership
|
||||
|
||||
|
||||
def test_groups_with_master_in_config_submulti():
|
||||
def test_groups_with_leader_in_config_submulti():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=submulti)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od = OptionDescription('root', '', [interface1])
|
||||
Config(od)
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
assert interface1.impl_get_group_type() == groups.leadership
|
||||
|
||||
|
||||
def test_values_with_master_and_slaves_submulti():
|
||||
def test_values_with_leader_and_followers_submulti():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=submulti)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
owner = api.owner.get()
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
assert interface1.impl_get_group_type() == groups.leadership
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.default
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(["192.168.230.145"])
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ["192.168.230.145"]
|
||||
|
@ -242,16 +240,15 @@ def test_values_with_master_and_slaves_submulti():
|
|||
raises(ValueError, "api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set([['255.255.255.0']])")
|
||||
|
||||
|
||||
def test_reset_values_with_master_and_slaves_submulti():
|
||||
def test_reset_values_with_leader_and_followers_submulti():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=submulti)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
owner = api.owner.get()
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
assert interface1.impl_get_group_type() == groups.leadership
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.default
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.230.145'])
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').owner.get() == owner
|
||||
|
@ -269,15 +266,14 @@ def test_reset_values_with_master_and_slaves_submulti():
|
|||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
|
||||
|
||||
def test_values_with_master_and_slaves_slave_submulti():
|
||||
def test_values_with_leader_and_followers_follower_submulti():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=submulti)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
raises(SlaveError, "api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set(['255.255.255.0'])")
|
||||
raises(LeadershipError, "api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set(['255.255.255.0'])")
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.230.145'])
|
||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set(['255.255.255.0'])
|
||||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set(['255.255.255.0', '255.255.255.0'])
|
||||
|
@ -289,11 +285,10 @@ def test_values_with_master_and_slaves_slave_submulti():
|
|||
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set(['255.255.255.0'])
|
||||
|
||||
|
||||
def test_values_with_master_and_slaves_master_submulti():
|
||||
def test_values_with_leader_and_leadership_submulti():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=submulti)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -310,11 +305,10 @@ def test_values_with_master_and_slaves_master_submulti():
|
|||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
|
||||
|
||||
def test_values_with_master_owner_submulti():
|
||||
def test_values_with_leader_owner_submulti():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=submulti)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -327,10 +321,10 @@ def test_values_with_master_owner_submulti():
|
|||
assert api.option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.default
|
||||
|
||||
|
||||
def test_values_with_master_disabled_submulti():
|
||||
def test_values_with_leader_disabled_submulti():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=submulti)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
|
@ -352,16 +346,15 @@ def test_values_with_master_disabled_submulti():
|
|||
api.option('ip_admin_eth0.ip_admin_eth0').value.pop(0)
|
||||
|
||||
|
||||
def test__master_is_submulti():
|
||||
def test_leader_is_submulti():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=submulti)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
api = Config(maconfig)
|
||||
api.property.read_write()
|
||||
owner = api.owner.get()
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
assert interface1.impl_get_group_type() == groups.leadership
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set([["192.168.230.145"]])
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == [["192.168.230.145"]]
|
||||
|
|
|
@ -4,7 +4,7 @@ from .autopath import do_autopath
|
|||
do_autopath()
|
||||
|
||||
from tiramisu import BoolOption, StrOption, SymLinkOption, \
|
||||
OptionDescription, MasterSlaves, Config
|
||||
OptionDescription, Leadership, Config
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu.api import TIRAMISU_VERSION
|
||||
|
@ -210,55 +210,55 @@ def test_symlink_get_information():
|
|||
assert linkopt.impl_get_information('test') == 'test2'
|
||||
|
||||
|
||||
def test_symlink_master():
|
||||
def test_symlink_leader():
|
||||
a = StrOption('a', "", multi=True)
|
||||
ip_admin_eth0 = SymLinkOption('ip_admin_eth0', a)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "", multi=True)
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
raises(ValueError, "Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
|
||||
|
||||
def test_symlink_slaves():
|
||||
def test_symlink_followers():
|
||||
a = StrOption('a', "", multi=True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = SymLinkOption('netmask_admin_eth0', a)
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
raises(ValueError, "Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
|
||||
|
||||
def test_symlink_with_master():
|
||||
def test_symlink_with_leader():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
master = SymLinkOption('master', ip_admin_eth0)
|
||||
od = OptionDescription('root', '', [interface1, master])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
leader = SymLinkOption('leader', ip_admin_eth0)
|
||||
od = OptionDescription('root', '', [interface1, leader])
|
||||
api = Config(od)
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': [], 'master': []}
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': [], 'leader': []}
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['val1', 'val2'])
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['val1', 'val2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None], 'master': ['val1', 'val2']}
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['val1', 'val2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None], 'leader': ['val1', 'val2']}
|
||||
|
||||
|
||||
def test_symlink_with_slave():
|
||||
def test_symlink_with_follower():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
slave = SymLinkOption('slave', netmask_admin_eth0)
|
||||
od = OptionDescription('root', '', [interface1, slave])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
follower = SymLinkOption('follower', netmask_admin_eth0)
|
||||
od = OptionDescription('root', '', [interface1, follower])
|
||||
api = Config(od)
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': [], 'slave': []}
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': [], 'follower': []}
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['val1', 'val2'])
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['val1', 'val2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None], 'slave': [None, None]}
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['val1', 'val2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None], 'follower': [None, None]}
|
||||
#
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get() == None
|
||||
assert api.option('slave', 0).value.get() == None
|
||||
assert api.option('slave', 1).value.get() == None
|
||||
assert api.option('follower', 0).value.get() == None
|
||||
assert api.option('follower', 1).value.get() == None
|
||||
#
|
||||
api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.set('val3')
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['val1', 'val2'], 'ip_admin_eth0.netmask_admin_eth0': [None, 'val3'], 'slave': [None, 'val3']}
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['val1', 'val2'], 'ip_admin_eth0.netmask_admin_eth0': [None, 'val3'], 'follower': [None, 'val3']}
|
||||
#
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get() == 'val3'
|
||||
assert api.option('slave', 0).value.get() == None
|
||||
assert api.option('slave', 1).value.get() == 'val3'
|
||||
assert api.option('follower', 0).value.get() == None
|
||||
assert api.option('follower', 1).value.get() == 'val3'
|
||||
|
||||
|
||||
#____________________________________________________________
|
||||
|
|
|
@ -19,7 +19,7 @@ from time import time
|
|||
from typing import List, Set, Any, Optional, Callable, Union, Dict
|
||||
|
||||
|
||||
from .error import APIError, ConfigError, SlaveError, PropertiesOptionError
|
||||
from .error import APIError, ConfigError, LeadershipError, PropertiesOptionError
|
||||
from .i18n import _
|
||||
from .setting import ConfigBag, OptionBag, owners, groups, Undefined, undefined, \
|
||||
FORBIDDEN_SET_PROPERTIES, SPECIAL_PROPERTIES
|
||||
|
@ -96,11 +96,11 @@ class CommonTiramisu(TiramisuHelp):
|
|||
self._option_bag = option_bag
|
||||
index = self._option_bag.index
|
||||
if index is not None:
|
||||
if option.impl_is_optiondescription() or not option.impl_is_master_slaves('slave'):
|
||||
raise APIError('index must be set only with a slave option')
|
||||
self._length = self._subconfig.cfgimpl_get_length_slave(self._option_bag)
|
||||
if option.impl_is_optiondescription() or not option.impl_is_follower():
|
||||
raise APIError('index must be set only with a follower option')
|
||||
self._length = self._subconfig.cfgimpl_get_length_leadership(self._option_bag)
|
||||
if index >= self._length:
|
||||
raise SlaveError(_('index "{}" is higher than the master length "{}" '
|
||||
raise LeadershipError(_('index "{}" is higher than the leadership length "{}" '
|
||||
'for option "{}"').format(index,
|
||||
self._length,
|
||||
option.impl_get_display_name()))
|
||||
|
@ -111,7 +111,7 @@ class CommonTiramisu(TiramisuHelp):
|
|||
|
||||
class CommonTiramisuOption(CommonTiramisu):
|
||||
_allow_optiondescription = False
|
||||
_slave_need_index = True
|
||||
_follower_need_index = True
|
||||
_validate_properties = False
|
||||
|
||||
def __init__(self,
|
||||
|
@ -124,15 +124,15 @@ class CommonTiramisuOption(CommonTiramisu):
|
|||
# for help()
|
||||
if option_bag is not None and self._option_bag.config_bag.context.impl_type != 'group':
|
||||
self._get_option()
|
||||
if option_bag.config_bag is not None and self._slave_need_index:
|
||||
self._test_slave_index()
|
||||
if option_bag.config_bag is not None and self._follower_need_index:
|
||||
self._test_follower_index()
|
||||
|
||||
def _test_slave_index(self) -> None:
|
||||
def _test_follower_index(self) -> None:
|
||||
option = self._option_bag.option
|
||||
if not option.impl_is_optiondescription() and \
|
||||
self._option_bag.index is None and \
|
||||
option.impl_is_master_slaves('slave'):
|
||||
raise APIError(_('index must be set with the slave option "{}"').format(self._option_bag.path))
|
||||
option.impl_is_follower():
|
||||
raise APIError(_('index must be set with the follower option "{}"').format(self._option_bag.path))
|
||||
|
||||
def __getattr__(self, name):
|
||||
raise APIError(_('unknown method {}').format(name))
|
||||
|
@ -141,7 +141,7 @@ class CommonTiramisuOption(CommonTiramisu):
|
|||
class _TiramisuOptionOptionDescription(CommonTiramisuOption):
|
||||
"""Manage option"""
|
||||
_allow_optiondescription = True
|
||||
_slave_need_index = False
|
||||
_follower_need_index = False
|
||||
|
||||
def get(self):
|
||||
"""Get Tiramisu option"""
|
||||
|
@ -154,10 +154,10 @@ class _TiramisuOptionOptionDescription(CommonTiramisuOption):
|
|||
type_ = type_.lower()
|
||||
return type_
|
||||
|
||||
def ismasterslaves(self):
|
||||
"""Test if option is a master or a slave"""
|
||||
def isleadership(self):
|
||||
"""Test if option is a leader or a follower"""
|
||||
option = self._option_bag.option
|
||||
return option.impl_is_master_slaves()
|
||||
return option.impl_is_leadership()
|
||||
|
||||
def doc(self):
|
||||
"""Get option document"""
|
||||
|
@ -220,15 +220,15 @@ class _TiramisuOptionOption(_TiramisuOptionOptionDescription):
|
|||
option = self._option_bag.option
|
||||
return option.impl_is_submulti()
|
||||
|
||||
def ismaster(self):
|
||||
"""Test if option is a master"""
|
||||
def isleader(self):
|
||||
"""Test if option is a leader"""
|
||||
option = self._option_bag.option
|
||||
return option.impl_is_master_slaves('master')
|
||||
return option.impl_is_leader()
|
||||
|
||||
def isslave(self):
|
||||
"""Test if option is a slave"""
|
||||
def isfollower(self):
|
||||
"""Test if option is a follower"""
|
||||
option = self._option_bag.option
|
||||
return option.impl_is_master_slaves('slave')
|
||||
return option.impl_is_follower()
|
||||
|
||||
def issymlinkoption(self) -> bool:
|
||||
option = self._option_bag.option
|
||||
|
@ -258,7 +258,7 @@ class _TiramisuOptionOption(_TiramisuOptionOptionDescription):
|
|||
class TiramisuOptionOption(CommonTiramisuOption):
|
||||
"""Manage option"""
|
||||
_allow_optiondescription = True
|
||||
_slave_need_index = False
|
||||
_follower_need_index = False
|
||||
|
||||
def __new__(cls,
|
||||
name,
|
||||
|
@ -318,7 +318,7 @@ class TiramisuOptionOwner(CommonTiramisuOption):
|
|||
class TiramisuOptionProperty(CommonTiramisuOption):
|
||||
"""Manage option's property"""
|
||||
_allow_optiondescription = True
|
||||
_slave_need_index = False
|
||||
_follower_need_index = False
|
||||
|
||||
def __init__(self,
|
||||
name: str,
|
||||
|
@ -334,7 +334,7 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
|||
only_raises=False):
|
||||
"""Get properties for an option"""
|
||||
option = self._option_bag.option
|
||||
self._test_slave_index()
|
||||
self._test_follower_index()
|
||||
properties = self._option_bag.properties
|
||||
if not only_raises:
|
||||
return properties
|
||||
|
@ -376,7 +376,7 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
|||
class TiramisuOptionPermissive(CommonTiramisuOption):
|
||||
"""Manage option's permissive"""
|
||||
_allow_optiondescription = True
|
||||
_slave_need_index = False
|
||||
_follower_need_index = False
|
||||
|
||||
def __init__(self,
|
||||
name: str,
|
||||
|
@ -407,7 +407,7 @@ class TiramisuOptionPermissive(CommonTiramisuOption):
|
|||
class TiramisuOptionInformation(CommonTiramisuOption):
|
||||
"""Manage option's informations"""
|
||||
_allow_optiondescription = True
|
||||
_slave_need_index = False
|
||||
_follower_need_index = False
|
||||
|
||||
def get(self, key, default=undefined):
|
||||
"""Get information"""
|
||||
|
@ -443,14 +443,14 @@ class _TiramisuOptionValueOption:
|
|||
def get(self):
|
||||
"""Get option's value"""
|
||||
option = self._option_bag.option
|
||||
self._test_slave_index()
|
||||
self._test_follower_index()
|
||||
return self._subconfig.getattr(self._name,
|
||||
self._option_bag)
|
||||
|
||||
def set(self, value):
|
||||
"""Change option's value"""
|
||||
option = self._option_bag.option
|
||||
self._test_slave_index()
|
||||
self._test_follower_index()
|
||||
values = self._option_bag.config_bag.context.cfgimpl_get_values()
|
||||
if isinstance(value, list):
|
||||
while undefined in value:
|
||||
|
@ -464,16 +464,16 @@ class _TiramisuOptionValueOption:
|
|||
|
||||
def reset(self):
|
||||
"""Reset value for an option"""
|
||||
self._test_slave_index()
|
||||
self._test_follower_index()
|
||||
self._subconfig.delattr(self._option_bag)
|
||||
|
||||
def default(self):
|
||||
"""Get default value (default of option or calculated value)"""
|
||||
option = self._option_bag.option
|
||||
values = self._option_bag.config_bag.context.cfgimpl_get_values()
|
||||
if option.impl_is_master_slaves('slave') and self._option_bag.index is None:
|
||||
if option.impl_is_follower() and self._option_bag.index is None:
|
||||
value = []
|
||||
length = self._subconfig.cfgimpl_get_length_slave(self._option_bag)
|
||||
length = self._subconfig.cfgimpl_get_length_leadership(self._option_bag)
|
||||
for idx in range(length):
|
||||
soption_bag = OptionBag()
|
||||
soption_bag.set_option(option,
|
||||
|
@ -485,16 +485,17 @@ class _TiramisuOptionValueOption:
|
|||
return values.getdefaultvalue(self._option_bag)
|
||||
|
||||
|
||||
class _TiramisuOptionValueMaster:
|
||||
class _TiramisuOptionValueLeader:
|
||||
def pop(self, index):
|
||||
"""Pop a value"""
|
||||
assert not self._option_bag.option.impl_is_symlinkoption(), _("can't delete a SymLinkOption")
|
||||
self._option_bag.config_bag.context.cfgimpl_get_values().reset_master(index,
|
||||
self._option_bag,
|
||||
option_bag = self._option_bag
|
||||
assert not option_bag.option.impl_is_symlinkoption(), _("can't delete a SymLinkOption")
|
||||
option_bag.config_bag.context.cfgimpl_get_values().reset_leadership(index,
|
||||
option_bag,
|
||||
self._subconfig)
|
||||
|
||||
def len(self):
|
||||
"""Length of master option"""
|
||||
"""Length of leadership"""
|
||||
option = self._option_bag.option
|
||||
# for example if index is None
|
||||
if '_length' not in vars(self):
|
||||
|
@ -508,13 +509,13 @@ class _TiramisuOptionValueGroup:
|
|||
self._option_bag.config_bag.context.reset(self._option_bag.path)
|
||||
|
||||
|
||||
class _TiramisuOptionValueSlave:
|
||||
class _TiramisuOptionValueFollower:
|
||||
def len(self):
|
||||
"""Length of slave option"""
|
||||
"""Length of follower option"""
|
||||
option = self._option_bag.option
|
||||
# for example if index is None
|
||||
if '_length' not in vars(self):
|
||||
self._length = self._subconfig.cfgimpl_get_length_slave(self._option_bag)
|
||||
self._length = self._subconfig.cfgimpl_get_length_leadership(self._option_bag)
|
||||
return self._length
|
||||
|
||||
|
||||
|
@ -550,7 +551,7 @@ class _TiramisuOptionValueOptionDescription:
|
|||
class TiramisuOptionValue(CommonTiramisuOption):
|
||||
"""Manage option's value"""
|
||||
_allow_optiondescription = True
|
||||
_slave_need_index = False
|
||||
_follower_need_index = False
|
||||
|
||||
def __new__(cls,
|
||||
name,
|
||||
|
@ -570,14 +571,14 @@ class TiramisuOptionValue(CommonTiramisuOption):
|
|||
types.append(_TiramisuOptionValueOption)
|
||||
if isinstance(option, ChoiceOption):
|
||||
types.append(_TiramisuOptionValueChoiceOption)
|
||||
if option.impl_is_master_slaves('master'):
|
||||
types.append(_TiramisuOptionValueMaster)
|
||||
elif option.impl_is_master_slaves('slave'):
|
||||
types.append(_TiramisuOptionValueSlave)
|
||||
if option.impl_is_leader():
|
||||
types.append(_TiramisuOptionValueLeader)
|
||||
elif option.impl_is_follower():
|
||||
types.append(_TiramisuOptionValueFollower)
|
||||
if option_bag.config_bag.context.impl_type == 'group':
|
||||
types.append(_TiramisuOptionValueGroup)
|
||||
new_type_dict = {'_allow_optiondescription': cls._allow_optiondescription,
|
||||
'_slave_need_index': cls._slave_need_index}
|
||||
'_follower_need_index': cls._follower_need_index}
|
||||
new_type = type('TiramisuOptionValue', tuple(types), new_type_dict)(name=name,
|
||||
subconfig=subconfig,
|
||||
option_bag=option_bag)
|
||||
|
@ -651,7 +652,7 @@ class _TiramisuOptionDescription(_TiramisuOption):
|
|||
self._config_bag)
|
||||
t_option = TiramisuOption(name,
|
||||
path,
|
||||
None, # index for a slave ?
|
||||
None, # index for a follower ?
|
||||
subconfig,
|
||||
self._config_bag)
|
||||
if first:
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
from typing import Any, Optional, Union, Callable, Dict, List
|
||||
|
||||
|
||||
from .error import PropertiesOptionError, ConfigError, SlaveError
|
||||
from .error import PropertiesOptionError, ConfigError, LeadershipError
|
||||
from .i18n import _
|
||||
from .setting import undefined, ConfigBag, OptionBag, Undefined
|
||||
from .storage import get_default_values_storages, get_default_settings_storages
|
||||
|
@ -51,12 +51,12 @@ def manager_callback(callbk: Union[ParamOption, ParamValue],
|
|||
opt = opt.to_dynoption(option.rootpath,
|
||||
option.impl_getsuffix())
|
||||
path = opt.impl_getpath()
|
||||
if index is not None and opt.impl_is_master_slaves() and \
|
||||
opt.impl_get_master_slaves().in_same_group(option):
|
||||
if index is not None and opt.impl_get_leadership() and \
|
||||
opt.impl_get_leadership().in_same_group(option):
|
||||
if opt == option:
|
||||
index_ = None
|
||||
with_index = False
|
||||
elif opt.impl_is_master_slaves('slave'):
|
||||
elif opt.impl_is_follower():
|
||||
index_ = index
|
||||
with_index = False
|
||||
else:
|
||||
|
@ -66,7 +66,7 @@ def manager_callback(callbk: Union[ParamOption, ParamValue],
|
|||
index_ = None
|
||||
with_index = False
|
||||
if opt == option and orig_value is not undefined and \
|
||||
(not opt.impl_is_master_slaves('slave') or index is None):
|
||||
(not opt.impl_is_follower() or index is None):
|
||||
return orig_value
|
||||
# don't validate if option is option that we tried to validate
|
||||
config_bag = config_bag.copy()
|
||||
|
@ -152,17 +152,17 @@ def carry_out_calculation(option,
|
|||
opt1 == 11
|
||||
=> calculate(<function func at 0x1cea320>, [11], {})
|
||||
|
||||
- a multi option and not master/slave:
|
||||
- a multi option and not leadership
|
||||
opt1 == [1, 2, 3]
|
||||
=> calculate(<function func at 0x223c320>, [[1, 2, 3]], {})
|
||||
|
||||
- option is master or slave of opt1:
|
||||
- option is leader or follower of opt1:
|
||||
opt1 == [1, 2, 3]
|
||||
=> calculate(<function func at 0x223c320>, [1], {})
|
||||
=> calculate(<function func at 0x223c320>, [2], {})
|
||||
=> calculate(<function func at 0x223c320>, [3], {})
|
||||
|
||||
- opt is a master or slave but not related to option:
|
||||
- opt is a leader or follower but not related to option:
|
||||
opt1 == [1, 2, 3]
|
||||
=> calculate(<function func at 0x11b0320>, [[1, 2, 3]], {})
|
||||
|
||||
|
@ -252,17 +252,17 @@ def carry_out_calculation(option,
|
|||
args,
|
||||
kwargs)
|
||||
if isinstance(ret, list) and not option.impl_is_dynoptiondescription() and \
|
||||
option.impl_is_master_slaves('slave'):
|
||||
option.impl_is_follower():
|
||||
if args or kwargs:
|
||||
raise SlaveError(_('function "{}" with arguments "{}" and "{}" '
|
||||
'return the list "{}" for the slave option "{}"'
|
||||
raise LeadershipError(_('function "{}" with arguments "{}" and "{}" '
|
||||
'return the list "{}" for the follower option "{}"'
|
||||
'').format(callback.__name__,
|
||||
args,
|
||||
kwargs,
|
||||
ret,
|
||||
option.impl_get_display_name()))
|
||||
else:
|
||||
raise SlaveError(_('function "{}" return the list "{}" for the slave option "{}"'
|
||||
raise LeadershipError(_('function "{}" return the list "{}" for the follower option "{}"'
|
||||
'').format(callback.__name__,
|
||||
ret,
|
||||
option.impl_getname()))
|
||||
|
|
|
@ -23,10 +23,11 @@ import weakref
|
|||
from copy import copy
|
||||
|
||||
|
||||
from .error import PropertiesOptionError, ConfigError, ConflictError, SlaveError
|
||||
from .option import SynDynOptionDescription, DynOptionDescription, MasterSlaves
|
||||
from .error import PropertiesOptionError, ConfigError, ConflictError, \
|
||||
LeadershipError
|
||||
from .option import SynDynOptionDescription, DynOptionDescription, Leadership
|
||||
from .option.baseoption import BaseOption, valid_name
|
||||
from .setting import OptionBag, ConfigBag, groups, Settings, undefined
|
||||
from .setting import OptionBag, ConfigBag, Settings, undefined
|
||||
from .storage import get_storages, gen_storage_id, get_default_values_storages
|
||||
from .value import Values
|
||||
from .i18n import _
|
||||
|
@ -49,7 +50,7 @@ class SubConfig(object):
|
|||
config_bag,
|
||||
subpath=None,
|
||||
fromconsistency=None):
|
||||
""" Configuration option management master class
|
||||
""" Configuration option management class
|
||||
|
||||
:param descr: describes the configuration schema
|
||||
:type descr: an instance of ``option.OptionDescription``
|
||||
|
@ -58,10 +59,9 @@ class SubConfig(object):
|
|||
:type subpath: `str` with the path name
|
||||
"""
|
||||
# main option description
|
||||
error = False
|
||||
if descr is not None and (not isinstance(descr, (BaseOption, SynDynOptionDescription)) or not descr.impl_is_optiondescription()):
|
||||
error = True
|
||||
if error:
|
||||
if __debug__ and descr is not None and \
|
||||
(not isinstance(descr, (BaseOption, SynDynOptionDescription)) or
|
||||
not descr.impl_is_optiondescription()):
|
||||
try:
|
||||
msg = descr.impl_get_displayname()
|
||||
except AttributeError:
|
||||
|
@ -71,28 +71,27 @@ class SubConfig(object):
|
|||
self._impl_descr = descr
|
||||
self._impl_context = context
|
||||
self._impl_path = subpath
|
||||
if descr is not None and \
|
||||
descr.impl_get_group_type() == groups.master:
|
||||
master = descr.getmaster()
|
||||
masterpath = master.impl_getname()
|
||||
full_masterpath = self._get_subpath(masterpath)
|
||||
if descr is not None and descr.impl_is_leadership():
|
||||
leader = descr.get_leader()
|
||||
leaderpath = leader.impl_getname()
|
||||
full_leaderpath = self._get_subpath(leaderpath)
|
||||
cconfig_bag = config_bag.copy()
|
||||
cconfig_bag.remove_validation()
|
||||
moption_bag = OptionBag()
|
||||
moption_bag.set_option(master,
|
||||
full_masterpath,
|
||||
moption_bag.set_option(leader,
|
||||
full_leaderpath,
|
||||
None,
|
||||
cconfig_bag)
|
||||
if fromconsistency:
|
||||
moption_bag.fromconsistency = fromconsistency
|
||||
value = self.getattr(masterpath,
|
||||
value = self.getattr(leaderpath,
|
||||
moption_bag)
|
||||
self._impl_length = len(value)
|
||||
|
||||
def cfgimpl_get_length(self):
|
||||
return self._impl_length
|
||||
|
||||
def cfgimpl_get_length_slave(self,
|
||||
def cfgimpl_get_length_leadership(self,
|
||||
option_bag):
|
||||
if option_bag.option.impl_is_symlinkoption():
|
||||
context = self.cfgimpl_get_context()
|
||||
|
@ -238,8 +237,8 @@ class SubConfig(object):
|
|||
raise ConfigError(_("can't assign to a SymLinkOption"))
|
||||
context = option_bag.config_bag.context
|
||||
context.cfgimpl_get_settings().validate_properties(option_bag)
|
||||
if option_bag.option.impl_is_master_slaves('master') and len(value) < self._impl_length:
|
||||
raise SlaveError(_('cannot reduce length of the master "{}"'
|
||||
if option_bag.option.impl_is_leader() and len(value) < self._impl_length:
|
||||
raise LeadershipError(_('cannot reduce length of a leader "{}"'
|
||||
'').format(option_bag.option.impl_get_display_name()))
|
||||
return context.cfgimpl_get_values().setvalue(value,
|
||||
option_bag,
|
||||
|
@ -253,7 +252,7 @@ class SubConfig(object):
|
|||
raise TypeError(_("can't delete a SymLinkOption"))
|
||||
values = self.cfgimpl_get_values()
|
||||
if option_bag.index is not None:
|
||||
values.reset_slave(option_bag,
|
||||
values.reset_follower(option_bag,
|
||||
_commit)
|
||||
else:
|
||||
values.reset(option_bag,
|
||||
|
@ -313,16 +312,16 @@ class SubConfig(object):
|
|||
|
||||
self.cfgimpl_get_settings().validate_properties(option_bag)
|
||||
|
||||
if option.impl_is_master_slaves('slave'):
|
||||
length = self.cfgimpl_get_length_slave(option_bag)
|
||||
slave_len = self.cfgimpl_get_values()._p_.get_max_length(option_bag.path)
|
||||
if slave_len > length:
|
||||
raise SlaveError(_('slave option "{}" has higher length "{}" than the master '
|
||||
if option.impl_is_follower():
|
||||
length = self.cfgimpl_get_length_leadership(option_bag)
|
||||
follower_len = self.cfgimpl_get_values()._p_.get_max_length(option_bag.path)
|
||||
if follower_len > length:
|
||||
raise LeadershipError(_('follower option "{}" has higher length "{}" than the leader '
|
||||
'length "{}"').format(option.impl_get_display_name(),
|
||||
slave_len,
|
||||
follower_len,
|
||||
length,
|
||||
option_bag.index))
|
||||
if option.impl_is_master_slaves('slave') and option_bag.index is None:
|
||||
if option.impl_is_follower() and option_bag.index is None:
|
||||
value = []
|
||||
for idx in range(length):
|
||||
soption_bag = OptionBag()
|
||||
|
@ -717,7 +716,7 @@ class KernelConfig(_CommonConfig):
|
|||
force_settings=None,
|
||||
_duplicate=False,
|
||||
storage=None):
|
||||
""" Configuration option management master class
|
||||
""" Configuration option management class
|
||||
|
||||
:param descr: describes the configuration schema
|
||||
:type descr: an instance of ``option.OptionDescription``
|
||||
|
@ -730,8 +729,8 @@ class KernelConfig(_CommonConfig):
|
|||
:type persistent: `boolean`
|
||||
"""
|
||||
self._impl_meta = None
|
||||
if isinstance(descr, MasterSlaves):
|
||||
raise ConfigError(_('cannot set masterslaves object has root optiondescription'))
|
||||
if isinstance(descr, Leadership):
|
||||
raise ConfigError(_('cannot set leadership object has root optiondescription'))
|
||||
if isinstance(descr, DynOptionDescription):
|
||||
raise ConfigError(_('cannot set dynoptiondescription object has root optiondescription'))
|
||||
if force_settings is not None and force_values is not None:
|
||||
|
@ -872,7 +871,7 @@ class KernelGroupConfig(_CommonConfig):
|
|||
err._requires,
|
||||
err._name,
|
||||
err._orig_opt))
|
||||
except (ValueError, SlaveError, AttributeError) as err:
|
||||
except (ValueError, LeadershipError, AttributeError) as err:
|
||||
ret.append(err)
|
||||
if _commit and self.impl_type != 'group':
|
||||
self.cfgimpl_get_values()._p_.commit()
|
||||
|
@ -1089,7 +1088,7 @@ class KernelMixConfig(KernelGroupConfig):
|
|||
err._requires,
|
||||
err._name,
|
||||
err._orig_opt))
|
||||
except (ValueError, SlaveError, AttributeError) as err:
|
||||
except (ValueError, LeadershipError, AttributeError) as err:
|
||||
ret.append(err)
|
||||
|
||||
try:
|
||||
|
@ -1100,7 +1099,7 @@ class KernelMixConfig(KernelGroupConfig):
|
|||
subconfig.setattr(value,
|
||||
option_bag,
|
||||
_commit=False)
|
||||
except (PropertiesOptionError, ValueError, SlaveError) as err:
|
||||
except (PropertiesOptionError, ValueError, LeadershipError) as err:
|
||||
ret.append(err)
|
||||
return ret
|
||||
|
||||
|
|
|
@ -144,8 +144,8 @@ class RequirementError(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class SlaveError(Exception):
|
||||
"problem with a slave's value length"
|
||||
class LeadershipError(Exception):
|
||||
"problem with a leadership's value length"
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from .optiondescription import OptionDescription
|
||||
from .dynoptiondescription import DynOptionDescription
|
||||
from .syndynoptiondescription import SynDynOptionDescription, SynDynMasterSlaves
|
||||
from .masterslaves import MasterSlaves
|
||||
from .syndynoptiondescription import SynDynOptionDescription, SynDynLeadership
|
||||
from .leadership import Leadership
|
||||
from .baseoption import submulti
|
||||
from .symlinkoption import SymLinkOption
|
||||
from .syndynoption import SynDynOption
|
||||
|
@ -25,8 +25,8 @@ from .filenameoption import FilenameOption
|
|||
from .passwordoption import PasswordOption
|
||||
|
||||
|
||||
__all__ = ('MasterSlaves', 'OptionDescription', 'DynOptionDescription',
|
||||
'SynDynOptionDescription', 'SynDynMasterSlaves', 'Option', 'SymLinkOption',
|
||||
__all__ = ('Leadership', 'OptionDescription', 'DynOptionDescription',
|
||||
'SynDynOptionDescription', 'SynDynLeadership', 'Option', 'SymLinkOption',
|
||||
'SynDynOption', 'ChoiceOption', 'BoolOption', 'DateOption',
|
||||
'IntOption', 'FloatOption', 'StrOption', 'UnicodeOption',
|
||||
'IPOption', 'PortOption', 'NetworkOption', 'NetmaskOption',
|
||||
|
|
|
@ -90,7 +90,7 @@ class Base:
|
|||
properties = frozenset(properties)
|
||||
if is_multi and 'empty' not in properties:
|
||||
# if option is a multi, it cannot be "empty" (None not allowed in the list)
|
||||
# "empty" is removed for slave's option
|
||||
# "empty" is removed for follower's option
|
||||
properties = properties | {'empty'}
|
||||
if not isinstance(properties, frozenset):
|
||||
raise TypeError(_('invalid properties type {0} for {1},'
|
||||
|
|
|
@ -52,7 +52,7 @@ class DynOptionDescription(OptionDescription):
|
|||
# check children + set relation to this dynoptiondescription
|
||||
for child in children:
|
||||
if isinstance(child, OptionDescription):
|
||||
if __debug__ and child.impl_get_group_type() != groups.master:
|
||||
if __debug__ and child.impl_get_group_type() != groups.leadership:
|
||||
raise ConfigError(_('cannot set optiondescription in a '
|
||||
'dynoptiondescription'))
|
||||
for chld in child.get_children(config_bag=undefined):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"master slaves support"
|
||||
"Leadership support"
|
||||
# Copyright (C) 2014-2019 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
|
@ -28,16 +28,16 @@ from ..i18n import _
|
|||
from ..setting import groups, undefined, OptionBag, Settings
|
||||
from ..value import Values
|
||||
from .optiondescription import OptionDescription
|
||||
from .syndynoptiondescription import SynDynMasterSlaves
|
||||
from .syndynoptiondescription import SynDynLeadership
|
||||
from .baseoption import BaseOption
|
||||
from .option import Option
|
||||
from ..error import SlaveError, PropertiesOptionError, RequirementError
|
||||
from ..error import RequirementError
|
||||
from ..function import ParamOption
|
||||
|
||||
|
||||
class MasterSlaves(OptionDescription):
|
||||
__slots__ = ('master',
|
||||
'slaves')
|
||||
class Leadership(OptionDescription):
|
||||
__slots__ = ('leader',
|
||||
'followers')
|
||||
|
||||
def __init__(self,
|
||||
name: str,
|
||||
|
@ -46,86 +46,86 @@ class MasterSlaves(OptionDescription):
|
|||
requires=None,
|
||||
properties=None) -> None:
|
||||
|
||||
super(MasterSlaves, self).__init__(name,
|
||||
super().__init__(name,
|
||||
doc,
|
||||
children,
|
||||
requires=requires,
|
||||
properties=properties)
|
||||
self._group_type = groups.master
|
||||
slaves = []
|
||||
self._group_type = groups.leadership
|
||||
followers = []
|
||||
if len(children) < 2:
|
||||
raise ValueError(_('a master and a slave are mandatories in masterslaves "{}"'
|
||||
raise ValueError(_('a leader and a follower are mandatories in leadership "{}"'
|
||||
'').format(name))
|
||||
master = children[0]
|
||||
leader = children[0]
|
||||
for idx, child in enumerate(children):
|
||||
if __debug__:
|
||||
if child.impl_is_symlinkoption():
|
||||
raise ValueError(_('masterslaves "{0}" shall not have '
|
||||
raise ValueError(_('leadership "{0}" shall not have '
|
||||
"a symlinkoption").format(self.impl_get_display_name()))
|
||||
if not isinstance(child, Option):
|
||||
raise ValueError(_('masterslaves "{0}" shall not have '
|
||||
raise ValueError(_('leadership "{0}" shall not have '
|
||||
'a subgroup').format(self.impl_get_display_name()))
|
||||
if not child.impl_is_multi():
|
||||
raise ValueError(_('only multi option allowed in masterslaves "{0}" but option '
|
||||
raise ValueError(_('only multi option allowed in leadership "{0}" but option '
|
||||
'"{1}" is not a multi'
|
||||
'').format(self.impl_get_display_name(),
|
||||
child.impl_get_display_name()))
|
||||
if idx != 0 and child.impl_getdefault() != []:
|
||||
raise ValueError(_('not allowed default value for slave option "{0}" '
|
||||
'in masterslaves "{1}"'
|
||||
raise ValueError(_('not allowed default value for follower option "{0}" '
|
||||
'in leadership "{1}"'
|
||||
'').format(child.impl_get_display_name(),
|
||||
self.impl_get_display_name()))
|
||||
if idx != 0:
|
||||
# remove empty property for slave
|
||||
# remove empty property for follower
|
||||
child_properties = list(child._properties)
|
||||
child_properties.remove('empty')
|
||||
child._properties = frozenset(child_properties)
|
||||
slaves.append(child)
|
||||
followers.append(child)
|
||||
child._add_dependency(self)
|
||||
child._master_slaves = weakref.ref(self)
|
||||
callback, callback_params = master.impl_get_callback()
|
||||
child._leadership = weakref.ref(self)
|
||||
callback, callback_params = leader.impl_get_callback()
|
||||
if callback is not None and callback_params is not None:
|
||||
for callbk in chain(callback_params.args, callback_params.kwargs.values()):
|
||||
if isinstance(callbk, ParamOption) and callbk.option in slaves:
|
||||
raise ValueError(_("callback of master's option shall "
|
||||
"not refered to a slave's ones"))
|
||||
# master should not have requires, only MasterSlaves should have
|
||||
# so move requires to MasterSlaves
|
||||
# if MasterSlaves has requires too, cannot manage this move so raises
|
||||
master_requires = getattr(master, '_requires', None)
|
||||
if master_requires:
|
||||
if isinstance(callbk, ParamOption) and callbk.option in followers:
|
||||
raise ValueError(_("callback of leader's option shall "
|
||||
"not refered to a follower's ones"))
|
||||
# leader should not have requires, only Leadership should have
|
||||
# so move requires to Leadership
|
||||
# if Leadership has requires too, cannot manage this move so raises
|
||||
leader_requires = getattr(leader, '_requires', None)
|
||||
if leader_requires:
|
||||
if __debug__ and self.impl_getrequires():
|
||||
raise RequirementError(_('master {} have requirement, but MasterSlaves {} too'
|
||||
'').format(master.impl_getname(),
|
||||
raise RequirementError(_('leader {} have requirement, but Leadership {} too'
|
||||
'').format(leader.impl_getname(),
|
||||
self.impl_getname()))
|
||||
master_calproperties = getattr(master, '_calc_properties', None)
|
||||
if master_calproperties:
|
||||
leader_calproperties = getattr(leader, '_calc_properties', None)
|
||||
if leader_calproperties:
|
||||
if __debug__ and properties is not None:
|
||||
self.validate_properties(name, master_calproperties, frozenset(properties))
|
||||
setattr(self, '_calc_properties', master_calproperties)
|
||||
setattr(self, '_requires', master_requires)
|
||||
delattr(master, '_requires')
|
||||
self.validate_properties(name, leader_calproperties, frozenset(properties))
|
||||
setattr(self, '_calc_properties', leader_calproperties)
|
||||
setattr(self, '_requires', leader_requires)
|
||||
delattr(leader, '_requires')
|
||||
if __debug__:
|
||||
for requires_ in getattr(self, '_requires', ()):
|
||||
for require in requires_:
|
||||
for require_opt, values in require[0]:
|
||||
if require_opt.impl_is_multi() and require_opt.impl_is_master_slaves():
|
||||
if require_opt.impl_is_multi() and require_opt.impl_get_leadership():
|
||||
raise ValueError(_('malformed requirements option "{0}" '
|
||||
'must not be in slave for "{1}"').format(
|
||||
'must not be in follower for "{1}"').format(
|
||||
require_opt.impl_getname(),
|
||||
self.impl_getname()))
|
||||
|
||||
def is_master(self,
|
||||
def is_leader(self,
|
||||
opt: Option) -> bool:
|
||||
master = self.getmaster()
|
||||
return opt == master or (opt.impl_is_dynsymlinkoption() and opt.opt == master)
|
||||
leader = self.get_leader()
|
||||
return opt == leader or (opt.impl_is_dynsymlinkoption() and opt.opt == leader)
|
||||
|
||||
def getmaster(self) -> Option:
|
||||
def get_leader(self) -> Option:
|
||||
return self._children[1][0]
|
||||
|
||||
def getslaves(self) -> Iterator[Option]:
|
||||
for slave in self._children[1][1:]:
|
||||
yield slave
|
||||
def get_followers(self) -> Iterator[Option]:
|
||||
for follower in self._children[1][1:]:
|
||||
yield follower
|
||||
|
||||
def in_same_group(self,
|
||||
opt: Option) -> bool:
|
||||
|
@ -139,11 +139,11 @@ class MasterSlaves(OptionDescription):
|
|||
_commit: bool=True) -> None:
|
||||
config_bag = option_bag.config_bag.copy()
|
||||
config_bag.remove_validation()
|
||||
for slave in self.getslaves():
|
||||
slave_path = slave.impl_getpath()
|
||||
for follower in self.get_followers():
|
||||
follower_path = follower.impl_getpath()
|
||||
soption_bag = OptionBag()
|
||||
soption_bag.set_option(slave,
|
||||
slave_path,
|
||||
soption_bag.set_option(follower,
|
||||
follower_path,
|
||||
None,
|
||||
config_bag)
|
||||
values.reset(soption_bag,
|
||||
|
@ -153,31 +153,31 @@ class MasterSlaves(OptionDescription):
|
|||
values: Values,
|
||||
index: int,
|
||||
option_bag: OptionBag,
|
||||
slaves: Optional[List[Option]]=undefined) -> None:
|
||||
if slaves is undefined:
|
||||
# slaves is not undefined only in SynDynMasterSlaves
|
||||
slaves = self.getslaves()
|
||||
followers: Optional[List[Option]]=undefined) -> None:
|
||||
if followers is undefined:
|
||||
# followers are not undefined only in SynDynLeadership
|
||||
followers = self.get_followers()
|
||||
config_bag = option_bag.config_bag.copy()
|
||||
config_bag.remove_validation()
|
||||
for slave in slaves:
|
||||
slave_path = slave.impl_getpath()
|
||||
slavelen = values._p_.get_max_length(slave_path)
|
||||
for follower in followers:
|
||||
follower_path = follower.impl_getpath()
|
||||
followerlen = values._p_.get_max_length(follower_path)
|
||||
soption_bag = OptionBag()
|
||||
soption_bag.set_option(slave,
|
||||
slave_path,
|
||||
soption_bag.set_option(follower,
|
||||
follower_path,
|
||||
index,
|
||||
config_bag)
|
||||
# do not check force_default_on_freeze
|
||||
soption_bag.properties = set()
|
||||
if not values.is_default_owner(soption_bag,
|
||||
validate_meta=False) and slavelen > index:
|
||||
values._p_.resetvalue_index(slave_path,
|
||||
validate_meta=False) and followerlen > index:
|
||||
values._p_.resetvalue_index(follower_path,
|
||||
index,
|
||||
True)
|
||||
if slavelen > index + 1:
|
||||
for idx in range(index + 1, slavelen):
|
||||
if values._p_.hasvalue(slave_path, idx):
|
||||
values._p_.reduce_index(slave_path,
|
||||
if followerlen > index + 1:
|
||||
for idx in range(index + 1, followerlen):
|
||||
if values._p_.hasvalue(follower_path, idx):
|
||||
values._p_.reduce_index(follower_path,
|
||||
idx)
|
||||
|
||||
def reset_cache(self,
|
||||
|
@ -186,16 +186,16 @@ class MasterSlaves(OptionDescription):
|
|||
settings: Settings,
|
||||
resetted_opts: List[Option]) -> None:
|
||||
self._reset_cache(path,
|
||||
self.getmaster(),
|
||||
self.getslaves(),
|
||||
self.get_leader(),
|
||||
self.get_followers(),
|
||||
values,
|
||||
settings,
|
||||
resetted_opts)
|
||||
|
||||
def _reset_cache(self,
|
||||
path: str,
|
||||
master: Option,
|
||||
slaves: List[Option],
|
||||
leader: Option,
|
||||
followers: List[Option],
|
||||
values: Values,
|
||||
settings: Settings,
|
||||
resetted_opts: List[Option]) -> None:
|
||||
|
@ -203,24 +203,24 @@ class MasterSlaves(OptionDescription):
|
|||
values,
|
||||
settings,
|
||||
resetted_opts)
|
||||
master.reset_cache(master.impl_getpath(),
|
||||
leader.reset_cache(leader.impl_getpath(),
|
||||
values,
|
||||
settings,
|
||||
None)
|
||||
for slave in slaves:
|
||||
spath = slave.impl_getpath()
|
||||
slave.reset_cache(spath,
|
||||
for follower in followers:
|
||||
spath = follower.impl_getpath()
|
||||
follower.reset_cache(spath,
|
||||
values,
|
||||
settings,
|
||||
None)
|
||||
resetted_opts.append(spath)
|
||||
|
||||
def impl_is_master_slaves(self) -> None:
|
||||
def impl_is_leadership(self) -> None:
|
||||
return True
|
||||
|
||||
def to_dynoption(self,
|
||||
rootpath: str,
|
||||
suffix: str) -> SynDynMasterSlaves:
|
||||
return SynDynMasterSlaves(self,
|
||||
suffix: str) -> SynDynLeadership:
|
||||
return SynDynLeadership(self,
|
||||
rootpath,
|
||||
suffix)
|
|
@ -52,7 +52,7 @@ class Option(BaseOption):
|
|||
#calcul
|
||||
'_val_call',
|
||||
#
|
||||
'_master_slaves',
|
||||
'_leadership',
|
||||
'_choice_values',
|
||||
'_choice_values_params',
|
||||
)
|
||||
|
@ -381,24 +381,27 @@ class Option(BaseOption):
|
|||
pass
|
||||
|
||||
#__________________________________________________________________________
|
||||
# master/slaves
|
||||
# leadership
|
||||
# def impl_is_leadership(self):
|
||||
# return self.impl_get_leadership() is not None
|
||||
|
||||
def impl_is_master_slaves(self,
|
||||
type_: str='both') -> bool:
|
||||
master_slaves = self.impl_get_master_slaves()
|
||||
if master_slaves is not None:
|
||||
if type_ == 'both':
|
||||
return True
|
||||
is_master = master_slaves.is_master(self)
|
||||
if (type_ == 'master' and is_master) or (type_ == 'slave' and not is_master):
|
||||
return True
|
||||
return False
|
||||
def impl_is_leader(self):
|
||||
leadership = self.impl_get_leadership()
|
||||
if leadership is None:
|
||||
return leadership
|
||||
return self.impl_get_leadership().is_leader(self)
|
||||
|
||||
def impl_get_master_slaves(self):
|
||||
masterslave = getattr(self, '_master_slaves', None)
|
||||
if masterslave is None:
|
||||
return masterslave
|
||||
return masterslave()
|
||||
def impl_is_follower(self):
|
||||
leadership = self.impl_get_leadership()
|
||||
if leadership is None:
|
||||
return leadership
|
||||
return not leadership.is_leader(self)
|
||||
|
||||
def impl_get_leadership(self):
|
||||
leadership = getattr(self, '_leadership', None)
|
||||
if leadership is None:
|
||||
return leadership
|
||||
return leadership()
|
||||
|
||||
#____________________________________________________________
|
||||
# consistencies
|
||||
|
@ -662,7 +665,7 @@ class Option(BaseOption):
|
|||
if func in ALLOWED_CONST_LIST:
|
||||
index = None
|
||||
index_ = None
|
||||
elif current_option.impl_is_master_slaves('master'):
|
||||
elif current_option.impl_is_leader():
|
||||
index = option_bag.index
|
||||
index_ = None
|
||||
else:
|
||||
|
@ -681,8 +684,8 @@ class Option(BaseOption):
|
|||
current_value = option_bag.config_bag.context.getattr(path,
|
||||
coption_bag)
|
||||
if index_ is None and index is not None:
|
||||
#if self is a slave and current_option is a master and func not in ALLOWED_CONST_LIST
|
||||
#return only the value of the master for isolate slave
|
||||
#if self is a follower and current_option is a leader and func not in ALLOWED_CONST_LIST
|
||||
#return only the value of the leader for isolate follower
|
||||
current_value = current_value[index]
|
||||
return current_value
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ from ..i18n import _
|
|||
from ..setting import ConfigBag, OptionBag, groups, undefined, owners, Undefined
|
||||
from .baseoption import BaseOption
|
||||
from .option import ALLOWED_CONST_LIST
|
||||
from .syndynoptiondescription import SynDynOptionDescription, SynDynMasterSlaves
|
||||
from .syndynoptiondescription import SynDynOptionDescription, SynDynLeadership
|
||||
from ..error import ConfigError, ConflictError
|
||||
|
||||
|
||||
|
@ -80,9 +80,9 @@ class CacheOptionDescription(BaseOption):
|
|||
properties = option.impl_getproperties()
|
||||
if 'force_store_value' in properties:
|
||||
if __debug__:
|
||||
if option.impl_is_master_slaves('slave'):
|
||||
if option.impl_is_follower():
|
||||
# problem with index
|
||||
raise ConfigError(_('the slave "{0}" cannot have '
|
||||
raise ConfigError(_('the follower "{0}" cannot have '
|
||||
'"force_store_value" property').format(
|
||||
option.impl_get_display_name()))
|
||||
if option.issubdyn():
|
||||
|
@ -92,28 +92,28 @@ class CacheOptionDescription(BaseOption):
|
|||
force_store_values.append((subpath, option))
|
||||
if __debug__ and 'force_default_on_freeze' in properties and \
|
||||
'frozen' not in properties and \
|
||||
option.impl_is_master_slaves('master'):
|
||||
raise ConfigError(_('a master ({0}) cannot have '
|
||||
option.impl_is_leader():
|
||||
raise ConfigError(_('a leader ({0}) cannot have '
|
||||
'"force_default_on_freeze" property without "frozen"'
|
||||
'').format(subpath))
|
||||
for cons_id, func, all_cons_opts, params in option.get_consistencies():
|
||||
option._valid_consistencies(all_cons_opts[1:], init=False)
|
||||
if func not in ALLOWED_CONST_LIST and is_multi:
|
||||
if __debug__ and not option.impl_is_master_slaves():
|
||||
if __debug__ and not option.impl_get_leadership():
|
||||
raise ConfigError(_('malformed consistency option "{0}" '
|
||||
'must be a masterslaves').format(
|
||||
'must be a leadership').format(
|
||||
option.impl_getname()))
|
||||
masterslaves = option.impl_get_master_slaves()
|
||||
leadership = option.impl_get_leadership()
|
||||
for weak_opt in all_cons_opts:
|
||||
opt = weak_opt()
|
||||
if __debug__ and func not in ALLOWED_CONST_LIST and is_multi:
|
||||
if not opt.impl_is_master_slaves():
|
||||
if not opt.impl_get_leadership():
|
||||
raise ConfigError(_('malformed consistency option "{0}" '
|
||||
'must not be a multi for "{1}"').format(
|
||||
option.impl_getname(), opt.impl_getname()))
|
||||
elif masterslaves != opt.impl_get_master_slaves():
|
||||
elif leadership != opt.impl_get_leadership():
|
||||
raise ConfigError(_('malformed consistency option "{0}" '
|
||||
'must be in same masterslaves as "{1}"').format(
|
||||
'must be in same leadership as "{1}"').format(
|
||||
option.impl_getname(), opt.impl_getname()))
|
||||
_consistencies.setdefault(weak_opt,
|
||||
[]).append((_consistencies_id,
|
||||
|
@ -126,25 +126,25 @@ class CacheOptionDescription(BaseOption):
|
|||
self._add_dependency(option)
|
||||
|
||||
if __debug__:
|
||||
is_slave = None
|
||||
is_follower = None
|
||||
if is_multi:
|
||||
all_requires = option.impl_getrequires()
|
||||
for requires in all_requires:
|
||||
for require in requires:
|
||||
#if option in require is a multi:
|
||||
# * option in require must be a master or a slave
|
||||
# * current option must be a slave (and only a slave)
|
||||
# * option in require and current option must be in same masterslaves
|
||||
# * option in require must be a leader or a follower
|
||||
# * current option must be a follower (and only a follower)
|
||||
# * option in require and current option must be in same leadership
|
||||
for require_opt, values in require[0]:
|
||||
if require_opt.impl_is_multi():
|
||||
if is_slave is None:
|
||||
is_slave = option.impl_is_master_slaves('slave')
|
||||
if is_slave:
|
||||
masterslaves = option.impl_get_master_slaves()
|
||||
if is_slave and require_opt.impl_is_master_slaves():
|
||||
if masterslaves != require_opt.impl_get_master_slaves():
|
||||
if is_follower is None:
|
||||
is_follower = option.impl_is_follower()
|
||||
if is_follower:
|
||||
leadership = option.impl_get_leadership()
|
||||
if is_follower and require_opt.impl_get_leadership():
|
||||
if leadership != require_opt.impl_get_leadership():
|
||||
raise ValueError(_('malformed requirements option "{0}" '
|
||||
'must be in same masterslaves for "{1}"').format(
|
||||
'must be in same leadership for "{1}"').format(
|
||||
require_opt.impl_getname(), option.impl_getname()))
|
||||
else:
|
||||
raise ValueError(_('malformed requirements option "{0}" '
|
||||
|
@ -311,7 +311,7 @@ class OptionDescription(OptionDescriptionWalk):
|
|||
def impl_is_dynoptiondescription(self) -> bool:
|
||||
return False
|
||||
|
||||
def impl_is_master_slaves(self) -> bool:
|
||||
def impl_is_leadership(self) -> bool:
|
||||
return False
|
||||
|
||||
# ____________________________________________________________
|
||||
|
@ -319,7 +319,7 @@ class OptionDescription(OptionDescriptionWalk):
|
|||
group_type: groups.GroupType) -> None:
|
||||
"""sets a given group object to an OptionDescription
|
||||
|
||||
:param group_type: an instance of `GroupType` or `MasterGroupType`
|
||||
:param group_type: an instance of `GroupType` or `LeadershipGroupType`
|
||||
that lives in `setting.groups`
|
||||
"""
|
||||
if self._group_type != groups.default:
|
||||
|
@ -329,8 +329,8 @@ class OptionDescription(OptionDescriptionWalk):
|
|||
if not isinstance(group_type, groups.GroupType):
|
||||
raise ValueError(_('group_type: {0}'
|
||||
' not allowed').format(group_type))
|
||||
if isinstance(group_type, groups.MasterGroupType):
|
||||
raise ConfigError('please use MasterSlaves object instead of OptionDescription')
|
||||
if isinstance(group_type, groups.LeadershipGroupType):
|
||||
raise ConfigError('please use Leadership object instead of OptionDescription')
|
||||
self._group_type = group_type
|
||||
|
||||
def impl_get_group_type(self) -> groups.GroupType:
|
||||
|
|
|
@ -104,16 +104,15 @@ class SynDynOptionDescription:
|
|||
return self._opt.impl_get_display_name() + self._suffix
|
||||
|
||||
|
||||
class SynDynMasterSlaves(SynDynOptionDescription):
|
||||
|
||||
def getmaster(self) -> SynDynOption:
|
||||
return self._opt.getmaster().to_dynoption(self.impl_getpath(),
|
||||
class SynDynLeadership(SynDynOptionDescription):
|
||||
def get_leader(self) -> SynDynOption:
|
||||
return self._opt.get_leader().to_dynoption(self.impl_getpath(),
|
||||
self._suffix)
|
||||
|
||||
def getslaves(self) -> Iterator[SynDynOption]:
|
||||
def get_followers(self) -> Iterator[SynDynOption]:
|
||||
subpath = self.impl_getpath()
|
||||
for slave in self._opt.getslaves():
|
||||
yield slave.to_dynoption(subpath,
|
||||
for follower in self._opt.get_followers():
|
||||
yield follower.to_dynoption(subpath,
|
||||
self._suffix)
|
||||
|
||||
def reset_cache(self,
|
||||
|
@ -121,11 +120,11 @@ class SynDynMasterSlaves(SynDynOptionDescription):
|
|||
values: Values,
|
||||
settings: Settings,
|
||||
resetted_opts: List[str]) -> None:
|
||||
master = self.getmaster()
|
||||
slaves = self.getslaves()
|
||||
leader = self.get_leader()
|
||||
followers = self.get_followers()
|
||||
self._reset_cache(path,
|
||||
master,
|
||||
slaves,
|
||||
leader,
|
||||
followers,
|
||||
values,
|
||||
settings,
|
||||
resetted_opts)
|
||||
|
@ -134,5 +133,5 @@ class SynDynMasterSlaves(SynDynOptionDescription):
|
|||
*args,
|
||||
**kwargs) -> None:
|
||||
self._opt.pop(*args,
|
||||
slaves=self.getslaves(),
|
||||
followers=self.get_followers(),
|
||||
**kwargs)
|
||||
|
|
|
@ -75,7 +75,7 @@ everything_frozen
|
|||
property)
|
||||
|
||||
empty
|
||||
raise mandatory PropertiesOptionError if multi or master have empty value
|
||||
raise mandatory PropertiesOptionError if multi or leader have empty value
|
||||
|
||||
validator
|
||||
launch validator set by user in option (this property has no effect
|
||||
|
@ -258,7 +258,7 @@ class GroupModule(_NameSpace):
|
|||
"emulates a module to manage unique group (OptionDescription) names"
|
||||
class GroupType(str):
|
||||
"""allowed normal group (OptionDescription) names
|
||||
*normal* means : groups that are not master
|
||||
*normal* means : groups that are not leader
|
||||
"""
|
||||
pass
|
||||
|
||||
|
@ -266,9 +266,9 @@ class GroupModule(_NameSpace):
|
|||
"""groups that are default (typically 'default')"""
|
||||
pass
|
||||
|
||||
class MasterGroupType(GroupType):
|
||||
class LeadershipGroupType(GroupType):
|
||||
"""allowed normal group (OptionDescription) names
|
||||
*master* means : groups that have the 'master' attribute set
|
||||
*leadership* means : groups that have the 'leadership' attribute set
|
||||
"""
|
||||
pass
|
||||
|
||||
|
@ -301,12 +301,12 @@ groups = GroupModule()
|
|||
default group set when creating a new optiondescription"""
|
||||
groups.default = groups.DefaultGroupType('default')
|
||||
|
||||
"""groups.master
|
||||
master group is a special optiondescription, all suboptions should be
|
||||
multi option and all values should have same length, to find master's
|
||||
option, the optiondescription's name should be same than de master's
|
||||
"""groups.leadership
|
||||
leadership group is a special optiondescription, all suboptions should be
|
||||
multi option and all values should have same length, to find leader's
|
||||
option, the optiondescription's name should be same than de leader's
|
||||
option"""
|
||||
groups.master = groups.MasterGroupType('master')
|
||||
groups.leadership = groups.LeadershipGroupType('leadership')
|
||||
|
||||
""" groups.family
|
||||
example of group, no special behavior with this group's type"""
|
||||
|
@ -520,7 +520,7 @@ class Settings(object):
|
|||
"'{1}'").format(option_bag.path, reqpath))
|
||||
idx = None
|
||||
is_indexed = False
|
||||
if option.impl_is_master_slaves('slave'):
|
||||
if option.impl_is_follower():
|
||||
idx = option_bag.index
|
||||
elif option.impl_is_multi() and option_bag.index is not None:
|
||||
is_indexed = True
|
||||
|
@ -638,13 +638,13 @@ class Settings(object):
|
|||
"").format(opt.impl_get_display_name()))
|
||||
if 'force_default_on_freeze' in properties and \
|
||||
'frozen' not in properties and \
|
||||
opt.impl_is_master_slaves('master'):
|
||||
raise ConfigError(_('a master ({0}) cannot have '
|
||||
opt.impl_is_leader():
|
||||
raise ConfigError(_('a leader ({0}) cannot have '
|
||||
'"force_default_on_freeze" property without "frozen"'
|
||||
'').format(opt.impl_get_display_name()))
|
||||
self._p_.setproperties(path,
|
||||
properties)
|
||||
#values too because of slave values could have a PropertiesOptionError has value
|
||||
# values too because of follower values could have a PropertiesOptionError has value
|
||||
context.cfgimpl_reset_cache(option_bag)
|
||||
if option_bag is not None:
|
||||
del option_bag.properties
|
||||
|
|
|
@ -36,7 +36,7 @@ class Cache(DictCache):
|
|||
|
||||
def setcache(self, path, index, val, self_props, props):
|
||||
"""add val in cache for a specified path
|
||||
if slave, add index
|
||||
if follower, add index
|
||||
"""
|
||||
if 'cache' in props or 'cache' in self_props:
|
||||
if DEBUG:
|
||||
|
|
|
@ -98,15 +98,15 @@ class Values(object):
|
|||
"""actually retrieves the value
|
||||
|
||||
:param path: the path of the `Option`
|
||||
:param index: index for a slave `Option`
|
||||
:param index: index for a follower `Option`
|
||||
|
||||
:returns: value
|
||||
"""
|
||||
# get owner and value from store
|
||||
# index allowed only for slave
|
||||
# index allowed only for follower
|
||||
index = option_bag.index
|
||||
is_slave = option_bag.option.impl_is_master_slaves('slave')
|
||||
if index is None or not is_slave:
|
||||
is_follower = option_bag.option.impl_is_follower()
|
||||
if index is None or not is_follower:
|
||||
_index = None
|
||||
else:
|
||||
_index = index
|
||||
|
@ -231,7 +231,7 @@ class Values(object):
|
|||
else:
|
||||
allow_empty_list = opt.impl_allow_empty_list()
|
||||
if allow_empty_list is undefined:
|
||||
allow_empty_list = opt.impl_is_master_slaves('slave')
|
||||
allow_empty_list = opt.impl_is_follower()
|
||||
isempty = value is None or (not allow_empty_list and value == []) or \
|
||||
None in value or empty in value
|
||||
else:
|
||||
|
@ -315,11 +315,11 @@ class Values(object):
|
|||
meta = context.cfgimpl_get_meta()
|
||||
if meta is None:
|
||||
return None
|
||||
if option_bag.option.impl_is_master_slaves('slave'):
|
||||
master = option_bag.option.impl_get_master_slaves().getmaster()
|
||||
masterp = master.impl_getpath()
|
||||
# slave could be a "meta" only if master hasn't value
|
||||
if self._p_.hasvalue(masterp,
|
||||
if option_bag.option.impl_is_follower():
|
||||
leader = option_bag.option.impl_get_leadership().get_leader()
|
||||
leaderpath = leader.impl_getpath()
|
||||
# follower could be a "meta" only if leader hasn't value
|
||||
if self._p_.hasvalue(leaderpath,
|
||||
index=None):
|
||||
return None
|
||||
doption_bag = option_bag.copy()
|
||||
|
@ -432,8 +432,8 @@ class Values(object):
|
|||
fake_value.setvalue_validation(value,
|
||||
soption_bag)
|
||||
opt = option_bag.option
|
||||
if opt.impl_is_master_slaves('master'):
|
||||
opt.impl_get_master_slaves().reset(self,
|
||||
if opt.impl_is_leader():
|
||||
opt.impl_get_leadership().reset(self,
|
||||
option_bag,
|
||||
_commit=_commit)
|
||||
if hasvalue:
|
||||
|
@ -449,7 +449,7 @@ class Values(object):
|
|||
_commit)
|
||||
context.cfgimpl_reset_cache(option_bag)
|
||||
|
||||
def reset_slave(self,
|
||||
def reset_follower(self,
|
||||
option_bag,
|
||||
_commit=True):
|
||||
|
||||
|
@ -463,7 +463,7 @@ class Values(object):
|
|||
config_bag.context = fake_context
|
||||
soption_bag = option_bag.copy()
|
||||
soption_bag.config_bag = config_bag
|
||||
fake_value.reset_slave(soption_bag)
|
||||
fake_value.reset_follower(soption_bag)
|
||||
value = fake_value.getdefaultvalue(soption_bag)
|
||||
fake_value.setvalue_validation(value,
|
||||
soption_bag)
|
||||
|
@ -472,7 +472,7 @@ class Values(object):
|
|||
_commit)
|
||||
context.cfgimpl_reset_cache(option_bag)
|
||||
|
||||
def reset_master(self,
|
||||
def reset_leadership(self,
|
||||
index,
|
||||
option_bag,
|
||||
subconfig):
|
||||
|
@ -552,7 +552,7 @@ class Values(object):
|
|||
elif not option.impl_is_symlinkoption():
|
||||
# don't verifying symlink
|
||||
try:
|
||||
if not option.impl_is_master_slaves('slave'):
|
||||
if not option.impl_is_follower():
|
||||
option_bag = OptionBag()
|
||||
option_bag.set_option(option,
|
||||
path,
|
||||
|
|
Loading…
Reference in a new issue