mirror of https://github.com/docker/docker-py.git
Merge pull request #1459 from shin-/1300-storageopts
Add support for storage_opt in host_config
This commit is contained in:
commit
4a50784ad4
|
@ -549,6 +549,8 @@ class ContainerApiMixin(object):
|
||||||
security_opt (:py:class:`list`): A list of string values to
|
security_opt (:py:class:`list`): A list of string values to
|
||||||
customize labels for MLS systems, such as SELinux.
|
customize labels for MLS systems, such as SELinux.
|
||||||
shm_size (str or int): Size of /dev/shm (e.g. ``1G``).
|
shm_size (str or int): Size of /dev/shm (e.g. ``1G``).
|
||||||
|
storage_opt (dict): Storage driver options per container as a
|
||||||
|
key-value mapping.
|
||||||
sysctls (dict): Kernel parameters to set in the container.
|
sysctls (dict): Kernel parameters to set in the container.
|
||||||
tmpfs (dict): Temporary filesystems to mount, as a dictionary
|
tmpfs (dict): Temporary filesystems to mount, as a dictionary
|
||||||
mapping a path inside the container to options for that path.
|
mapping a path inside the container to options for that path.
|
||||||
|
|
|
@ -586,6 +586,8 @@ class ContainerCollection(Collection):
|
||||||
Default: ``False``.
|
Default: ``False``.
|
||||||
stop_signal (str): The stop signal to use to stop the container
|
stop_signal (str): The stop signal to use to stop the container
|
||||||
(e.g. ``SIGINT``).
|
(e.g. ``SIGINT``).
|
||||||
|
storage_opt (dict): Storage driver options per container as a
|
||||||
|
key-value mapping.
|
||||||
sysctls (dict): Kernel parameters to set in the container.
|
sysctls (dict): Kernel parameters to set in the container.
|
||||||
tmpfs (dict): Temporary filesystems to mount, as a dictionary
|
tmpfs (dict): Temporary filesystems to mount, as a dictionary
|
||||||
mapping a path inside the container to options for that path.
|
mapping a path inside the container to options for that path.
|
||||||
|
@ -833,6 +835,7 @@ RUN_HOST_CONFIG_KWARGS = [
|
||||||
'restart_policy',
|
'restart_policy',
|
||||||
'security_opt',
|
'security_opt',
|
||||||
'shm_size',
|
'shm_size',
|
||||||
|
'storage_opt',
|
||||||
'sysctls',
|
'sysctls',
|
||||||
'tmpfs',
|
'tmpfs',
|
||||||
'ulimits',
|
'ulimits',
|
||||||
|
|
|
@ -117,7 +117,7 @@ class HostConfig(dict):
|
||||||
oom_kill_disable=False, shm_size=None, sysctls=None,
|
oom_kill_disable=False, shm_size=None, sysctls=None,
|
||||||
tmpfs=None, oom_score_adj=None, dns_opt=None, cpu_shares=None,
|
tmpfs=None, oom_score_adj=None, dns_opt=None, cpu_shares=None,
|
||||||
cpuset_cpus=None, userns_mode=None, pids_limit=None,
|
cpuset_cpus=None, userns_mode=None, pids_limit=None,
|
||||||
isolation=None, auto_remove=False):
|
isolation=None, auto_remove=False, storage_opt=None):
|
||||||
|
|
||||||
if mem_limit is not None:
|
if mem_limit is not None:
|
||||||
self['Memory'] = parse_bytes(mem_limit)
|
self['Memory'] = parse_bytes(mem_limit)
|
||||||
|
@ -412,6 +412,11 @@ class HostConfig(dict):
|
||||||
raise host_config_version_error('auto_remove', '1.25')
|
raise host_config_version_error('auto_remove', '1.25')
|
||||||
self['AutoRemove'] = auto_remove
|
self['AutoRemove'] = auto_remove
|
||||||
|
|
||||||
|
if storage_opt is not None:
|
||||||
|
if version_lt(version, '1.24'):
|
||||||
|
raise host_config_version_error('storage_opt', '1.24')
|
||||||
|
self['StorageOpt'] = storage_opt
|
||||||
|
|
||||||
|
|
||||||
def host_config_type_error(param, param_value, expected):
|
def host_config_type_error(param, param_value, expected):
|
||||||
error_msg = 'Invalid type for {0} param: expected {1} but found {2}'
|
error_msg = 'Invalid type for {0} param: expected {1} but found {2}'
|
||||||
|
|
|
@ -422,6 +422,22 @@ class CreateContainerTest(BaseAPIIntegrationTest):
|
||||||
config = self.client.inspect_container(container)
|
config = self.client.inspect_container(container)
|
||||||
assert config['Config']['StopTimeout'] == 25
|
assert config['Config']['StopTimeout'] == 25
|
||||||
|
|
||||||
|
@requires_api_version('1.24')
|
||||||
|
def test_create_with_storage_opt(self):
|
||||||
|
if self.client.info()['Driver'] == 'aufs':
|
||||||
|
return pytest.skip('Not supported on AUFS')
|
||||||
|
host_config = self.client.create_host_config(
|
||||||
|
storage_opt={'size': '120G'}
|
||||||
|
)
|
||||||
|
container = self.client.create_container(
|
||||||
|
BUSYBOX, ['echo', 'test'], host_config=host_config
|
||||||
|
)
|
||||||
|
self.tmp_containers.append(container)
|
||||||
|
config = self.client.inspect_container(container)
|
||||||
|
assert config['HostConfig']['StorageOpt'] == {
|
||||||
|
'size': '120G'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class VolumeBindTest(BaseAPIIntegrationTest):
|
class VolumeBindTest(BaseAPIIntegrationTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
@ -75,6 +75,10 @@ class BaseAPIIntegrationTest(BaseIntegrationTest):
|
||||||
version=TEST_API_VERSION, timeout=60, **kwargs_from_env()
|
version=TEST_API_VERSION, timeout=60, **kwargs_from_env()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super(BaseAPIIntegrationTest, self).tearDown()
|
||||||
|
self.client.close()
|
||||||
|
|
||||||
def run_container(self, *args, **kwargs):
|
def run_container(self, *args, **kwargs):
|
||||||
container = self.client.create_container(*args, **kwargs)
|
container = self.client.create_container(*args, **kwargs)
|
||||||
self.tmp_containers.append(container)
|
self.tmp_containers.append(container)
|
||||||
|
|
Loading…
Reference in New Issue