summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2015-08-24 14:43:36 -0700
committerJoffrey F <joffrey@docker.com>2015-08-24 14:43:36 -0700
commit9bb6a6fd5649e33af88242b09fa0a5d979ea9220 (patch)
treef24f63fd4e2f8881a2e3d6d243ce22985c7f9369
parent4008cbce7131b6c33aec61035050e2adf975d4a3 (diff)
parent3caaa0050b044462157b755f3810e44857d73761 (diff)
downloaddocker-py-9bb6a6fd5649e33af88242b09fa0a5d979ea9220.tar.gz
Merge branch 'mohitsoni-master'
-rw-r--r--docker/utils/utils.py5
-rw-r--r--tests/test.py18
2 files changed, 22 insertions, 1 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index 8ac38e3..a3b63f4 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -395,7 +395,7 @@ 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
+ memswap_limit=None, cgroup_parent=None
):
host_config = {}
@@ -500,6 +500,9 @@ def create_host_config(
if lxc_conf is not None:
host_config['LxcConf'] = lxc_conf
+ if cgroup_parent is not None:
+ host_config['CgroupParent'] = cgroup_parent
+
if ulimits is not None:
if not isinstance(ulimits, list):
raise errors.DockerException(
diff --git a/tests/test.py b/tests/test.py
index 9e12bb8..5295763 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -492,6 +492,24 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
self.assertEqual(args[1]['headers'],
{'Content-Type': 'application/json'})
+ def test_create_container_with_cgroup_parent(self):
+ try:
+ self.client.create_container(
+ 'busybox', 'ls', host_config=create_host_config(
+ cgroup_parent='test'
+ )
+ )
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+
+ args = fake_request.call_args
+ self.assertEqual(args[0][0],
+ url_prefix + 'containers/create')
+ data = json.loads(args[1]['data'])
+ self.assertIn('HostConfig', data)
+ self.assertIn('CgroupParent', data['HostConfig'])
+ self.assertEqual(data['HostConfig']['CgroupParent'], 'test')
+
def test_create_container_with_working_dir(self):
try:
self.client.create_container('busybox', 'ls',