api: get leader from leadership
This commit is contained in:
parent
de9485b74e
commit
1a5e4e37d1
1 changed files with 8 additions and 3 deletions
|
@ -26,7 +26,7 @@ from .i18n import _
|
||||||
from .setting import ConfigBag, OptionBag, owners, groups, undefined, \
|
from .setting import ConfigBag, OptionBag, owners, groups, undefined, \
|
||||||
FORBIDDEN_SET_PROPERTIES, SPECIAL_PROPERTIES
|
FORBIDDEN_SET_PROPERTIES, SPECIAL_PROPERTIES
|
||||||
from .config import KernelConfig, KernelGroupConfig, KernelMetaConfig, KernelMixConfig
|
from .config import KernelConfig, KernelGroupConfig, KernelMetaConfig, KernelMixConfig
|
||||||
from .option import RegexpOption, OptionDescription, ChoiceOption
|
from .option import RegexpOption, OptionDescription, ChoiceOption, Leadership
|
||||||
from .todict import TiramisuDict
|
from .todict import TiramisuDict
|
||||||
from .autolib import Calculation
|
from .autolib import Calculation
|
||||||
|
|
||||||
|
@ -129,6 +129,7 @@ def option_type(typ):
|
||||||
options_bag = self._get_options_bag('with_index' not in types)
|
options_bag = self._get_options_bag('with_index' not in types)
|
||||||
option = options_bag[-1].option
|
option = options_bag[-1].option
|
||||||
if option.impl_is_optiondescription() and 'optiondescription' in types or \
|
if option.impl_is_optiondescription() and 'optiondescription' in types or \
|
||||||
|
option.impl_is_optiondescription() and option.impl_is_leadership() and 'leadership' in types or \
|
||||||
not option.impl_is_optiondescription() and (
|
not option.impl_is_optiondescription() and (
|
||||||
option.impl_is_symlinkoption() and 'symlink' in types or \
|
option.impl_is_symlinkoption() and 'symlink' in types or \
|
||||||
not option.impl_is_symlinkoption() and (
|
not option.impl_is_symlinkoption() and (
|
||||||
|
@ -377,10 +378,14 @@ class _TiramisuOptionOption(_TiramisuOptionOptionDescription):
|
||||||
#FIXME only from 0.0.0.0 to 255.255.255.255
|
#FIXME only from 0.0.0.0 to 255.255.255.255
|
||||||
return r'^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'
|
return r'^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'
|
||||||
|
|
||||||
@option_type('option')
|
@option_type(['option', 'leadership'])
|
||||||
def leader(self, options_bag: List[OptionBag]):
|
def leader(self, options_bag: List[OptionBag]):
|
||||||
"""Get the leader option for a follower option"""
|
"""Get the leader option for a follower option"""
|
||||||
path = options_bag[-1].option.impl_get_leadership().get_leader().impl_getpath()
|
option = options_bag[-1].option
|
||||||
|
leadership = options_bag[-1].option
|
||||||
|
if not isinstance(option, Leadership):
|
||||||
|
leadership = leadership.impl_get_leadership()
|
||||||
|
path = leadership.get_leader().impl_getpath()
|
||||||
return TiramisuOption(path,
|
return TiramisuOption(path,
|
||||||
None,
|
None,
|
||||||
self._config_bag,
|
self._config_bag,
|
||||||
|
|
Loading…
Reference in a new issue