The variables used for reporting errors were incorrect. Additionally,
the fetching of connection related params was using an old format.
(cherry picked from commit dc08bca1fd
)
This commit is contained in:
parent
a018a1e6d4
commit
b97a47ac2c
2 changed files with 16 additions and 16 deletions
|
@ -37,7 +37,7 @@ class F5Client(F5BaseClient):
|
||||||
if self._client:
|
if self._client:
|
||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
for x in range(0, 60):
|
for x in range(0, 10):
|
||||||
try:
|
try:
|
||||||
result = ManagementRoot(
|
result = ManagementRoot(
|
||||||
self.provider['server'],
|
self.provider['server'],
|
||||||
|
@ -53,7 +53,7 @@ class F5Client(F5BaseClient):
|
||||||
exc = ex
|
exc = ex
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
error = 'Unable to connect to {0} on port {1}.'.format(
|
error = 'Unable to connect to {0} on port {1}.'.format(
|
||||||
self.params['server'], self.params['server_port']
|
self.provider['server'], self.provider['server_port']
|
||||||
)
|
)
|
||||||
|
|
||||||
if exc is not None:
|
if exc is not None:
|
||||||
|
@ -71,7 +71,6 @@ class F5RestClient(F5BaseClient):
|
||||||
exc = None
|
exc = None
|
||||||
if self._client:
|
if self._client:
|
||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
for x in range(0, 10):
|
for x in range(0, 10):
|
||||||
try:
|
try:
|
||||||
url = "https://{0}:{1}/mgmt/shared/authn/login".format(
|
url = "https://{0}:{1}/mgmt/shared/authn/login".format(
|
||||||
|
|
|
@ -29,32 +29,33 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
class F5Client(F5BaseClient):
|
class F5Client(F5BaseClient):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(F5Client, self).__init__(*args, **kwargs)
|
||||||
|
self.provider = self.merge_provider_params()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def api(self):
|
def api(self):
|
||||||
exc = None
|
exc = None
|
||||||
if self._client:
|
if self._client:
|
||||||
return self._client
|
return self._client
|
||||||
for x in range(0, 3):
|
for x in range(0, 10):
|
||||||
try:
|
try:
|
||||||
server = self.params['provider']['server'] or self.params['server']
|
|
||||||
user = self.params['provider']['user'] or self.params['user']
|
|
||||||
password = self.params['provider']['password'] or self.params['password']
|
|
||||||
server_port = self.params['provider']['server_port'] or self.params['server_port'] or 443
|
|
||||||
validate_certs = self.params['provider']['validate_certs'] or self.params['validate_certs']
|
|
||||||
|
|
||||||
result = ManagementRoot(
|
result = ManagementRoot(
|
||||||
server,
|
self.provider['server'],
|
||||||
user,
|
self.provider['user'],
|
||||||
password,
|
self.provider['password'],
|
||||||
port=server_port,
|
port=self.provider['server_port'],
|
||||||
verify=validate_certs
|
verify=self.provider['validate_certs']
|
||||||
)
|
)
|
||||||
self._client = result
|
self._client = result
|
||||||
return self._client
|
return self._client
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
exc = ex
|
exc = ex
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
error = 'Unable to connect to {0} on port {1}.'.format(self.params['server'], self.params['server_port'])
|
error = 'Unable to connect to {0} on port {1}.'.format(
|
||||||
|
self.provider['server'], self.provider['server_port']
|
||||||
|
)
|
||||||
|
|
||||||
if exc is not None:
|
if exc is not None:
|
||||||
error += ' The reported error was "{0}".'.format(str(exc))
|
error += ' The reported error was "{0}".'.format(str(exc))
|
||||||
raise F5ModuleError(error)
|
raise F5ModuleError(error)
|
||||||
|
|
Loading…
Reference in a new issue