1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add copy of ipaddress.py from ansible.netcommon (#49)

* Add copy of ipaddress.py from ansible.netcommon, use that one in non-network modules.

* Copy required functions from ansible.netcommon. Simpler than using compat.ipaddress to do this.
This commit is contained in:
Felix Fontein 2020-03-26 21:44:26 +01:00 committed by GitHub
parent f799aa8356
commit 01ae744aa6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 2598 additions and 3 deletions

View file

File diff suppressed because it is too large Load diff

View file

@ -125,7 +125,7 @@ data:
''' '''
from ansible_collections.community.general.plugins.module_utils.scaleway import SCALEWAY_LOCATION, scaleway_argument_spec, Scaleway, payload_from_object from ansible_collections.community.general.plugins.module_utils.scaleway import SCALEWAY_LOCATION, scaleway_argument_spec, Scaleway, payload_from_object
from ansible_collections.ansible.netcommon.plugins.module_utils.compat.ipaddress import ip_network from ansible_collections.community.general.plugins.module_utils.compat.ipaddress import ip_network
from ansible.module_utils._text import to_text from ansible.module_utils._text import to_text
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule

View file

@ -270,7 +270,7 @@ firewall:
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible_collections.ansible.netcommon.plugins.module_utils.compat import ipaddress as compat_ipaddress from ansible_collections.community.general.plugins.module_utils.compat import ipaddress as compat_ipaddress
from ansible_collections.community.general.plugins.module_utils.hetzner import ( from ansible_collections.community.general.plugins.module_utils.hetzner import (
HETZNER_DEFAULT_ARGUMENT_SPEC, HETZNER_DEFAULT_ARGUMENT_SPEC,
BASE_URL, BASE_URL,

View file

@ -161,13 +161,30 @@ EXAMPLES = '''
RETURN = ''' # ''' RETURN = ''' # '''
import socket
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems from ansible.module_utils.six import iteritems
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import WapiModule from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import WapiModule
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import validate_ip_address, validate_ip_v6_address
from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import NIOS_IPV4_FIXED_ADDRESS, NIOS_IPV6_FIXED_ADDRESS from ansible_collections.community.general.plugins.module_utils.net_tools.nios.api import NIOS_IPV4_FIXED_ADDRESS, NIOS_IPV6_FIXED_ADDRESS
def validate_ip_address(address):
try:
socket.inet_aton(address)
except socket.error:
return False
return address.count(".") == 3
def validate_ip_v6_address(address):
try:
socket.inet_pton(socket.AF_INET6, address)
except socket.error:
return False
return True
def options(module): def options(module):
''' Transforms the module argument into a valid WAPI struct ''' Transforms the module argument into a valid WAPI struct
This function will transform the options argument into a structure that This function will transform the options argument into a structure that