follower option with consistency
This commit is contained in:
parent
73d45f54cf
commit
a33c7ed41e
|
@ -5,7 +5,7 @@ from .config import config_type, get_config, value_list, global_owner
|
|||
from py.test import raises
|
||||
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu import ChoiceOption, BoolOption, IntOption, IPOption, NetmaskOption, \
|
||||
from tiramisu import ChoiceOption, BoolOption, IntOption, IPOption, NetworkOption, NetmaskOption, \
|
||||
StrOption, OptionDescription, Leadership, Config
|
||||
from tiramisu.error import LeadershipError, PropertiesOptionError, APIError, ConfigError
|
||||
from tiramisu.storage import list_sessions
|
||||
|
@ -874,17 +874,19 @@ def test_follower_not_same_not_equal():
|
|||
|
||||
|
||||
def test_follower_consistency():
|
||||
ip_admin_eth1 = IPOption('ip_admin_eth1', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||
network_admin_eth1 = NetworkOption('network_admin_eth1', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||
netmask_admin_eth1 = NetmaskOption('netmask_admin_eth1', "masque du sous-réseau", multi=True)
|
||||
netmask_admin_eth1.impl_add_consistency('ip_netmask', ip_admin_eth1)
|
||||
interface1 = Leadership('interface1', '', [ip_admin_eth1, netmask_admin_eth1])
|
||||
netmask_admin_eth1.impl_add_consistency('network_netmask', network_admin_eth1)
|
||||
interface1 = Leadership('interface1', '', [network_admin_eth1, netmask_admin_eth1])
|
||||
od1 = OptionDescription('od', '', [interface1])
|
||||
maconfig = OptionDescription('toto', '', [od1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.property.read_write()
|
||||
cfg.option('od.interface1.ip_admin_eth1').value.set(['192.168.1.1', '192.168.2.1'])
|
||||
cfg.option('od.interface1.network_admin_eth1').value.set(['192.168.1.128', '192.168.2.0', '192.168.3.128'])
|
||||
cfg.option('od.interface1.netmask_admin_eth1', 0).value.set('255.255.255.128')
|
||||
cfg.option('od.interface1.netmask_admin_eth1', 1).value.set('255.255.255.0')
|
||||
cfg.option('od.interface1.ip_admin_eth1').value.pop(0)
|
||||
cfg.option('od.interface1.netmask_admin_eth1', 2).value.set('255.255.255.128')
|
||||
cfg.option('od.interface1.network_admin_eth1').value.pop(0)
|
||||
|
||||
|
||||
def test_follower_force_store_value():
|
||||
|
|
|
@ -282,8 +282,7 @@ class SubConfig(object):
|
|||
def getattr(self,
|
||||
name,
|
||||
option_bag,
|
||||
from_follower=False,
|
||||
follower_check_length=True):
|
||||
from_follower=False):
|
||||
"""
|
||||
attribute notation mechanism for accessing the value of an option
|
||||
:param name: attribute name
|
||||
|
@ -315,7 +314,7 @@ class SubConfig(object):
|
|||
if not from_follower or option_bag.option.impl_getrequires():
|
||||
self.cfgimpl_get_settings().validate_properties(option_bag)
|
||||
|
||||
if follower_check_length and option.impl_is_follower() and not from_follower:
|
||||
if option.impl_is_follower() and not from_follower:
|
||||
length = self.cfgimpl_get_length_leadership(option_bag)
|
||||
follower_len = self.cfgimpl_get_values()._p_.get_max_length(option_bag.path)
|
||||
if follower_len > length:
|
||||
|
@ -324,12 +323,8 @@ class SubConfig(object):
|
|||
follower_len,
|
||||
length,
|
||||
option_bag.index))
|
||||
else:
|
||||
length = None
|
||||
if option.impl_is_follower() and option_bag.index is None:
|
||||
value = []
|
||||
if length is None:
|
||||
length = self.cfgimpl_get_length_leadership(option_bag)
|
||||
for idx in range(length):
|
||||
soption_bag = OptionBag()
|
||||
soption_bag.set_option(option,
|
||||
|
|
|
@ -686,8 +686,7 @@ class Option(BaseOption):
|
|||
fromconsistency.append(cons_id)
|
||||
coption_bag.fromconsistency = fromconsistency
|
||||
current_value = option_bag.config_bag.context.getattr(path,
|
||||
coption_bag,
|
||||
follower_check_length=False)
|
||||
coption_bag)
|
||||
if index_ is None and index is not None:
|
||||
#if self is a follower and current_option is a leader and func not in ALLOWED_CONST_LIST
|
||||
#return only the value of the leader for isolate follower
|
||||
|
|
|
@ -513,12 +513,12 @@ class Values(object):
|
|||
length,
|
||||
option_bag.option.impl_get_display_name()))
|
||||
current_value.pop(index)
|
||||
self.setvalue(current_value,
|
||||
option_bag,
|
||||
_commit=True)
|
||||
subconfig.cfgimpl_get_description().pop(self,
|
||||
index,
|
||||
option_bag)
|
||||
self.setvalue(current_value,
|
||||
option_bag,
|
||||
_commit=True)
|
||||
|
||||
#______________________________________________________________________
|
||||
# information
|
||||
|
|
Loading…
Reference in New Issue