From d7f7e44b9e8d4667b453ca79123f4c679900f770 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 15 May 2023 21:43:31 +0200 Subject: [PATCH] Make sure plugins/module_utils/socket_handler.py works when Docker SDK for Python is not installed. (#620) --- changelogs/fragments/620-bugfixes.yml | 2 ++ plugins/module_utils/socket_handler.py | 8 ++------ 2 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/620-bugfixes.yml diff --git a/changelogs/fragments/620-bugfixes.yml b/changelogs/fragments/620-bugfixes.yml new file mode 100644 index 00000000..982b0744 --- /dev/null +++ b/changelogs/fragments/620-bugfixes.yml @@ -0,0 +1,2 @@ +bugfixes: + - "socket_handler module utils - make sure this fully works when Docker SDK for Python is not available (https://github.com/ansible-collections/community.docker/pull/620)." diff --git a/plugins/module_utils/socket_handler.py b/plugins/module_utils/socket_handler.py index f4a3ef79..878dc7c5 100644 --- a/plugins/module_utils/socket_handler.py +++ b/plugins/module_utils/socket_handler.py @@ -9,15 +9,11 @@ __metaclass__ = type import os import os.path import socket as pysocket +import struct from ansible.module_utils.six import PY2 -try: - from docker.utils import socket as docker_socket - import struct -except Exception: - # missing Docker SDK for Python handled in ansible_collections.community.docker.plugins.module_utils.common - pass +from ansible_collections.community.docker.plugins.module_utils._api.utils import socket as docker_socket from ansible_collections.community.docker.plugins.module_utils.socket_helper import ( make_unblocking,