Kaydet (Commit) 9e940708 authored tarafından Jan Losinski's avatar Jan Losinski Kaydeden (comit) Aanand Prasad

Add support for Tmpfs declaration in Hostconfig.

This adds support for the Tmpfs option introduced in Docker 1.10.
See: https://github.com/docker/docker/pull/13587Signed-off-by: 's avatarJan Losinski <losinski@wh2.tu-dresden.de>
üst 7befe694
...@@ -337,6 +337,33 @@ def convert_volume_binds(binds): ...@@ -337,6 +337,33 @@ def convert_volume_binds(binds):
return result return result
def convert_tmpfs_mounts(tmpfs):
if isinstance(tmpfs, dict):
return tmpfs
if not isinstance(tmpfs, list):
raise ValueError(
'Tmpfs spec must be a list'
)
result = {}
for mount in tmpfs:
if isinstance(mount, six.string_types):
if ":" in mount:
name, options = mount.split(":", 1)
else:
name = mount
options = ""
else:
raise ValueError(
"Tmpfs spec have to be str, unicode or tuple"
)
result[name] = options
return result
def parse_repository_tag(repo_name): def parse_repository_tag(repo_name):
parts = repo_name.rsplit('@', 1) parts = repo_name.rsplit('@', 1)
if len(parts) == 2: if len(parts) == 2:
...@@ -584,7 +611,7 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None, ...@@ -584,7 +611,7 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
mem_limit=None, memswap_limit=None, mem_swappiness=None, mem_limit=None, memswap_limit=None, mem_swappiness=None,
cgroup_parent=None, group_add=None, cpu_quota=None, cgroup_parent=None, group_add=None, cpu_quota=None,
cpu_period=None, oom_kill_disable=False, shm_size=None, cpu_period=None, oom_kill_disable=False, shm_size=None,
version=None): version=None, tmpfs=None):
host_config = {} host_config = {}
...@@ -751,6 +778,9 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None, ...@@ -751,6 +778,9 @@ def create_host_config(binds=None, port_bindings=None, lxc_conf=None,
host_config['CpuPeriod'] = cpu_period host_config['CpuPeriod'] = cpu_period
if tmpfs:
host_config["Tmpfs"] = convert_tmpfs_mounts(tmpfs)
return host_config return host_config
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment