From df15583ad078eb2f4f25925ba699ceb7639930c2 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 19 Jul 2017 12:52:49 -0700 Subject: [PATCH] Promulgate house's fix for docker_volume to docker_secret * Revert change to docker_common as it's not as good as the try: except fix * limit docker_volume fix to ImportErrors * fix docker_secret i nthe same way * Remove docker_secret from import tests --- lib/ansible/module_utils/docker_common.py | 3 --- lib/ansible/modules/cloud/docker/docker_secret.py | 9 ++++++++- lib/ansible/modules/cloud/docker/docker_volume.py | 8 ++++---- test/sanity/import/skip.txt | 1 - 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/ansible/module_utils/docker_common.py b/lib/ansible/module_utils/docker_common.py index ca46823ff9b..2608fcd6e33 100644 --- a/lib/ansible/module_utils/docker_common.py +++ b/lib/ansible/module_utils/docker_common.py @@ -90,9 +90,6 @@ if not HAS_DOCKER_PY: def __init__(self, **kwargs): pass - class APIError: - def __init__(self, **kwargs): - pass class DockerBaseClass(object): diff --git a/lib/ansible/modules/cloud/docker/docker_secret.py b/lib/ansible/modules/cloud/docker/docker_secret.py index c45aa651c05..183ffd85240 100644 --- a/lib/ansible/modules/cloud/docker/docker_secret.py +++ b/lib/ansible/modules/cloud/docker/docker_secret.py @@ -145,8 +145,15 @@ secret_id: ''' import hashlib + +try: + from docker.errors import APIError +except ImportError: + # missing docker-py handled in ansible.module_utils.docker + pass + from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass, APIError +from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass from ansible.module_utils._text import to_native, to_bytes diff --git a/lib/ansible/modules/cloud/docker/docker_volume.py b/lib/ansible/modules/cloud/docker/docker_volume.py index 96d804e9a78..2265fcfe7a6 100644 --- a/lib/ansible/modules/cloud/docker/docker_volume.py +++ b/lib/ansible/modules/cloud/docker/docker_volume.py @@ -106,15 +106,15 @@ facts: sample: {} ''' -from ansible.module_utils.six import iteritems, text_type -from ansible.module_utils.docker_common import DockerBaseClass, AnsibleDockerClient - try: from docker.errors import APIError -except: +except ImportError: # missing docker-py handled in ansible.module_utils.docker pass +from ansible.module_utils.six import iteritems, text_type +from ansible.module_utils.docker_common import DockerBaseClass, AnsibleDockerClient + class TaskParameters(DockerBaseClass): def __init__(self, client): diff --git a/test/sanity/import/skip.txt b/test/sanity/import/skip.txt index 3cb419c2e06..309164decc2 100644 --- a/test/sanity/import/skip.txt +++ b/test/sanity/import/skip.txt @@ -41,7 +41,6 @@ lib/ansible/modules/cloud/cloudstack/cs_vpn_gateway.py lib/ansible/modules/cloud/cloudstack/cs_zone.py lib/ansible/modules/cloud/cloudstack/cs_zone_facts.py lib/ansible/modules/cloud/dimensiondata/dimensiondata_network.py -lib/ansible/modules/cloud/docker/docker_secret.py lib/ansible/modules/cloud/google/gc_storage.py lib/ansible/modules/cloud/google/gcdns_record.py lib/ansible/modules/cloud/google/gcdns_zone.py