summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-16 13:05:22 +0000
committerGerrit Code Review <review@openstack.org>2017-06-16 13:05:22 +0000
commitfbd558547e2513183c754a7c24563b495866d7f6 (patch)
tree08b8c88b45ada7d573083484b3dce48c3d4040a7
parente6da7152ab39cc05ffc958e43b88cd00a324bba5 (diff)
parent1e0785c32089229a65f0a3d469f899440d7af2a9 (diff)
Merge "Move to docker python SDK 2.x.x"
-rw-r--r--magnum/common/docker_utils.py6
-rw-r--r--magnum/conf/docker.py2
-rw-r--r--magnum/tests/unit/common/test_docker_utils.py16
-rw-r--r--requirements.txt2
4 files changed, 12 insertions, 14 deletions
diff --git a/magnum/common/docker_utils.py b/magnum/common/docker_utils.py
index d0790be..5d93449 100644
--- a/magnum/common/docker_utils.py
+++ b/magnum/common/docker_utils.py
@@ -14,8 +14,6 @@
14import contextlib 14import contextlib
15 15
16import docker 16import docker
17from docker import client
18from docker import tls
19from docker.utils import utils 17from docker.utils import utils
20 18
21from magnum.conductor.handlers.common import cert_manager 19from magnum.conductor.handlers.common import cert_manager
@@ -79,7 +77,7 @@ def docker_for_cluster(context, cluster):
79 magnum_cert.close() 77 magnum_cert.close()
80 78
81 79
82class DockerHTTPClient(client.Client): 80class DockerHTTPClient(docker.APIClient):
83 def __init__(self, url='unix://var/run/docker.sock', 81 def __init__(self, url='unix://var/run/docker.sock',
84 ver=CONF.docker.docker_remote_api_version, 82 ver=CONF.docker.docker_remote_api_version,
85 timeout=CONF.docker.default_timeout, 83 timeout=CONF.docker.default_timeout,
@@ -88,7 +86,7 @@ class DockerHTTPClient(client.Client):
88 client_cert=None): 86 client_cert=None):
89 87
90 if ca_cert and client_key and client_cert: 88 if ca_cert and client_key and client_cert:
91 ssl_config = tls.TLSConfig( 89 ssl_config = docker.tls.TLSConfig(
92 client_cert=(client_cert, client_key), 90 client_cert=(client_cert, client_key),
93 verify=ca_cert, 91 verify=ca_cert,
94 assert_hostname=False, 92 assert_hostname=False,
diff --git a/magnum/conf/docker.py b/magnum/conf/docker.py
index dbb0e07..fc65c06 100644
--- a/magnum/conf/docker.py
+++ b/magnum/conf/docker.py
@@ -17,7 +17,7 @@ docker_group = cfg.OptGroup(name='docker',
17 17
18docker_opts = [ 18docker_opts = [
19 cfg.StrOpt('docker_remote_api_version', 19 cfg.StrOpt('docker_remote_api_version',
20 default='1.20', 20 default='1.21',
21 help='Docker remote api version. Override it according to ' 21 help='Docker remote api version. Override it according to '
22 'specific docker api version in your environment.'), 22 'specific docker api version in your environment.'),
23 cfg.IntOpt('default_timeout', 23 cfg.IntOpt('default_timeout',
diff --git a/magnum/tests/unit/common/test_docker_utils.py b/magnum/tests/unit/common/test_docker_utils.py
index 110763b..8933957 100644
--- a/magnum/tests/unit/common/test_docker_utils.py
+++ b/magnum/tests/unit/common/test_docker_utils.py
@@ -12,7 +12,7 @@
12# License for the specific language governing permissions and limitations 12# License for the specific language governing permissions and limitations
13# under the License. 13# under the License.
14 14
15from docker import client as docker_py_client 15import docker
16import mock 16import mock
17 17
18from magnum.common import docker_utils 18from magnum.common import docker_utils
@@ -30,9 +30,9 @@ class TestDockerUtils(base.BaseTestCase):
30 def fake_version(): 30 def fake_version():
31 return {'ApiVersion': '1.18'} 31 return {'ApiVersion': '1.18'}
32 32
33 docker = mock.MagicMock() 33 docker_client = mock.MagicMock()
34 docker.version.side_effect = fake_version 34 docker_client.version.side_effect = fake_version
35 res = docker_utils.is_docker_api_version_atleast(docker, '1.19') 35 res = docker_utils.is_docker_api_version_atleast(docker_client, '1.21')
36 self.assertFalse(res) 36 self.assertFalse(res)
37 37
38 38
@@ -73,8 +73,8 @@ class DockerClientTestCase(base.BaseTestCase):
73 self.assertEqual(CONF.docker.default_timeout, 73 self.assertEqual(CONF.docker.default_timeout,
74 client.timeout) 74 client.timeout)
75 75
76 @mock.patch.object(docker_py_client.Client, 'inspect_container') 76 @mock.patch.object(docker.APIClient, 'inspect_container')
77 @mock.patch.object(docker_py_client.Client, 'containers') 77 @mock.patch.object(docker.APIClient, 'containers')
78 def test_list_instances(self, mock_containers, mock_inspect): 78 def test_list_instances(self, mock_containers, mock_inspect):
79 client = docker_utils.DockerHTTPClient() 79 client = docker_utils.DockerHTTPClient()
80 80
@@ -90,8 +90,8 @@ class DockerClientTestCase(base.BaseTestCase):
90 mock_containers.assert_called_once_with(all=True) 90 mock_containers.assert_called_once_with(all=True)
91 mock_inspect.assert_has_calls([mock.call(x) for x in range(0, 3)]) 91 mock_inspect.assert_has_calls([mock.call(x) for x in range(0, 3)])
92 92
93 @mock.patch.object(docker_py_client.Client, 'inspect_container') 93 @mock.patch.object(docker.APIClient, 'inspect_container')
94 @mock.patch.object(docker_py_client.Client, 'containers') 94 @mock.patch.object(docker.APIClient, 'containers')
95 def test_list_instances_inspect(self, mock_containers, mock_inspect): 95 def test_list_instances_inspect(self, mock_containers, mock_inspect):
96 client = docker_utils.DockerHTTPClient() 96 client = docker_utils.DockerHTTPClient()
97 97
diff --git a/requirements.txt b/requirements.txt
index c34c519..0beda31 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -13,7 +13,7 @@ WebOb>=1.7.1 # MIT
13alembic>=0.8.10 # MIT 13alembic>=0.8.10 # MIT
14cliff>=2.6.0 # Apache-2.0 14cliff>=2.6.0 # Apache-2.0
15decorator>=3.4.0 # BSD 15decorator>=3.4.0 # BSD
16docker-py>=1.8.1 # Apache-2.0 16docker>=2.0.0 # Apache-2.0
17enum34;python_version=='2.7' or python_version=='2.6' or python_version=='3.3' # BSD 17enum34;python_version=='2.7' or python_version=='2.6' or python_version=='3.3' # BSD
18eventlet!=0.18.3,!=0.20.1,<0.21.0,>=0.18.2 # MIT 18eventlet!=0.18.3,!=0.20.1,<0.21.0,>=0.18.2 # MIT
19iso8601>=0.1.11 # MIT 19iso8601>=0.1.11 # MIT