diff options
| author | Martin Basti <mbasti@redhat.com> | 2016-09-02 13:25:19 +0200 |
|---|---|---|
| committer | David Kupka <dkupka@redhat.com> | 2016-09-07 16:22:03 +0200 |
| commit | 81d64d530cca148198312d3d993502575b288f63 (patch) | |
| tree | 9bb1467d829f6fb59b2393c60246ac1e15a9bd7a /ipapython | |
| parent | daeaf2a8234ba684352d98fbc8d734100e6d63d1 (diff) | |
| download | freeipa-81d64d530cca148198312d3d993502575b288f63.tar.gz freeipa-81d64d530cca148198312d3d993502575b288f63.tar.xz freeipa-81d64d530cca148198312d3d993502575b288f63.zip | |
Allow network ip addresses
Currently cloud environments uses heavily prefix /32 (/128) what makes
IPA validators to fail. IPA should not care if IP address is network or not.
This commit allows usage of network addresses in:
* host plugin
* dns plugin
* server-installer
* client-installer
https://fedorahosted.org/freeipa/ticket/5814
Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipapython')
| -rw-r--r-- | ipapython/ipautil.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 8de9acfb0..8a9aa0ed2 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -132,8 +132,8 @@ class CheckedIPAddress(UnsafeIPAddress): Reserved or link-local addresses are never accepted. """ def __init__(self, addr, match_local=False, parse_netmask=True, - allow_network=False, allow_loopback=False, - allow_broadcast=False, allow_multicast=False): + allow_loopback=False, allow_broadcast=False, + allow_multicast=False): super(CheckedIPAddress, self).__init__(addr) if isinstance(addr, CheckedIPAddress): @@ -199,14 +199,15 @@ class CheckedIPAddress(UnsafeIPAddress): elif self.version == 6: self._net = netaddr.IPNetwork(str(self) + '/64') - if not allow_network and self == self._net.network: - raise ValueError("cannot use IP network address {}".format(addr)) if not allow_broadcast and (self.version == 4 and self == self._net.broadcast): raise ValueError("cannot use broadcast IP address {}".format(addr)) self.prefixlen = self._net.prefixlen + def is_network_addr(self): + return self == self._net.network + def valid_ip(addr): return netaddr.valid_ipv4(addr) or netaddr.valid_ipv6(addr) |
