sailesh1993 / rpms / cloud-init

Forked from rpms/cloud-init a year ago
Clone
Karanbir Singh 079df3
diff -uNr cloud-init-0.7.5__orig/cloudinit/url_helper.py cloud-init-0.7.5/cloudinit/url_helper.py
Karanbir Singh 079df3
--- cloud-init-0.7.5__orig/cloudinit/url_helper.py	2014-04-01 19:26:07.000000000 +0100
Karanbir Singh 079df3
+++ cloud-init-0.7.5/cloudinit/url_helper.py	2014-08-29 11:21:04.347660108 +0100
Karanbir Singh 079df3
@@ -237,6 +237,14 @@
Karanbir Singh 079df3
             return UrlResponse(r)
Karanbir Singh 079df3
         except exceptions.RequestException as e:
Karanbir Singh 079df3
+            # CloudStack workaround to handle trailing slash (#7544)
Karanbir Singh 079df3
+            if e.response.status_code == 404:
Karanbir Singh 079df3
+                if url.endswith("/"):
Karanbir Singh 079df3
+                    url = url[:-1]
Karanbir Singh 079df3
+                    req_args["url"] = url
Karanbir Singh 079df3
+                else:
Karanbir Singh 079df3
+                    url = url + "/"
Karanbir Singh 079df3
+                    req_args["url"] = url
Karanbir Singh 8b7282
             if (isinstance(e, (exceptions.HTTPError))
Karanbir Singh 079df3
                 and hasattr(e, 'response')  # This appeared in v 0.10.8
Karanbir Singh 079df3
                 and hasattr(e.response, 'status_code')):
Karanbir Singh 079df3
                 excps.append(UrlError(e, code=e.response.status_code,