diff options
author | Asteroide <thomas.duval@orange.com> | 2018-10-05 15:01:17 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-10-05 15:01:17 +0000 |
commit | cbea4e360e9bfaa9698cf7c61c83c96a1ba89b8c (patch) | |
tree | a8bf6a7bfb06605ed5bfab77570afbe1e46cff4b /moon_interface/moon_interface/authz_requests.py | |
parent | a3f68df52836676b23ac0f5e3d8c40c957ee80a7 (diff) | |
parent | 2e35a7e46f0929438c1c206e3116caa829f07dc6 (diff) |
Merge "Update code to 4.6 official version"
Diffstat (limited to 'moon_interface/moon_interface/authz_requests.py')
-rw-r--r-- | moon_interface/moon_interface/authz_requests.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/moon_interface/moon_interface/authz_requests.py b/moon_interface/moon_interface/authz_requests.py index c809053b..cf50dfe5 100644 --- a/moon_interface/moon_interface/authz_requests.py +++ b/moon_interface/moon_interface/authz_requests.py @@ -53,7 +53,9 @@ class AuthzRequest: raise exceptions.AuthzException( "error in address no hostname or hostip" ) + tried_hostnames = [] while tries < 2: + tried_hostnames.append(hostname) try: req = requests.post("http://{}:{}/authz".format( hostname, @@ -62,18 +64,20 @@ class AuthzRequest: if req.status_code != 200: raise exceptions.AuthzException( "Receive bad response from Authz function " - "(with address - {})".format(req.status_code) + "(with {} -> {})".format(hostname, req.status_code) ) success = True - break except requests.exceptions.ConnectionError: - logger.error("Cannot connect to {}".format( - "http://{}:{}/authz".format( - hostname, - self.container_chaining[0]["port"] - ))) - except: - logger.error("Unexpected error:", sys.exc_info()[0]) + if tries > 1: + logger.error("Cannot connect to {}".format( + "http://[{}]:{}/authz".format( + ", ".join(tried_hostnames), + self.container_chaining[0]["port"] + ))) + except Exception as e: + logger.exception(e) + else: + break hostname = self.container_chaining[0]["hostname"], tries += 1 |