Skip to content

Commit

Permalink
Various f5 module fixes (ansible#39510)
Browse files Browse the repository at this point in the history
Mainly fixing coding conventions. Also, added ipv6 suppor to pool members
  • Loading branch information
caphrim007 authored Apr 30, 2018
1 parent 7c9122a commit 0cb11c6
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 132 deletions.
9 changes: 1 addition & 8 deletions lib/ansible/modules/network/f5/bigip_irule.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
short_description: Manage iRules across different modules on a BIG-IP
description:
- Manage iRules across different modules on a BIG-IP.
version_added: "2.2"
version_added: 2.2
options:
content:
description:
Expand Down Expand Up @@ -106,30 +106,23 @@
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback

HAS_DEVEL_IMPORTS = False

try:
# Sideband repository used for dev
from library.module_utils.network.f5.bigip import HAS_F5SDK
from library.module_utils.network.f5.bigip import F5Client
from library.module_utils.network.f5.common import F5ModuleError
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 fqdn_name
from library.module_utils.network.f5.common import f5_argument_spec
try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError:
HAS_F5SDK = False
HAS_DEVEL_IMPORTS = True
except ImportError:
# Upstream Ansible
from ansible.module_utils.network.f5.bigip import HAS_F5SDK
from ansible.module_utils.network.f5.bigip import F5Client
from ansible.module_utils.network.f5.common import F5ModuleError
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 fqdn_name
from ansible.module_utils.network.f5.common import f5_argument_spec
try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
Expand Down
18 changes: 4 additions & 14 deletions lib/ansible/modules/network/f5/bigip_monitor_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
module: bigip_monitor_http
short_description: Manages F5 BIG-IP LTM http monitors
description: Manages F5 BIG-IP LTM http monitors.
version_added: "2.5"
version_added: 2.5
options:
name:
description:
Expand Down Expand Up @@ -165,30 +165,25 @@
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback

HAS_DEVEL_IMPORTS = False

try:
# Sideband repository used for dev
from library.module_utils.network.f5.bigip import HAS_F5SDK
from library.module_utils.network.f5.bigip import F5Client
from library.module_utils.network.f5.common import F5ModuleError
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 fqdn_name
from library.module_utils.network.f5.common import fq_name
from library.module_utils.network.f5.common import f5_argument_spec
try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError:
HAS_F5SDK = False
HAS_DEVEL_IMPORTS = True
except ImportError:
# Upstream Ansible
from ansible.module_utils.network.f5.bigip import HAS_F5SDK
from ansible.module_utils.network.f5.bigip import F5Client
from ansible.module_utils.network.f5.common import F5ModuleError
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 fqdn_name
from ansible.module_utils.network.f5.common import fq_name
from ansible.module_utils.network.f5.common import f5_argument_spec
try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
Expand Down Expand Up @@ -224,11 +219,6 @@ class Parameters(AnsibleF5Parameters):
'target_username', 'target_password'
]

def _fqdn_name(self, value):
if value is not None and not value.startswith('/'):
return '/{0}/{1}'.format(self.partition, value)
return value

def to_return(self):
result = {}
try:
Expand Down Expand Up @@ -303,7 +293,7 @@ def time_until_up(self):
def parent(self):
if self._values['parent'] is None:
return None
result = self._fqdn_name(self._values['parent'])
result = fq_name(self.partition, self._values['parent'])
return result

@property
Expand Down
18 changes: 4 additions & 14 deletions lib/ansible/modules/network/f5/bigip_monitor_https.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
module: bigip_monitor_https
short_description: Manages F5 BIG-IP LTM https monitors
description: Manages F5 BIG-IP LTM https monitors.
version_added: "2.5"
version_added: 2.5
options:
name:
description:
Expand Down Expand Up @@ -153,30 +153,25 @@
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback

HAS_DEVEL_IMPORTS = False

try:
# Sideband repository used for dev
from library.module_utils.network.f5.bigip import HAS_F5SDK
from library.module_utils.network.f5.bigip import F5Client
from library.module_utils.network.f5.common import F5ModuleError
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 fqdn_name
from library.module_utils.network.f5.common import fq_name
from library.module_utils.network.f5.common import f5_argument_spec
try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError:
HAS_F5SDK = False
HAS_DEVEL_IMPORTS = True
except ImportError:
# Upstream Ansible
from ansible.module_utils.network.f5.bigip import HAS_F5SDK
from ansible.module_utils.network.f5.bigip import F5Client
from ansible.module_utils.network.f5.common import F5ModuleError
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 fqdn_name
from ansible.module_utils.network.f5.common import fq_name
from ansible.module_utils.network.f5.common import f5_argument_spec
try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
Expand Down Expand Up @@ -212,11 +207,6 @@ class Parameters(AnsibleF5Parameters):
'target_username', 'target_password'
]

def _fqdn_name(self, value):
if value is not None and not value.startswith('/'):
return '/{0}/{1}'.format(self.partition, value)
return value

def to_return(self):
result = {}
try:
Expand Down Expand Up @@ -299,7 +289,7 @@ def time_until_up(self):
def parent(self):
if self._values['parent'] is None:
return None
result = self._fqdn_name(self._values['parent'])
result = fq_name(self.partition, self._values['parent'])
return result

@property
Expand Down
18 changes: 4 additions & 14 deletions lib/ansible/modules/network/f5/bigip_monitor_snmp_dca.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- The BIG-IP has an SNMP data collecting agent (DCA) that can query remote
SNMP agents of various types, including the UC Davis agent (UCD) and the
Windows 2000 Server agent (WIN2000).
version_added: "2.5"
version_added: 2.5
options:
name:
description:
Expand Down Expand Up @@ -222,30 +222,25 @@
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback

HAS_DEVEL_IMPORTS = False

try:
# Sideband repository used for dev
from library.module_utils.network.f5.bigip import HAS_F5SDK
from library.module_utils.network.f5.bigip import F5Client
from library.module_utils.network.f5.common import F5ModuleError
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 fqdn_name
from library.module_utils.network.f5.common import fq_name
from library.module_utils.network.f5.common import f5_argument_spec
try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError:
HAS_F5SDK = False
HAS_DEVEL_IMPORTS = True
except ImportError:
# Upstream Ansible
from ansible.module_utils.network.f5.bigip import HAS_F5SDK
from ansible.module_utils.network.f5.bigip import F5Client
from ansible.module_utils.network.f5.common import F5ModuleError
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 fqdn_name
from ansible.module_utils.network.f5.common import fq_name
from ansible.module_utils.network.f5.common import f5_argument_spec
try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
Expand Down Expand Up @@ -284,11 +279,6 @@ class Parameters(AnsibleF5Parameters):
'memory_threshold', 'disk_coefficient', 'disk_threshold'
]

def _fqdn_name(self, value):
if value is not None and not value.startswith('/'):
return '/{0}/{1}'.format(self.partition, value)
return value

def to_return(self):
result = {}
try:
Expand Down Expand Up @@ -325,7 +315,7 @@ def time_until_up(self):
def parent(self):
if self._values['parent'] is None:
return None
result = self._fqdn_name(self._values['parent'])
result = fq_name(self.partition, self._values['parent'])
return result

@property
Expand Down
24 changes: 5 additions & 19 deletions lib/ansible/modules/network/f5/bigip_monitor_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
module: bigip_monitor_tcp
short_description: Manages F5 BIG-IP LTM tcp monitors
description: Manages F5 BIG-IP LTM tcp monitors via iControl SOAP API.
version_added: "1.4"
version_added: 1.4
options:
name:
description:
Expand Down Expand Up @@ -161,30 +161,25 @@
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback

HAS_DEVEL_IMPORTS = False

try:
# Sideband repository used for dev
from library.module_utils.network.f5.bigip import HAS_F5SDK
from library.module_utils.network.f5.bigip import F5Client
from library.module_utils.network.f5.common import F5ModuleError
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 fqdn_name
from library.module_utils.network.f5.common import fq_name
from library.module_utils.network.f5.common import f5_argument_spec
try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError:
HAS_F5SDK = False
HAS_DEVEL_IMPORTS = True
except ImportError:
# Upstream Ansible
from ansible.module_utils.network.f5.bigip import HAS_F5SDK
from ansible.module_utils.network.f5.bigip import F5Client
from ansible.module_utils.network.f5.common import F5ModuleError
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 fqdn_name
from ansible.module_utils.network.f5.common import fq_name
from ansible.module_utils.network.f5.common import f5_argument_spec
try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
Expand Down Expand Up @@ -219,11 +214,6 @@ class Parameters(AnsibleF5Parameters):
'destination', 'send', 'receive', 'interval', 'timeout', 'time_until_up'
]

def _fqdn_name(self, value):
if value is not None and not value.startswith('/'):
return '/{0}/{1}'.format(self.partition, value)
return value

def to_return(self):
result = {}
try:
Expand Down Expand Up @@ -284,7 +274,7 @@ def time_until_up(self):
def parent(self):
if self._values['parent'] is None:
return None
result = self._fqdn_name(self._values['parent'])
result = fq_name(self.partition, self._values['parent'])
return result

@property
Expand Down Expand Up @@ -565,18 +555,14 @@ def __init__(self):
self.argument_spec = {}
self.argument_spec.update(f5_argument_spec)
self.argument_spec.update(argument_spec)
self.mutually_exclusive = [
['parent', 'parent_partition']
]


def main():
spec = ArgumentSpec()

module = AnsibleModule(
argument_spec=spec.argument_spec,
supports_check_mode=spec.supports_check_mode,
mutually_exclusive=spec.mutually_exclusive
supports_check_mode=spec.supports_check_mode
)
if not HAS_F5SDK:
module.fail_json(msg="The python f5-sdk module is required")
Expand Down
14 changes: 1 addition & 13 deletions lib/ansible/modules/network/f5/bigip_monitor_tcp_echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
module: bigip_monitor_tcp_echo
short_description: Manages F5 BIG-IP LTM tcp echo monitors
description: Manages F5 BIG-IP LTM tcp echo monitors.
version_added: "2.4"
version_added: 2.4
options:
name:
description:
Expand Down Expand Up @@ -133,30 +133,23 @@
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import env_fallback

HAS_DEVEL_IMPORTS = False

try:
# Sideband repository used for dev
from library.module_utils.network.f5.bigip import HAS_F5SDK
from library.module_utils.network.f5.bigip import F5Client
from library.module_utils.network.f5.common import F5ModuleError
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 fqdn_name
from library.module_utils.network.f5.common import f5_argument_spec
try:
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
except ImportError:
HAS_F5SDK = False
HAS_DEVEL_IMPORTS = True
except ImportError:
# Upstream Ansible
from ansible.module_utils.network.f5.bigip import HAS_F5SDK
from ansible.module_utils.network.f5.bigip import F5Client
from ansible.module_utils.network.f5.common import F5ModuleError
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 fqdn_name
from ansible.module_utils.network.f5.common import f5_argument_spec
try:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
Expand Down Expand Up @@ -188,11 +181,6 @@ class Parameters(AnsibleF5Parameters):
'ip', 'interval', 'timeout', 'time_until_up'
]

def _fqdn_name(self, value):
if value is not None and not value.startswith('/'):
return '/{0}/{1}'.format(self.partition, value)
return value

def to_return(self):
result = {}
try:
Expand Down
Loading

0 comments on commit 0cb11c6

Please sign in to comment.