Kaydet (Commit) 827bd98d authored tarafından Joffrey F's avatar Joffrey F

Merge branch 'master' of github.com:docker/docker-py

...@@ -6,7 +6,7 @@ from .. import utils ...@@ -6,7 +6,7 @@ from .. import utils
class ConfigApiMixin(object): class ConfigApiMixin(object):
@utils.minimum_version('1.25') @utils.minimum_version('1.30')
def create_config(self, name, data, labels=None): def create_config(self, name, data, labels=None):
""" """
Create a config Create a config
...@@ -35,7 +35,7 @@ class ConfigApiMixin(object): ...@@ -35,7 +35,7 @@ class ConfigApiMixin(object):
self._post_json(url, data=body), True self._post_json(url, data=body), True
) )
@utils.minimum_version('1.25') @utils.minimum_version('1.30')
@utils.check_resource('id') @utils.check_resource('id')
def inspect_config(self, id): def inspect_config(self, id):
""" """
...@@ -53,7 +53,7 @@ class ConfigApiMixin(object): ...@@ -53,7 +53,7 @@ class ConfigApiMixin(object):
url = self._url('/configs/{0}', id) url = self._url('/configs/{0}', id)
return self._result(self._get(url), True) return self._result(self._get(url), True)
@utils.minimum_version('1.25') @utils.minimum_version('1.30')
@utils.check_resource('id') @utils.check_resource('id')
def remove_config(self, id): def remove_config(self, id):
""" """
...@@ -73,7 +73,7 @@ class ConfigApiMixin(object): ...@@ -73,7 +73,7 @@ class ConfigApiMixin(object):
self._raise_for_status(res) self._raise_for_status(res)
return True return True
@utils.minimum_version('1.25') @utils.minimum_version('1.30')
def configs(self, filters=None): def configs(self, filters=None):
""" """
List configs List configs
......
...@@ -1018,7 +1018,10 @@ class ContainerApiMixin(object): ...@@ -1018,7 +1018,10 @@ class ContainerApiMixin(object):
""" """
params = {'t': timeout} params = {'t': timeout}
url = self._url("/containers/{0}/restart", container) url = self._url("/containers/{0}/restart", container)
res = self._post(url, params=params) conn_timeout = self.timeout
if conn_timeout is not None:
conn_timeout += timeout
res = self._post(url, params=params, timeout=conn_timeout)
self._raise_for_status(res) self._raise_for_status(res)
@utils.check_resource('container') @utils.check_resource('container')
...@@ -1107,9 +1110,10 @@ class ContainerApiMixin(object): ...@@ -1107,9 +1110,10 @@ class ContainerApiMixin(object):
else: else:
params = {'t': timeout} params = {'t': timeout}
url = self._url("/containers/{0}/stop", container) url = self._url("/containers/{0}/stop", container)
conn_timeout = self.timeout
res = self._post(url, params=params, if conn_timeout is not None:
timeout=(timeout + (self.timeout or 0))) conn_timeout += timeout
res = self._post(url, params=params, timeout=conn_timeout)
self._raise_for_status(res) self._raise_for_status(res)
@utils.check_resource('container') @utils.check_resource('container')
......
...@@ -1165,6 +1165,15 @@ class RestartContainerTest(BaseAPIIntegrationTest): ...@@ -1165,6 +1165,15 @@ class RestartContainerTest(BaseAPIIntegrationTest):
assert info2['State']['Running'] is True assert info2['State']['Running'] is True
self.client.kill(id) self.client.kill(id)
def test_restart_with_low_timeout(self):
container = self.client.create_container(BUSYBOX, ['sleep', '9999'])
self.client.start(container)
self.client.timeout = 1
self.client.restart(container, timeout=3)
self.client.timeout = None
self.client.restart(container, timeout=3)
self.client.kill(container)
def test_restart_with_dict_instead_of_id(self): def test_restart_with_dict_instead_of_id(self):
container = self.client.create_container(BUSYBOX, ['sleep', '9999']) container = self.client.create_container(BUSYBOX, ['sleep', '9999'])
assert 'Id' in container assert 'Id' in container
......
...@@ -1335,7 +1335,7 @@ class ContainerTest(BaseAPIClientTest): ...@@ -1335,7 +1335,7 @@ class ContainerTest(BaseAPIClientTest):
'POST', 'POST',
url_prefix + 'containers/3cc2351ab11b/restart', url_prefix + 'containers/3cc2351ab11b/restart',
params={'t': 2}, params={'t': 2},
timeout=DEFAULT_TIMEOUT_SECONDS timeout=(DEFAULT_TIMEOUT_SECONDS + 2)
) )
def test_restart_container_with_dict_instead_of_id(self): def test_restart_container_with_dict_instead_of_id(self):
...@@ -1345,7 +1345,7 @@ class ContainerTest(BaseAPIClientTest): ...@@ -1345,7 +1345,7 @@ class ContainerTest(BaseAPIClientTest):
'POST', 'POST',
url_prefix + 'containers/3cc2351ab11b/restart', url_prefix + 'containers/3cc2351ab11b/restart',
params={'t': 2}, params={'t': 2},
timeout=DEFAULT_TIMEOUT_SECONDS timeout=(DEFAULT_TIMEOUT_SECONDS + 2)
) )
def test_remove_container(self): def test_remove_container(self):
......
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