summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2015-09-15 20:48:33 +0200
committerJoffrey F <joffrey@docker.com>2015-09-24 10:08:02 -0700
commit3ee30ed5e4fbfc54471ad4e591687a010322e9a7 (patch)
tree44bf99c3ea6a44729fcf098c4c1aa1816c91e305
parent02f330d8dc3da47215bed47b44fac73941ea6920 (diff)
downloaddocker-py-3ee30ed5e4fbfc54471ad4e591687a010322e9a7.tar.gz
Add support for cpu_quota and cpu_period in host_config
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/utils/utils.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index 46b3516..bbea8e7 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -457,7 +457,8 @@ def create_host_config(
restart_policy=None, cap_add=None, cap_drop=None, devices=None,
extra_hosts=None, read_only=None, pid_mode=None, ipc_mode=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 = {}
@@ -601,6 +602,22 @@ def create_host_config(
log_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