mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
Fixes multiple lgtm issues (#45629)
Most of the issues were just inclusions of code that were not used. This cleans those up. Other alerts were semi-false-positives for now
This commit is contained in:
parent
e68f895e61
commit
e619052424
40 changed files with 255 additions and 239 deletions
21
lib/ansible/module_utils/network/f5/compare.py
Normal file
21
lib/ansible/module_utils/network/f5/compare.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright (c) 2017 F5 Networks Inc.
|
||||||
|
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
|
def cmp_simple_list(want, have):
|
||||||
|
if want is None:
|
||||||
|
return None
|
||||||
|
if have is None and want == '':
|
||||||
|
return None
|
||||||
|
if have is not None and want == '':
|
||||||
|
return []
|
||||||
|
if have is None:
|
||||||
|
return want
|
||||||
|
if set(want) != set(have):
|
||||||
|
return want
|
||||||
|
return None
|
|
@ -90,7 +90,6 @@ try:
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 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 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 exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import fail_json
|
from library.module_utils.network.f5.common import fail_json
|
||||||
|
@ -100,7 +99,6 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 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 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 exit_json
|
from ansible.module_utils.network.f5.common import exit_json
|
||||||
from ansible.module_utils.network.f5.common import fail_json
|
from ansible.module_utils.network.f5.common import fail_json
|
||||||
|
@ -411,8 +409,10 @@ def main():
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
exit_json(module, results, client)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
|
cleanup_tokens(client)
|
||||||
fail_json(module, ex, client)
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,6 @@ try:
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 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 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 exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import fail_json
|
from library.module_utils.network.f5.common import fail_json
|
||||||
|
@ -105,7 +104,6 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 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 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 exit_json
|
from ansible.module_utils.network.f5.common import exit_json
|
||||||
from ansible.module_utils.network.f5.common import fail_json
|
from ansible.module_utils.network.f5.common import fail_json
|
||||||
|
@ -401,7 +399,7 @@ class ModuleManager(object):
|
||||||
if resp.status == 200:
|
if resp.status == 200:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def read_current_from_device(self):
|
def read_current_from_device(self): # lgtm [py/similar-function]
|
||||||
uri = "https://{0}:{1}/mgmt/tm/cli/script/{2}".format(
|
uri = "https://{0}:{1}/mgmt/tm/cli/script/{2}".format(
|
||||||
self.client.provider['server'],
|
self.client.provider['server'],
|
||||||
self.client.provider['server_port'],
|
self.client.provider['server_port'],
|
||||||
|
@ -454,8 +452,10 @@ def main():
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
exit_json(module, results, client)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
|
cleanup_tokens(client)
|
||||||
fail_json(module, ex, client)
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -267,10 +267,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 compare_complex_list
|
from library.module_utils.network.f5.common import compare_complex_list
|
||||||
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_network
|
|
||||||
from library.module_utils.network.f5.ipaddress import is_valid_ip_interface
|
from library.module_utils.network.f5.ipaddress import is_valid_ip_interface
|
||||||
from library.module_utils.compat.ipaddress import ip_address
|
|
||||||
from library.module_utils.compat.ipaddress import ip_network
|
from library.module_utils.compat.ipaddress import ip_network
|
||||||
from library.module_utils.compat.ipaddress import ip_interface
|
from library.module_utils.compat.ipaddress import ip_interface
|
||||||
try:
|
try:
|
||||||
|
@ -285,10 +282,7 @@ 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 compare_complex_list
|
from ansible.module_utils.network.f5.common import compare_complex_list
|
||||||
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_network
|
|
||||||
from ansible.module_utils.network.f5.ipaddress import is_valid_ip_interface
|
from ansible.module_utils.network.f5.ipaddress import is_valid_ip_interface
|
||||||
from ansible.module_utils.compat.ipaddress import ip_address
|
|
||||||
from ansible.module_utils.compat.ipaddress import ip_network
|
from ansible.module_utils.compat.ipaddress import ip_network
|
||||||
from ansible.module_utils.compat.ipaddress import ip_interface
|
from ansible.module_utils.compat.ipaddress import ip_interface
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -210,7 +210,6 @@ try:
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 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 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 exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import fail_json
|
from library.module_utils.network.f5.common import fail_json
|
||||||
|
@ -219,7 +218,6 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 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 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 exit_json
|
from ansible.module_utils.network.f5.common import exit_json
|
||||||
from ansible.module_utils.network.f5.common import fail_json
|
from ansible.module_utils.network.f5.common import fail_json
|
||||||
|
@ -796,8 +794,10 @@ def main():
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
exit_json(module, results, client)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
|
cleanup_tokens(client)
|
||||||
fail_json(module, ex, client)
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ class ModuleManager(object):
|
||||||
self.have = None
|
self.have = None
|
||||||
self.changes = Parameters()
|
self.changes = Parameters()
|
||||||
|
|
||||||
def _update_changed_options(self):
|
def _update_changed_options(self): # lgtm [py/similar-function]
|
||||||
changed = {}
|
changed = {}
|
||||||
for key in Parameters.updatables:
|
for key in Parameters.updatables:
|
||||||
if getattr(self.want, key) is not None:
|
if getattr(self.want, key) is not None:
|
||||||
|
@ -219,7 +219,7 @@ class ModuleManager(object):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def exec_module(self):
|
def exec_module(self): # lgtm [py/similar-function]
|
||||||
changed = False
|
changed = False
|
||||||
result = dict()
|
result = dict()
|
||||||
state = self.want.state
|
state = self.want.state
|
||||||
|
|
|
@ -378,7 +378,7 @@ class ModuleManager(object):
|
||||||
if changed:
|
if changed:
|
||||||
self.changes = UsableChanges(params=changed)
|
self.changes = UsableChanges(params=changed)
|
||||||
|
|
||||||
def _update_changed_options(self):
|
def _update_changed_options(self): # lgtm [py/similar-function]
|
||||||
changed = {}
|
changed = {}
|
||||||
for key in Parameters.updatables:
|
for key in Parameters.updatables:
|
||||||
if getattr(self.want, key) is not None:
|
if getattr(self.want, key) is not None:
|
||||||
|
|
|
@ -688,8 +688,10 @@ def main():
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
exit_json(module, results, client)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
|
cleanup_tokens(client)
|
||||||
fail_json(module, ex, client)
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,11 +83,9 @@ RETURN = r'''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.urls import open_url
|
|
||||||
from ansible.module_utils.six import iteritems
|
from ansible.module_utils.six import iteritems
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
import xml.etree.ElementTree
|
import xml.etree.ElementTree
|
||||||
|
|
||||||
|
@ -97,11 +95,8 @@ try:
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 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 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.icontrol import iControlRestSession
|
from library.module_utils.network.f5.icontrol import iControlRestSession
|
||||||
from library.module_utils.network.f5.icontrol import Request
|
|
||||||
from library.module_utils.network.f5.icontrol import Response
|
|
||||||
try:
|
try:
|
||||||
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||||
from f5.sdk_exception import UtilError
|
from f5.sdk_exception import UtilError
|
||||||
|
@ -113,11 +108,8 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 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 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.icontrol import iControlRestSession
|
from ansible.module_utils.network.f5.icontrol import iControlRestSession
|
||||||
from ansible.module_utils.network.f5.icontrol import Request
|
|
||||||
from ansible.module_utils.network.f5.icontrol import Response
|
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||||
from f5.sdk_exception import UtilError
|
from f5.sdk_exception import UtilError
|
||||||
|
|
|
@ -139,7 +139,7 @@ class ModuleManager(object):
|
||||||
self.want = Parameters(params=self.module.params)
|
self.want = Parameters(params=self.module.params)
|
||||||
self.changes = Parameters()
|
self.changes = Parameters()
|
||||||
|
|
||||||
def _update_changed_options(self):
|
def _update_changed_options(self): # lgtm [py/similar-function]
|
||||||
changed = {}
|
changed = {}
|
||||||
for key in Parameters.updatables:
|
for key in Parameters.updatables:
|
||||||
if getattr(self.want, key) is not None:
|
if getattr(self.want, key) is not None:
|
||||||
|
@ -165,7 +165,7 @@ class ModuleManager(object):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def exec_module(self):
|
def exec_module(self): # lgtm [py/similar-function]
|
||||||
changed = False
|
changed = False
|
||||||
result = dict()
|
result = dict()
|
||||||
state = self.want.state
|
state = self.want.state
|
||||||
|
|
|
@ -249,7 +249,7 @@ class ModuleManager(object):
|
||||||
self.want = ModuleParameters(params=self.module.params)
|
self.want = ModuleParameters(params=self.module.params)
|
||||||
self.changes = UsableChanges()
|
self.changes = UsableChanges()
|
||||||
|
|
||||||
def _update_changed_options(self):
|
def _update_changed_options(self): # lgtm [py/similar-function]
|
||||||
changed = {}
|
changed = {}
|
||||||
for key in Parameters.updatables:
|
for key in Parameters.updatables:
|
||||||
if getattr(self.want, key) is not None:
|
if getattr(self.want, key) is not None:
|
||||||
|
|
|
@ -165,7 +165,6 @@ try:
|
||||||
from library.module_utils.compat.ipaddress import ip_interface
|
from library.module_utils.compat.ipaddress import ip_interface
|
||||||
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 is_valid_ip_interface
|
from library.module_utils.network.f5.ipaddress import is_valid_ip_interface
|
||||||
from library.module_utils.network.f5.ipaddress import is_valid_ip_network
|
|
||||||
try:
|
try:
|
||||||
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -182,7 +181,6 @@ except ImportError:
|
||||||
from ansible.module_utils.compat.ipaddress import ip_interface
|
from ansible.module_utils.compat.ipaddress import ip_interface
|
||||||
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 is_valid_ip_interface
|
from ansible.module_utils.network.f5.ipaddress import is_valid_ip_interface
|
||||||
from ansible.module_utils.network.f5.ipaddress import is_valid_ip_network
|
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -364,7 +364,7 @@ class ModuleManager(object):
|
||||||
return True
|
return True
|
||||||
raise F5ModuleError(resp.content)
|
raise F5ModuleError(resp.content)
|
||||||
|
|
||||||
def read_current_from_device(self):
|
def read_current_from_device(self): # lgtm [py/similar-function]
|
||||||
uri = "https://{0}:{1}/mgmt/tm/security/dos/profile/{2}".format(
|
uri = "https://{0}:{1}/mgmt/tm/security/dos/profile/{2}".format(
|
||||||
self.client.provider['server'],
|
self.client.provider['server'],
|
||||||
self.client.provider['server_port'],
|
self.client.provider['server_port'],
|
||||||
|
@ -420,8 +420,10 @@ def main():
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
exit_json(module, results, client)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
|
cleanup_tokens(client)
|
||||||
fail_json(module, ex, client)
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,6 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.basic import env_fallback
|
from ansible.module_utils.basic import env_fallback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from library.module_utils.network.f5.bigip import HAS_F5SDK
|
|
||||||
from library.module_utils.network.f5.bigip import F5RestClient
|
from library.module_utils.network.f5.bigip import F5RestClient
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 AnsibleF5Parameters
|
||||||
|
@ -99,7 +98,6 @@ try:
|
||||||
from library.module_utils.network.f5.common import exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import transform_name
|
from library.module_utils.network.f5.common import transform_name
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from ansible.module_utils.network.f5.bigip import HAS_F5SDK
|
|
||||||
from ansible.module_utils.network.f5.bigip import F5RestClient
|
from ansible.module_utils.network.f5.bigip import F5RestClient
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 AnsibleF5Parameters
|
||||||
|
@ -527,8 +525,10 @@ def main():
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
exit_json(module, results, client)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
|
cleanup_tokens(client)
|
||||||
fail_json(module, ex, client)
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,6 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.basic import env_fallback
|
from ansible.module_utils.basic import env_fallback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from library.module_utils.network.f5.bigip import HAS_F5SDK
|
|
||||||
from library.module_utils.network.f5.bigip import F5RestClient
|
from library.module_utils.network.f5.bigip import F5RestClient
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 AnsibleF5Parameters
|
||||||
|
@ -99,7 +98,6 @@ try:
|
||||||
from library.module_utils.network.f5.common import exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import transform_name
|
from library.module_utils.network.f5.common import transform_name
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from ansible.module_utils.network.f5.bigip import HAS_F5SDK
|
|
||||||
from ansible.module_utils.network.f5.bigip import F5RestClient
|
from ansible.module_utils.network.f5.bigip import F5RestClient
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 AnsibleF5Parameters
|
||||||
|
@ -527,8 +525,10 @@ def main():
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
exit_json(module, results, client)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
|
cleanup_tokens(client)
|
||||||
fail_json(module, ex, client)
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,6 @@ synchronize_zone_files:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.basic import env_fallback
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from library.module_utils.network.f5.bigip import HAS_F5SDK
|
from library.module_utils.network.f5.bigip import HAS_F5SDK
|
||||||
|
@ -83,7 +82,6 @@ try:
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 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 fq_name
|
|
||||||
from library.module_utils.network.f5.common import f5_argument_spec
|
from library.module_utils.network.f5.common import f5_argument_spec
|
||||||
try:
|
try:
|
||||||
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||||
|
@ -95,7 +93,6 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 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 fq_name
|
|
||||||
from ansible.module_utils.network.f5.common import f5_argument_spec
|
from ansible.module_utils.network.f5.common import f5_argument_spec
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||||
|
@ -251,7 +248,7 @@ class ModuleManager(object):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def exec_module(self):
|
def exec_module(self): # lgtm [py/similar-function]
|
||||||
result = dict()
|
result = dict()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -304,7 +304,7 @@ class ModuleParameters(Parameters):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ip(self):
|
def ip(self): # lgtm [py/similar-function]
|
||||||
if self._values['ip'] is None:
|
if self._values['ip'] is None:
|
||||||
return None
|
return None
|
||||||
if self._values['ip'] in ['*', '0.0.0.0']:
|
if self._values['ip'] in ['*', '0.0.0.0']:
|
||||||
|
@ -424,7 +424,7 @@ class ModuleManager(object):
|
||||||
if changed:
|
if changed:
|
||||||
self.changes = UsableChanges(params=changed)
|
self.changes = UsableChanges(params=changed)
|
||||||
|
|
||||||
def _update_changed_options(self):
|
def _update_changed_options(self): # lgtm [py/similar-function]
|
||||||
diff = Difference(self.want, self.have)
|
diff = Difference(self.want, self.have)
|
||||||
updatables = Parameters.updatables
|
updatables = Parameters.updatables
|
||||||
changed = dict()
|
changed = dict()
|
||||||
|
@ -439,7 +439,7 @@ class ModuleManager(object):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _announce_deprecations(self):
|
def _announce_deprecations(self): # lgtm [py/similar-function]
|
||||||
warnings = []
|
warnings = []
|
||||||
if self.want:
|
if self.want:
|
||||||
warnings += self.want._values.get('__warnings', [])
|
warnings += self.want._values.get('__warnings', [])
|
||||||
|
|
|
@ -344,7 +344,7 @@ class ModuleParameters(Parameters):
|
||||||
return int(self._values['timeout'])
|
return int(self._values['timeout'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ip(self):
|
def ip(self): # lgtm [py/similar-function]
|
||||||
if self._values['ip'] is None:
|
if self._values['ip'] is None:
|
||||||
return None
|
return None
|
||||||
if self._values['ip'] in ['*', '0.0.0.0']:
|
if self._values['ip'] in ['*', '0.0.0.0']:
|
||||||
|
|
|
@ -370,7 +370,7 @@ class ModuleParameters(Parameters):
|
||||||
return int(self._values['timeout'])
|
return int(self._values['timeout'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ip(self):
|
def ip(self): # lgtm [py/similar-function]
|
||||||
if self._values['ip'] is None:
|
if self._values['ip'] is None:
|
||||||
return None
|
return None
|
||||||
if self._values['ip'] in ['*', '0.0.0.0']:
|
if self._values['ip'] in ['*', '0.0.0.0']:
|
||||||
|
|
|
@ -362,21 +362,6 @@ class BaseManager(object):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.module = kwargs.get('module', None)
|
self.module = kwargs.get('module', None)
|
||||||
self.client = kwargs.get('client', None)
|
self.client = kwargs.get('client', None)
|
||||||
self.want = self.get_module_params(params=self.module.params)
|
|
||||||
self.have = self.get_api_params()
|
|
||||||
self.changes = self.get_usable_changes()
|
|
||||||
|
|
||||||
def get_usable_changes(self, params=None):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_api_params(self, params=None):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_module_params(self, params=None):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_reportable_changes(self, params=None):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def _set_changed_options(self):
|
def _set_changed_options(self):
|
||||||
changed = {}
|
changed = {}
|
||||||
|
@ -482,6 +467,13 @@ class V1Manager(BaseManager):
|
||||||
"""Manages remote-syslog settings
|
"""Manages remote-syslog settings
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(V1Manager, self).__init__(*args, **kwargs)
|
||||||
|
self.want = self.get_module_params(params=self.module.params)
|
||||||
|
self.have = self.get_api_params()
|
||||||
|
self.changes = self.get_usable_changes()
|
||||||
|
|
||||||
def _validate_creation_parameters(self):
|
def _validate_creation_parameters(self):
|
||||||
if self.want.syslog_format is None:
|
if self.want.syslog_format is None:
|
||||||
self.want.update({'syslog_format': 'bsd-syslog'})
|
self.want.update({'syslog_format': 'bsd-syslog'})
|
||||||
|
@ -560,6 +552,12 @@ class V2Manager(BaseManager):
|
||||||
"""Manages remote-high-speed-log settings
|
"""Manages remote-high-speed-log settings
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(V2Manager, self).__init__(*args, **kwargs)
|
||||||
|
self.want = self.get_module_params(params=self.module.params)
|
||||||
|
self.have = self.get_api_params()
|
||||||
|
self.changes = self.get_usable_changes()
|
||||||
|
|
||||||
def get_reportable_changes(self, params=None):
|
def get_reportable_changes(self, params=None):
|
||||||
if params:
|
if params:
|
||||||
return V2ReportableChanges(params=params)
|
return V2ReportableChanges(params=params)
|
||||||
|
|
|
@ -85,6 +85,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.compare import cmp_simple_list
|
||||||
try:
|
try:
|
||||||
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -97,6 +98,7 @@ 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.compare import cmp_simple_list
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -193,16 +195,8 @@ class Difference(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def destinations(self):
|
def destinations(self):
|
||||||
if self.want.destinations is None:
|
result = cmp_simple_list(self.want.destinations, self.have.destinations)
|
||||||
return None
|
return result
|
||||||
if self.have.destinations is None and self.want.destinations == '':
|
|
||||||
return None
|
|
||||||
if self.have.destinations is not None and self.want.destinations == '':
|
|
||||||
return []
|
|
||||||
if self.have.destinations is None:
|
|
||||||
return self.want.destinations
|
|
||||||
if set(self.want.destinations) != set(self.have.destinations):
|
|
||||||
return self.want.destinations
|
|
||||||
|
|
||||||
|
|
||||||
class ModuleManager(object):
|
class ModuleManager(object):
|
||||||
|
|
|
@ -183,7 +183,6 @@ 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 transform_name
|
from library.module_utils.network.f5.common import transform_name
|
||||||
from library.module_utils.network.f5.common import flatten_boolean
|
|
||||||
from library.module_utils.network.f5.common import exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import fail_json
|
from library.module_utils.network.f5.common import fail_json
|
||||||
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
@ -195,7 +194,6 @@ 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 transform_name
|
from ansible.module_utils.network.f5.common import transform_name
|
||||||
from ansible.module_utils.network.f5.common import flatten_boolean
|
|
||||||
from ansible.module_utils.network.f5.common import exit_json
|
from ansible.module_utils.network.f5.common import exit_json
|
||||||
from ansible.module_utils.network.f5.common import fail_json
|
from ansible.module_utils.network.f5.common import fail_json
|
||||||
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
|
|
@ -171,7 +171,6 @@ 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 transform_name
|
from library.module_utils.network.f5.common import transform_name
|
||||||
from library.module_utils.network.f5.common import flatten_boolean
|
|
||||||
from library.module_utils.network.f5.common import exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import fail_json
|
from library.module_utils.network.f5.common import fail_json
|
||||||
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
@ -184,7 +183,6 @@ 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 transform_name
|
from ansible.module_utils.network.f5.common import transform_name
|
||||||
from ansible.module_utils.network.f5.common import flatten_boolean
|
|
||||||
from ansible.module_utils.network.f5.common import exit_json
|
from ansible.module_utils.network.f5.common import exit_json
|
||||||
from ansible.module_utils.network.f5.common import fail_json
|
from ansible.module_utils.network.f5.common import fail_json
|
||||||
from ansible.module_utils.network.f5.common import f5_argument_spec
|
from ansible.module_utils.network.f5.common import f5_argument_spec
|
||||||
|
|
|
@ -236,7 +236,6 @@ 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 transform_name
|
from library.module_utils.network.f5.common import transform_name
|
||||||
from library.module_utils.network.f5.common import flatten_boolean
|
|
||||||
from library.module_utils.network.f5.common import exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import fail_json
|
from library.module_utils.network.f5.common import fail_json
|
||||||
|
|
||||||
|
@ -248,7 +247,6 @@ 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 transform_name
|
from ansible.module_utils.network.f5.common import transform_name
|
||||||
from ansible.module_utils.network.f5.common import flatten_boolean
|
|
||||||
from ansible.module_utils.network.f5.common import exit_json
|
from ansible.module_utils.network.f5.common import exit_json
|
||||||
from ansible.module_utils.network.f5.common import fail_json
|
from ansible.module_utils.network.f5.common import fail_json
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,6 @@ 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 transform_name
|
from library.module_utils.network.f5.common import transform_name
|
||||||
from library.module_utils.network.f5.common import flatten_boolean
|
|
||||||
from library.module_utils.network.f5.common import exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import fail_json
|
from library.module_utils.network.f5.common import fail_json
|
||||||
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
@ -192,7 +191,6 @@ 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 transform_name
|
from ansible.module_utils.network.f5.common import transform_name
|
||||||
from ansible.module_utils.network.f5.common import flatten_boolean
|
|
||||||
from ansible.module_utils.network.f5.common import exit_json
|
from ansible.module_utils.network.f5.common import exit_json
|
||||||
from ansible.module_utils.network.f5.common import fail_json
|
from ansible.module_utils.network.f5.common import fail_json
|
||||||
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
|
|
@ -148,10 +148,8 @@ try:
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 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 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 transform_name
|
from library.module_utils.network.f5.common import transform_name
|
||||||
from library.module_utils.network.f5.common import flatten_boolean
|
|
||||||
from library.module_utils.network.f5.common import exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import fail_json
|
from library.module_utils.network.f5.common import fail_json
|
||||||
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
@ -160,10 +158,8 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 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 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 transform_name
|
from ansible.module_utils.network.f5.common import transform_name
|
||||||
from ansible.module_utils.network.f5.common import flatten_boolean
|
|
||||||
from ansible.module_utils.network.f5.common import exit_json
|
from ansible.module_utils.network.f5.common import exit_json
|
||||||
from ansible.module_utils.network.f5.common import fail_json
|
from ansible.module_utils.network.f5.common import fail_json
|
||||||
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
|
|
@ -165,10 +165,8 @@ try:
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 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 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 transform_name
|
from library.module_utils.network.f5.common import transform_name
|
||||||
from library.module_utils.network.f5.common import flatten_boolean
|
|
||||||
from library.module_utils.network.f5.common import exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import fail_json
|
from library.module_utils.network.f5.common import fail_json
|
||||||
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
@ -177,10 +175,8 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 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 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 transform_name
|
from ansible.module_utils.network.f5.common import transform_name
|
||||||
from ansible.module_utils.network.f5.common import flatten_boolean
|
|
||||||
from ansible.module_utils.network.f5.common import exit_json
|
from ansible.module_utils.network.f5.common import exit_json
|
||||||
from ansible.module_utils.network.f5.common import fail_json
|
from ansible.module_utils.network.f5.common import fail_json
|
||||||
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
||||||
|
|
|
@ -1103,8 +1103,10 @@ def main():
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
exit_json(module, results, client)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
|
cleanup_tokens(client)
|
||||||
fail_json(module, ex, client)
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -264,37 +264,32 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.basic import env_fallback
|
from ansible.module_utils.basic import env_fallback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from library.module_utils.network.f5.bigip import HAS_F5SDK
|
from library.module_utils.network.f5.bigip import F5RestClient
|
||||||
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 F5ModuleError
|
||||||
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 fq_name
|
from library.module_utils.network.f5.common import fq_name
|
||||||
from library.module_utils.network.f5.common import is_valid_hostname
|
from library.module_utils.network.f5.common import cleanup_tokens
|
||||||
|
from library.module_utils.network.f5.common import transform_name
|
||||||
|
from library.module_utils.network.f5.common import exit_json
|
||||||
|
from library.module_utils.network.f5.common import fail_json
|
||||||
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 is_valid_hostname
|
||||||
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 validate_ip_address
|
|
||||||
from library.module_utils.network.f5.ipaddress import validate_ip_v6_address
|
from library.module_utils.network.f5.ipaddress import validate_ip_v6_address
|
||||||
try:
|
|
||||||
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
|
||||||
except ImportError:
|
|
||||||
HAS_F5SDK = False
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from ansible.module_utils.network.f5.bigip import HAS_F5SDK
|
from ansible.module_utils.network.f5.bigip import F5RestClient
|
||||||
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 F5ModuleError
|
||||||
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 fq_name
|
from ansible.module_utils.network.f5.common import fq_name
|
||||||
|
from ansible.module_utils.network.f5.common import cleanup_tokens
|
||||||
|
from ansible.module_utils.network.f5.common import transform_name
|
||||||
|
from ansible.module_utils.network.f5.common import exit_json
|
||||||
|
from ansible.module_utils.network.f5.common import fail_json
|
||||||
|
from ansible.module_utils.network.f5.common import f5_argument_spec
|
||||||
from ansible.module_utils.network.f5.common import is_valid_hostname
|
from ansible.module_utils.network.f5.common import is_valid_hostname
|
||||||
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 validate_ip_address
|
|
||||||
from ansible.module_utils.network.f5.ipaddress import validate_ip_v6_address
|
from ansible.module_utils.network.f5.ipaddress import validate_ip_v6_address
|
||||||
try:
|
|
||||||
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
|
||||||
except ImportError:
|
|
||||||
HAS_F5SDK = False
|
|
||||||
|
|
||||||
|
|
||||||
class Parameters(AnsibleF5Parameters):
|
class Parameters(AnsibleF5Parameters):
|
||||||
|
@ -306,17 +301,17 @@ class Parameters(AnsibleF5Parameters):
|
||||||
|
|
||||||
api_attributes = [
|
api_attributes = [
|
||||||
'rateLimit', 'connectionLimit', 'description', 'ratio', 'priorityGroup',
|
'rateLimit', 'connectionLimit', 'description', 'ratio', 'priorityGroup',
|
||||||
'address', 'fqdn', 'session', 'state'
|
'address', 'fqdn', 'session', 'state',
|
||||||
]
|
]
|
||||||
|
|
||||||
returnables = [
|
returnables = [
|
||||||
'rate_limit', 'connection_limit', 'description', 'ratio', 'priority_group',
|
'rate_limit', 'connection_limit', 'description', 'ratio', 'priority_group',
|
||||||
'fqdn_auto_populate', 'session', 'state', 'fqdn', 'address'
|
'fqdn_auto_populate', 'session', 'state', 'fqdn', 'address',
|
||||||
]
|
]
|
||||||
|
|
||||||
updatables = [
|
updatables = [
|
||||||
'rate_limit', 'connection_limit', 'description', 'ratio', 'priority_group',
|
'rate_limit', 'connection_limit', 'description', 'ratio', 'priority_group',
|
||||||
'fqdn_auto_populate', 'state'
|
'fqdn_auto_populate', 'state',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -573,13 +568,10 @@ class ModuleManager(object):
|
||||||
result = dict()
|
result = dict()
|
||||||
state = self.want.state
|
state = self.want.state
|
||||||
|
|
||||||
try:
|
if state in ['present', 'present', 'enabled', 'disabled', 'forced_offline']:
|
||||||
if state in ['present', 'present', 'enabled', 'disabled', 'forced_offline']:
|
changed = self.present()
|
||||||
changed = self.present()
|
elif state == "absent":
|
||||||
elif state == "absent":
|
changed = self.absent()
|
||||||
changed = self.absent()
|
|
||||||
except iControlUnexpectedHTTPError as e:
|
|
||||||
raise F5ModuleError(str(e))
|
|
||||||
|
|
||||||
reportable = ReportableChanges(params=self.changes.to_return())
|
reportable = ReportableChanges(params=self.changes.to_return())
|
||||||
changes = reportable.to_return()
|
changes = reportable.to_return()
|
||||||
|
@ -603,25 +595,53 @@ class ModuleManager(object):
|
||||||
return self.create()
|
return self.create()
|
||||||
|
|
||||||
def exists(self):
|
def exists(self):
|
||||||
try:
|
if not self.pool_exist():
|
||||||
pool = self.client.api.tm.ltm.pools.pool.load(
|
F5ModuleError('The specified pool does not exist')
|
||||||
name=self.want.pool,
|
|
||||||
partition=self.want.partition
|
uri = "https://{0}:{1}/mgmt/tm/ltm/pool/{2}/members/{3}".format(
|
||||||
)
|
self.client.provider['server'],
|
||||||
except Exception as ex:
|
self.client.provider['server_port'],
|
||||||
raise F5ModuleError('The specified pool does not exist')
|
transform_name(self.want.partition, self.want.pool),
|
||||||
result = pool.members_s.members.exists(
|
transform_name(self.want.partition, self.want.full_name)
|
||||||
name=self.want.full_name,
|
|
||||||
partition=self.want.partition
|
|
||||||
)
|
)
|
||||||
return result
|
resp = self.client.api.get(uri)
|
||||||
|
try:
|
||||||
|
response = resp.json()
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
if resp.status == 404 or 'code' in response and response['code'] == 404:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def pool_exist(self):
|
||||||
|
uri = "https://{0}:{1}/mgmt/tm/ltm/pool/{2}".format(
|
||||||
|
self.client.provider['server'],
|
||||||
|
self.client.provider['server_port'],
|
||||||
|
transform_name(self.want.partition, self.want.pool)
|
||||||
|
)
|
||||||
|
resp = self.client.api.get(uri)
|
||||||
|
try:
|
||||||
|
response = resp.json()
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
if resp.status == 404 or 'code' in response and response['code'] == 404:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def node_exists(self):
|
def node_exists(self):
|
||||||
resource = self.client.api.tm.ltm.nodes.node.exists(
|
uri = "https://{0}:{1}/mgmt/tm/ltm/node/{2}".format(
|
||||||
name=self.want.node_name,
|
self.client.provider['server'],
|
||||||
partition=self.want.partition
|
self.client.provider['server_port'],
|
||||||
|
transform_name(self.want.partition, self.want.node_name)
|
||||||
)
|
)
|
||||||
return resource
|
resp = self.client.api.get(uri)
|
||||||
|
try:
|
||||||
|
response = resp.json()
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
if resp.status == 404 or 'code' in response and response['code'] == 404:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.have = self.read_current_from_device()
|
self.have = self.read_current_from_device()
|
||||||
|
@ -711,27 +731,47 @@ class ModuleManager(object):
|
||||||
|
|
||||||
def create_on_device(self):
|
def create_on_device(self):
|
||||||
params = self.changes.api_params()
|
params = self.changes.api_params()
|
||||||
pool = self.client.api.tm.ltm.pools.pool.load(
|
params['name'] = self.want.full_name
|
||||||
name=self.want.pool,
|
params['partition'] = self.want.partition
|
||||||
partition=self.want.partition
|
uri = "https://{0}:{1}/mgmt/tm/ltm/pool/{2}/members".format(
|
||||||
)
|
self.client.provider['server'],
|
||||||
pool.members_s.members.create(
|
self.client.provider['server_port'],
|
||||||
name=self.want.full_name,
|
transform_name(self.want.partition, self.want.pool),
|
||||||
partition=self.want.partition,
|
|
||||||
**params
|
|
||||||
)
|
)
|
||||||
|
resp = self.client.api.post(uri, json=params)
|
||||||
|
try:
|
||||||
|
response = resp.json()
|
||||||
|
except ValueError as ex:
|
||||||
|
raise F5ModuleError(str(ex))
|
||||||
|
|
||||||
|
if 'code' in response and response['code'] in [400, 403]:
|
||||||
|
if 'message' in response:
|
||||||
|
raise F5ModuleError(response['message'])
|
||||||
|
else:
|
||||||
|
raise F5ModuleError(resp.content)
|
||||||
|
return response['selfLink']
|
||||||
|
|
||||||
def update_on_device(self):
|
def update_on_device(self):
|
||||||
params = self.changes.api_params()
|
params = self.changes.api_params()
|
||||||
pool = self.client.api.tm.ltm.pools.pool.load(
|
uri = "https://{0}:{1}/mgmt/tm/ltm/pool/{2}/members/{3}".format(
|
||||||
name=self.want.pool,
|
self.client.provider['server'],
|
||||||
partition=self.want.partition
|
self.client.provider['server_port'],
|
||||||
|
transform_name(self.want.partition, self.want.pool),
|
||||||
|
transform_name(self.want.partition, self.want.full_name)
|
||||||
|
|
||||||
)
|
)
|
||||||
resource = pool.members_s.members.load(
|
resp = self.client.api.patch(uri, json=params)
|
||||||
name=self.want.full_name,
|
try:
|
||||||
partition=self.want.partition
|
response = resp.json()
|
||||||
)
|
except ValueError as ex:
|
||||||
resource.modify(**params)
|
raise F5ModuleError(str(ex))
|
||||||
|
|
||||||
|
if 'code' in response and response['code'] == 400:
|
||||||
|
if 'message' in response:
|
||||||
|
raise F5ModuleError(response['message'])
|
||||||
|
else:
|
||||||
|
raise F5ModuleError(resp.content)
|
||||||
|
|
||||||
def absent(self):
|
def absent(self):
|
||||||
if self.exists():
|
if self.exists():
|
||||||
|
@ -741,42 +781,68 @@ class ModuleManager(object):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def remove_from_device(self):
|
def remove_from_device(self):
|
||||||
pool = self.client.api.tm.ltm.pools.pool.load(
|
uri = "https://{0}:{1}/mgmt/tm/ltm/pool/{2}/members/{3}".format(
|
||||||
name=self.want.pool,
|
self.client.provider['server'],
|
||||||
partition=self.want.partition
|
self.client.provider['server_port'],
|
||||||
|
transform_name(self.want.partition, self.want.pool),
|
||||||
|
transform_name(self.want.partition, self.want.full_name)
|
||||||
|
|
||||||
)
|
)
|
||||||
resource = pool.members_s.members.load(
|
response = self.client.api.delete(uri)
|
||||||
name=self.want.full_name,
|
if response.status == 200:
|
||||||
partition=self.want.partition
|
return True
|
||||||
)
|
raise F5ModuleError(response.content)
|
||||||
if resource:
|
|
||||||
resource.delete()
|
|
||||||
|
|
||||||
def remove_node_from_device(self):
|
def remove_node_from_device(self):
|
||||||
resource = self.client.api.tm.ltm.nodes.node.load(
|
uri = "https://{0}:{1}/mgmt/tm/ltm/node/{2}".format(
|
||||||
name=self.want.node_name,
|
self.client.provider['server'],
|
||||||
partition=self.want.partition
|
self.client.provider['server_port'],
|
||||||
|
transform_name(self.want.partition, self.want.node_name)
|
||||||
)
|
)
|
||||||
if resource:
|
response = self.client.api.delete(uri)
|
||||||
resource.delete()
|
if response.status == 200:
|
||||||
|
return True
|
||||||
|
raise F5ModuleError(response.content)
|
||||||
|
|
||||||
def read_current_from_device(self):
|
def read_current_from_device(self):
|
||||||
pool = self.client.api.tm.ltm.pools.pool.load(
|
uri = "https://{0}:{1}/mgmt/tm/ltm/pool/{2}/members/{3}".format(
|
||||||
name=self.want.pool,
|
self.client.provider['server'],
|
||||||
partition=self.want.partition
|
self.client.provider['server_port'],
|
||||||
|
transform_name(self.want.partition, self.want.pool),
|
||||||
|
transform_name(self.want.partition, self.want.full_name)
|
||||||
|
|
||||||
)
|
)
|
||||||
resource = pool.members_s.members.load(
|
resp = self.client.api.get(uri)
|
||||||
name=self.want.full_name,
|
try:
|
||||||
partition=self.want.partition
|
response = resp.json()
|
||||||
)
|
except ValueError as ex:
|
||||||
return ApiParameters(params=resource.attrs)
|
raise F5ModuleError(str(ex))
|
||||||
|
|
||||||
|
if 'code' in response and response['code'] == 400:
|
||||||
|
if 'message' in response:
|
||||||
|
raise F5ModuleError(response['message'])
|
||||||
|
else:
|
||||||
|
raise F5ModuleError(resp.content)
|
||||||
|
return ApiParameters(params=response)
|
||||||
|
|
||||||
def read_current_node_from_device(self, node):
|
def read_current_node_from_device(self, node):
|
||||||
resource = self.client.api.tm.ltm.nodes.node.load(
|
uri = "https://{0}:{1}/mgmt/tm/ltm/node/{2}".format(
|
||||||
name=node,
|
self.client.provider['server'],
|
||||||
partition=self.want.partition
|
self.client.provider['server_port'],
|
||||||
|
transform_name(self.want.partition, node)
|
||||||
)
|
)
|
||||||
return NodeApiParameters(params=resource.attrs)
|
resp = self.client.api.get(uri)
|
||||||
|
try:
|
||||||
|
response = resp.json()
|
||||||
|
except ValueError as ex:
|
||||||
|
raise F5ModuleError(str(ex))
|
||||||
|
|
||||||
|
if 'code' in response and response['code'] == 400:
|
||||||
|
if 'message' in response:
|
||||||
|
raise F5ModuleError(response['message'])
|
||||||
|
else:
|
||||||
|
raise F5ModuleError(resp.content)
|
||||||
|
return NodeApiParameters(params=response)
|
||||||
|
|
||||||
|
|
||||||
class ArgumentSpec(object):
|
class ArgumentSpec(object):
|
||||||
|
@ -823,20 +889,19 @@ def main():
|
||||||
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=spec.argument_spec,
|
argument_spec=spec.argument_spec,
|
||||||
supports_check_mode=spec.supports_check_mode
|
supports_check_mode=spec.supports_check_mode,
|
||||||
)
|
)
|
||||||
if not HAS_F5SDK:
|
|
||||||
module.fail_json(msg="The python f5-sdk module is required")
|
client = F5RestClient(**module.params)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client = F5Client(**module.params)
|
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
cleanup_tokens(client)
|
cleanup_tokens(client)
|
||||||
module.exit_json(**results)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
cleanup_tokens(client)
|
cleanup_tokens(client)
|
||||||
module.fail_json(msg=str(ex))
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -124,7 +124,6 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.basic import env_fallback
|
from ansible.module_utils.basic import env_fallback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from library.module_utils.network.f5.bigip import HAS_F5SDK
|
|
||||||
from library.module_utils.network.f5.bigip import F5RestClient
|
from library.module_utils.network.f5.bigip import F5RestClient
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 AnsibleF5Parameters
|
||||||
|
@ -136,7 +135,6 @@ try:
|
||||||
from library.module_utils.network.f5.common import exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import fail_json
|
from library.module_utils.network.f5.common import fail_json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from ansible.module_utils.network.f5.bigip import HAS_F5SDK
|
|
||||||
from ansible.module_utils.network.f5.bigip import F5RestClient
|
from ansible.module_utils.network.f5.bigip import F5RestClient
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 AnsibleF5Parameters
|
||||||
|
@ -557,8 +555,10 @@ def main():
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
exit_json(module, results, client)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
|
cleanup_tokens(client)
|
||||||
fail_json(module, ex, client)
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,6 @@ try:
|
||||||
try:
|
try:
|
||||||
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||||
from f5.bigip.contexts import TransactionContextManager
|
from f5.bigip.contexts import TransactionContextManager
|
||||||
from f5.sdk_exception import LazyAttributesRequired
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_F5SDK = False
|
HAS_F5SDK = False
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -130,7 +129,6 @@ except ImportError:
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||||
from f5.bigip.contexts import TransactionContextManager
|
from f5.bigip.contexts import TransactionContextManager
|
||||||
from f5.sdk_exception import LazyAttributesRequired
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_F5SDK = False
|
HAS_F5SDK = False
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,6 @@ import socket
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six import string_types
|
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -582,8 +581,10 @@ def main():
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
exit_json(module, results, client)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
|
cleanup_tokens(client)
|
||||||
fail_json(module, ex, client)
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,6 @@ remote_access:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.basic import env_fallback
|
|
||||||
from ansible.module_utils.six import iteritems
|
from ansible.module_utils.six import iteritems
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -152,7 +151,6 @@ try:
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 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 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 exit_json
|
from library.module_utils.network.f5.common import exit_json
|
||||||
from library.module_utils.network.f5.common import fail_json
|
from library.module_utils.network.f5.common import fail_json
|
||||||
|
@ -163,7 +161,6 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 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 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 exit_json
|
from ansible.module_utils.network.f5.common import exit_json
|
||||||
from ansible.module_utils.network.f5.common import fail_json
|
from ansible.module_utils.network.f5.common import fail_json
|
||||||
|
@ -547,8 +544,10 @@ def main():
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
exit_json(module, results, client)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
|
cleanup_tokens(client)
|
||||||
fail_json(module, ex, client)
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,6 @@ try:
|
||||||
from library.module_utils.network.f5.ipaddress import ipv6_netmask_to_cidr
|
from library.module_utils.network.f5.ipaddress import ipv6_netmask_to_cidr
|
||||||
from library.module_utils.compat.ipaddress import ip_address
|
from library.module_utils.compat.ipaddress import ip_address
|
||||||
from library.module_utils.compat.ipaddress import ip_network
|
from library.module_utils.compat.ipaddress import ip_network
|
||||||
from library.module_utils.compat.ipaddress import ip_interface
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from ansible.module_utils.network.f5.bigip import F5RestClient
|
from ansible.module_utils.network.f5.bigip import F5RestClient
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
from ansible.module_utils.network.f5.common import F5ModuleError
|
||||||
|
@ -181,7 +180,6 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.ipaddress import ipv6_netmask_to_cidr
|
from ansible.module_utils.network.f5.ipaddress import ipv6_netmask_to_cidr
|
||||||
from ansible.module_utils.compat.ipaddress import ip_address
|
from ansible.module_utils.compat.ipaddress import ip_address
|
||||||
from ansible.module_utils.compat.ipaddress import ip_network
|
from ansible.module_utils.compat.ipaddress import ip_network
|
||||||
from ansible.module_utils.compat.ipaddress import ip_interface
|
|
||||||
|
|
||||||
|
|
||||||
class Parameters(AnsibleF5Parameters):
|
class Parameters(AnsibleF5Parameters):
|
||||||
|
@ -684,8 +682,10 @@ def main():
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
|
cleanup_tokens(client)
|
||||||
exit_json(module, results, client)
|
exit_json(module, results, client)
|
||||||
except F5ModuleError as ex:
|
except F5ModuleError as ex:
|
||||||
|
cleanup_tokens(client)
|
||||||
fail_json(module, ex, client)
|
fail_json(module, ex, client)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,6 @@ security_banner:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.parsing.convert_bool import BOOLEANS
|
|
||||||
from ansible.module_utils.parsing.convert_bool import BOOLEANS_TRUE
|
from ansible.module_utils.parsing.convert_bool import BOOLEANS_TRUE
|
||||||
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE
|
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,6 @@ try:
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 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 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_complex_list
|
from library.module_utils.network.f5.common import compare_complex_list
|
||||||
try:
|
try:
|
||||||
|
@ -163,7 +162,6 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 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 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_complex_list
|
from ansible.module_utils.network.f5.common import compare_complex_list
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -184,7 +184,6 @@ qinq_ethertype:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.basic import env_fallback
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from library.module_utils.network.f5.bigip import HAS_F5SDK
|
from library.module_utils.network.f5.bigip import HAS_F5SDK
|
||||||
|
@ -192,8 +191,8 @@ try:
|
||||||
from library.module_utils.network.f5.common import F5ModuleError
|
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 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 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.compare import cmp_simple_list
|
||||||
try:
|
try:
|
||||||
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -204,8 +203,8 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import F5ModuleError
|
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 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 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.compare import cmp_simple_list
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -364,16 +363,8 @@ class Difference(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def interfaces(self):
|
def interfaces(self):
|
||||||
if self.want.interfaces is None:
|
result = cmp_simple_list(self.want.interfaces, self.have.interfaces)
|
||||||
return None
|
return result
|
||||||
if self.have.interfaces is None and self.want.interfaces == '':
|
|
||||||
return None
|
|
||||||
if self.have.interfaces is not None and self.want.interfaces == '':
|
|
||||||
return []
|
|
||||||
if self.have.interfaces is None:
|
|
||||||
return self.want.interfaces
|
|
||||||
if set(self.want.interfaces) != set(self.have.interfaces):
|
|
||||||
return self.want.interfaces
|
|
||||||
|
|
||||||
|
|
||||||
class ModuleManager(object):
|
class ModuleManager(object):
|
||||||
|
|
|
@ -218,11 +218,6 @@ except ImportError:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_F5SDK = False
|
HAS_F5SDK = False
|
||||||
|
|
||||||
try:
|
|
||||||
from StringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from io import StringIO
|
|
||||||
|
|
||||||
|
|
||||||
class Parameters(AnsibleF5Parameters):
|
class Parameters(AnsibleF5Parameters):
|
||||||
api_map = {
|
api_map = {
|
||||||
|
|
|
@ -650,6 +650,7 @@ try:
|
||||||
from library.module_utils.network.f5.common import transform_name
|
from library.module_utils.network.f5.common import transform_name
|
||||||
from library.module_utils.network.f5.common import mark_managed_by
|
from library.module_utils.network.f5.common import mark_managed_by
|
||||||
from library.module_utils.network.f5.common import only_has_managed_metadata
|
from library.module_utils.network.f5.common import only_has_managed_metadata
|
||||||
|
from library.module_utils.network.f5.compare import cmp_simple_list
|
||||||
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 ip_interface
|
from library.module_utils.network.f5.ipaddress import ip_interface
|
||||||
from library.module_utils.network.f5.ipaddress import validate_ip_v6_address
|
from library.module_utils.network.f5.ipaddress import validate_ip_v6_address
|
||||||
|
@ -667,6 +668,7 @@ except ImportError:
|
||||||
from ansible.module_utils.network.f5.common import transform_name
|
from ansible.module_utils.network.f5.common import transform_name
|
||||||
from ansible.module_utils.network.f5.common import mark_managed_by
|
from ansible.module_utils.network.f5.common import mark_managed_by
|
||||||
from ansible.module_utils.network.f5.common import only_has_managed_metadata
|
from ansible.module_utils.network.f5.common import only_has_managed_metadata
|
||||||
|
from ansible.module_utils.network.f5.compare import cmp_simple_list
|
||||||
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 ip_interface
|
from ansible.module_utils.network.f5.ipaddress import ip_interface
|
||||||
from ansible.module_utils.network.f5.ipaddress import validate_ip_v6_address
|
from ansible.module_utils.network.f5.ipaddress import validate_ip_v6_address
|
||||||
|
@ -2754,16 +2756,8 @@ class Difference(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def security_log_profiles(self):
|
def security_log_profiles(self):
|
||||||
if self.want.security_log_profiles is None:
|
result = cmp_simple_list(self.want.security_log_profiles, self.have.security_log_profiles)
|
||||||
return None
|
return result
|
||||||
if self.have.security_log_profiles is None and self.want.security_log_profiles == '':
|
|
||||||
return None
|
|
||||||
if self.have.security_log_profiles is not None and self.want.security_log_profiles == '':
|
|
||||||
return []
|
|
||||||
if self.have.security_log_profiles is None:
|
|
||||||
return self.want.security_log_profiles
|
|
||||||
if set(self.want.security_log_profiles) != set(self.have.security_log_profiles):
|
|
||||||
return self.want.security_log_profiles
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def security_nat_policy(self):
|
def security_nat_policy(self):
|
||||||
|
|
|
@ -385,41 +385,33 @@ class Difference(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def untagged_interfaces(self):
|
def untagged_interfaces(self):
|
||||||
result = []
|
result = self.cmp_interfaces(self.want.untagged_interfaces, self.have.untagged_interfaces, False)
|
||||||
if self.want.untagged_interfaces is None:
|
|
||||||
return None
|
|
||||||
elif self.want.untagged_interfaces == '' and self.have.untagged_interfaces is None:
|
|
||||||
return None
|
|
||||||
elif self.want.untagged_interfaces == '' and len(self.have.untagged_interfaces) > 0:
|
|
||||||
pass
|
|
||||||
elif not self.have.untagged_interfaces:
|
|
||||||
result = dict(
|
|
||||||
interfaces=[dict(name=x, untagged=True) for x in self.want.untagged_interfaces]
|
|
||||||
)
|
|
||||||
elif set(self.want.untagged_interfaces) != set(self.have.untagged_interfaces):
|
|
||||||
result = dict(
|
|
||||||
interfaces=[dict(name=x, untagged=True) for x in self.want.untagged_interfaces]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tagged_interfaces(self):
|
def tagged_interfaces(self):
|
||||||
|
result = self.cmp_interfaces(self.want.tagged_interfaces, self.have.tagged_interfaces, True)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def cmp_interfaces(self, want, have, tagged):
|
||||||
result = []
|
result = []
|
||||||
if self.want.tagged_interfaces is None:
|
if tagged:
|
||||||
|
tag_key = 'tagged'
|
||||||
|
else:
|
||||||
|
tag_key = 'untagged'
|
||||||
|
if want is None:
|
||||||
return None
|
return None
|
||||||
elif self.want.tagged_interfaces == '' and self.have.tagged_interfaces is None:
|
elif want == '' and have is None:
|
||||||
return None
|
return None
|
||||||
elif self.want.tagged_interfaces == '' and len(self.have.tagged_interfaces) > 0:
|
elif want == '' and len(have) > 0:
|
||||||
pass
|
pass
|
||||||
elif not self.have.tagged_interfaces:
|
elif not have:
|
||||||
result = dict(
|
result = dict(
|
||||||
interfaces=[dict(name=x, tagged=True) for x in self.want.tagged_interfaces]
|
interfaces=[{'name': x, tag_key: True} for x in want]
|
||||||
)
|
)
|
||||||
elif set(self.want.tagged_interfaces) != set(self.have.tagged_interfaces):
|
elif set(want) != set(have):
|
||||||
result = dict(
|
result = dict(
|
||||||
interfaces=[dict(name=x, tagged=True) for x in self.want.tagged_interfaces]
|
interfaces=[{'name': x, tag_key: True} for x in want]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue