From 8b24b3576817613dc375b1a5cdf03907d577312c Mon Sep 17 00:00:00 2001 From: Liam Young Date: Tue, 26 Jan 2016 16:51:44 +0000 Subject: [PATCH 1/2] If the swift proxy servers are down the swift client throws requests.exceptions.ConnectionError not exceptions.ClientException --- hooks/glance_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hooks/glance_utils.py b/hooks/glance_utils.py index fd68d9ac..ba7d5f66 100644 --- a/hooks/glance_utils.py +++ b/hooks/glance_utils.py @@ -1,5 +1,6 @@ #!/usr/bin/python +import requests import os import shutil import subprocess @@ -487,7 +488,8 @@ def swift_temp_url_key(): from swiftclient import exceptions @retry_on_exception(15, base_delay=10, - exc_type=exceptions.ClientException) + exc_type=(exceptions.ClientException, + requests.exceptions.ConnectionError)) def connect_and_post(): log('Connecting swift client...') swift_connection = client.Connection( From aef5836a851dec9d072e0a0a9a52fb1b915455b2 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Wed, 27 Jan 2016 12:41:15 +0000 Subject: [PATCH 2/2] Late import requests --- hooks/glance_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/glance_utils.py b/hooks/glance_utils.py index ba7d5f66..eb5014c4 100644 --- a/hooks/glance_utils.py +++ b/hooks/glance_utils.py @@ -1,6 +1,5 @@ #!/usr/bin/python -import requests import os import shutil import subprocess @@ -474,6 +473,7 @@ def swift_temp_url_key(): """Generate a temp URL key, post it to Swift and return its value. If it is already posted, the current value of the key will be returned. """ + import requests keystone_ctxt = context.IdentityServiceContext(service='glance', service_user='glance')() if not keystone_ctxt: