summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicheal Waltz <mwaltz@qualcomm.com>2015-07-23 11:34:33 -0700
committerToshio Kuratomi <toshio@fedoraproject.org>2015-08-06 09:50:47 -0700
commit1f1f646d9cedade0fad192c3fd1aa7b221366dd8 (patch)
tree9d9dcdd1493389bce0f5ae4496759ba818b4e06c
parent944aa1c4e54a9dbcf43776828ae283d2df634bec (diff)
downloadansible-modules-core-1f1f646d9cedade0fad192c3fd1aa7b221366dd8.tar.gz
Set the API version when checking differences in containers and use
this to determine the location of the Memory value depending on the version used. In v1.18 and earlier it was ['Config']['Memory'], but in v1.19 it changed to ['HostConfig']['Memory'].
-rw-r--r--cloud/docker/docker.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/cloud/docker/docker.py b/cloud/docker/docker.py
index 2d6e669d..c7f90c2c 100644
--- a/cloud/docker/docker.py
+++ b/cloud/docker/docker.py
@@ -892,6 +892,9 @@ class DockerManager(object):
running = self.get_running_containers()
current = self.get_inspect_containers(running)
+ #Get API version
+ api_version = self.client.version()['ApiVersion']
+
image = self.get_inspect_image()
if image is None:
# The image isn't present. Assume that we're about to pull a new
@@ -956,6 +959,10 @@ class DockerManager(object):
expected_mem = _human_to_bytes(self.module.params.get('memory_limit'))
actual_mem = container['HostConfig']['Memory']
+ #Use v1.18 API and earlier Memory element location
+ if docker_api_version <= 1.18:
+ actual_mem = container['Config']['Memory']
+
if expected_mem and actual_mem != expected_mem:
self.reload_reasons.append('memory ({0} => {1})'.format(actual_mem, expected_mem))
differing.append(container)