diff --git a/tiramisu/option/netmaskoption.py b/tiramisu/option/netmaskoption.py index 58d7ffa..0e4d196 100644 --- a/tiramisu/option/netmaskoption.py +++ b/tiramisu/option/netmaskoption.py @@ -77,29 +77,28 @@ class NetmaskOption(StrOption): warnings_only, context, _cidr=False): - # opts must be (netmask, ip) options if context is undefined and len(vals) != 2: raise ConfigError(_('ip_netmask needs an IP and a netmask')) if None in vals or len(vals) != 2: return - msg = None val_netmask, val_ip = vals + opt_netmask, opt_ip = opts ip = ip_interface('{0}/{1}'.format(val_ip, val_netmask)) - network = ip.network - if ip.ip == network.network_address: - if not _cidr and current_opt == opts[1]: - msg = _('this is a network with netmask "{0}" ("{1}")') - else: - msg = _('IP "{0}" ("{1}") is the network') - elif ip.ip == network.broadcast_address: - if not _cidr and current_opt == opts[1]: - msg = _('this is a broadcast with netmask "{0}" ("{1}")') - else: - msg = _('IP "{0}" ("{1}") is the broadcast') - if msg is not None: - if not _cidr and current_opt == opts[1]: - raise ValueError(msg.format(val_netmask, - opts[0].impl_get_display_name())) - else: - raise ValueError(msg.format(val_ip, - opts[1].impl_get_display_name())) + if not _cidr and current_opt == opt_ip + if ip.ip == ip.network.network_address: + raise ValueError( _('this is a network with netmask "{0}" ("{1}")' + '').format(val_netmask, + opt_netmask.impl_get_display_name())) + elif ip.ip == ip.network.broadcast_address: + raise ValueError(_('this is a broadcast with netmask "{0}" ("{1}")' + '').format(val_netmask, + opt_netmask.impl_get_display_name())) + else: + if ip.ip == ip.network.network_address: + raise ValueError(_('IP "{0}" ("{1}") is the network' + '').format(val_ip, + opt_ip.impl_get_display_name())) + elif ip.ip == ip.network.broadcast_address: + raise ValueError(_('IP "{0}" ("{1}") is the broadcast' + '')format(val_ip, + opt_ip.impl_get_display_name()))