Add MasterSlaves object
This commit is contained in:
parent
7e281235bc
commit
5a1987f2e6
|
@ -5,7 +5,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
|
||||
from tiramisu.option import BoolOption, IPOption, IntOption, StrOption, OptionDescription, MasterSlaves
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.error import ConfigError, PropertiesOptionError
|
||||
from tiramisu.setting import groups
|
||||
|
@ -349,8 +349,8 @@ def test_force_cache():
|
|||
def test_cache_master_slave():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -511,8 +511,8 @@ def test_cache_callback():
|
|||
def test_cache_master_and_slaves_master():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.cfgimpl_get_settings().remove('expire')
|
||||
|
@ -552,8 +552,8 @@ def test_cache_master_and_slaves_master():
|
|||
def test_cache_master_callback():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'value': ((val1, False),)})
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.cfgimpl_get_settings().remove('expire')
|
||||
|
@ -580,8 +580,8 @@ def test_cache_master_slave_different():
|
|||
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 = OptionDescription("int", "", [b, c, d])
|
||||
descr.impl_set_group_type(groups.master)
|
||||
descr = MasterSlaves("int", "", [b, c, d])
|
||||
#descr.impl_set_group_type(groups.master)
|
||||
cfg = Config(descr)
|
||||
cfg.cfgimpl_get_settings().remove('expire')
|
||||
cfg.read_write()
|
||||
|
|
|
@ -7,7 +7,7 @@ from tiramisu.option import BoolOption, StrOption, ChoiceOption, IPOption, \
|
|||
NetworkOption, NetmaskOption, IntOption, FloatOption, \
|
||||
UnicodeOption, PortOption, BroadcastOption, DomainnameOption, \
|
||||
EmailOption, URLOption, UsernameOption, FilenameOption, SymLinkOption, \
|
||||
OptionDescription, DynOptionDescription, DynSymLinkOption, submulti
|
||||
OptionDescription, DynOptionDescription, DynSymLinkOption, submulti, MasterSlaves
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError, ConflictError
|
||||
from tiramisu.storage import delete_session
|
||||
|
@ -925,8 +925,8 @@ def test_consistency_ip_in_network_dyndescription():
|
|||
def test_masterslaves_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True)
|
||||
stm = OptionDescription('st1', '', [st1, st2])
|
||||
stm.impl_set_group_type(groups.master)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -1013,8 +1013,8 @@ def test_masterslaves_dyndescription():
|
|||
def test_masterslaves_default_multi_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, default_multi='no')
|
||||
stm = OptionDescription('st1', '', [st1, st2])
|
||||
stm.impl_set_group_type(groups.master)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -1046,8 +1046,8 @@ def test_masterslaves_default_multi_dyndescription():
|
|||
def test_masterslaves_submulti_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=submulti)
|
||||
stm = OptionDescription('st1', '', [st1, st2])
|
||||
stm.impl_set_group_type(groups.master)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -1086,54 +1086,54 @@ def test_masterslaves_submulti_dyndescription():
|
|||
assert cfg.getowner(st2val2) == owners.default
|
||||
|
||||
|
||||
def test_masterslaves_consistency_ip_dyndescription():
|
||||
a = NetworkOption('net', '', multi=True)
|
||||
b = NetmaskOption('mask', '', multi=True)
|
||||
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)
|
||||
cfg.netval1.netval1 = ['192.168.1.0']
|
||||
cfg.netval1.maskval1 = ['255.255.255.0']
|
||||
cfg.netval1.broadval1 = ['192.168.1.255']
|
||||
|
||||
cfg.netval1.netval1 = ['192.168.1.0', '192.168.2.128']
|
||||
cfg.netval1.maskval1 = ['255.255.255.0', '255.255.255.128']
|
||||
cfg.netval1.broadval1 = ['192.168.1.255', '192.168.2.255']
|
||||
cfg.netval1.broadval1[1] = '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():
|
||||
# a = NetworkOption('net', '', multi=True)
|
||||
# b = NetmaskOption('mask', '', multi=True)
|
||||
# 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)
|
||||
# cfg.netval1.netval1 = ['192.168.1.0']
|
||||
# cfg.netval1.maskval1 = ['255.255.255.0']
|
||||
# cfg.netval1.broadval1 = ['192.168.1.255']
|
||||
#
|
||||
# cfg.netval1.netval1 = ['192.168.1.0', '192.168.2.128']
|
||||
# cfg.netval1.maskval1 = ['255.255.255.0', '255.255.255.128']
|
||||
# cfg.netval1.broadval1 = ['192.168.1.255', '192.168.2.255']
|
||||
# cfg.netval1.broadval1[1] = '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)
|
||||
cfg.read_write()
|
||||
cfg.netval1.netval1 = ['192.168.1.0']
|
||||
cfg.read_only()
|
||||
raises(PropertiesOptionError, "cfg.netval1.netval1")
|
||||
#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)
|
||||
# cfg.read_write()
|
||||
# cfg.netval1.netval1 = ['192.168.1.0']
|
||||
# cfg.read_only()
|
||||
# raises(PropertiesOptionError, "cfg.netval1.netval1")
|
||||
|
||||
|
||||
def test_masterslaves_callback_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params={'value': ((st1, False),)})
|
||||
stm = OptionDescription('st1', '', [st1, st2])
|
||||
stm.impl_set_group_type(groups.master)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -1214,8 +1214,8 @@ def test_masterslaves_callback_dyndescription():
|
|||
def test_masterslaves_callback_value_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params={'value': ('val',)})
|
||||
stm = OptionDescription('st1', '', [st1, st2])
|
||||
stm.impl_set_group_type(groups.master)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -1232,8 +1232,8 @@ def test_masterslaves_callback_nomulti_dyndescription():
|
|||
v1 = StrOption('v1', '', "val")
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params={'': ((v1, False),)})
|
||||
stm = OptionDescription('st1', '', [st1, st2])
|
||||
stm.impl_set_group_type(groups.master)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od, v1])
|
||||
|
@ -1249,8 +1249,8 @@ def test_masterslaves_callback_samegroup_dyndescription():
|
|||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True)
|
||||
st3 = StrOption('st3', "", multi=True, callback=return_dynval, callback_params={'': ((st2, False),)})
|
||||
stm = OptionDescription('st1', '', [st1, st2, st3])
|
||||
stm.impl_set_group_type(groups.master)
|
||||
stm = MasterSlaves('st1', '', [st1, st2, st3])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
|
|
@ -7,7 +7,7 @@ from py.test import raises
|
|||
|
||||
from tiramisu.setting import owners, groups
|
||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription, SymLinkOption
|
||||
StrOption, OptionDescription, SymLinkOption, MasterSlaves
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError
|
||||
|
||||
|
@ -195,16 +195,16 @@ def test_force_store_value_no_requirement():
|
|||
def test_force_store_value_masterslaves_slave():
|
||||
b = IntOption('int', 'Test int option', multi=True)
|
||||
c = StrOption('str', 'Test string option', multi=True, properties=('force_store_value',))
|
||||
descr = OptionDescription("int", "", [b, c])
|
||||
descr.impl_set_group_type(groups.master)
|
||||
descr = MasterSlaves("int", "", [b, c])
|
||||
#descr.impl_set_group_type(groups.master)
|
||||
raises(ConfigError, "conf = Config(descr)")
|
||||
|
||||
|
||||
def test_force_store_value_masterslaves():
|
||||
b = IntOption('int', 'Test int option', multi=True, properties=('force_store_value',))
|
||||
c = StrOption('str', 'Test string option', multi=True)
|
||||
descr = OptionDescription("int", "", [b, c])
|
||||
descr.impl_set_group_type(groups.master)
|
||||
descr = MasterSlaves("int", "", [b, c])
|
||||
#descr.impl_set_group_type(groups.master)
|
||||
conf = Config(descr)
|
||||
assert conf.cfgimpl_get_values().get_modified_values() == {'int': ('forced', ())}
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ do_autopath()
|
|||
|
||||
from py.test import raises
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import IntOption, StrOption, UnicodeOption, OptionDescription, SymLinkOption
|
||||
from tiramisu.option import IntOption, StrOption, UnicodeOption, OptionDescription, \
|
||||
SymLinkOption, MasterSlaves
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError
|
||||
from tiramisu.setting import groups
|
||||
from tiramisu.storage import delete_session
|
||||
|
@ -481,8 +482,8 @@ def test_mandatory_master():
|
|||
properties=('mandatory', ))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau",
|
||||
multi=True)
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
o = OptionDescription('o', '', [interface1])
|
||||
config = Config(o, session_id='man104')
|
||||
config.read_only()
|
||||
|
@ -500,8 +501,8 @@ def test_mandatory_warnings_master():
|
|||
properties=('mandatory', ))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau",
|
||||
multi=True)
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
o = OptionDescription('o', '', [interface1])
|
||||
config = Config(o, session_id='man105')
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['ip_admin_eth0.ip_admin_eth0']
|
||||
|
@ -516,8 +517,8 @@ def test_mandatory_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
o = OptionDescription('o', '', [interface1])
|
||||
config = Config(o, session_id='man106')
|
||||
config.read_write()
|
||||
|
@ -569,8 +570,8 @@ def test_mandatory_warnings_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
o = OptionDescription('o', '', [interface1])
|
||||
config = Config(o, session_id='man107')
|
||||
config.read_write()
|
||||
|
@ -600,8 +601,8 @@ def test_mandatory_slave():
|
|||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
o = OptionDescription('o', '', [interface1])
|
||||
config = Config(o, session_id='man108')
|
||||
config.read_only()
|
||||
|
@ -638,8 +639,8 @@ def test_mandatory_warnings_slave():
|
|||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
o = OptionDescription('o', '', [interface1])
|
||||
config = Config(o, session_id='man109')
|
||||
config.read_only()
|
||||
|
@ -647,7 +648,7 @@ def test_mandatory_warnings_slave():
|
|||
assert config.ip_admin_eth0.netmask_admin_eth0 == []
|
||||
#
|
||||
config.read_write()
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == []
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['ip_admin_eth0.netmask_admin_eth0']
|
||||
config.ip_admin_eth0.ip_admin_eth0.append('ip')
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['ip_admin_eth0.netmask_admin_eth0']
|
||||
try:
|
||||
|
|
|
@ -5,7 +5,8 @@ from py.test import raises
|
|||
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu.config import Config, GroupConfig, MetaConfig
|
||||
from tiramisu.option import IntOption, StrOption, NetworkOption, NetmaskOption, OptionDescription
|
||||
from tiramisu.option import IntOption, StrOption, NetworkOption, NetmaskOption, \
|
||||
OptionDescription, MasterSlaves
|
||||
from tiramisu.error import ConfigError, ConflictError, PropertiesOptionError
|
||||
|
||||
owners.addowner('meta')
|
||||
|
@ -297,8 +298,8 @@ def test_meta_unconsistent():
|
|||
def test_meta_master_slaves():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
|
@ -313,15 +314,15 @@ def test_meta_master_slaves():
|
|||
assert [conf1, conf2] == meta.find_firsts(byname='netmask_admin_eth0').cfgimpl_get_children()
|
||||
|
||||
|
||||
def test_meta_master_slaves_value():
|
||||
def test_meta_master_slaves_value2():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.1']
|
||||
meta = MetaConfig([conf1, conf2], session_id="meta")
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.8']
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
del(meta.conf1.ip_admin_eth0)
|
||||
assert meta.conf1.netmask_admin_eth0 == []
|
||||
|
@ -338,8 +339,8 @@ def test_meta_master_slaves_value():
|
|||
def test_meta_master_slaves_value_default():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True)
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
|
@ -352,13 +353,15 @@ def test_meta_master_slaves_value_default():
|
|||
assert meta.conf1.netmask_admin_eth0 == ['255.255.0.0']
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
del(conf1)
|
||||
del(conf2)
|
||||
|
||||
|
||||
def test_meta_master_slaves_owners():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
|
@ -388,8 +391,8 @@ 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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
|
@ -424,8 +427,8 @@ 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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
|
@ -453,8 +456,8 @@ 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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
|
@ -497,8 +500,8 @@ 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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
|
@ -541,8 +544,8 @@ 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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
|
@ -557,8 +560,8 @@ 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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
|
@ -572,8 +575,8 @@ 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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
|
@ -613,8 +616,8 @@ def test_meta_callback_slave():
|
|||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params={'': ((val, False),)})
|
||||
val3 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)})
|
||||
val4 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)})
|
||||
interface1 = OptionDescription('val1', '', [val1, val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||
cfg = Config(maconfig, session_id='cfg')
|
||||
meta = MetaConfig([cfg])
|
||||
|
@ -692,8 +695,8 @@ def test_meta_properties_meta_set_value():
|
|||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf22 = Config(interface1, session_id='conf22')
|
||||
conf22.read_write()
|
||||
conf23 = Config(interface1, session_id='conf23')
|
||||
|
|
|
@ -6,7 +6,7 @@ from py.test import raises
|
|||
from tiramisu.config import Config
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription, SymLinkOption, IPOption, NetmaskOption
|
||||
StrOption, OptionDescription, SymLinkOption, IPOption, NetmaskOption, MasterSlaves
|
||||
from tiramisu.error import PropertiesOptionError, ConflictError, SlaveError, ConfigError
|
||||
|
||||
|
||||
|
@ -461,8 +461,8 @@ def test_callback_multi_callback():
|
|||
def test_callback_master_and_slaves_master():
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_val)
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -475,8 +475,8 @@ def test_callback_master_and_slaves_master():
|
|||
def test_callback_slave():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'': (['string', 'new'],)})
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -495,8 +495,8 @@ def test_callback_master_and_slaves_master2():
|
|||
val2 = StrOption('val2', "", multi=True, default_multi='val2')
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val2, False),)})
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params={'': ((val3, False),)})
|
||||
interface1 = OptionDescription('val1', '', [val1, val2, val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -511,8 +511,8 @@ def test_callback_master_and_slaves_master_mandatory():
|
|||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params={'': ((val, False),)}, properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value2, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value2, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
interface1 = OptionDescription('val1', '', [val1, val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_only()
|
||||
|
@ -534,8 +534,8 @@ def test_callback_master_and_slaves_master_mandatory2():
|
|||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params={'': ((val, False),), 'val': ((val_, False),)}, properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value2, callback_params={'': ((val1, False),), 'val': ((val_, False),)}, properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value2, callback_params={'': ((val1, False),), 'val': ((val_, False),)}, properties=('mandatory',))
|
||||
interface1 = OptionDescription('val1', '', [val1, val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [val, val_, interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_only()
|
||||
|
@ -559,8 +559,8 @@ def test_callback_master_and_slaves_master_mandatory3():
|
|||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params={'': ((val, False),), 'val': ((val_, False),)}, properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
interface1 = OptionDescription('val1', '', [val1, val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [val, val_, interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_only()
|
||||
|
@ -580,8 +580,8 @@ def test_callback_master_and_slaves_master_mandatory4():
|
|||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params={'': ((val, False),)}, properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
interface1 = OptionDescription('val1', '', [val1, val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_only()
|
||||
|
@ -601,8 +601,8 @@ def test_callback_master_and_slaves_master3():
|
|||
val2 = StrOption('val2', "", multi=True, default_multi='val2', properties=('expert',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val2, False),)})
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params={'': ((val3, False),)})
|
||||
interface1 = OptionDescription('val1', '', [val1, val2, val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -614,8 +614,8 @@ def test_callback_master_and_slaves_master4():
|
|||
val2 = StrOption('val2', "", multi=True, default_multi='val2', properties=('expert', 'mandatory'))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val2, False),)})
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params={'': ((val3, False),)})
|
||||
interface1 = OptionDescription('val1', '', [val1, val2, val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -633,10 +633,10 @@ 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 = OptionDescription('val1', '', [val1, val2])
|
||||
interface2 = OptionDescription('val3', '', [val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface2.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
interface2 = MasterSlaves('val3', '', [val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
#interface2.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, interface2])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -654,21 +654,22 @@ 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 = OptionDescription('val1', '', [val1, val2])
|
||||
interface2 = OptionDescription('val3', '', [val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface2.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
interface2 = MasterSlaves('val3', '', [val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
#interface2.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, interface2])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
assert list(cfg.cfgimpl_get_values().mandatory_warnings()) == ["val1.val1", "val1.val2"]
|
||||
assert list(cfg.cfgimpl_get_values().mandatory_warnings()) == ["val1.val1"]
|
||||
#assert list(cfg.cfgimpl_get_values().mandatory_warnings()) == ["val1.val1", "val1.val2"]
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_master_list():
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_list)
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -688,8 +689,8 @@ def test_callback_master_and_slaves_master_list():
|
|||
def test_callback_master_and_slaves_slave():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_val)
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -722,8 +723,8 @@ def test_callback_master_and_slaves_slave():
|
|||
def test_callback_master_and_slaves():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_val)
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -733,8 +734,8 @@ def test_callback_master_and_slaves_slave_cal():
|
|||
val3 = StrOption('val3', "", multi=True)
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params={'': ((val3, False),)})
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_val)
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val3])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -764,8 +765,8 @@ def test_callback_master_and_slaves_master_disabled():
|
|||
#properties must be transitive
|
||||
val1 = StrOption('val1', "", multi=True, properties=('disabled',))
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -778,8 +779,8 @@ def test_callback_master_and_slaves_master_callback_disabled():
|
|||
val0 = StrOption('val0', "", multi=True, properties=('disabled',))
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params={'': ((val0, False),)})
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val0])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -795,8 +796,8 @@ def test_callback_master_and_slaves_master_callback_disabled():
|
|||
def test_callback_master_and_slaves_slave_disabled():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, properties=('disabled',))
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -822,8 +823,8 @@ def test_callback_master_and_slaves_slave_callback_disabled():
|
|||
val0 = StrOption('val0', "", multi=True, properties=('disabled',))
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'': ((val0, False),)})
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val0])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -847,8 +848,8 @@ def test_callback_master_and_slaves_value():
|
|||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ('yes',)})
|
||||
val5 = StrOption('val5', "", multi=True, callback=return_value, callback_params={'': ((val4, False),)})
|
||||
val6 = StrOption('val6', "", multi=True, callback=return_value, callback_params={'': ((val5, False),)})
|
||||
interface1 = OptionDescription('val1', '', [val1, val2, val3, val5, val6])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2, val3, val5, val6])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val4])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -914,12 +915,7 @@ def test_callback_master_and_slaves_value():
|
|||
def test_callback_master():
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value)
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params={'': ((val2, False),)})
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1
|
||||
raises(ValueError, "interface1.impl_set_group_type(groups.master)")
|
||||
|
||||
|
||||
#FIXME: slave est un symlink
|
||||
raises(ValueError, "MasterSlaves('val1', '', [val1, val2])")
|
||||
|
||||
|
||||
def test_callback_different_type():
|
||||
|
@ -927,8 +923,8 @@ 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={'': ((val, False), (val1, False)), 'k': ((val_, False),)})
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val, val_])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -1063,8 +1059,8 @@ def test_callback_multi_list_params_key():
|
|||
def test_masterslaves_callback_description():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_value, callback_params={'': ((st1, False),)})
|
||||
stm = OptionDescription('st1', '', [st1, st2])
|
||||
stm.impl_set_group_type(groups.master)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = OptionDescription('st', '', [stm])
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
|
|
@ -6,7 +6,7 @@ from py.test import raises
|
|||
from tiramisu.setting import owners, groups
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import IPOption, NetworkOption, NetmaskOption, IntOption,\
|
||||
BroadcastOption, StrOption, SymLinkOption, OptionDescription, submulti
|
||||
BroadcastOption, StrOption, SymLinkOption, OptionDescription, submulti, MasterSlaves
|
||||
from tiramisu.error import ConfigError, ValueWarning, PropertiesOptionError
|
||||
import warnings
|
||||
|
||||
|
@ -229,8 +229,8 @@ def test_consistency_not_equal_default_submulti():
|
|||
def test_consistency_not_equal_masterslave():
|
||||
a = IntOption('a', '', multi=True)
|
||||
b = IntOption('b', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
c = Config(od)
|
||||
assert c.a == []
|
||||
|
@ -253,8 +253,8 @@ def test_consistency_not_equal_masterslave_error_multi1():
|
|||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = NetmaskOption('c', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
od2 = OptionDescription('b', '', [od, c])
|
||||
c.impl_add_consistency('ip_netmask', a)
|
||||
raises(ConfigError, "Config(od2)")
|
||||
|
@ -264,8 +264,8 @@ def test_consistency_not_equal_masterslave_error_multi2():
|
|||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = IPOption('c', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
od2 = OptionDescription('b', '', [od, c])
|
||||
b.impl_add_consistency('ip_netmask', c)
|
||||
raises(ConfigError, "Config(od2)")
|
||||
|
@ -276,10 +276,10 @@ def test_consistency_not_equal_masterslave_error_othermaster():
|
|||
b = NetmaskOption('b', '', multi=True)
|
||||
c = IPOption('c', '', multi=True)
|
||||
d = NetmaskOption('d', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od2 = OptionDescription('c', '', [c, d])
|
||||
od2.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
od2 = MasterSlaves('c', '', [c, d])
|
||||
#od2.impl_set_group_type(groups.master)
|
||||
od3 = OptionDescription('b', '', [od, od2])
|
||||
d.impl_add_consistency('ip_netmask', a)
|
||||
raises(ConfigError, "Config(od2)")
|
||||
|
@ -288,8 +288,8 @@ def test_consistency_not_equal_masterslave_error_othermaster():
|
|||
def test_consistency_not_equal_masterslaves_default():
|
||||
a = IntOption('a', '', multi=True)
|
||||
b = IntOption('b', '', multi=True, default_multi=1)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
a.impl_add_consistency('not_equal', b)
|
||||
c = Config(od)
|
||||
assert c.a == []
|
||||
|
@ -449,9 +449,9 @@ def test_consistency_ip_netmask_error_multi():
|
|||
def test_consistency_ip_netmask_multi():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
b.impl_add_consistency('ip_netmask', a)
|
||||
od.impl_set_group_type(groups.master)
|
||||
#od.impl_set_group_type(groups.master)
|
||||
c = Config(od)
|
||||
c.a = ['192.168.1.1']
|
||||
c.b = ['255.255.255.0']
|
||||
|
@ -464,8 +464,8 @@ def test_consistency_ip_netmask_multi():
|
|||
def test_consistency_network_netmask_multi():
|
||||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c = Config(od)
|
||||
c.a = ['192.168.1.1']
|
||||
|
@ -479,8 +479,8 @@ def test_consistency_network_netmask_multi():
|
|||
def test_consistency_network_netmask_multi_slave_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 = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
|
@ -490,8 +490,8 @@ def test_consistency_network_netmask_multi_slave_default_multi():
|
|||
def test_consistency_network_netmask_multi_slave_default():
|
||||
a = NetworkOption('a', '', multi=True, properties=('mandatory',))
|
||||
b = NetmaskOption('b', '', default_multi=u'255.255.255.0', multi=True, properties=('mandatory',))
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
|
@ -527,8 +527,8 @@ def return_netmask2(master):
|
|||
def test_consistency_network_netmask_multi_slave_callback():
|
||||
a = NetworkOption('a', '', multi=True, properties=('mandatory',))
|
||||
b = NetmaskOption('b', '', callback=return_netmask, multi=True, properties=('mandatory',))
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
|
@ -551,8 +551,8 @@ def test_consistency_network_netmask_multi_slave_callback():
|
|||
def test_consistency_network_netmask_multi_slave_callback_value():
|
||||
a = NetworkOption('a', '', multi=True, properties=('mandatory',))
|
||||
b = NetmaskOption('b', '', callback=return_netmask2, callback_params={'': ((a, False),)}, multi=True, properties=('mandatory',))
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
|
@ -576,8 +576,8 @@ def test_consistency_network_netmask_multi_slave_callback_value():
|
|||
def test_consistency_ip_netmask_multi_master():
|
||||
a = IPOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('ip_netmask', a)
|
||||
c = Config(od)
|
||||
c.a = ['192.168.1.1']
|
||||
|
@ -594,8 +594,8 @@ def test_consistency_ip_netmask_multi_master():
|
|||
def test_consistency_network_netmask_multi_master():
|
||||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c = Config(od)
|
||||
c.a = ['192.168.1.1']
|
||||
|
@ -610,8 +610,8 @@ def test_consistency_broadcast():
|
|||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = BroadcastOption('c', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b, c])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b, c])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c.impl_add_consistency('broadcast', a, b)
|
||||
c = Config(od)
|
||||
|
@ -635,8 +635,8 @@ def test_consistency_broadcast_error():
|
|||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = BroadcastOption('c', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b, c])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b, c])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c.impl_add_consistency('broadcast', a)
|
||||
c = Config(od)
|
||||
|
@ -684,8 +684,8 @@ def test_consistency_not_all():
|
|||
a = NetworkOption('a', '', multi=True)
|
||||
b = NetmaskOption('b', '', multi=True)
|
||||
c = BroadcastOption('c', '', multi=True)
|
||||
od = OptionDescription('a', '', [a, b, c])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b, c])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c = Config(od)
|
||||
c.a = ['192.168.1.0']
|
||||
|
@ -800,8 +800,8 @@ 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 = OptionDescription('a', '', [a, b])
|
||||
od.impl_set_group_type(groups.master)
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
c = Config(od)
|
||||
c.read_only()
|
||||
|
|
|
@ -6,7 +6,7 @@ from py.test import raises
|
|||
from tiramisu.setting import owners, groups
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription, SymLinkOption
|
||||
StrOption, OptionDescription, SymLinkOption, MasterSlaves
|
||||
from tiramisu.error import ConfigError, ConstError, PropertiesOptionError
|
||||
|
||||
|
||||
|
@ -159,8 +159,8 @@ def test_setowner_symlinkoption():
|
|||
def test_owner_masterslaves():
|
||||
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
||||
c = StrOption('str', 'Test string option', multi=True)
|
||||
descr = OptionDescription("int", "", [b, c])
|
||||
descr.impl_set_group_type(groups.master)
|
||||
descr = MasterSlaves("int", "", [b, c])
|
||||
#descr.impl_set_group_type(groups.master)
|
||||
cfg = Config(descr)
|
||||
raises(ConfigError, 'cfg.cfgimpl_get_values().setowner(c, owners.user)')
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from tiramisu.error import display_list, ConfigError
|
|||
from tiramisu.setting import owners, groups
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription
|
||||
StrOption, OptionDescription, MasterSlaves
|
||||
from tiramisu.error import PropertiesOptionError
|
||||
|
||||
|
||||
|
@ -259,16 +259,16 @@ def test_multi_with_requires_that_is_multi_inverse():
|
|||
def test_multi_with_requires_that_is_masterslave():
|
||||
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 = OptionDescription("int", "", [b, c])
|
||||
descr.impl_set_group_type(groups.master)
|
||||
descr = MasterSlaves("int", "", [b, c])
|
||||
#descr.impl_set_group_type(groups.master)
|
||||
Config(descr)
|
||||
|
||||
|
||||
def test_multi_with_requires_that_is_masterslave_master():
|
||||
b = IntOption('int', 'Test int option', multi=True)
|
||||
c = StrOption('str', 'Test string option', requires=[{'option': b, 'expected': 1, 'action': 'hidden'}], multi=True)
|
||||
descr = OptionDescription("str", "", [c, b])
|
||||
descr.impl_set_group_type(groups.master)
|
||||
descr = MasterSlaves("str", "", [c, b])
|
||||
#descr.impl_set_group_type(groups.master)
|
||||
raises(ValueError, "Config(descr)")
|
||||
|
||||
|
||||
|
@ -276,8 +276,8 @@ def test_multi_with_requires_that_is_masterslave_slave():
|
|||
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 = OptionDescription("int", "", [b, c, d])
|
||||
descr.impl_set_group_type(groups.master)
|
||||
descr = MasterSlaves("int", "", [b, c, d])
|
||||
#descr.impl_set_group_type(groups.master)
|
||||
config = Config(descr)
|
||||
config.read_write()
|
||||
assert config.int == [0]
|
||||
|
@ -299,8 +299,8 @@ def test_multi_with_requires_that_is_masterslave_slave_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 = OptionDescription("int", "", [b, c, d])
|
||||
descr.impl_set_group_type(groups.master)
|
||||
descr = MasterSlaves("int", "", [b, c, d])
|
||||
#descr.impl_set_group_type(groups.master)
|
||||
config = Config(descr)
|
||||
config.read_write()
|
||||
assert config.int == [0]
|
||||
|
@ -321,12 +321,12 @@ def test_multi_with_requires_that_is_masterslave_slave_inverse():
|
|||
def test_multi_with_requires_that_is_not_same_masterslave():
|
||||
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 = OptionDescription("int", "", [b, c])
|
||||
descr1.impl_set_group_type(groups.master)
|
||||
descr1 = MasterSlaves("int", "", [b, c])
|
||||
#descr1.impl_set_group_type(groups.master)
|
||||
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 = OptionDescription("int1", "", [d, e])
|
||||
descr2.impl_set_group_type(groups.master)
|
||||
descr2 = MasterSlaves("int1", "", [d, e])
|
||||
#descr2.impl_set_group_type(groups.master)
|
||||
descr3 = OptionDescription('val', '', [descr1, descr2])
|
||||
descr3
|
||||
raises(ValueError, "Config(descr3)")
|
||||
|
|
|
@ -5,7 +5,7 @@ import warnings
|
|||
from py.test import raises
|
||||
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import BoolOption, StrOption, OptionDescription
|
||||
from tiramisu.option import BoolOption, StrOption, OptionDescription, MasterSlaves
|
||||
from tiramisu.setting import groups
|
||||
from tiramisu.error import ValueWarning, ConfigError
|
||||
from tiramisu.i18n import _
|
||||
|
@ -138,8 +138,8 @@ def test_validator_params_value_values_index():
|
|||
def test_validator_params_value_values_master():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
cfg = Config(root)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == []
|
||||
|
@ -150,8 +150,8 @@ def test_validator_params_value_values_master():
|
|||
def test_validator_params_value_values_index_master():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
cfg = Config(root)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == []
|
||||
|
@ -162,8 +162,8 @@ def test_validator_params_value_values_index_master():
|
|||
def test_validator_params_value_values_slave():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
cfg = Config(root)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == []
|
||||
|
@ -176,8 +176,8 @@ def test_validator_params_value_values_slave():
|
|||
def test_validator_params_value_values_index_slave():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
cfg = Config(root)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == []
|
||||
|
@ -199,8 +199,8 @@ def test_validator_params_value_values_kwargs_empty():
|
|||
multi=True,
|
||||
validator=value_empty,
|
||||
validator_params={'': ((v, False),)})
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [v, interface1])
|
||||
cfg = Config(root)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == ['ip']
|
||||
|
@ -217,8 +217,8 @@ def test_validator_params_value_values_kwargs():
|
|||
multi=True,
|
||||
validator=value_values_auto,
|
||||
validator_params={'auto': ((v, False),)})
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [v, interface1])
|
||||
cfg = Config(root)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == ['ip']
|
||||
|
@ -234,8 +234,8 @@ def test_validator_params_value_values_kwargs_values():
|
|||
multi=True,
|
||||
validator=value_values_auto2,
|
||||
validator_params={'values': ((ip_admin_eth0, False),)})
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
cfg = Config(root)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == []
|
||||
|
@ -252,8 +252,8 @@ def test_validator_params_value_values_kwargs2():
|
|||
multi=True,
|
||||
validator=value_values_index2,
|
||||
validator_params={'': (['val1'],), 'index': ((ip_admin_eth0, False),)})
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
cfg = Config(root)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == []
|
||||
|
@ -269,8 +269,8 @@ def test_validator_params_value_values_kwargs_index():
|
|||
multi=True,
|
||||
validator=value_values_index2,
|
||||
validator_params={'index': ((ip_admin_eth0, False),)})
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
cfg = Config(root)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == []
|
||||
|
@ -405,8 +405,8 @@ def test_validator_warning_master_slave():
|
|||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
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
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
cfg = Config(root)
|
||||
|
@ -454,8 +454,8 @@ def test_validator_slave_param():
|
|||
multi=True,
|
||||
validator=return_true,
|
||||
validator_params={'param': ((ip_admin_eth0, False),)})
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
cfg = Config(root)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == []
|
||||
|
|
|
@ -5,7 +5,7 @@ do_autopath()
|
|||
from tiramisu.setting import groups, owners
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, \
|
||||
StrOption, OptionDescription
|
||||
StrOption, OptionDescription, MasterSlaves
|
||||
from tiramisu.error import SlaveError, PropertiesOptionError
|
||||
|
||||
from py.test import raises
|
||||
|
@ -164,16 +164,16 @@ def test_iter_not_group():
|
|||
def test_groups_with_master():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
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
|
||||
|
||||
|
||||
def test_groups_with_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
Config(interface1)
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
|
||||
|
@ -181,8 +181,8 @@ def test_groups_with_master_in_config():
|
|||
def test_groups_with_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
cfg = Config(interface1)
|
||||
cfg.read_write()
|
||||
cfg.cfgimpl_get_settings().setpermissive(('hidden',))
|
||||
|
@ -195,8 +195,8 @@ def test_groups_with_master_hidden_in_config():
|
|||
def test_groups_with_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
cfg = Config(interface1)
|
||||
cfg.read_write()
|
||||
cfg.cfgimpl_get_settings().setpermissive(('hidden',))
|
||||
|
@ -227,8 +227,8 @@ def test_groups_with_master_hidden_in_config3():
|
|||
#if master is hidden, slave 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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
cfg = Config(interface1)
|
||||
cfg.read_write()
|
||||
cfg.cfgimpl_get_settings().setpermissive(('hidden',))
|
||||
|
@ -249,8 +249,8 @@ def test_allowed_groups():
|
|||
def test_values_with_master_disabled_master():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -266,8 +266,8 @@ def test_values_with_master_disabled_master():
|
|||
def test_values_with_master_remove():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -288,34 +288,28 @@ def test_values_with_master_remove():
|
|||
def test_master_not_valid_name():
|
||||
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)
|
||||
invalid_group = OptionDescription('interface1', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
invalid_group
|
||||
raises(ValueError, "invalid_group.impl_set_group_type(groups.master)")
|
||||
raises(ValueError, "MasterSlaves('interface1', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
|
||||
|
||||
def test_sub_group_in_master_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", '', [])
|
||||
invalid_group = OptionDescription('ip_admin_eth0', '', [subgroup, ip_admin_eth0, netmask_admin_eth0])
|
||||
invalid_group
|
||||
raises(ValueError, "invalid_group.impl_set_group_type(groups.master)")
|
||||
raises(ValueError, "MasterSlaves('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")
|
||||
group = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
group
|
||||
raises(ValueError, "group.impl_set_group_type(groups.master)")
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
|
||||
|
||||
#____________________________________________________________
|
||||
def test_values_with_master_and_slaves():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -337,8 +331,8 @@ def test_values_with_master_and_slaves():
|
|||
def test_reset_values_with_master_and_slaves():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -366,15 +360,14 @@ def test_reset_values_with_master_and_slaves():
|
|||
def test_reset_values_with_master_and_slaves_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'])
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
raises(ValueError, "interface1.impl_set_group_type(groups.master)")
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
|
||||
|
||||
def test_reset_values_with_master_and_slaves_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -414,8 +407,8 @@ def test_reset_values_with_master_and_slaves_default():
|
|||
def test_reset_values_with_master_and_slaves_setitem():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -443,8 +436,8 @@ def test_reset_values_with_master_and_slaves_setitem():
|
|||
def test_values_with_master_and_slaves_slave():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -471,8 +464,8 @@ def test_values_with_master_and_slaves_slave():
|
|||
def test_values_with_master_and_slaves_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -491,8 +484,8 @@ def test_values_with_master_and_slaves_pop():
|
|||
def test_values_with_master_and_slaves_master():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -513,8 +506,8 @@ def test_values_with_master_and_slaves_master():
|
|||
def test_values_with_master_and_slaves_master_error():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -529,8 +522,8 @@ def test_values_with_master_and_slaves_master_error():
|
|||
def test_values_with_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -548,8 +541,8 @@ def test_values_with_master_owner():
|
|||
def test_values_with_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -594,8 +587,8 @@ def test_multi_insert():
|
|||
def test_multi_insert_master():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -618,8 +611,8 @@ def test_multi_sort():
|
|||
def test_multi_sort_master():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -642,8 +635,8 @@ def test_multi_reverse():
|
|||
def test_multi_reverse_master():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -667,8 +660,8 @@ def test_multi_extend():
|
|||
def test_multi_extend_master():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -688,8 +681,8 @@ def test_multi_non_valid_value():
|
|||
def test_multi_master_default_slave():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -701,8 +694,8 @@ def test_multi_master_default_slave():
|
|||
def test_groups_with_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
|
|
@ -6,7 +6,8 @@ from copy import copy
|
|||
from tiramisu.setting import groups
|
||||
from tiramisu import setting
|
||||
setting.expires_time = 1
|
||||
from tiramisu.option import IPOption, OptionDescription, BoolOption, IntOption, StrOption
|
||||
from tiramisu.option import IPOption, OptionDescription, BoolOption, IntOption, StrOption, \
|
||||
MasterSlaves
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.error import PropertiesOptionError, RequirementError
|
||||
from py.test import raises
|
||||
|
@ -847,8 +848,8 @@ def test_master_slave_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -873,8 +874,8 @@ def test_master_slave_requires_no_master():
|
|||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [activate, interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
|
|
@ -6,7 +6,7 @@ from py.test import raises
|
|||
|
||||
from tiramisu.error import ConfigError
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import BoolOption, OptionDescription
|
||||
from tiramisu.option import BoolOption, OptionDescription, MasterSlaves
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu.storage import list_sessions, delete_session
|
||||
|
||||
|
@ -154,8 +154,8 @@ def test_create_persistent_retrieve_owner():
|
|||
def test_create_persistent_retrieve_owner_masterslaves():
|
||||
a = BoolOption('a', '', multi=True)
|
||||
b = BoolOption('b', '', multi=True)
|
||||
o = OptionDescription('a', '', [a, b])
|
||||
o.impl_set_group_type(groups.master)
|
||||
o = MasterSlaves('a', '', [a, b])
|
||||
#o.impl_set_group_type(groups.master)
|
||||
o1 = OptionDescription('a', '', [o])
|
||||
try:
|
||||
c = Config(o1, session_id='test_persistent', persistent=True)
|
||||
|
|
|
@ -4,7 +4,7 @@ do_autopath()
|
|||
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu.config import Config, MetaConfig
|
||||
from tiramisu.option import StrOption, IntOption, OptionDescription, submulti
|
||||
from tiramisu.option import StrOption, IntOption, OptionDescription, submulti, MasterSlaves
|
||||
from tiramisu.value import SubMulti, Multi
|
||||
from tiramisu.error import SlaveError
|
||||
|
||||
|
@ -357,16 +357,16 @@ def test_callback_submulti_list_list():
|
|||
def test_groups_with_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
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
|
||||
|
||||
|
||||
def test_groups_with_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
Config(interface1)
|
||||
assert interface1.impl_get_group_type() == groups.master
|
||||
|
||||
|
@ -374,8 +374,8 @@ def test_groups_with_master_in_config_submulti():
|
|||
def test_values_with_master_and_slaves_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -403,8 +403,8 @@ def test_values_with_master_and_slaves_submulti():
|
|||
def test_reset_values_with_master_and_slaves_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -435,8 +435,8 @@ def test_reset_values_with_master_and_slaves_submulti():
|
|||
def test_values_with_master_and_slaves_slave_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -459,8 +459,8 @@ def test_values_with_master_and_slaves_slave_submulti():
|
|||
def test_values_with_master_and_slaves_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -481,8 +481,8 @@ def test_values_with_master_and_slaves_master_submulti():
|
|||
def test_values_with_master_and_slaves_master_error_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -497,8 +497,8 @@ def test_values_with_master_and_slaves_master_error_submulti():
|
|||
def test_values_with_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -516,8 +516,8 @@ def test_values_with_master_owner_submulti():
|
|||
def test_values_with_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -549,8 +549,8 @@ def test_values_with_master_disabled_submulti():
|
|||
def test_multi_insert_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -563,8 +563,8 @@ def test_multi_insert_master_submulti():
|
|||
def test_multi_sort_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -577,8 +577,8 @@ def test_multi_sort_master_submulti():
|
|||
def test_multi_reverse_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -591,8 +591,8 @@ def test_multi_reverse_master_submulti():
|
|||
def test_multi_extend_master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -605,8 +605,8 @@ def test_multi_extend_master_submulti():
|
|||
def test_slave_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
@ -622,8 +622,8 @@ def test_slave_submulti():
|
|||
def test__master_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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
|
|
|
@ -3,7 +3,7 @@ from .autopath import do_autopath
|
|||
do_autopath()
|
||||
|
||||
from tiramisu.option import BoolOption, StrOption, SymLinkOption, \
|
||||
OptionDescription
|
||||
OptionDescription, MasterSlaves
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.error import PropertiesOptionError
|
||||
from tiramisu.setting import groups, owners
|
||||
|
@ -133,18 +133,14 @@ def test_symlink_master():
|
|||
a = StrOption('a', "", multi=True)
|
||||
ip_admin_eth0 = SymLinkOption('ip_admin_eth0', a)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "", multi=True)
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1
|
||||
raises(ValueError, 'interface1.impl_set_group_type(groups.master)')
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
|
||||
|
||||
def test_symlink_slaves():
|
||||
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)
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1
|
||||
raises(ValueError, 'interface1.impl_set_group_type(groups.master)')
|
||||
raises(ValueError, "MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
|
||||
|
||||
#____________________________________________________________
|
||||
|
|
|
@ -170,11 +170,11 @@ class SubConfig(object):
|
|||
reset_one_option_cache(opt, path)
|
||||
|
||||
# remove cache for option which has dependencies with this option
|
||||
if not isinstance(opt, OptionDescription) and not isinstance(opt, SynDynOptionDescription) and \
|
||||
opt.impl_is_master_slaves('slave'):
|
||||
slaves = opt.impl_get_master_slaves().getslaves(opt)
|
||||
else:
|
||||
slaves = []
|
||||
#if not isinstance(opt, OptionDescription) and not isinstance(opt, SynDynOptionDescription) and \
|
||||
# opt.impl_is_master_slaves('slave'):
|
||||
# slaves = opt.impl_get_master_slaves().getslaves(opt)
|
||||
#else:
|
||||
slaves = []
|
||||
for option in chain(opt._get_dependencies(self), slaves):
|
||||
if option in orig_opts:
|
||||
continue
|
||||
|
@ -439,6 +439,15 @@ class SubConfig(object):
|
|||
raise props
|
||||
return SubConfig(option, self._impl_context, subpath)
|
||||
else:
|
||||
if validate:
|
||||
ret = self.cfgimpl_get_description().impl_validate(context,
|
||||
force_permissive,
|
||||
_setting_properties)
|
||||
if ret:
|
||||
if returns_raise:
|
||||
return ret
|
||||
else:
|
||||
raise ret
|
||||
cfg = self.cfgimpl_get_values()._get_cached_value(
|
||||
option, path=subpath,
|
||||
validate=validate,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from .masterslave import MasterSlaves
|
||||
from .optiondescription import OptionDescription, DynOptionDescription, \
|
||||
SynDynOptionDescription
|
||||
SynDynOptionDescription, MasterSlaves
|
||||
from .baseoption import SymLinkOption, DynSymLinkOption, submulti
|
||||
from .option import Option
|
||||
from .choiceoption import ChoiceOption
|
||||
|
|
|
@ -243,9 +243,11 @@ class Base(object):
|
|||
self._val_call = (val, val_call)
|
||||
|
||||
def impl_is_optiondescription(self):
|
||||
#FIXME deplacer dans OpenDescription ?
|
||||
return self.__class__.__name__ in ['OptionDescription',
|
||||
'DynOptionDescription',
|
||||
'SynDynOptionDescription']
|
||||
'SynDynOptionDescription',
|
||||
'MasterSlaves']
|
||||
|
||||
def impl_is_dynoptiondescription(self):
|
||||
return self.__class__.__name__ in ['DynOptionDescription',
|
||||
|
|
|
@ -19,263 +19,6 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
from ..i18n import _
|
||||
from ..setting import log, undefined, debug
|
||||
from ..error import SlaveError, PropertiesOptionError
|
||||
from .optiondescription import MasterSlaves
|
||||
|
||||
|
||||
class MasterSlaves(object):
|
||||
__slots__ = ('master', 'slaves')
|
||||
|
||||
def __init__(self, name, childs=None, validate=True, add=True):
|
||||
#if master (same name has group) is set
|
||||
#for collect all slaves
|
||||
slaves = []
|
||||
if childs[0].impl_getname() == name:
|
||||
master = childs[0]
|
||||
else:
|
||||
raise ValueError(_('master group with wrong'
|
||||
' master name for {0}'
|
||||
).format(name))
|
||||
for child in childs[1:]:
|
||||
if child.impl_getdefault() != []:
|
||||
raise ValueError(_("not allowed default value for option {0} "
|
||||
"in master/slave object {1}").format(child.impl_getname(),
|
||||
name))
|
||||
slaves.append(child)
|
||||
if validate:
|
||||
callback, callback_params = master.impl_get_callback()
|
||||
if callback is not None and callback_params != {}:
|
||||
for callbacks in callback_params.values():
|
||||
for callbk in callbacks:
|
||||
if isinstance(callbk, tuple):
|
||||
if callbk[0] in slaves:
|
||||
raise ValueError(_("callback of master's option shall "
|
||||
"not refered a slave's ones"))
|
||||
#everything is ok, store references
|
||||
self.master = master
|
||||
self.slaves = tuple(slaves)
|
||||
if add:
|
||||
for child in childs:
|
||||
child._master_slaves = self
|
||||
if child != self.master:
|
||||
child._add_dependency(self)
|
||||
self.master._add_dependency(self)
|
||||
|
||||
def is_master(self, opt):
|
||||
master = self.master.impl_getname()
|
||||
return opt.impl_getname() == master or (opt.impl_is_dynsymlinkoption() and
|
||||
opt._opt.impl_getname() == master)
|
||||
|
||||
def getmaster(self, opt):
|
||||
master = self.master
|
||||
if opt.impl_is_dynsymlinkoption():
|
||||
suffix = opt.impl_getsuffix()
|
||||
name = master.impl_getname() + suffix
|
||||
base_path = opt._dyn.split('.')[0] + '.'
|
||||
path = base_path + name
|
||||
master = master._impl_to_dyn(name, path)
|
||||
return master
|
||||
|
||||
def getslaves(self, opt):
|
||||
if opt.impl_is_dynsymlinkoption():
|
||||
for slave in self.slaves:
|
||||
suffix = opt.impl_getsuffix()
|
||||
name = slave.impl_getname() + suffix
|
||||
base_path = opt._dyn.split('.')[0] + '.'
|
||||
path = base_path + name
|
||||
yield slave._impl_to_dyn(name, path)
|
||||
else:
|
||||
for slave in self.slaves:
|
||||
yield slave
|
||||
|
||||
def in_same_group(self, opt):
|
||||
if opt.impl_is_dynsymlinkoption():
|
||||
return opt._opt == self.master or opt._opt in self.slaves
|
||||
else:
|
||||
return opt == self.master or opt in self.slaves
|
||||
|
||||
def reset(self, opt, values, setting_properties, _commit=True):
|
||||
for slave in self.getslaves(opt):
|
||||
values.reset(slave, validate=False, _setting_properties=setting_properties,
|
||||
_commit=_commit)
|
||||
|
||||
def pop(self, opt, values, index):
|
||||
for slave in self.getslaves(opt):
|
||||
if not values.is_default_owner(slave, validate_properties=False,
|
||||
validate_meta=False, index=index):
|
||||
multi = values._get_cached_value(slave, validate=False,
|
||||
validate_properties=False,
|
||||
)
|
||||
if isinstance(multi, Exception):
|
||||
raise multi
|
||||
multi.pop(index, force=True)
|
||||
|
||||
def getitem(self, values, opt, path, validate, force_permissive,
|
||||
trusted_cached_properties, validate_properties, session,
|
||||
slave_path=undefined, slave_value=undefined,
|
||||
setting_properties=undefined, self_properties=undefined, index=None,
|
||||
check_frozen=False):
|
||||
if self.is_master(opt):
|
||||
return self._getmaster(values, opt, path, validate,
|
||||
force_permissive,
|
||||
validate_properties, slave_path,
|
||||
slave_value, self_properties, index,
|
||||
setting_properties, session, check_frozen)
|
||||
else:
|
||||
return self._getslave(values, opt, path, validate,
|
||||
force_permissive, trusted_cached_properties,
|
||||
validate_properties, setting_properties,
|
||||
self_properties, index,
|
||||
session, check_frozen)
|
||||
|
||||
def _getmaster(self, values, opt, path, validate, force_permissive,
|
||||
validate_properties, c_slave_path,
|
||||
c_slave_value, self_properties, index,
|
||||
setting_properties, session, check_frozen):
|
||||
value = values._get_cached_value(opt, path=path, validate=validate,
|
||||
force_permissive=force_permissive,
|
||||
validate_properties=validate_properties,
|
||||
self_properties=self_properties,
|
||||
from_masterslave=True, index=index,
|
||||
setting_properties=setting_properties,
|
||||
check_frozen=check_frozen)
|
||||
if isinstance(value, Exception):
|
||||
return value
|
||||
if index is None and validate is True:
|
||||
masterlen = len(value)
|
||||
for slave in self.getslaves(opt):
|
||||
slave_path = slave.impl_getpath(values._getcontext())
|
||||
slavelen = values._p_.get_max_length(slave_path, session)
|
||||
self.validate_slave_length(masterlen, slavelen, slave.impl_getname(), opt)
|
||||
return value
|
||||
|
||||
def _getslave(self, values, opt, path, validate, force_permissive,
|
||||
trusted_cached_properties, validate_properties, setting_properties,
|
||||
self_properties, index, session, check_frozen):
|
||||
"""
|
||||
if master has length 0:
|
||||
return []
|
||||
if master has length bigger than 0:
|
||||
if default owner:
|
||||
if has callback:
|
||||
if return a list:
|
||||
list same length as master: return list
|
||||
list is smaller than master: return list + None
|
||||
list is greater than master: raise SlaveError
|
||||
if has default value:
|
||||
list same length as master: return list
|
||||
list is smaller than master: return list + None
|
||||
list is greater than master: raise SlaveError
|
||||
if has default_multi value:
|
||||
return default_multi * master's length
|
||||
if has value:
|
||||
list same length as master: return list
|
||||
list is smaller than master: return list + None
|
||||
list is greater than master: raise SlaveError
|
||||
"""
|
||||
master = self.getmaster(opt)
|
||||
context = values._getcontext()
|
||||
masterp = master.impl_getpath(context)
|
||||
masterlen = self.get_length(values, opt, session, validate, undefined,
|
||||
undefined, force_permissive,
|
||||
master=master, setting_properties=setting_properties)
|
||||
if isinstance(masterlen, Exception):
|
||||
if isinstance(masterlen, PropertiesOptionError):
|
||||
masterlen.set_orig_opt(opt)
|
||||
return masterlen
|
||||
master_is_meta = values._is_meta(master, masterp, session)
|
||||
multi = values._get_multi(opt, path)
|
||||
#if masterlen is [], test properties (has no value, don't get any value)
|
||||
#if masterlen == 0:
|
||||
if validate_properties:
|
||||
props = context.cfgimpl_get_settings().validate_properties(opt, False,
|
||||
check_frozen,
|
||||
value=multi,
|
||||
path=path,
|
||||
force_permissive=force_permissive,
|
||||
setting_properties=setting_properties)
|
||||
if props:
|
||||
return props
|
||||
#else:
|
||||
if index is None:
|
||||
indexes = range(0, masterlen)
|
||||
else:
|
||||
indexes = [index]
|
||||
for idx in indexes:
|
||||
value = values._get_cached_value(opt, path, validate,
|
||||
force_permissive,
|
||||
trusted_cached_properties,
|
||||
validate_properties,
|
||||
with_meta=master_is_meta,
|
||||
index=idx,
|
||||
# not self_properties,
|
||||
# depends to index
|
||||
#self_properties=self_properties,
|
||||
setting_properties=setting_properties,
|
||||
masterlen=masterlen,
|
||||
from_masterslave=True,
|
||||
check_frozen=check_frozen)
|
||||
if isinstance(value, Exception):
|
||||
if isinstance(value, PropertiesOptionError):
|
||||
err = value
|
||||
if index is None:
|
||||
multi.append_properties_error(value)
|
||||
else:
|
||||
multi = value
|
||||
else:
|
||||
return value
|
||||
elif index is None:
|
||||
multi.append(value, setitem=False, force=True, validate=False,
|
||||
force_permissive=force_permissive)
|
||||
else:
|
||||
multi = value
|
||||
return multi
|
||||
|
||||
def validate(self, values, opt, index, path, session, setitem):
|
||||
if self.is_master(opt):
|
||||
#for regen slave path
|
||||
base_path = '.'.join(path.split('.')[:-1]) + '.'
|
||||
for slave in self.getslaves(opt):
|
||||
slave_path = base_path + slave.impl_getname()
|
||||
slavelen = values._p_.get_max_length(slave_path, session)
|
||||
self.validate_slave_length(index, slavelen, slave.impl_getname(), opt)
|
||||
else:
|
||||
val_len = self.get_length(values, opt, session, slave_path=path)
|
||||
if isinstance(val_len, Exception):
|
||||
return val_len
|
||||
self.validate_slave_length(val_len, index,
|
||||
opt.impl_getname(), opt, setitem=setitem)
|
||||
|
||||
def get_length(self, values, opt, session, validate=True, slave_path=undefined,
|
||||
slave_value=undefined, force_permissive=False, master=None,
|
||||
masterp=None, setting_properties=undefined):
|
||||
"""get master len with slave option"""
|
||||
if master is None:
|
||||
master = self.getmaster(opt)
|
||||
if masterp is None:
|
||||
masterp = master.impl_getpath(values._getcontext())
|
||||
if slave_value is undefined:
|
||||
slave_path = undefined
|
||||
value = self.getitem(values, master, masterp, validate,
|
||||
force_permissive, None, True, session, slave_path=slave_path,
|
||||
slave_value=slave_value, setting_properties=setting_properties)
|
||||
if isinstance(value, Exception):
|
||||
return value
|
||||
return len(value)
|
||||
|
||||
def validate_slave_length(self, masterlen, valuelen, name, opt, setitem=False):
|
||||
if valuelen > masterlen or (valuelen < masterlen and setitem):
|
||||
if debug: # pragma: no cover
|
||||
log.debug('validate_slave_length: masterlen: {0}, valuelen: {1}, '
|
||||
'setitem: {2}'.format(masterlen, valuelen, setitem))
|
||||
raise SlaveError(_("invalid len for the slave: {0}"
|
||||
" which has {1} as master").format(
|
||||
name, self.getmaster(opt).impl_getname()))
|
||||
|
||||
def reset_cache(self, opt, values, type_, orig_opts):
|
||||
path = self.getmaster(opt).impl_getpath(values._getcontext())
|
||||
values._p_.delcache(path)
|
||||
for slave in self.getslaves(opt):
|
||||
slave_path = slave.impl_getpath(values._getcontext())
|
||||
values._p_.delcache(slave_path)
|
||||
|
|
|
@ -29,7 +29,6 @@ from ..autolib import carry_out_calculation
|
|||
from ..error import (ConfigError, ValueWarning, PropertiesOptionError,
|
||||
display_list)
|
||||
from itertools import combinations
|
||||
|
||||
ALLOWED_CONST_LIST = ['_cons_not_equal']
|
||||
|
||||
if sys.version_info[0] >= 3: # pragma: no cover
|
||||
|
|
|
@ -23,11 +23,11 @@ import re
|
|||
|
||||
|
||||
from ..i18n import _
|
||||
from ..setting import groups, undefined, owners # , log
|
||||
from ..setting import groups, undefined, owners, log, debug
|
||||
from .baseoption import BaseOption
|
||||
from .option import Option, ALLOWED_CONST_LIST
|
||||
from . import MasterSlaves
|
||||
from ..error import ConfigError, ConflictError
|
||||
#from . import MasterSlaves
|
||||
from ..error import ConfigError, ConflictError, SlaveError, PropertiesOptionError
|
||||
from ..autolib import carry_out_calculation
|
||||
|
||||
|
||||
|
@ -461,6 +461,7 @@ class OptionDescription(OptionDescriptionWalk):
|
|||
if isinstance(group_type, groups.GroupType):
|
||||
self._group_type = group_type
|
||||
if isinstance(group_type, groups.MasterGroupType):
|
||||
raise Exception('please use MasterSlaves object instead of OptionDescription')
|
||||
children = self.impl_getchildren()
|
||||
for child in children:
|
||||
if child._is_symlinkoption(): # pragma: optional cover
|
||||
|
@ -557,6 +558,300 @@ class SynDynOptionDescription(object):
|
|||
return self._opt
|
||||
|
||||
|
||||
class MasterSlaves(OptionDescription):
|
||||
__slots__ = ('master', 'slaves')
|
||||
|
||||
def __init__(self, name, doc, children, requires=None, properties=None):
|
||||
#if master (same name has group) is set
|
||||
#for collect all slaves
|
||||
super(MasterSlaves, self).__init__(name,
|
||||
doc,
|
||||
children,
|
||||
requires=requires,
|
||||
properties=properties)
|
||||
self._group_type = groups.master
|
||||
slaves = []
|
||||
master = children[0]
|
||||
if master.impl_getname() != name:
|
||||
raise ValueError(_('master group with wrong'
|
||||
' master name for {0}'
|
||||
).format(name))
|
||||
for child in children[1:]:
|
||||
if child.impl_getdefault() != []:
|
||||
raise ValueError(_("not allowed default value for option {0} "
|
||||
"in master/slave object {1}").format(child.impl_getname(),
|
||||
name))
|
||||
slaves.append(child)
|
||||
child._add_dependency(self)
|
||||
for child in children:
|
||||
if child._is_symlinkoption(): # pragma: optional cover
|
||||
raise ValueError(_("master group {0} shall not have "
|
||||
"a symlinkoption").format(self.impl_getname()))
|
||||
if not isinstance(child, Option): # pragma: optional cover
|
||||
raise ValueError(_("master group {0} shall not have "
|
||||
"a subgroup").format(self.impl_getname()))
|
||||
if not child.impl_is_multi(): # pragma: optional cover
|
||||
raise ValueError(_("not allowed option {0} "
|
||||
"in group {1}"
|
||||
": this option is not a multi"
|
||||
"").format(child.impl_getname(), self.impl_getname()))
|
||||
callback, callback_params = master.impl_get_callback()
|
||||
if callback is not None and callback_params != {}:
|
||||
for callbacks in callback_params.values():
|
||||
for callbk in callbacks:
|
||||
if isinstance(callbk, tuple):
|
||||
if callbk[0] in slaves:
|
||||
raise ValueError(_("callback of master's option shall "
|
||||
"not refered a slave's ones"))
|
||||
#everything is ok, store references
|
||||
#self.master = master
|
||||
#self.slaves = tuple(slaves)
|
||||
for child in children:
|
||||
child._master_slaves = self
|
||||
master._add_dependency(self)
|
||||
|
||||
def is_master(self, opt):
|
||||
master = self._children[0][0]
|
||||
return opt.impl_getname() == master or (opt.impl_is_dynsymlinkoption() and
|
||||
opt._opt.impl_getname() == master)
|
||||
|
||||
def getmaster(self, opt):
|
||||
master = self._children[1][0]
|
||||
if opt is not None and opt.impl_is_dynsymlinkoption():
|
||||
suffix = opt.impl_getsuffix()
|
||||
name = master.impl_getname() + suffix
|
||||
base_path = opt._dyn.split('.')[0] + '.'
|
||||
path = base_path + name
|
||||
master = master._impl_to_dyn(name, path)
|
||||
return master
|
||||
|
||||
def getslaves(self, opt):
|
||||
if opt.impl_is_dynsymlinkoption():
|
||||
for slave in self._children[1][1:]:
|
||||
suffix = opt.impl_getsuffix()
|
||||
name = slave.impl_getname() + suffix
|
||||
base_path = opt._dyn.split('.')[0] + '.'
|
||||
path = base_path + name
|
||||
yield slave._impl_to_dyn(name, path)
|
||||
else:
|
||||
for slave in self._children[1][1:]:
|
||||
yield slave
|
||||
|
||||
def in_same_group(self, opt):
|
||||
if opt.impl_is_dynsymlinkoption():
|
||||
c_opt = opt._opt
|
||||
else:
|
||||
c_opt = opt
|
||||
return c_opt in self._children[1]
|
||||
|
||||
def reset(self, opt, values, setting_properties, _commit=True):
|
||||
for slave in self.getslaves(opt):
|
||||
values.reset(slave, validate=False, _setting_properties=setting_properties,
|
||||
_commit=_commit)
|
||||
|
||||
def pop(self, opt, values, index):
|
||||
for slave in self.getslaves(opt):
|
||||
if not values.is_default_owner(slave, validate_properties=False,
|
||||
validate_meta=False, index=index):
|
||||
multi = values._get_cached_value(slave, validate=False,
|
||||
validate_properties=False,
|
||||
)
|
||||
if isinstance(multi, Exception):
|
||||
raise multi
|
||||
multi.pop(index, force=True)
|
||||
|
||||
def getitem(self, values, opt, path, validate, force_permissive,
|
||||
trusted_cached_properties, validate_properties,
|
||||
slave_path=undefined, slave_value=undefined,
|
||||
setting_properties=undefined, self_properties=undefined, index=None,
|
||||
check_frozen=False):
|
||||
if self.is_master(opt):
|
||||
return self._getmaster(values, opt, path, validate,
|
||||
force_permissive,
|
||||
validate_properties, slave_path,
|
||||
slave_value, self_properties, index,
|
||||
setting_properties, check_frozen)
|
||||
else:
|
||||
return self._getslave(values, opt, path, validate,
|
||||
force_permissive, trusted_cached_properties,
|
||||
validate_properties, setting_properties,
|
||||
self_properties, index,
|
||||
check_frozen)
|
||||
|
||||
def _getmaster(self, values, opt, path, validate, force_permissive,
|
||||
validate_properties, c_slave_path,
|
||||
c_slave_value, self_properties, index,
|
||||
setting_properties, check_frozen):
|
||||
return values._get_cached_value(opt, path=path, validate=validate,
|
||||
force_permissive=force_permissive,
|
||||
validate_properties=validate_properties,
|
||||
self_properties=self_properties,
|
||||
from_masterslave=True, index=index,
|
||||
setting_properties=setting_properties,
|
||||
check_frozen=check_frozen)
|
||||
|
||||
def _getslave(self, values, opt, path, validate, force_permissive,
|
||||
trusted_cached_properties, validate_properties, setting_properties,
|
||||
self_properties, index, check_frozen):
|
||||
"""
|
||||
if master has length 0:
|
||||
return []
|
||||
if master has length bigger than 0:
|
||||
if default owner:
|
||||
if has callback:
|
||||
if return a list:
|
||||
list same length as master: return list
|
||||
list is smaller than master: return list + None
|
||||
list is greater than master: raise SlaveError
|
||||
if has default value:
|
||||
list same length as master: return list
|
||||
list is smaller than master: return list + None
|
||||
list is greater than master: raise SlaveError
|
||||
if has default_multi value:
|
||||
return default_multi * master's length
|
||||
if has value:
|
||||
list same length as master: return list
|
||||
list is smaller than master: return list + None
|
||||
list is greater than master: raise SlaveError
|
||||
"""
|
||||
master = self.getmaster(opt)
|
||||
context = values._getcontext()
|
||||
masterp = master.impl_getpath(context)
|
||||
mastervalue = values._get_cached_value(master, path=masterp, validate=validate,
|
||||
force_permissive=force_permissive,
|
||||
validate_properties=validate_properties,
|
||||
self_properties=self_properties,
|
||||
from_masterslave=True,
|
||||
setting_properties=setting_properties,
|
||||
check_frozen=check_frozen)
|
||||
if isinstance(mastervalue, Exception):
|
||||
if isinstance(mastervalue, PropertiesOptionError):
|
||||
mastervalue.set_orig_opt(opt)
|
||||
return mastervalue
|
||||
masterlen = len(mastervalue)
|
||||
master_is_meta = values._is_meta(master, masterp, force_permissive=force_permissive)
|
||||
multi = values._get_multi(opt, path)
|
||||
if validate_properties:
|
||||
props = context.cfgimpl_get_settings().validate_properties(opt, False,
|
||||
check_frozen,
|
||||
value=multi,
|
||||
path=path,
|
||||
force_permissive=force_permissive,
|
||||
setting_properties=setting_properties)
|
||||
if props:
|
||||
return props
|
||||
if index is None:
|
||||
indexes = xrange(0, masterlen)
|
||||
else:
|
||||
indexes = [index]
|
||||
for idx in indexes:
|
||||
value = values._get_cached_value(opt, path, validate,
|
||||
force_permissive,
|
||||
trusted_cached_properties,
|
||||
validate_properties,
|
||||
with_meta=master_is_meta,
|
||||
index=idx,
|
||||
# not self_properties,
|
||||
# depends to index
|
||||
#self_properties=self_properties,
|
||||
setting_properties=setting_properties,
|
||||
masterlen=masterlen,
|
||||
from_masterslave=True,
|
||||
check_frozen=check_frozen)
|
||||
if isinstance(value, Exception):
|
||||
if isinstance(value, PropertiesOptionError):
|
||||
err = value
|
||||
if index is None:
|
||||
multi.append_properties_error(value)
|
||||
else:
|
||||
multi = value
|
||||
else:
|
||||
return value
|
||||
elif index is None:
|
||||
multi.append(value, setitem=False, force=True, validate=False,
|
||||
force_permissive=force_permissive)
|
||||
else:
|
||||
multi = value
|
||||
return multi
|
||||
|
||||
def validate(self, values, opt, index, path, setitem):
|
||||
if self.is_master(opt):
|
||||
#for regen slave path
|
||||
base_path = '.'.join(path.split('.')[:-1]) + '.'
|
||||
for slave in self.getslaves(opt):
|
||||
slave_path = base_path + slave.impl_getname()
|
||||
slavelen = values._p_.get_max_length(slave_path)
|
||||
self.validate_slave_length(index, slavelen, slave.impl_getname(), opt)
|
||||
else:
|
||||
val_len = self.get_length(values, opt, slave_path=path)
|
||||
if isinstance(val_len, Exception):
|
||||
return val_len
|
||||
self.validate_slave_length(val_len, index,
|
||||
opt.impl_getname(), opt, setitem=setitem)
|
||||
|
||||
def get_length(self, values, opt, validate=True, slave_path=undefined,
|
||||
slave_value=undefined, force_permissive=False, master=None,
|
||||
masterp=None, setting_properties=undefined):
|
||||
"""get master len with slave option"""
|
||||
if master is None:
|
||||
master = self.getmaster(None)
|
||||
if masterp is None:
|
||||
masterp = master.impl_getpath(self._getcontext())
|
||||
if slave_value is undefined:
|
||||
slave_path = undefined
|
||||
value = self.getitem(values, master, masterp, validate,
|
||||
force_permissive, None, True, slave_path=slave_path,
|
||||
slave_value=slave_value, setting_properties=setting_properties)
|
||||
if isinstance(value, Exception):
|
||||
return value
|
||||
return len(value)
|
||||
|
||||
def validate_slave_length(self, masterlen, valuelen, name, opt, setitem=False):
|
||||
if valuelen > masterlen or (valuelen < masterlen and setitem):
|
||||
if debug: # pragma: no cover
|
||||
log.debug('validate_slave_length: masterlen: {0}, valuelen: {1}, '
|
||||
'setitem: {2}'.format(masterlen, valuelen, setitem))
|
||||
if not opt.impl_is_master_slaves('master'):
|
||||
opt = self.getmaster(opt)
|
||||
raise SlaveError(_("invalid len for the slave: {0}"
|
||||
" which has {1} as master").format(
|
||||
name, opt.impl_getname()))
|
||||
|
||||
def reset_cache(self, opt, values, type_, orig_opts):
|
||||
path = self.getmaster(opt).impl_getpath(values._getcontext())
|
||||
values._p_.delcache(path)
|
||||
for slave in self.getslaves(opt):
|
||||
slave_path = slave.impl_getpath(values._getcontext())
|
||||
values._p_.delcache(slave_path)
|
||||
|
||||
def _getattr(self, name, suffix=undefined, context=undefined, dyn=True):
|
||||
return super(MasterSlaves, self)._getattr(name, suffix, context, dyn)
|
||||
|
||||
def impl_validate(self, context, force_permissive, setting_properties, masterlen=None,
|
||||
slavelen=None, opt=None, setitem=False):
|
||||
values = context.cfgimpl_get_values()
|
||||
if masterlen is None:
|
||||
master = self.getmaster(opt)
|
||||
masterp = master.impl_getpath(context)
|
||||
|
||||
mastervalue = values._get_cached_value(master, path=masterp,
|
||||
force_permissive=force_permissive,
|
||||
from_masterslave=True,
|
||||
setting_properties=setting_properties)
|
||||
if isinstance(mastervalue, Exception):
|
||||
return mastervalue
|
||||
masterlen = len(mastervalue)
|
||||
else:
|
||||
master = opt
|
||||
if slavelen is not None:
|
||||
self.validate_slave_length(masterlen, slavelen, opt.impl_getname(), master, setitem=setitem)
|
||||
else:
|
||||
for slave in self.getslaves(master):
|
||||
slave_path = slave.impl_getpath(context)
|
||||
slavelen = values._p_.get_max_length(slave_path, None)
|
||||
self.validate_slave_length(masterlen, slavelen, slave.impl_getname(), master)
|
||||
|
||||
|
||||
def _impl_getpaths(klass, include_groups, _currpath):
|
||||
"""returns a list of all paths in klass, recursively
|
||||
_currpath should not be provided (helps with recursion)
|
||||
|
|
|
@ -109,16 +109,6 @@ def get_storages(context, session_id, persistent):
|
|||
return properties, permissives, values, session_id
|
||||
|
||||
|
||||
#def get_storages_option(type_):
|
||||
# imp = storage_option_type.get()
|
||||
# if type_ == 'base':
|
||||
# return imp.StorageBase
|
||||
# elif type_ == 'masterslaves':
|
||||
# return imp.StorageMasterSlaves
|
||||
# else:
|
||||
# return imp.StorageOptionDescription
|
||||
|
||||
|
||||
def get_default_values_storages():
|
||||
imp = default_validation.get()
|
||||
storage = imp.Storage('__validator_storage', persistent=False, test=True)
|
||||
|
|
|
@ -25,7 +25,6 @@ use it. But if something goes wrong, you will lost your modifications.
|
|||
from .value import Values
|
||||
from .setting import Settings
|
||||
from .storage import Storage, list_sessions, delete_session, storage_setting
|
||||
from .option import StorageBase, StorageOptionDescription, StorageMasterSlaves
|
||||
from .util import load
|
||||
|
||||
|
||||
|
@ -33,5 +32,5 @@ load()
|
|||
|
||||
|
||||
__all__ = (storage_setting, Values, Settings, Storage, list_sessions, delete_session,
|
||||
StorageBase, StorageOptionDescription, StorageMasterSlaves)
|
||||
StorageBase)
|
||||
# Base, OptionDescription)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# ____________________________________________________________
|
||||
from ..setting import owners
|
||||
|
||||
|
||||
class Cache(object):
|
||||
|
|
|
@ -292,7 +292,7 @@ class Values(object):
|
|||
if isinstance(val, Exception):
|
||||
return val
|
||||
# cache doesn't work with SubMulti yet
|
||||
if not index and not isinstance(val, SubMulti) and 'cache' in setting_properties and \
|
||||
if index is None and not isinstance(val, SubMulti) and 'cache' in setting_properties and \
|
||||
validate and validate_properties and force_permissive is False \
|
||||
and trusted_cached_properties is True and _orig_context is undefined:
|
||||
if 'expire' in setting_properties:
|
||||
|
@ -413,7 +413,7 @@ class Values(object):
|
|||
force_permissive=force_permissive,
|
||||
setting_properties=_setting_properties,
|
||||
session=session, not_raises=not_raises,
|
||||
index=index)
|
||||
index=index, setitem=True)
|
||||
if props and not_raises:
|
||||
return props
|
||||
err = opt.impl_validate(value, fake_context, display_warnings=False, force_index=index,
|
||||
|
@ -458,15 +458,23 @@ class Values(object):
|
|||
|
||||
def validate(self, opt, value, path, check_frozen=True, force_permissive=False,
|
||||
setting_properties=undefined, valid_masterslave=True,
|
||||
not_raises=False, session=None, index=None):
|
||||
not_raises=False, session=None, index=None, setitem=False):
|
||||
if valid_masterslave and opt.impl_is_master_slaves():
|
||||
if session is None:
|
||||
session = self._p_.getsession()
|
||||
len_value = len(value)
|
||||
if opt.impl_is_master_slaves('master'):
|
||||
masterlen = len(value)
|
||||
slavelen = None
|
||||
else:
|
||||
masterlen = None
|
||||
slavelen = len(value)
|
||||
setitem = True
|
||||
val = opt.impl_get_master_slaves().validate(self, opt, len_value, path, session, setitem=setitem)
|
||||
if isinstance(val, Exception):
|
||||
return val
|
||||
opt.impl_get_master_slaves().impl_validate(self._getcontext(), force_permissive,
|
||||
setting_properties, masterlen=masterlen,
|
||||
slavelen=slavelen, opt=opt, setitem=True)
|
||||
#val = opt.impl_get_master_slaves().impl_validate(self, opt, len_value, path, session, setitem=setitem)
|
||||
#if isinstance(val, Exception):
|
||||
# return val
|
||||
props = self._getcontext().cfgimpl_get_settings().validate_properties(opt,
|
||||
False,
|
||||
check_frozen,
|
||||
|
@ -480,15 +488,17 @@ class Values(object):
|
|||
return props
|
||||
raise props
|
||||
|
||||
def _is_meta(self, opt, path, session):
|
||||
def _is_meta(self, opt, path, session=None, force_permissive=False):
|
||||
context = self._getcontext()
|
||||
if context.cfgimpl_get_meta() is None:
|
||||
return False
|
||||
setting = context.cfgimpl_get_settings()
|
||||
self_properties = setting._getproperties(opt, path, read_write=False)
|
||||
if self._p_.getowner(path, owners.default, session, only_default=True) is not owners.default:
|
||||
return False
|
||||
if context.cfgimpl_get_meta() is not None:
|
||||
return True
|
||||
return False
|
||||
if session is None:
|
||||
session = self._p_.getsession()
|
||||
return self.is_default_owner(opt, path=path, validate_properties=True,
|
||||
validate_meta=False, index=None,
|
||||
force_permissive=force_permissive)
|
||||
|
||||
def getowner(self, opt, index=None, force_permissive=False, session=None):
|
||||
"""
|
||||
|
@ -534,12 +544,12 @@ class Values(object):
|
|||
if opt.impl_is_master_slaves('slave'):
|
||||
master = opt.impl_get_master_slaves().getmaster(opt)
|
||||
masterp = master.impl_getpath(context)
|
||||
validate_meta = self._is_meta(opt, masterp, session)
|
||||
validate_meta = self._is_meta(master, masterp, session)
|
||||
else:
|
||||
validate_meta = True
|
||||
if validate_meta:
|
||||
if validate_meta and owner is owners.default:
|
||||
meta = context.cfgimpl_get_meta()
|
||||
if owner is owners.default and meta is not None:
|
||||
if meta is not None:
|
||||
owner = meta.cfgimpl_get_values()._getowner(opt, path, session,
|
||||
validate_properties=validate_properties,
|
||||
force_permissive=force_permissive,
|
||||
|
@ -571,7 +581,7 @@ class Values(object):
|
|||
raise props
|
||||
self._p_.setowner(path, owner, session, index=index)
|
||||
|
||||
def is_default_owner(self, opt, validate_properties=True,
|
||||
def is_default_owner(self, opt, path=None, validate_properties=True,
|
||||
validate_meta=True, index=None,
|
||||
force_permissive=False):
|
||||
"""
|
||||
|
@ -579,7 +589,8 @@ class Values(object):
|
|||
(not the toplevel config)
|
||||
:return: boolean
|
||||
"""
|
||||
path = opt.impl_getpath(self._getcontext())
|
||||
if path is None:
|
||||
path = opt.impl_getpath(self._getcontext())
|
||||
return self._is_default_owner(opt, path, session=None,
|
||||
validate_properties=validate_properties,
|
||||
validate_meta=validate_meta, index=index,
|
||||
|
|
Loading…
Reference in New Issue