mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-07 05:43:26 +00:00
ipadnszone: Fix values accepted by allow_transfer and allow_query.
In FreeIPA CLI, The attributes `allow_query` and `allow_transfer` can hold IPv4 or IPv6 address or network address, and the values `none` and `any`. This patch adds support for network addresses, `none` and `any`, which were not supported. Fix issue #475.
This commit is contained in:
@@ -28,6 +28,7 @@ import os
|
||||
import uuid
|
||||
import tempfile
|
||||
import shutil
|
||||
import netaddr
|
||||
import gssapi
|
||||
from datetime import datetime
|
||||
from pprint import pformat
|
||||
@@ -413,6 +414,24 @@ def is_valid_port(port):
|
||||
return False
|
||||
|
||||
|
||||
def is_ip_address(ipaddr):
|
||||
"""Test if given IP address is a valid IPv4 or IPv6 address."""
|
||||
try:
|
||||
netaddr.IPAddress(str(ipaddr))
|
||||
except (netaddr.AddrFormatError, ValueError):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def is_ip_network_address(ipaddr):
|
||||
"""Test if given IP address is a valid IPv4 or IPv6 address."""
|
||||
try:
|
||||
netaddr.IPNetwork(str(ipaddr))
|
||||
except (netaddr.AddrFormatError, ValueError):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def is_ipv4_addr(ipaddr):
|
||||
"""Test if given IP address is a valid IPv4 address."""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user