mirror of https://github.com/docker/docker-py.git
Add support for cpu_quota and cpu_period in host_config
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
02f330d8dc
commit
3ee30ed5e4
|
@ -457,7 +457,8 @@ def create_host_config(
|
||||||
restart_policy=None, cap_add=None, cap_drop=None, devices=None,
|
restart_policy=None, cap_add=None, cap_drop=None, devices=None,
|
||||||
extra_hosts=None, read_only=None, pid_mode=None, ipc_mode=None,
|
extra_hosts=None, read_only=None, pid_mode=None, ipc_mode=None,
|
||||||
security_opt=None, ulimits=None, log_config=None, mem_limit=None,
|
security_opt=None, ulimits=None, log_config=None, mem_limit=None,
|
||||||
memswap_limit=None, cgroup_parent=None, group_add=None, version=None
|
memswap_limit=None, cgroup_parent=None, group_add=None, cpu_quota=None,
|
||||||
|
cpu_period=None, version=None
|
||||||
):
|
):
|
||||||
host_config = {}
|
host_config = {}
|
||||||
|
|
||||||
|
@ -601,6 +602,22 @@ def create_host_config(
|
||||||
log_config = LogConfig(**log_config)
|
log_config = LogConfig(**log_config)
|
||||||
host_config['LogConfig'] = log_config
|
host_config['LogConfig'] = log_config
|
||||||
|
|
||||||
|
if cpu_quota and not isinstance(cpu_quota, int):
|
||||||
|
raise TypeError(
|
||||||
|
'Invalid type for cpu_quota param: expected int but'
|
||||||
|
' found {0}'.format(type(cpu_quota))
|
||||||
|
)
|
||||||
|
elif cpu_quota:
|
||||||
|
host_config['CpuQuota'] = cpu_quota
|
||||||
|
|
||||||
|
if cpu_period and not isinstance(cpu_period, int):
|
||||||
|
raise TypeError(
|
||||||
|
'Invalid type for cpu_period param: expected int but'
|
||||||
|
' found {0}'.format(type(cpu_period))
|
||||||
|
)
|
||||||
|
elif cpu_period:
|
||||||
|
host_config['CpuPeriod'] = cpu_period
|
||||||
|
|
||||||
return host_config
|
return host_config
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue