summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan S. Brown <sb@ryansb.com>2016-09-14 11:33:29 -0400
committerRyan S. Brown <sb@ryansb.com>2016-09-14 11:34:10 -0400
commit0bda419f66fa761408533228c36a9d2fbccc5e8f (patch)
tree105debbf3896671176e818e6531e5ab0322157aa
parent4656b6a8465dfc7f1356799f3b291c7f8d39e92a (diff)
downloadansible-0bda419f66fa761408533228c36a9d2fbccc5e8f.tar.gz
Allow AWSRetry class to be created without boto3/botocore installed
-rw-r--r--lib/ansible/module_utils/ec2.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/ansible/module_utils/ec2.py b/lib/ansible/module_utils/ec2.py
index 4e654c8f22..f9f18c1227 100644
--- a/lib/ansible/module_utils/ec2.py
+++ b/lib/ansible/module_utils/ec2.py
@@ -58,8 +58,18 @@ class AnsibleAWSError(Exception):
pass
+def _botocore_exception_maybe():
+ """
+ Allow for boto3 not being installed when using these utils by wrapping
+ botocore.exceptions instead of assigning from it directly.
+ """
+ if HAS_BOTO3:
+ return botocore.exceptions.ClientError
+ return type(None)
+
+
class AWSRetry(CloudRetry):
- base_class = botocore.exceptions.ClientError
+ base_class = _botocore_exception_maybe()
@staticmethod
def status_code_from_exception(error):