mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 14:41:23 -07:00
Fixes ipv6 and defaults errors (#48776)
This commit is contained in:
parent
01b06dd5f2
commit
2cd4224fb3
2 changed files with 16 additions and 8 deletions
|
@ -94,12 +94,12 @@ def is_valid_ip_interface(address):
|
||||||
|
|
||||||
|
|
||||||
def get_netmask(address):
|
def get_netmask(address):
|
||||||
addr = ip_network(address)
|
addr = ip_network(u'{0}'.format(address))
|
||||||
netmask = addr.netmask.compressed
|
netmask = addr.netmask.compressed
|
||||||
return netmask
|
return netmask
|
||||||
|
|
||||||
|
|
||||||
def compress_address(address):
|
def compress_address(address):
|
||||||
addr = ip_network(address)
|
addr = ip_network(u'{0}'.format(address))
|
||||||
result = addr.compressed.split('/')[0]
|
result = addr.compressed.split('/')[0]
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -36,7 +36,9 @@ options:
|
||||||
description:
|
description:
|
||||||
- Netmask of the provided virtual address. This value cannot be
|
- Netmask of the provided virtual address. This value cannot be
|
||||||
modified after it is set.
|
modified after it is set.
|
||||||
default: 255.255.255.255
|
- When creating a new virtual address, if this parameter is not specified, the
|
||||||
|
default value is C(255.255.255.255) for IPv4 addresses and
|
||||||
|
C(ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff) for IPv6 addresses.
|
||||||
connection_limit:
|
connection_limit:
|
||||||
description:
|
description:
|
||||||
- Specifies the number of concurrent connections that the system
|
- Specifies the number of concurrent connections that the system
|
||||||
|
@ -279,6 +281,7 @@ try:
|
||||||
from library.module_utils.network.f5.common import fq_name
|
from library.module_utils.network.f5.common import fq_name
|
||||||
from library.module_utils.network.f5.common import f5_argument_spec
|
from library.module_utils.network.f5.common import f5_argument_spec
|
||||||
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
from library.module_utils.network.f5.ipaddress import compress_address
|
||||||
from library.module_utils.network.f5.icontrol import tmos_version
|
from library.module_utils.network.f5.icontrol import tmos_version
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from ansible.module_utils.network.f5.bigip import F5RestClient
|
from ansible.module_utils.network.f5.bigip import F5RestClient
|
||||||
|
@ -291,6 +294,7 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import fq_name
|
from ansible.module_utils.network.f5.common import fq_name
|
||||||
from ansible.module_utils.network.f5.common import f5_argument_spec
|
from ansible.module_utils.network.f5.common import f5_argument_spec
|
||||||
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
from ansible.module_utils.network.f5.ipaddress import compress_address
|
||||||
from ansible.module_utils.network.f5.icontrol import tmos_version
|
from ansible.module_utils.network.f5.icontrol import tmos_version
|
||||||
|
|
||||||
|
|
||||||
|
@ -487,7 +491,7 @@ class ModuleParameters(Parameters):
|
||||||
if self._values['address'] is None:
|
if self._values['address'] is None:
|
||||||
return None
|
return None
|
||||||
if is_valid_ip(self._values['address']):
|
if is_valid_ip(self._values['address']):
|
||||||
return self._values['address']
|
return compress_address(self._values['address'])
|
||||||
else:
|
else:
|
||||||
raise F5ModuleError(
|
raise F5ModuleError(
|
||||||
"The provided 'address' is not a valid IP address"
|
"The provided 'address' is not a valid IP address"
|
||||||
|
@ -713,6 +717,7 @@ class ModuleManager(object):
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
self._set_changed_options()
|
self._set_changed_options()
|
||||||
|
|
||||||
if self.want.traffic_group is None:
|
if self.want.traffic_group is None:
|
||||||
self.want.update({'traffic_group': '/Common/traffic-group-1'})
|
self.want.update({'traffic_group': '/Common/traffic-group-1'})
|
||||||
if self.want.arp is None:
|
if self.want.arp is None:
|
||||||
|
@ -720,6 +725,12 @@ class ModuleManager(object):
|
||||||
if self.want.spanning is None:
|
if self.want.spanning is None:
|
||||||
self.want.update({'spanning': False})
|
self.want.update({'spanning': False})
|
||||||
|
|
||||||
|
if self.want.netmask is None:
|
||||||
|
if is_valid_ip(self.want.address, type='ipv4'):
|
||||||
|
self.want.update({'netmask': '255.255.255.255'})
|
||||||
|
else:
|
||||||
|
self.want.update({'netmask': 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'})
|
||||||
|
|
||||||
if self.want.arp and self.want.spanning:
|
if self.want.arp and self.want.spanning:
|
||||||
raise F5ModuleError(
|
raise F5ModuleError(
|
||||||
"'arp' and 'spanning' cannot both be enabled on virtual address."
|
"'arp' and 'spanning' cannot both be enabled on virtual address."
|
||||||
|
@ -866,10 +877,7 @@ class ArgumentSpec(object):
|
||||||
),
|
),
|
||||||
name=dict(),
|
name=dict(),
|
||||||
address=dict(),
|
address=dict(),
|
||||||
netmask=dict(
|
netmask=dict(),
|
||||||
type='str',
|
|
||||||
default='255.255.255.255',
|
|
||||||
),
|
|
||||||
connection_limit=dict(
|
connection_limit=dict(
|
||||||
type='int'
|
type='int'
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue