From ebd03eb6490b8e60fe0f090aac921efb7778f1f5 Mon Sep 17 00:00:00 2001 From: Andrew Gauld Date: Tue, 13 Aug 2019 13:32:27 +0000 Subject: Update obsolete docker python version Issue-ID: DCAEGEN2-1725 Signed-off-by: Andrew Gauld Change-Id: I2bbb52591c6c1774303d8d2b6bc3480fb28d9fac Signed-off-by: Andrew Gauld --- python-dockering/ChangeLog.md | 4 ++++ python-dockering/dockering/config_building.py | 2 +- python-dockering/dockering/core.py | 2 +- python-dockering/pom.xml | 2 +- python-dockering/setup.py | 4 ++-- python-dockering/tests/test_config_building.py | 14 +++++++------- python-dockering/tests/test_core.py | 1 - python-dockering/tox.ini | 2 +- 8 files changed, 17 insertions(+), 14 deletions(-) diff --git a/python-dockering/ChangeLog.md b/python-dockering/ChangeLog.md index d63a413..d471c85 100644 --- a/python-dockering/ChangeLog.md +++ b/python-dockering/ChangeLog.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.4.1] + +* Upgrade to use docker 4.x.x from docker-py 1.x.x + ## [1.4.0] * Turn off cert verification for https healthchecks. See comments in the code. diff --git a/python-dockering/dockering/config_building.py b/python-dockering/dockering/config_building.py index 08fd1c0..144131e 100644 --- a/python-dockering/dockering/config_building.py +++ b/python-dockering/dockering/config_building.py @@ -65,7 +65,7 @@ def create_envs_healthcheck(docker_config, default_interval="15s", # server cert verification because the hostname is actually the ip # address. envs["SERVICE_CHECK_TLS_SKIP_VERIFY"] = "true" - utils.logger.warn("Https-based health checks may not work because Registrator issue #516") + utils.logger.warning("Https-based health checks may not work because Registrator issue #516") elif hc["type"] == "script": envs["SERVICE_CHECK_SCRIPT"] = hc["script"] elif hc["type"] == "docker": diff --git a/python-dockering/dockering/core.py b/python-dockering/dockering/core.py index d82e346..b70aabb 100644 --- a/python-dockering/dockering/core.py +++ b/python-dockering/dockering/core.py @@ -34,7 +34,7 @@ def create_client(hostname, port, reauth=False, logins=[]): """ base_url = "tcp://{0}:{1}".format(hostname, port) try: - client = docker.Client(base_url=base_url) + client = docker.APIClient(base_url=base_url) for dcl in logins: dcl["reauth"] = reauth diff --git a/python-dockering/pom.xml b/python-dockering/pom.xml index 887266d..96a05be 100644 --- a/python-dockering/pom.xml +++ b/python-dockering/pom.xml @@ -27,7 +27,7 @@ limitations under the License. org.onap.dcaegen2.utils python-dockering dcaegen2-utils-python-dockering - 1.1.0-SNAPSHOT + 1.4.1-SNAPSHOT http://maven.apache.org diff --git a/python-dockering/setup.py b/python-dockering/setup.py index 45da8de..9e32b72 100644 --- a/python-dockering/setup.py +++ b/python-dockering/setup.py @@ -23,14 +23,14 @@ from setuptools import setup setup( name='onap-dcae-dockering', description='Library used to manage Docker containers in DCAE', - version="1.4.0", + version="1.4.1", license='Apache 2', author="Michael Hwang", email="mhwang@research.att.com", packages=['dockering'], zip_safe=False, install_requires=[ - "docker-py>=1.0.0,<2.0.0", + "docker>=4.0.0,<5.0.0", "six" ] ) diff --git a/python-dockering/tests/test_config_building.py b/python-dockering/tests/test_config_building.py index 16ecb58..c1df84a 100644 --- a/python-dockering/tests/test_config_building.py +++ b/python-dockering/tests/test_config_building.py @@ -26,20 +26,20 @@ from dockering.exceptions import DockerConstructionError # The docker-py library sneakily expects version to "know" that there is an # actual Docker API that you can connect with. -DOCKER_API_VERSION = "1.24" -create_host_config = partial(docker.utils.utils.create_host_config, +DOCKER_API_VERSION = "auto" +HostConfig = partial(docker.types.HostConfig, version=DOCKER_API_VERSION) def test_add_host_config_params_volumes(): hcp = doc.add_host_config_params_volumes() - hc = create_host_config(**hcp) + hc = HostConfig(**hcp) expected = { 'NetworkMode': 'default' } assert expected == hc volumes = [{"host": {"path": "some-path-host"}, "container": {"bind": "some-path-container", "mode": "ro"}}] hcp = doc.add_host_config_params_volumes(volumes=volumes) - hc = create_host_config(**hcp) + hc = HostConfig(**hcp) expected = {'Binds': ['some-path-host:some-path-container:ro'], 'NetworkMode': 'default'} assert expected == hc @@ -47,13 +47,13 @@ def test_add_host_config_params_volumes(): def test_add_host_config_params_ports(): ports = [ "22:22", "80:80" ] hcp = doc.add_host_config_params_ports(ports=ports) - hc = create_host_config(**hcp) + hc = HostConfig(**hcp) expected = {'PortBindings': {'22/tcp': [{'HostPort': '22', 'HostIp': ''}], '80/tcp': [{'HostPort': '80', 'HostIp': ''}]}, 'NetworkMode': 'default'} assert expected == hc hcp = doc.add_host_config_params_ports() - hc = create_host_config(**hcp) + hc = HostConfig(**hcp) expected = {'NetworkMode': 'default', 'PublishAllPorts': True} assert expected == hc @@ -61,7 +61,7 @@ def test_add_host_config_params_ports(): def test_add_host_config_params_dns(): docker_host = "192.168.1.1" hcp = doc.add_host_config_params_dns(docker_host) - hc = create_host_config(**hcp) + hc = HostConfig(**hcp) expected = {'NetworkMode': 'default', 'DnsSearch': ['service.consul'], 'Dns': ['192.168.1.1'], 'ExtraHosts': ['consul:192.168.1.1']} assert expected == hc diff --git a/python-dockering/tests/test_core.py b/python-dockering/tests/test_core.py index 76e027b..08cadfc 100644 --- a/python-dockering/tests/test_core.py +++ b/python-dockering/tests/test_core.py @@ -20,7 +20,6 @@ import os from functools import partial import pytest -import docker from dockering import core as doc from dockering.exceptions import DockerError, DockerConnectionError diff --git a/python-dockering/tox.ini b/python-dockering/tox.ini index 71de279..4a4d41e 100644 --- a/python-dockering/tox.ini +++ b/python-dockering/tox.ini @@ -1,6 +1,6 @@ # content of: tox.ini , put in same dir as setup.py [tox] -envlist = py27,py35 +envlist = py27,py36 [testenv] deps= -- cgit 1.2.3-korg