Merge pull request #1882 from sebi-hgdata/sebi/docker_memory_version_check

mem_limit client version check
This commit is contained in:
Toshio Kuratomi 2015-08-06 07:52:15 -07:00
commit 34b4d9c8b2

View file

@ -1404,12 +1404,12 @@ class DockerManager(object):
mem_limit = _human_to_bytes(self.module.params.get('memory_limit')) mem_limit = _human_to_bytes(self.module.params.get('memory_limit'))
except ValueError as e: except ValueError as e:
self.module.fail_json(msg=str(e)) self.module.fail_json(msg=str(e))
api_version = self.client.version()['ApiVersion']
params = {'image': self.module.params.get('image'), params = {'image': self.module.params.get('image'),
'command': self.module.params.get('command'), 'command': self.module.params.get('command'),
'ports': self.exposed_ports, 'ports': self.exposed_ports,
'volumes': self.volumes, 'volumes': self.volumes,
'mem_limit': mem_limit,
'environment': self.env, 'environment': self.env,
'hostname': self.module.params.get('hostname'), 'hostname': self.module.params.get('hostname'),
'domainname': self.module.params.get('domainname'), 'domainname': self.module.params.get('domainname'),
@ -1421,10 +1421,16 @@ class DockerManager(object):
'host_config': self.create_host_config(), 'host_config': self.create_host_config(),
'user': self.module.params.get('docker_user'), 'user': self.module.params.get('docker_user'),
} }
if self.ensure_capability('host_config', fail=False): if self.ensure_capability('host_config', fail=False):
params['host_config'] = self.get_host_config() params['host_config'] = self.get_host_config()
#For v1.19 API and above use HostConfig, otherwise use Config
if api_version < 1.19:
params['mem_limit'] = mem_limit
else:
params['host_config']['mem_limit'] = mem_limit
def do_create(count, params): def do_create(count, params):
results = [] results = []
for _ in range(count): for _ in range(count):