simplify netmaskoption
This commit is contained in:
parent
0e20318a9b
commit
74d367c731
1 changed files with 4 additions and 4 deletions
|
@ -54,21 +54,21 @@ class NetmaskOption(StrOption):
|
||||||
vals,
|
vals,
|
||||||
warnings_only,
|
warnings_only,
|
||||||
context):
|
context):
|
||||||
#opts must be (netmask, network) options
|
|
||||||
if context is undefined and len(vals) != 2:
|
if context is undefined and len(vals) != 2:
|
||||||
raise ConfigError(_('network_netmask needs a network and a netmask'))
|
raise ConfigError(_('network_netmask needs a network and a netmask'))
|
||||||
if None in vals or len(vals) != 2:
|
if None in vals or len(vals) != 2:
|
||||||
return
|
return
|
||||||
val_netmask, val_network = vals
|
val_netmask, val_network = vals
|
||||||
|
opt_netmask, opt_network = opts
|
||||||
try:
|
try:
|
||||||
ip_network('{0}/{1}'.format(val_network, val_netmask))
|
ip_network('{0}/{1}'.format(val_network, val_netmask))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if current_opt == opts[1]:
|
if current_opt == opt_network:
|
||||||
raise ValueError(_('with netmask "{0}" ("{1}")').format(val_netmask,
|
raise ValueError(_('with netmask "{0}" ("{1}")').format(val_netmask,
|
||||||
opts[0].impl_get_display_name()))
|
opt_netmask.impl_get_display_name()))
|
||||||
else:
|
else:
|
||||||
raise ValueError(_('with network "{0}" ("{1}")').format(val_network,
|
raise ValueError(_('with network "{0}" ("{1}")').format(val_network,
|
||||||
opts[1].impl_get_display_name()))
|
opt_network.impl_get_display_name()))
|
||||||
|
|
||||||
def _cons_ip_netmask(self,
|
def _cons_ip_netmask(self,
|
||||||
current_opt,
|
current_opt,
|
||||||
|
|
Loading…
Reference in a new issue