fixes edge cases where software installation would time out if tomcat was not ready (#61065)

pull/60571/head
Wojciech Wypior 5 years ago committed by Tim Rupp
parent adb886e4ce
commit 0210447fa7

@ -6,6 +6,7 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import time
try:
from library.module_utils.network.f5.common import F5BaseClient
@ -24,6 +25,7 @@ class F5RestClient(F5BaseClient):
self.headers = {
'Content-Type': 'application/json'
}
self.retries = 0
@property
def api(self):
@ -57,8 +59,15 @@ class F5RestClient(F5BaseClient):
)
if response.status not in [200]:
return None, response.content
if b'Configuration Utility restarting...' in response.content and self.retries < 3:
time.sleep(30)
self.retries += 1
return self.connect_via_token_auth()
else:
self.retries = 0
return None, response.content
self.retries = 0
session.request.headers['X-F5-Auth-Token'] = response.json()['token']['token']
return session, None
@ -78,5 +87,12 @@ class F5RestClient(F5BaseClient):
)
if response.status not in [200]:
return None, response.content
if b'Configuration Utility restarting...' in response.content and self.retries < 3:
time.sleep(30)
self.retries += 1
return self.connect_via_basic_auth()
else:
self.retries = 0
return None, response.content
self.retries = 0
return session, None

@ -43,6 +43,7 @@ options:
extends_documentation_fragment: f5
author:
- Tim Rupp (@caphrim007)
- Wojciech Wypior (@wojtek0806)
'''
EXAMPLES = r'''
- name: Ensure an existing image is installed in specified volume
@ -75,6 +76,7 @@ RETURN = r'''
import time
import ssl
from ansible.module_utils.six.moves.urllib.error import URLError
from ansible.module_utils.urls import urlparse
from ansible.module_utils.basic import AnsibleModule
@ -340,6 +342,9 @@ class ModuleManager(object):
self._set_volume_url(item)
break
if not self.volume_url:
self.volume_url = uri + self.want.volume
resp = self.client.api.get(self.volume_url)
try:
@ -470,6 +475,9 @@ class ModuleManager(object):
# Suggests BIG-IP is still in the middle of restarting itself or
# restjavad is restarting.
return None
except URLError:
# At times during reboot BIG-IP will reset or timeout connections so we catch and pass this here.
return None
if 'code' in response and response['code'] == 400:
if 'message' in response:

Loading…
Cancel
Save