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

More bigip software fixes (#45633)

Fixes problems related to token timeout. Adds cleanup of tokens.
This commit is contained in:
Tim Rupp 2018-09-13 15:58:17 -04:00 committed by GitHub
parent ddb3764039
commit 5a3a865ca0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View file

@ -116,7 +116,6 @@ try:
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 fq_name
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 fail_json
@ -126,7 +125,6 @@ except ImportError:
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 fq_name
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 fail_json
@ -473,8 +471,10 @@ def main():
client = F5RestClient(**module.params)
mm = ModuleManager(module=module, client=client)
results = mm.exec_module()
cleanup_tokens(client)
exit_json(module, results, client)
except F5ModuleError as ex:
cleanup_tokens(client)
fail_json(module, ex, client)

View file

@ -71,26 +71,23 @@ RETURN = r'''
'''
import time
import ssl
from ansible.module_utils.basic import AnsibleModule
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.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 fq_name
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 fail_json
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.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 fq_name
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 fail_json
@ -416,6 +413,8 @@ class ModuleManager(object):
try:
self.client.reconnect()
volume = self.read_volume_from_device()
if volume is None:
continue
if 'active' in volume and volume['active'] is True:
break
except F5ModuleError:
@ -437,6 +436,9 @@ class ModuleManager(object):
while True:
time.sleep(10)
volume = self.read_volume_from_device()
if volume is None or 'status' not in volume:
self.client.reconnect()
continue
if volume['status'] == 'complete':
break
elif volume['status'] == 'failed':
@ -448,11 +450,15 @@ class ModuleManager(object):
self.client.provider['server_port'],
self.want.volume
)
resp = self.client.api.get(uri)
try:
resp = self.client.api.get(uri)
response = resp.json()
except ValueError as ex:
raise F5ModuleError(str(ex))
except ssl.SSLError:
# Suggests BIG-IP is still in the middle of restarting itself or
# restjavad is restarting.
return None
if 'code' in response and response['code'] == 400:
if 'message' in response:
@ -490,8 +496,10 @@ def main():
client = F5RestClient(**module.params)
mm = ModuleManager(module=module, client=client)
results = mm.exec_module()
cleanup_tokens(client)
exit_json(module, results, client)
except F5ModuleError as ex:
cleanup_tokens(client)
fail_json(module, ex, client)