-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move RetryingBotoClientWrapper into module_utils.retries
This means we can use it later with non-module plugins
- Loading branch information
Showing
6 changed files
with
81 additions
and
40 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
changelogs/fragments/20221101-move-RetryingBotoClientWrapper.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- module_utils - moves RetryingBotoClientWrapper into module.retries so it's available for other plugin types (). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# (c) 2022 Red Hat Inc. | ||
# | ||
# This file is part of Ansible | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import (absolute_import, division, print_function) | ||
__metaclass__ = type | ||
|
||
from ansible.module_utils._text import to_native | ||
|
||
|
||
class AnsibleAWSError(Exception): | ||
|
||
def __str__(self): | ||
if self.exception and self.message: | ||
return "{0}: {1}".format(self.message, to_native(self.exception)) | ||
|
||
return super(AnsibleAWSError, self).__str__() | ||
|
||
def __init__(self, message=None, exception=None, **kwargs): | ||
if not message and not exception: | ||
super(AnsibleAWSError, self).__init__() | ||
if not message: | ||
super(AnsibleAWSError, self).__init__(exception) | ||
if not exception: | ||
super(AnsibleAWSError, self).__init__(message) | ||
|
||
self.exception = exception | ||
self.message = message | ||
|
||
# In places where passing more information to module.fail_json would be helpful | ||
# store the extra info. Other plugin types have to raise the correct exception | ||
# such as AnsibleLookupError, so can't easily consume this. | ||
self.kwargs = kwargs or {} | ||
|
||
|
||
class AnsibleBotocoreError(AnsibleAWSError): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters