mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-12 11:24:00 -07:00
Update f5 module_utils from downstream (#44092)
Upstreaming fixes and features for f5 module_utils as part of 2.7 dev cycle
This commit is contained in:
parent
cda3b53035
commit
96a6011b3f
3 changed files with 104 additions and 42 deletions
|
@ -7,7 +7,23 @@ from __future__ import absolute_import, division, print_function
|
|||
__metaclass__ = type
|
||||
|
||||
from ansible.module_utils.network.common.utils import validate_ip_address
|
||||
from ansible.module_utils.network.common.utils import validate_ip_v6_address
|
||||
|
||||
try:
|
||||
# Ansible 2.6 and later
|
||||
from ansible.module_utils.network.common.utils import validate_ip_v6_address
|
||||
except ImportError:
|
||||
import socket
|
||||
|
||||
# Ansible 2.5 and earlier
|
||||
#
|
||||
# This method is simply backported from the 2.6 source code.
|
||||
def validate_ip_v6_address(address):
|
||||
try:
|
||||
socket.inet_pton(socket.AF_INET6, address)
|
||||
except socket.error:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
try:
|
||||
from library.module_utils.compat.ipaddress import ip_interface
|
||||
|
@ -63,7 +79,7 @@ def ipv6_netmask_to_cidr(mask):
|
|||
|
||||
def is_valid_ip_network(address):
|
||||
try:
|
||||
ip_network(address)
|
||||
ip_network(u'{0}'.format(address))
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
@ -71,7 +87,7 @@ def is_valid_ip_network(address):
|
|||
|
||||
def is_valid_ip_interface(address):
|
||||
try:
|
||||
ip_interface(address)
|
||||
ip_interface(u'{0}'.format(address))
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue