Get docker's default api version definition from both 1.2 location and pre-1.2 location

Fixes #1227
reviewable/pr18780/r1
Toshio Kuratomi 10 years ago
parent 09aa79c58f
commit e356692c74

@ -373,6 +373,13 @@ if HAS_DOCKER_PY:
from docker.errors import APIError as DockerAPIError
except ImportError:
from docker.client import APIError as DockerAPIError
try:
# docker-py 1.2+
import docker.constants
DEFAULT_DOCKER_API_VERSION = docker.constants.DEFAULT_DOCKER_API_VERSION
except (ImportError, AttributeError):
# docker-py less than 1.2
DEFAULT_DOCKER_API_VERSION = docker.client.DEFAULT_DOCKER_API_VERSION
def _human_to_bytes(number):
@ -563,9 +570,7 @@ class DockerManager(object):
else:
docker_url = 'unix://var/run/docker.sock'
docker_api_version = module.params.get('docker_api_version')
if not docker_api_version:
docker_api_version=docker.client.DEFAULT_DOCKER_API_VERSION
docker_api_version = module.params.get('docker_api_version', DEFAULT_DOCKER_API_VERSION)
tls_client_cert = module.params.get('tls_client_cert', None)
if not tls_client_cert and env_cert_path:

Loading…
Cancel
Save