From e2ba8a54935df8d40676529f67b16f5927e51000 Mon Sep 17 00:00:00 2001 From: Luke Marsden Date: Wed, 3 Jun 2015 12:00:43 +0100 Subject: Add volume_driver param to client.create_container - Add appropriate test which also asserts that volume names can be passed through to drivers. - Add new param to docs. Signed-off-by: Luke Marsden --- docker/client.py | 5 +++-- docker/utils/utils.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'docker') diff --git a/docker/client.py b/docker/client.py index b664806..0851865 100644 --- a/docker/client.py +++ b/docker/client.py @@ -465,7 +465,7 @@ class Client(requests.Session): network_disabled=False, name=None, entrypoint=None, cpu_shares=None, working_dir=None, domainname=None, memswap_limit=0, cpuset=None, host_config=None, - mac_address=None, labels=None): + mac_address=None, labels=None, volume_driver=None): if isinstance(volumes, six.string_types): volumes = [volumes, ] @@ -479,7 +479,8 @@ class Client(requests.Session): self._version, image, command, hostname, user, detach, stdin_open, tty, mem_limit, ports, environment, dns, volumes, volumes_from, network_disabled, entrypoint, cpu_shares, working_dir, domainname, - memswap_limit, cpuset, host_config, mac_address, labels + memswap_limit, cpuset, host_config, mac_address, labels, + volume_driver ) return self.create_container_from_config(config, name) diff --git a/docker/utils/utils.py b/docker/utils/utils.py index e4a3c9e..c60a5fa 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -486,7 +486,7 @@ def create_container_config( dns=None, volumes=None, volumes_from=None, network_disabled=False, entrypoint=None, cpu_shares=None, working_dir=None, domainname=None, memswap_limit=0, cpuset=None, host_config=None, mac_address=None, - labels=None + labels=None, volume_driver=None ): if isinstance(command, six.string_types): command = shlex.split(str(command)) @@ -586,4 +586,5 @@ def create_container_config( 'HostConfig': host_config, 'MacAddress': mac_address, 'Labels': labels, + 'VolumeDriver': volume_driver, } -- cgit v1.2.1 From e8229198585f0e459442a0b4aae79f9f4a04862b Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Tue, 16 Jun 2015 17:07:11 -0700 Subject: Only allow volume_driver param if API version >= 1.19 --- docker/utils/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'docker') diff --git a/docker/utils/utils.py b/docker/utils/utils.py index c60a5fa..7ab5592 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -497,10 +497,15 @@ def create_container_config( ] if labels is not None and compare_version('1.18', version) < 0: - raise errors.DockerException( + raise errors.InvalidVersion( 'labels were only introduced in API version 1.18' ) + if volume_driver is not None and compare_version('1.19', version) < 0: + raise errors.InvalidVersion( + 'Volume drivers were only introduced in API version 1.19' + ) + if isinstance(labels, list): labels = dict((lbl, six.text_type('')) for lbl in labels) @@ -554,9 +559,9 @@ def create_container_config( message = ('{0!r} parameter has no effect on create_container().' ' It has been moved to start()') if dns is not None: - raise errors.DockerException(message.format('dns')) + raise errors.InvalidVersion(message.format('dns')) if volumes_from is not None: - raise errors.DockerException(message.format('volumes_from')) + raise errors.InvalidVersion(message.format('volumes_from')) return { 'Hostname': hostname, -- cgit v1.2.1 From 5bda9da03632834c3b52c94097c087300f5d8ac0 Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Tue, 16 Jun 2015 17:07:32 -0700 Subject: Bumped default API version == 1.19 --- docker/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docker') diff --git a/docker/constants.py b/docker/constants.py index 233d9b1..f99f192 100644 --- a/docker/constants.py +++ b/docker/constants.py @@ -1,4 +1,4 @@ -DEFAULT_DOCKER_API_VERSION = '1.18' +DEFAULT_DOCKER_API_VERSION = '1.19' DEFAULT_TIMEOUT_SECONDS = 60 STREAM_HEADER_SIZE_BYTES = 8 CONTAINER_LIMITS_KEYS = [ -- cgit v1.2.1