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