Add parameter and remove netaddr (#44584)

This patch adds a description parameter to most fields. It also removes
netaddr from the modules.
pull/44594/head
Tim Rupp 6 years ago committed by GitHub
parent 31a5b874a1
commit 1fd6821db0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -24,12 +24,16 @@ options:
description: description:
- Specifies the name of the monitor. - Specifies the name of the monitor.
required: True required: True
description:
description:
- The description of the monitor.
version_added: 2.7
parent: parent:
description: description:
- The parent template of this monitor template. Once this value has - The parent template of this monitor template. Once this value has
been set, it cannot be changed. By default, this value is the C(http) been set, it cannot be changed. By default, this value is the C(http)
parent on the C(Common) partition. parent on the C(Common) partition.
default: "/Common/external" default: /Common/external
arguments: arguments:
description: description:
- Specifies any command-line arguments that the script requires. - Specifies any command-line arguments that the script requires.
@ -59,12 +63,14 @@ options:
timeout: timeout:
description: description:
- The number of seconds in which the node or service must respond to - The number of seconds in which the node or service must respond to
the monitor request. If the target responds within the set time the monitor request.
period, it is considered up. If the target does not respond within - If the target responds within the set time period, it is considered up.
the set time period, it is considered down. You can change this - If the target does not respond within the set time period, it is considered
number to any number you want, however, it should be 3 times the down.
interval number of seconds plus 1 second. If this parameter is not - You can change this number to any number you want, however, it should be
provided when creating a new monitor, then the default value will be 16. 3 times the interval number of seconds plus 1 second.
- If this parameter is not provided when creating a new monitor, then the
default value will be C(16).
variables: variables:
description: description:
- Specifies any variables that the script requires. - Specifies any variables that the script requires.
@ -84,6 +90,7 @@ options:
extends_documentation_fragment: f5 extends_documentation_fragment: f5
author: author:
- Tim Rupp (@caphrim007) - Tim Rupp (@caphrim007)
- Wojciech Wypior (@wojtek0806)
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@ -130,6 +137,11 @@ parent:
returned: changed returned: changed
type: string type: string
sample: external sample: external
description:
description: The description of the monitor.
returned: changed
type: str
sample: Important Monitor
ip: ip:
description: The new IP of IP/port definition. description: The new IP of IP/port definition.
returned: changed returned: changed
@ -163,6 +175,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.common import compare_dictionary from library.module_utils.network.f5.common import compare_dictionary
from library.module_utils.network.f5.ipaddress import is_valid_ip
try: try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
@ -176,17 +189,12 @@ 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.common import compare_dictionary from ansible.module_utils.network.f5.common import compare_dictionary
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
try: try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
HAS_F5SDK = False HAS_F5SDK = False
try:
import netaddr
HAS_NETADDR = True
except ImportError:
HAS_NETADDR = False
class Parameters(AnsibleF5Parameters): class Parameters(AnsibleF5Parameters):
api_map = { api_map = {
@ -197,17 +205,17 @@ class Parameters(AnsibleF5Parameters):
} }
api_attributes = [ api_attributes = [
'defaultsFrom', 'interval', 'timeout', 'destination', 'run', 'args' 'defaultsFrom', 'interval', 'timeout', 'destination', 'run', 'args', 'description'
] ]
returnables = [ returnables = [
'parent', 'ip', 'port', 'interval', 'timeout', 'variables', 'external_program', 'parent', 'ip', 'port', 'interval', 'timeout', 'variables', 'external_program',
'arguments' 'arguments', 'description'
] ]
updatables = [ updatables = [
'destination', 'interval', 'timeout', 'variables', 'external_program', 'destination', 'interval', 'timeout', 'variables', 'external_program',
'arguments' 'arguments', 'description'
] ]
def to_return(self): def to_return(self):
@ -256,12 +264,11 @@ class Parameters(AnsibleF5Parameters):
def ip(self): def ip(self):
if self._values['ip'] is None: if self._values['ip'] is None:
return None return None
try:
if self._values['ip'] in ['*', '0.0.0.0']: if self._values['ip'] in ['*', '0.0.0.0']:
return '*' return '*'
result = str(netaddr.IPAddress(self._values['ip'])) elif is_valid_ip(self._values['ip']):
return result return self._values['ip']
except netaddr.core.AddrFormatError: else:
raise F5ModuleError( raise F5ModuleError(
"The provided 'ip' parameter is not an IP address." "The provided 'ip' parameter is not an IP address."
) )
@ -609,6 +616,7 @@ class ArgumentSpec(object):
argument_spec = dict( argument_spec = dict(
name=dict(required=True), name=dict(required=True),
parent=dict(default='/Common/external'), parent=dict(default='/Common/external'),
description=dict(),
arguments=dict(), arguments=dict(),
ip=dict(), ip=dict(),
port=dict(type='int'), port=dict(type='int'),

@ -28,7 +28,11 @@ options:
- The parent template of this monitor template. Once this value has - The parent template of this monitor template. Once this value has
been set, it cannot be changed. By default, this value is the C(http) been set, it cannot be changed. By default, this value is the C(http)
parent on the C(Common) partition. parent on the C(Common) partition.
default: "/Common/http" default: /Common/http
description:
description:
- The description of the monitor.
version_added: 2.7
send: send:
description: description:
- The send string for the monitor call. When creating a new monitor, if - The send string for the monitor call. When creating a new monitor, if
@ -100,6 +104,7 @@ notes:
extends_documentation_fragment: f5 extends_documentation_fragment: f5
author: author:
- Tim Rupp (@caphrim007) - Tim Rupp (@caphrim007)
- Wojciech Wypior (@wojtek0806)
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@ -140,6 +145,11 @@ parent:
returned: changed returned: changed
type: string type: string
sample: http sample: http
description:
description: The description of the monitor.
returned: changed
type: str
sample: Important_Monitor
ip: ip:
description: The new IP of IP/port definition. description: The new IP of IP/port definition.
returned: changed returned: changed
@ -173,6 +183,7 @@ try:
from library.module_utils.network.f5.common import cleanup_tokens from library.module_utils.network.f5.common import cleanup_tokens
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
try: try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
@ -185,17 +196,12 @@ except ImportError:
from ansible.module_utils.network.f5.common import cleanup_tokens from ansible.module_utils.network.f5.common import cleanup_tokens
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
try: try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
HAS_F5SDK = False HAS_F5SDK = False
try:
import netaddr
HAS_NETADDR = True
except ImportError:
HAS_NETADDR = False
class Parameters(AnsibleF5Parameters): class Parameters(AnsibleF5Parameters):
api_map = { api_map = {
@ -207,17 +213,17 @@ class Parameters(AnsibleF5Parameters):
api_attributes = [ api_attributes = [
'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'recv', 'send', 'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'recv', 'send',
'destination', 'username', 'password', 'recvDisable' 'destination', 'username', 'password', 'recvDisable', 'description'
] ]
returnables = [ returnables = [
'parent', 'send', 'receive', 'ip', 'port', 'interval', 'timeout', 'parent', 'send', 'receive', 'ip', 'port', 'interval', 'timeout',
'time_until_up', 'receive_disable' 'time_until_up', 'receive_disable', 'description'
] ]
updatables = [ updatables = [
'destination', 'send', 'receive', 'interval', 'timeout', 'time_until_up', 'destination', 'send', 'receive', 'interval', 'timeout', 'time_until_up',
'target_username', 'target_password', 'receive_disable' 'target_username', 'target_password', 'receive_disable', 'description'
] ]
def to_return(self): def to_return(self):
@ -266,12 +272,11 @@ class Parameters(AnsibleF5Parameters):
def ip(self): def ip(self):
if self._values['ip'] is None: if self._values['ip'] is None:
return None return None
try:
if self._values['ip'] in ['*', '0.0.0.0']: if self._values['ip'] in ['*', '0.0.0.0']:
return '*' return '*'
result = str(netaddr.IPAddress(self._values['ip'])) elif is_valid_ip(self._values['ip']):
return result return self._values['ip']
except netaddr.core.AddrFormatError: else:
raise F5ModuleError( raise F5ModuleError(
"The provided 'ip' parameter is not an IP address." "The provided 'ip' parameter is not an IP address."
) )
@ -545,6 +550,7 @@ class ArgumentSpec(object):
argument_spec = dict( argument_spec = dict(
name=dict(required=True), name=dict(required=True),
parent=dict(default='/Common/http'), parent=dict(default='/Common/http'),
description=dict(),
send=dict(), send=dict(),
receive=dict(), receive=dict(),
receive_disable=dict(required=False), receive_disable=dict(required=False),
@ -578,8 +584,6 @@ def main():
) )
if not HAS_F5SDK: if not HAS_F5SDK:
module.fail_json(msg="The python f5-sdk module is required") module.fail_json(msg="The python f5-sdk module is required")
if not HAS_NETADDR:
module.fail_json(msg="The python netaddr module is required")
try: try:
client = F5Client(**module.params) client = F5Client(**module.params)

@ -23,12 +23,16 @@ options:
description: description:
- Monitor name. - Monitor name.
required: True required: True
description:
description:
- The description of the monitor.
version_added: 2.7
parent: parent:
description: description:
- The parent template of this monitor template. Once this value has - The parent template of this monitor template. Once this value has
been set, it cannot be changed. By default, this value is the C(https) been set, it cannot be changed. By default, this value is the C(https)
parent on the C(Common) partition. parent on the C(Common) partition.
default: "/Common/https" default: /Common/https
send: send:
description: description:
- The send string for the monitor call. When creating a new monitor, if - The send string for the monitor call. When creating a new monitor, if
@ -99,6 +103,7 @@ notes:
extends_documentation_fragment: f5 extends_documentation_fragment: f5
author: author:
- Tim Rupp (@caphrim007) - Tim Rupp (@caphrim007)
- Wojciech Wypior (@wojtek0806)
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@ -138,6 +143,11 @@ interval:
returned: changed returned: changed
type: int type: int
sample: 2 sample: 2
description:
description: The description of the monitor.
returned: changed
type: str
sample: Important Monitor
timeout: timeout:
description: The new timeout in which the remote system must respond to the monitor. description: The new timeout in which the remote system must respond to the monitor.
returned: changed returned: changed
@ -161,6 +171,7 @@ try:
from library.module_utils.network.f5.common import cleanup_tokens from library.module_utils.network.f5.common import cleanup_tokens
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
try: try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
@ -173,17 +184,12 @@ except ImportError:
from ansible.module_utils.network.f5.common import cleanup_tokens from ansible.module_utils.network.f5.common import cleanup_tokens
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
try: try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
HAS_F5SDK = False HAS_F5SDK = False
try:
import netaddr
HAS_NETADDR = True
except ImportError:
HAS_NETADDR = False
class Parameters(AnsibleF5Parameters): class Parameters(AnsibleF5Parameters):
api_map = { api_map = {
@ -195,17 +201,17 @@ class Parameters(AnsibleF5Parameters):
api_attributes = [ api_attributes = [
'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'recv', 'send', 'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'recv', 'send',
'destination', 'username', 'password', 'recvDisable' 'destination', 'username', 'password', 'recvDisable', 'description'
] ]
returnables = [ returnables = [
'parent', 'send', 'receive', 'ip', 'port', 'interval', 'timeout', 'parent', 'send', 'receive', 'ip', 'port', 'interval', 'timeout',
'time_until_up', 'receive_disable' 'time_until_up', 'receive_disable', 'description'
] ]
updatables = [ updatables = [
'destination', 'send', 'receive', 'interval', 'timeout', 'time_until_up', 'destination', 'send', 'receive', 'interval', 'timeout', 'time_until_up',
'target_username', 'target_password', 'receive_disable' 'target_username', 'target_password', 'receive_disable', 'description'
] ]
def to_return(self): def to_return(self):
@ -262,12 +268,10 @@ class Parameters(AnsibleF5Parameters):
def ip(self): def ip(self):
if self._values['ip'] is None: if self._values['ip'] is None:
return None return None
try: elif self._values['ip'] in ['*', '0.0.0.0']:
if self._values['ip'] in ['*', '0.0.0.0']:
return '*' return '*'
result = str(netaddr.IPAddress(self._values['ip'])) elif is_valid_ip(self._values['ip']):
return result return self._values['ip']
except netaddr.core.AddrFormatError:
raise F5ModuleError( raise F5ModuleError(
"The provided 'ip' parameter is not an IP address." "The provided 'ip' parameter is not an IP address."
) )
@ -530,6 +534,7 @@ class ArgumentSpec(object):
argument_spec = dict( argument_spec = dict(
name=dict(required=True), name=dict(required=True),
parent=dict(default='/Common/https'), parent=dict(default='/Common/https'),
description=dict(),
send=dict(), send=dict(),
receive=dict(), receive=dict(),
receive_disable=dict(required=False), receive_disable=dict(required=False),
@ -563,8 +568,6 @@ def main():
) )
if not HAS_F5SDK: if not HAS_F5SDK:
module.fail_json(msg="The python f5-sdk module is required") module.fail_json(msg="The python f5-sdk module is required")
if not HAS_NETADDR:
module.fail_json(msg="The python netaddr module is required")
try: try:
client = F5Client(**module.params) client = F5Client(**module.params)

@ -129,6 +129,7 @@ notes:
extends_documentation_fragment: f5 extends_documentation_fragment: f5
author: author:
- Tim Rupp (@caphrim007) - Tim Rupp (@caphrim007)
- Wojciech Wypior (@wojtek0806)
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@ -157,6 +158,11 @@ parent:
returned: changed returned: changed
type: string type: string
sample: snmp_dca sample: snmp_dca
description:
description: The description of the monitor.
returned: changed
type: str
sample: Important Monitor
interval: interval:
description: The new interval in which to run the monitor check. description: The new interval in which to run the monitor check.
returned: changed returned: changed
@ -264,7 +270,7 @@ class Parameters(AnsibleF5Parameters):
api_attributes = [ api_attributes = [
'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'destination', 'community', 'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'destination', 'community',
'version', 'agentType', 'cpuCoefficient', 'cpuThreshold', 'memoryCoefficient', 'version', 'agentType', 'cpuCoefficient', 'cpuThreshold', 'memoryCoefficient',
'memoryThreshold', 'diskCoefficient', 'diskThreshold' 'memoryThreshold', 'diskCoefficient', 'diskThreshold', 'description'
] ]
returnables = [ returnables = [

@ -29,6 +29,10 @@ options:
been set, it cannot be changed. By default, this value is the C(tcp) been set, it cannot be changed. By default, this value is the C(tcp)
parent on the C(Common) partition. parent on the C(Common) partition.
default: /Common/tcp default: /Common/tcp
description:
description:
- The description of the monitor.
version_added: 2.7
send: send:
description: description:
- The send string for the monitor call. - The send string for the monitor call.
@ -90,6 +94,7 @@ notes:
extends_documentation_fragment: f5 extends_documentation_fragment: f5
author: author:
- Tim Rupp (@caphrim007) - Tim Rupp (@caphrim007)
- Wojciech Wypior (@wojtek0806)
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@ -126,6 +131,11 @@ send:
returned: changed returned: changed
type: string type: string
sample: tcp string to send sample: tcp string to send
description:
description: The description of the monitor.
returned: changed
type: str
sample: Important Monitor
receive: receive:
description: The new receive string for this monitor. description: The new receive string for this monitor.
returned: changed returned: changed
@ -169,6 +179,7 @@ try:
from library.module_utils.network.f5.common import cleanup_tokens from library.module_utils.network.f5.common import cleanup_tokens
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
try: try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
@ -181,17 +192,12 @@ except ImportError:
from ansible.module_utils.network.f5.common import cleanup_tokens from ansible.module_utils.network.f5.common import cleanup_tokens
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
try: try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
HAS_F5SDK = False HAS_F5SDK = False
try:
import netaddr
HAS_NETADDR = True
except ImportError:
HAS_NETADDR = False
class Parameters(AnsibleF5Parameters): class Parameters(AnsibleF5Parameters):
api_map = { api_map = {
@ -202,16 +208,17 @@ class Parameters(AnsibleF5Parameters):
api_attributes = [ api_attributes = [
'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'recv', 'send', 'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'recv', 'send',
'destination' 'destination', 'description'
] ]
returnables = [ returnables = [
'parent', 'send', 'receive', 'ip', 'port', 'interval', 'timeout', 'parent', 'send', 'receive', 'ip', 'port', 'interval', 'timeout',
'time_until_up' 'time_until_up', 'description'
] ]
updatables = [ updatables = [
'destination', 'send', 'receive', 'interval', 'timeout', 'time_until_up' 'destination', 'send', 'receive', 'interval', 'timeout', 'time_until_up',
'description'
] ]
def to_return(self): def to_return(self):
@ -254,12 +261,11 @@ class Parameters(AnsibleF5Parameters):
def ip(self): def ip(self):
if self._values['ip'] is None: if self._values['ip'] is None:
return None return None
try:
if self._values['ip'] in ['*', '0.0.0.0']: if self._values['ip'] in ['*', '0.0.0.0']:
return '*' return '*'
result = str(netaddr.IPAddress(self._values['ip'])) if is_valid_ip(self._values['ip']):
return result return self._values['ip']
except netaddr.core.AddrFormatError: else:
raise F5ModuleError( raise F5ModuleError(
"The provided 'ip' parameter is not an IP address." "The provided 'ip' parameter is not an IP address."
) )
@ -536,6 +542,7 @@ class ArgumentSpec(object):
argument_spec = dict( argument_spec = dict(
name=dict(required=True), name=dict(required=True),
parent=dict(default='/Common/tcp'), parent=dict(default='/Common/tcp'),
description=dict(),
send=dict(), send=dict(),
receive=dict(), receive=dict(),
ip=dict(), ip=dict(),
@ -566,8 +573,6 @@ def main():
) )
if not HAS_F5SDK: if not HAS_F5SDK:
module.fail_json(msg="The python f5-sdk module is required") module.fail_json(msg="The python f5-sdk module is required")
if not HAS_NETADDR:
module.fail_json(msg="The python netaddr module is required")
try: try:
client = F5Client(**module.params) client = F5Client(**module.params)

@ -29,6 +29,10 @@ options:
been set, it cannot be changed. By default, this value is the C(tcp_echo) been set, it cannot be changed. By default, this value is the C(tcp_echo)
parent on the C(Common) partition. parent on the C(Common) partition.
default: /Common/tcp_echo default: /Common/tcp_echo
description:
description:
- The description of the monitor.
version_added: 2.7
ip: ip:
description: description:
- IP address part of the IP/port definition. If this parameter is not - IP address part of the IP/port definition. If this parameter is not
@ -77,6 +81,7 @@ notes:
extends_documentation_fragment: f5 extends_documentation_fragment: f5
author: author:
- Tim Rupp (@caphrim007) - Tim Rupp (@caphrim007)
- Wojciech Wypior (@wojtek0806)
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@ -111,6 +116,11 @@ ip:
returned: changed returned: changed
type: string type: string
sample: 10.12.13.14 sample: 10.12.13.14
description:
description: The description of the monitor.
returned: changed
type: str
sample: Important Monitor
interval: interval:
description: The new interval in which to run the monitor check. description: The new interval in which to run the monitor check.
returned: changed returned: changed
@ -140,6 +150,7 @@ try:
from library.module_utils.network.f5.common import AnsibleF5Parameters from library.module_utils.network.f5.common import AnsibleF5Parameters
from library.module_utils.network.f5.common import cleanup_tokens from library.module_utils.network.f5.common import cleanup_tokens
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
try: try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
@ -151,17 +162,12 @@ except ImportError:
from ansible.module_utils.network.f5.common import AnsibleF5Parameters from ansible.module_utils.network.f5.common import AnsibleF5Parameters
from ansible.module_utils.network.f5.common import cleanup_tokens from ansible.module_utils.network.f5.common import cleanup_tokens
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
try: try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
HAS_F5SDK = False HAS_F5SDK = False
try:
import netaddr
HAS_NETADDR = True
except ImportError:
HAS_NETADDR = False
class Parameters(AnsibleF5Parameters): class Parameters(AnsibleF5Parameters):
api_map = { api_map = {
@ -170,15 +176,16 @@ class Parameters(AnsibleF5Parameters):
} }
api_attributes = [ api_attributes = [
'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'destination' 'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'destination',
'description'
] ]
returnables = [ returnables = [
'parent', 'ip', 'interval', 'timeout', 'time_until_up' 'parent', 'ip', 'interval', 'timeout', 'time_until_up', 'description'
] ]
updatables = [ updatables = [
'ip', 'interval', 'timeout', 'time_until_up' 'ip', 'interval', 'timeout', 'time_until_up', 'description'
] ]
def to_return(self): def to_return(self):
@ -211,12 +218,11 @@ class Parameters(AnsibleF5Parameters):
def ip(self): def ip(self):
if self._values['ip'] is None: if self._values['ip'] is None:
return None return None
try:
if self._values['ip'] in ['*', '0.0.0.0']: if self._values['ip'] in ['*', '0.0.0.0']:
return '*' return '*'
result = str(netaddr.IPAddress(self._values['ip'])) elif is_valid_ip(self._values['ip']):
return result return self._values['ip']
except netaddr.core.AddrFormatError: else:
raise F5ModuleError( raise F5ModuleError(
"The provided 'ip' parameter is not an IP address." "The provided 'ip' parameter is not an IP address."
) )
@ -469,6 +475,7 @@ class ArgumentSpec(object):
argument_spec = dict( argument_spec = dict(
name=dict(required=True), name=dict(required=True),
parent=dict(default='/Common/tcp_echo'), parent=dict(default='/Common/tcp_echo'),
description=dict(),
ip=dict(), ip=dict(),
interval=dict(type='int'), interval=dict(type='int'),
timeout=dict(type='int'), timeout=dict(type='int'),
@ -496,8 +503,6 @@ def main():
) )
if not HAS_F5SDK: if not HAS_F5SDK:
module.fail_json(msg="The python f5-sdk module is required") module.fail_json(msg="The python f5-sdk module is required")
if not HAS_NETADDR:
module.fail_json(msg="The python netaddr module is required")
try: try:
client = F5Client(**module.params) client = F5Client(**module.params)

@ -28,7 +28,11 @@ options:
- The parent template of this monitor template. Once this value has - The parent template of this monitor template. Once this value has
been set, it cannot be changed. By default, this value is the C(tcp_half_open) been set, it cannot be changed. By default, this value is the C(tcp_half_open)
parent on the C(Common) partition. parent on the C(Common) partition.
default: "/Common/tcp_half_open" default: /Common/tcp_half_open
description:
description:
- The description of the monitor.
version_added: 2.7
ip: ip:
description: description:
- IP address part of the IP/port definition. If this parameter is not - IP address part of the IP/port definition. If this parameter is not
@ -84,6 +88,7 @@ notes:
extends_documentation_fragment: f5 extends_documentation_fragment: f5
author: author:
- Tim Rupp (@caphrim007) - Tim Rupp (@caphrim007)
- Wojciech Wypior (@wojtek0806)
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@ -122,6 +127,11 @@ parent:
returned: changed returned: changed
type: string type: string
sample: tcp sample: tcp
description:
description: The description of the monitor.
returned: changed
type: str
sample: Important Monitor
ip: ip:
description: The new IP of IP/port definition. description: The new IP of IP/port definition.
returned: changed returned: changed
@ -156,6 +166,7 @@ try:
from library.module_utils.network.f5.common import AnsibleF5Parameters from library.module_utils.network.f5.common import AnsibleF5Parameters
from library.module_utils.network.f5.common import cleanup_tokens from library.module_utils.network.f5.common import cleanup_tokens
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
try: try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
@ -167,17 +178,12 @@ except ImportError:
from ansible.module_utils.network.f5.common import AnsibleF5Parameters from ansible.module_utils.network.f5.common import AnsibleF5Parameters
from ansible.module_utils.network.f5.common import cleanup_tokens from ansible.module_utils.network.f5.common import cleanup_tokens
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
try: try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
HAS_F5SDK = False HAS_F5SDK = False
try:
import netaddr
HAS_NETADDR = True
except ImportError:
HAS_NETADDR = False
class Parameters(AnsibleF5Parameters): class Parameters(AnsibleF5Parameters):
api_map = { api_map = {
@ -187,15 +193,17 @@ class Parameters(AnsibleF5Parameters):
} }
api_attributes = [ api_attributes = [
'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'destination' 'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'destination',
'description'
] ]
returnables = [ returnables = [
'parent', 'ip', 'port', 'interval', 'timeout', 'time_until_up' 'parent', 'ip', 'port', 'interval', 'timeout', 'time_until_up',
'description'
] ]
updatables = [ updatables = [
'destination', 'interval', 'timeout', 'time_until_up' 'destination', 'interval', 'timeout', 'time_until_up', 'description'
] ]
def to_return(self): def to_return(self):
@ -244,12 +252,10 @@ class Parameters(AnsibleF5Parameters):
def ip(self): def ip(self):
if self._values['ip'] is None: if self._values['ip'] is None:
return None return None
try: elif self._values['ip'] in ['*', '0.0.0.0']:
if self._values['ip'] in ['*', '0.0.0.0']:
return '*' return '*'
result = str(netaddr.IPAddress(self._values['ip'])) elif is_valid_ip(self._values['ip']):
return result return self._values['ip']
except netaddr.core.AddrFormatError:
raise F5ModuleError( raise F5ModuleError(
"The provided 'ip' parameter is not an IP address." "The provided 'ip' parameter is not an IP address."
) )
@ -514,6 +520,7 @@ class ArgumentSpec(object):
argument_spec = dict( argument_spec = dict(
name=dict(required=True), name=dict(required=True),
parent=dict(default='/Common/tcp_half_open'), parent=dict(default='/Common/tcp_half_open'),
description=dict(),
ip=dict(), ip=dict(),
port=dict(type='int'), port=dict(type='int'),
interval=dict(type='int'), interval=dict(type='int'),
@ -542,8 +549,6 @@ def main():
) )
if not HAS_F5SDK: if not HAS_F5SDK:
module.fail_json(msg="The python f5-sdk module is required") module.fail_json(msg="The python f5-sdk module is required")
if not HAS_NETADDR:
module.fail_json(msg="The python netaddr module is required")
try: try:
client = F5Client(**module.params) client = F5Client(**module.params)

@ -28,7 +28,11 @@ options:
- The parent template of this monitor template. Once this value has - The parent template of this monitor template. Once this value has
been set, it cannot be changed. By default, this value is the C(udp) been set, it cannot be changed. By default, this value is the C(udp)
parent on the C(Common) partition. parent on the C(Common) partition.
default: "/Common/udp" default: /Common/udp
description:
description:
- The description of the monitor.
version_added: 2.7
send: send:
description: description:
- The send string for the monitor call. When creating a new monitor, if - The send string for the monitor call. When creating a new monitor, if
@ -94,6 +98,7 @@ notes:
extends_documentation_fragment: f5 extends_documentation_fragment: f5
author: author:
- Tim Rupp (@caphrim007) - Tim Rupp (@caphrim007)
- Wojciech Wypior (@wojtek0806)
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@ -123,6 +128,11 @@ parent:
returned: changed returned: changed
type: string type: string
sample: http sample: http
description:
description: The description of the monitor.
returned: changed
type: str
sample: Important Monitor
ip: ip:
description: The new IP of IP/port definition. description: The new IP of IP/port definition.
returned: changed returned: changed
@ -157,6 +167,7 @@ try:
from library.module_utils.network.f5.common import AnsibleF5Parameters from library.module_utils.network.f5.common import AnsibleF5Parameters
from library.module_utils.network.f5.common import cleanup_tokens from library.module_utils.network.f5.common import cleanup_tokens
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
try: try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
@ -168,17 +179,12 @@ except ImportError:
from ansible.module_utils.network.f5.common import AnsibleF5Parameters from ansible.module_utils.network.f5.common import AnsibleF5Parameters
from ansible.module_utils.network.f5.common import cleanup_tokens from ansible.module_utils.network.f5.common import cleanup_tokens
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
try: try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError: except ImportError:
HAS_F5SDK = False HAS_F5SDK = False
try:
import netaddr
HAS_NETADDR = True
except ImportError:
HAS_NETADDR = False
class Parameters(AnsibleF5Parameters): class Parameters(AnsibleF5Parameters):
api_map = { api_map = {
@ -189,16 +195,17 @@ class Parameters(AnsibleF5Parameters):
api_attributes = [ api_attributes = [
'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'recv', 'send', 'timeUntilUp', 'defaultsFrom', 'interval', 'timeout', 'recv', 'send',
'destination' 'destination', 'description'
] ]
returnables = [ returnables = [
'parent', 'send', 'receive', 'ip', 'port', 'interval', 'timeout', 'parent', 'send', 'receive', 'ip', 'port', 'interval', 'timeout',
'time_until_up' 'time_until_up', 'description'
] ]
updatables = [ updatables = [
'destination', 'send', 'receive', 'interval', 'timeout', 'time_until_up' 'destination', 'send', 'receive', 'interval', 'timeout', 'time_until_up',
'description'
] ]
def to_return(self): def to_return(self):
@ -247,12 +254,11 @@ class Parameters(AnsibleF5Parameters):
def ip(self): def ip(self):
if self._values['ip'] is None: if self._values['ip'] is None:
return None return None
try:
if self._values['ip'] in ['*', '0.0.0.0']: if self._values['ip'] in ['*', '0.0.0.0']:
return '*' return '*'
result = str(netaddr.IPAddress(self._values['ip'])) elif is_valid_ip(self._values['ip']):
return result return self._values['ip']
except netaddr.core.AddrFormatError: else:
raise F5ModuleError( raise F5ModuleError(
"The provided 'ip' parameter is not an IP address." "The provided 'ip' parameter is not an IP address."
) )
@ -518,6 +524,7 @@ class ArgumentSpec(object):
argument_spec = dict( argument_spec = dict(
name=dict(required=True), name=dict(required=True),
parent=dict(default='/Common/udp'), parent=dict(default='/Common/udp'),
description=dict(),
send=dict(), send=dict(),
receive=dict(), receive=dict(),
receive_disable=dict(required=False), receive_disable=dict(required=False),
@ -549,8 +556,6 @@ def main():
) )
if not HAS_F5SDK: if not HAS_F5SDK:
module.fail_json(msg="The python f5-sdk module is required") module.fail_json(msg="The python f5-sdk module is required")
if not HAS_NETADDR:
module.fail_json(msg="The python netaddr module is required")
try: try:
client = F5Client(**module.params) client = F5Client(**module.params)

Loading…
Cancel
Save