20a859
From 949f87447031d8d83b8108aaa11046eb8a50650b Mon Sep 17 00:00:00 2001
20a859
From: Lars Kellogg-Stedman <lars@redhat.com>
20a859
Date: Thu, 8 Dec 2016 15:24:24 -0500
20a859
Subject: [PATCH] url_helper: fail gracefully if oauthlib is not available
20a859
20a859
We are unable to ship python-oauthlib in RHEL.  Allow imports of
20a859
url_helper to succeed even when oauthlib is unavailable.
20a859
20a859
X-downstream-only: true
20a859
---
20a859
 cloudinit/url_helper.py | 10 +++++++++-
20a859
 1 file changed, 9 insertions(+), 1 deletion(-)
20a859
20a859
diff --git a/cloudinit/url_helper.py b/cloudinit/url_helper.py
20a859
index 312b046..19c8148 100644
20a859
--- a/cloudinit/url_helper.py
20a859
+++ b/cloudinit/url_helper.py
20a859
@@ -17,7 +17,11 @@ import time
20a859
 from email.utils import parsedate
20a859
 from functools import partial
20a859
 
20a859
-import oauthlib.oauth1 as oauth1
20a859
+try:
20a859
+    import oauthlib.oauth1 as oauth1
20a859
+except ImportError:
20a859
+    oauth1 = None
20a859
+
20a859
 from requests import exceptions
20a859
 
20a859
 from six.moves.urllib.parse import (
20a859
@@ -481,6 +485,10 @@ class OauthUrlHelper(object):
20a859
 
20a859
 def oauth_headers(url, consumer_key, token_key, token_secret, consumer_secret,
20a859
                   timestamp=None):
20a859
+
20a859
+    if oauth1 is None:
20a859
+        raise NotImplementedError('oauth support is not available')
20a859
+
20a859
     if timestamp:
20a859
         timestamp = str(timestamp)
20a859
     else: