From 36c71dc9fb73b7fd7a4d664e715522168ee7c0ce Mon Sep 17 00:00:00 2001 From: Ante Karamatic Date: Wed, 17 Feb 2016 12:27:44 +0100 Subject: [PATCH 1/3] Give up also when Keystone denies connection, seen in Liberty --- hooks/hooks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/hooks.py b/hooks/hooks.py index 3b1313b4..39fa99c1 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -189,7 +189,7 @@ def setup_keystone_certs(unit=None, rid=None): import requests try: # Kilo and newer - from keystoneclient.exceptions import ConnectionRefused + from keystoneclient.exceptions import ConnectionRefused, Forbidden except ImportError: # Juno and older from keystoneclient.exceptions import ConnectionError as \ @@ -228,7 +228,7 @@ def setup_keystone_certs(unit=None, rid=None): # Juno and older ca_cert = requests.request('GET', auth_endpoint + '/certificates/ca').text - except (ConnectionRefused, requests.exceptions.ConnectionError): + except (ConnectionRefused, requests.exceptions.ConnectionError, Forbidden): log("Error connecting to keystone - skipping ca/signing cert setup", level=WARNING) return From 0b939b62175bf61bc40737c0e12d7d2cab5dee31 Mon Sep 17 00:00:00 2001 From: Ante Karamatic Date: Wed, 17 Feb 2016 15:32:06 +0100 Subject: [PATCH 2/3] Add Forbidden exception for Juno and older --- hooks/hooks.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hooks/hooks.py b/hooks/hooks.py index 39fa99c1..9a4b1a98 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -189,11 +189,16 @@ def setup_keystone_certs(unit=None, rid=None): import requests try: # Kilo and newer - from keystoneclient.exceptions import ConnectionRefused, Forbidden + from keystoneclient.exceptions import ( + ConnectionRefused, + Forbidden + ) except ImportError: # Juno and older - from keystoneclient.exceptions import ConnectionError as \ - ConnectionRefused + from keystoneclient.exceptions import ( + ConnectionError as ConnectionRefused, + Forbidden + ) from keystoneclient.v2_0 import client From e6eb46d3b0448b865019e188889fd1ebe2b50eb0 Mon Sep 17 00:00:00 2001 From: Ante Karamatic Date: Wed, 17 Feb 2016 17:02:22 +0100 Subject: [PATCH 3/3] Fix lint errors --- hooks/hooks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/hooks.py b/hooks/hooks.py index 9a4b1a98..e88c633e 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -192,13 +192,13 @@ def setup_keystone_certs(unit=None, rid=None): from keystoneclient.exceptions import ( ConnectionRefused, Forbidden - ) + ) except ImportError: # Juno and older from keystoneclient.exceptions import ( ConnectionError as ConnectionRefused, Forbidden - ) + ) from keystoneclient.v2_0 import client