Merge pull request #2552 from dbonev/2452-implement-cpu-quota

Added support for cpu_quota flag
This commit is contained in:
Aanand Prasad 2015-12-17 12:21:15 +00:00
commit 100d6f2fbb
5 changed files with 12 additions and 1 deletions

View File

@ -31,6 +31,7 @@ DOCKER_CONFIG_KEYS = [
'cap_drop',
'cgroup_parent',
'command',
'cpu_quota',
'cpu_shares',
'cpuset',
'detach',

View File

@ -29,6 +29,7 @@
},
"container_name": {"type": "string"},
"cpu_shares": {"type": ["number", "string"]},
"cpu_quota": {"type": ["number", "string"]},
"cpuset": {"type": "string"},
"devices": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"dns": {"$ref": "#/definitions/string_or_list"},

View File

@ -59,6 +59,7 @@ DOCKER_START_KEYS = [
'restart',
'volumes_from',
'security_opt',
'cpu_quota',
]
@ -610,6 +611,7 @@ class Service(object):
security_opt=options.get('security_opt'),
ipc_mode=options.get('ipc'),
cgroup_parent=options.get('cgroup_parent'),
cpu_quota=options.get('cpu_quota'),
)
def build(self, no_cache=False, pull=False, force_rm=False):

View File

@ -385,12 +385,13 @@ specifying read-only access(``ro``) or read-write(``rw``).
- container_name
- service_name:rw
### cpu\_shares, cpuset, domainname, entrypoint, hostname, ipc, mac\_address, mem\_limit, memswap\_limit, privileged, read\_only, restart, stdin\_open, tty, user, working\_dir
### cpu\_shares, cpu\_quota, cpuset, domainname, entrypoint, hostname, ipc, mac\_address, mem\_limit, memswap\_limit, privileged, read\_only, restart, stdin\_open, tty, user, working\_dir
Each of these is a single value, analogous to its
[docker run](https://docs.docker.com/reference/run/) counterpart.
cpu_shares: 73
cpu_quota: 50000
cpuset: 0,1
entrypoint: /code/entrypoint.sh

View File

@ -102,6 +102,12 @@ class ServiceTest(DockerClientTestCase):
container.start()
self.assertEqual(container.get('HostConfig.CpuShares'), 73)
def test_create_container_with_cpu_quota(self):
service = self.create_service('db', cpu_quota=40000)
container = service.create_container()
container.start()
self.assertEqual(container.get('HostConfig.CpuQuota'), 40000)
def test_create_container_with_extra_hosts_list(self):
extra_hosts = ['somehost:162.242.195.82', 'otherhost:50.31.209.229']
service = self.create_service('db', extra_hosts=extra_hosts)