refactor name only_private
This commit is contained in:
parent
162ae02df8
commit
2490d00935
|
@ -7,7 +7,7 @@ from tiramisu.option import IPOption, NetworkOption, NetmaskOption, \
|
|||
|
||||
def test_ip():
|
||||
a = IPOption('a', '')
|
||||
b = IPOption('b', '', only_private=True)
|
||||
b = IPOption('b', '', private_only=True)
|
||||
od = OptionDescription('od', '', [a, b])
|
||||
c = Config(od)
|
||||
c.a = '192.168.1.1'
|
||||
|
|
|
@ -756,15 +756,15 @@ class SymLinkOption(BaseOption):
|
|||
|
||||
class IPOption(Option):
|
||||
"represents the choice of an ip"
|
||||
__slots__ = ('_only_private', '_allow_reserved')
|
||||
__slots__ = ('_private_only', '_allow_reserved')
|
||||
_opt_type = 'ip'
|
||||
|
||||
def __init__(self, name, doc, default=None, default_multi=None,
|
||||
requires=None, multi=False, callback=None,
|
||||
callback_params=None, validator=None, validator_params=None,
|
||||
properties=None, only_private=False, allow_reserved=False,
|
||||
properties=None, private_only=False, allow_reserved=False,
|
||||
warnings_only=False):
|
||||
self._only_private = only_private
|
||||
self._private_only = private_only
|
||||
self._allow_reserved = allow_reserved
|
||||
super(IPOption, self).__init__(name, doc, default=default,
|
||||
default_multi=default_multi,
|
||||
|
@ -787,7 +787,7 @@ class IPOption(Option):
|
|||
ip = IP('{0}/32'.format(value))
|
||||
if not self._allow_reserved and ip.iptype() == 'RESERVED':
|
||||
raise ValueError(_("IP mustn't not be in reserved class"))
|
||||
if self._only_private and not ip.iptype() == 'PRIVATE':
|
||||
if self._private_only and not ip.iptype() == 'PRIVATE':
|
||||
raise ValueError(_("IP must be in private class"))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue