mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Fixes repeated calls to create an API object (#35816)
This patch fixes repeated attempts that the module would make to re-create an API object. The change stores a copy for later lookup instead. This prevents uncontrolled tokens from being created.
This commit is contained in:
parent
e62c1cd050
commit
95188ed35c
4 changed files with 58 additions and 28 deletions
|
@ -27,7 +27,8 @@ except ImportError:
|
|||
class F5Client(F5BaseClient):
|
||||
@property
|
||||
def api(self):
|
||||
result = None
|
||||
if self._client:
|
||||
return self._client
|
||||
for x in range(0, 10):
|
||||
try:
|
||||
result = ManagementRoot(
|
||||
|
@ -38,13 +39,11 @@ class F5Client(F5BaseClient):
|
|||
verify=self.params['validate_certs'],
|
||||
token='local'
|
||||
)
|
||||
break
|
||||
self._client = result
|
||||
return self._client
|
||||
except Exception:
|
||||
time.sleep(3)
|
||||
if result:
|
||||
return result
|
||||
else:
|
||||
raise F5ModuleError(
|
||||
'Unable to connect to {0} on port {1}. '
|
||||
'Is "validate_certs" preventing this?'.format(self.params['server'], self.params['server_port'])
|
||||
)
|
||||
raise F5ModuleError(
|
||||
'Unable to connect to {0} on port {1}. '
|
||||
'Is "validate_certs" preventing this?'.format(self.params['server'], self.params['server_port'])
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue