From 6306504c58e639bcdbff8d4463af4e8d729f7ef2 Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Fri, 22 Jul 2016 04:16:04 +1000 Subject: [PATCH] Lazy load oauthlib for plugin loading If oauthlib is not available the oauth plugins should not be marked as available when iterating plugins. Change-Id: Idabb7adf61dc5ca36fc1524af47e346f8f296245 --- keystoneauth1/extras/oauth1/_loading.py | 4 ++++ keystoneauth1/extras/oauth1/v3.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/keystoneauth1/extras/oauth1/_loading.py b/keystoneauth1/extras/oauth1/_loading.py index 20129f00..fa43232e 100644 --- a/keystoneauth1/extras/oauth1/_loading.py +++ b/keystoneauth1/extras/oauth1/_loading.py @@ -22,6 +22,10 @@ class V3OAuth1(loading.BaseIdentityLoader): def plugin_class(self): return v3.OAuth1 + @property + def available(self): + return v3.oauth1 is not None + def get_options(self): options = super(V3OAuth1, self).get_options() diff --git a/keystoneauth1/extras/oauth1/v3.py b/keystoneauth1/extras/oauth1/v3.py index bad801b5..98c768db 100644 --- a/keystoneauth1/extras/oauth1/v3.py +++ b/keystoneauth1/extras/oauth1/v3.py @@ -23,7 +23,10 @@ import logging -from oauthlib import oauth1 +try: + from oauthlib import oauth1 +except ImportError: + oauth1 = None from keystoneauth1.identity import v3