mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #7925 from devpopol/fixes/api_error
fixes the now-incorrect module for ApiError -- noticed since 0.3.2
This commit is contained in:
commit
05eb6aacec
1 changed files with 7 additions and 2 deletions
|
@ -113,6 +113,11 @@ except ImportError, e:
|
||||||
print "failed=True msg='failed to import python module: %s'" % e
|
print "failed=True msg='failed to import python module: %s'" % e
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from docker.errors import APIError as DockerAPIError
|
||||||
|
except ImportError:
|
||||||
|
from docker.client import APIError as DockerAPIError
|
||||||
|
|
||||||
class DockerImageManager:
|
class DockerImageManager:
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
|
@ -187,7 +192,7 @@ class DockerImageManager:
|
||||||
try:
|
try:
|
||||||
self.client.remove_image(i['Id'])
|
self.client.remove_image(i['Id'])
|
||||||
self.changed = True
|
self.changed = True
|
||||||
except docker.APIError as e:
|
except DockerAPIError as e:
|
||||||
# image can be removed by docker if not used
|
# image can be removed by docker if not used
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -235,7 +240,7 @@ def main():
|
||||||
|
|
||||||
module.exit_json(failed=failed, changed=manager.has_changed(), msg=msg, image_id=image_id)
|
module.exit_json(failed=failed, changed=manager.has_changed(), msg=msg, image_id=image_id)
|
||||||
|
|
||||||
except docker.client.APIError as e:
|
except DockerAPIError as e:
|
||||||
module.exit_json(failed=True, changed=manager.has_changed(), msg="Docker API error: " + e.explanation)
|
module.exit_json(failed=True, changed=manager.has_changed(), msg="Docker API error: " + e.explanation)
|
||||||
|
|
||||||
except RequestException as e:
|
except RequestException as e:
|
||||||
|
|
Loading…
Reference in a new issue