diff options
author | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 11:55:22 -0700 |
---|---|---|
committer | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 11:55:22 -0700 |
commit | 6f44dc8efed3fd90d452ae39213564628df0acdb (patch) | |
tree | 9e123945e733f196b942b81e4312a06fb7eb5bc7 /docker | |
parent | 0c74f7ce9339080d4f27ee39365bc109bada0efb (diff) |
Imported Upstream version 1.2.3
Diffstat (limited to 'docker')
-rw-r--r-- | docker/client.py | 21 | ||||
-rw-r--r-- | docker/utils/decorators.py | 8 | ||||
-rw-r--r-- | docker/utils/utils.py | 9 | ||||
-rw-r--r-- | docker/version.py | 4 |
4 files changed, 31 insertions, 11 deletions
diff --git a/docker/client.py b/docker/client.py index 2d1349c..b664806 100644 --- a/docker/client.py +++ b/docker/client.py @@ -526,14 +526,19 @@ class Client(requests.Session): 'exec_start instead', DeprecationWarning ) create_res = self.exec_create( - container, cmd, detach, stdout, stderr, tty + container, cmd, stdout, stderr, tty ) return self.exec_start(create_res, detach, tty, stream) - def exec_create(self, container, cmd, stdout=True, stderr=True, tty=False): + def exec_create(self, container, cmd, stdout=True, stderr=True, tty=False, + privileged=False): if utils.compare_version('1.15', self._version) < 0: raise errors.InvalidVersion('Exec is not supported in API < 1.15') + if privileged and utils.compare_version('1.19', self._version) < 0: + raise errors.InvalidVersion( + 'Privileged exec is not supported in API < 1.19' + ) if isinstance(container, dict): container = container.get('Id') if isinstance(cmd, six.string_types): @@ -542,7 +547,7 @@ class Client(requests.Session): data = { 'Container': container, 'User': '', - 'Privileged': False, + 'Privileged': privileged, 'Tty': tty, 'AttachStdin': False, 'AttachStdout': stdout, @@ -730,7 +735,7 @@ class Client(requests.Session): raise errors.DeprecatedMethod( 'insert is not available for API version >=1.12' ) - api_url = self._url("/images/{0}/insert".fornat(image)) + api_url = self._url("/images/{0}/insert".format(image)) params = { 'url': url, 'path': path @@ -747,6 +752,8 @@ class Client(requests.Session): @check_resource def inspect_image(self, image): + if isinstance(image, dict): + image = image.get('Id') return self._result( self._get(self._url("/images/{0}/json".format(image))), True @@ -1059,6 +1066,12 @@ class Client(requests.Session): url = self._url("/containers/{0}/start".format(container)) if not start_config: start_config = None + elif utils.compare_version('1.15', self._version) > 0: + warnings.warn( + 'Passing host config parameters in start() is deprecated. ' + 'Please use host_config in create_container instead!', + DeprecationWarning + ) res = self._post_json(url, data=start_config) self._raise_for_status(res) diff --git a/docker/utils/decorators.py b/docker/utils/decorators.py index 1ed0b6a..4771da2 100644 --- a/docker/utils/decorators.py +++ b/docker/utils/decorators.py @@ -8,9 +8,9 @@ def check_resource(f): resource_id = kwargs.pop('container') elif kwargs.get('image'): resource_id = kwargs.pop('image') - else: - raise errors.NullResource( - 'image or container param is undefined' - ) + if not resource_id: + raise errors.NullResource( + 'image or container param is undefined' + ) return f(self, resource_id, *args, **kwargs) return wrapped diff --git a/docker/utils/utils.py b/docker/utils/utils.py index a18939d..724af46 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -174,6 +174,9 @@ def convert_port_bindings(port_bindings): def convert_volume_binds(binds): + if isinstance(binds, list): + return binds + result = [] for k, v in binds.items(): if isinstance(v, dict): @@ -322,6 +325,9 @@ def parse_bytes(s): if len(s) == 0: s = 0 else: + if s[-2:-1].isalpha() and s[-1].isalpha(): + if (s[-1] == "b" or s[-1] == "B"): + s = s[:-1] units = BYTE_UNITS suffix = s[-1].lower() @@ -380,7 +386,7 @@ def create_host_config( host_config['PublishAllPorts'] = publish_all_ports if read_only is not None: - host_config['ReadOnlyRootFs'] = read_only + host_config['ReadonlyRootfs'] = read_only if dns_search: host_config['DnsSearch'] = dns_search @@ -577,6 +583,7 @@ def create_container_config( 'Entrypoint': entrypoint, 'CpuShares': cpu_shares, 'Cpuset': cpuset, + 'CpusetCpus': cpuset, 'WorkingDir': working_dir, 'MemorySwap': memswap_limit, 'HostConfig': host_config, diff --git a/docker/version.py b/docker/version.py index a57056b..d7a9a77 100644 --- a/docker/version.py +++ b/docker/version.py @@ -1,2 +1,2 @@ -version = "1.2.2" -version_info = tuple([int(d) for d in version.replace("-dev", "").split(".")]) +version = "1.2.3" +version_info = tuple([int(d) for d in version.split("-")[0].split(".")]) |