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

Fixes and features for bigip gtm monitor modules (#44540)

Merging in gtm monitor work from downstream repo. includes various
new fixes and features.
This commit is contained in:
Tim Rupp 2018-08-22 18:19:55 -04:00 committed by GitHub
parent a73340ee74
commit 6da6652e6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 99 deletions

View file

@ -191,6 +191,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:
@ -202,17 +203,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 = {
@ -311,12 +307,11 @@ class ModuleParameters(Parameters):
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 '*' elif is_valid_ip(self._values['ip']):
result = str(netaddr.IPAddress(self._values['ip'])) return self._values['ip']
return result else:
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."
) )
@ -607,8 +602,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)

View file

@ -163,6 +163,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 +177,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 = {
@ -256,12 +252,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 '*' elif is_valid_ip(self._values['ip']):
result = str(netaddr.IPAddress(self._values['ip'])) return self._values['ip']
return result else:
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."
) )

View file

@ -228,6 +228,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:
@ -240,17 +241,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 = {
@ -351,12 +347,11 @@ class ModuleParameters(Parameters):
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 '*' elif is_valid_ip(self._values['ip']):
result = str(netaddr.IPAddress(self._values['ip'])) return self._values['ip']
return result else:
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."
) )
@ -729,8 +724,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)

View file

@ -237,6 +237,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:
@ -249,17 +250,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 = {
@ -377,12 +373,11 @@ class ModuleParameters(Parameters):
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 '*' elif is_valid_ip(self._values['ip']):
result = str(netaddr.IPAddress(self._values['ip'])) return self._values['ip']
return result else:
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."
) )
@ -774,8 +769,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)

View file

@ -276,6 +276,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:
@ -288,17 +289,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 = {
@ -439,12 +435,11 @@ class ModuleParameters(Parameters):
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 '*' elif is_valid_ip(self._values['ip']):
result = str(netaddr.IPAddress(self._values['ip'])) return self._values['ip']
return result else:
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."
) )
@ -894,8 +889,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)

View file

@ -221,6 +221,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:
@ -233,17 +234,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 = {
@ -355,15 +351,13 @@ class ModuleParameters(Parameters):
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 '*' elif is_valid_ip(self._values['ip']):
result = str(netaddr.IPAddress(self._values['ip'])) return self._values['ip']
return result raise F5ModuleError(
except netaddr.core.AddrFormatError: "The provided 'ip' parameter is not an IP address."
raise F5ModuleError( )
"The provided 'ip' parameter is not an IP address."
)
@property @property
def parent(self): def parent(self):
@ -737,8 +731,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)

View file

@ -196,6 +196,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:
@ -207,17 +208,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 = {
@ -344,12 +340,11 @@ class ModuleParameters(Parameters):
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 '*' elif is_valid_ip(self._values['ip']):
result = str(netaddr.IPAddress(self._values['ip'])) return self._values['ip']
return result else:
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."
) )
@ -651,8 +646,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)