Add cpu_shares option for docker module

This commit is contained in:
Alexey Wasilyev 2015-11-26 17:49:18 +03:00 committed by Matt Clay
parent c680611fe4
commit 4d30ae313d

View file

@ -366,6 +366,13 @@ options:
required: false
default: 60
version_added: "2.1"
cpu_shares:
description:
- CPU shares (relative weight). Requires docker-py >= 0.6.0.
required: false
default: 0
version_added: "2.0"
author:
- "Cove Schneider (@cove)"
- "Joshua Conner (@joshuaconner)"
@ -1160,6 +1167,16 @@ class DockerManager(object):
differing.append(container)
continue
# CPU_SHARES
expected_cpu_shares = self.module.params.get('cpu_shares')
actual_cpu_shares = container['HostConfig']['CpuShares']
if expected_cpu_shares and actual_cpu_shares != expected_cpu_shares:
self.reload_reasons.append('cpu_shares ({0} => {1})'.format(actual_cpu_shares, expected_cpu_shares))
differing.append(container)
continue
# MEM_LIMIT
try:
@ -1541,6 +1558,7 @@ class DockerManager(object):
'volumes_from': self.module.params.get('volumes_from'),
'dns': self.module.params.get('dns'),
'cpuset': self.module.params.get('cpu_set'),
'cpu_shares': self.module.params.get('cpu_shares'),
'user': self.module.params.get('docker_user'),
}
if docker.utils.compare_version('1.10', self.client.version()['ApiVersion']) >= 0:
@ -1769,6 +1787,7 @@ def main():
devices = dict(default=None, type='list'),
memory_limit = dict(default=0),
memory_swap = dict(default=0),
cpu_shares = dict(default=0),
docker_url = dict(),
use_tls = dict(default=None, choices=['no', 'encrypt', 'verify']),
tls_client_cert = dict(required=False, default=None, type='str'),