From c629d5b0139c0dcd680af273745ab59ff30b19c0 Mon Sep 17 00:00:00 2001 From: Olaf Kilian Date: Fri, 20 Nov 2015 21:05:19 +0100 Subject: [PATCH] Add requirement and check for compatible version of docker-py --- cloud/docker/docker_login.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cloud/docker/docker_login.py b/cloud/docker/docker_login.py index 4fc4decbe62..cdc1f95d042 100644 --- a/cloud/docker/docker_login.py +++ b/cloud/docker/docker_login.py @@ -70,7 +70,7 @@ options: required: false default: 600 -requirements: [ "python >= 2.6", "docker-py" ] +requirements: [ "python >= 2.6", "docker-py >= 1.1.0" ] ''' EXAMPLES = ''' @@ -102,11 +102,16 @@ import os.path import json import base64 from urlparse import urlparse +from distutils.version import StrictVersion try: import docker.client from docker.errors import APIError as DockerAPIError has_lib_docker = True + if StrictVersion(docker.__version__) >= StrictVersion("1.1.0"): + has_correct_lib_docker_version = True + else: + has_correct_lib_docker_version = False except ImportError, e: has_lib_docker = False @@ -231,7 +236,10 @@ def main(): ) if not has_lib_docker: - module.fail_json(msg="python library docker-py required: pip install docker-py==1.1.0") + module.fail_json(msg="python library docker-py required: pip install docker-py>=1.1.0") + + if not has_correct_lib_docker_version: + module.fail_json(msg="your version of docker-py is outdated: pip install docker-py>=1.1.0") if not has_lib_requests_execeptions: module.fail_json(msg="python library requests required: pip install requests")