From 3daeea37ea21f743970690008b4b67c8639cf8cf Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Tue, 20 Jun 2017 22:21:21 +0000 Subject: [PATCH] Upgrade from docker-py to docker The pypi package 'docker-py' [1] has been renamed to 'docker' [2]. It is better to move to the new 'docker' package because the old package will be deprecated and all the new features will go into the new package only. Package 'docker' has been added to requirements [3]. The old package 'docker-py' is still allowed to be in the global requirements during the transition period but it should be removed after all or most of the projects finsih the migration. [1] https://pypi.python.org/pypi/docker-py [2] https://pypi.python.org/pypi/docker [3] https://review.openstack.org/#/c/423715/ Change-Id: Ibcd5a57a1fbf55dcc5a690e41f20917f95b63da0 --- ansible/library/kolla_container_facts.py | 5 +---- ansible/library/kolla_docker.py | 5 +---- ansible/library/kolla_toolbox.py | 5 +---- ansible/roles/baremetal/tasks/install.yml | 4 ++-- ansible/roles/prechecks/tasks/package_checks.yml | 2 +- ansible/roles/prechecks/vars/main.yml | 2 +- contrib/dev/vagrant/bootstrap.sh | 2 +- doc/quickstart.rst | 4 ++-- requirements.txt | 2 +- tests/test_kolla_docker.py | 2 +- tools/setup_gate.sh | 2 +- 11 files changed, 13 insertions(+), 22 deletions(-) diff --git a/ansible/library/kolla_container_facts.py b/ansible/library/kolla_container_facts.py index dcdd931e94..90816e2e25 100644 --- a/ansible/library/kolla_container_facts.py +++ b/ansible/library/kolla_container_facts.py @@ -53,10 +53,7 @@ import docker def get_docker_client(): - try: - return docker.Client - except AttributeError: - return docker.APIClient + return docker.APIClient def main(): diff --git a/ansible/library/kolla_docker.py b/ansible/library/kolla_docker.py index 5ed25617b7..f827c7a004 100644 --- a/ansible/library/kolla_docker.py +++ b/ansible/library/kolla_docker.py @@ -198,10 +198,7 @@ import docker def get_docker_client(): - try: - return docker.Client - except AttributeError: - return docker.APIClient + return docker.APIClient class DockerWorker(object): diff --git a/ansible/library/kolla_toolbox.py b/ansible/library/kolla_toolbox.py index 56039a5fba..0957a8bd1c 100644 --- a/ansible/library/kolla_toolbox.py +++ b/ansible/library/kolla_toolbox.py @@ -109,10 +109,7 @@ def gen_commandline(params): def get_docker_client(): - try: - return docker.Client - except AttributeError: - return docker.APIClient + return docker.APIClient def main(): diff --git a/ansible/roles/baremetal/tasks/install.yml b/ansible/roles/baremetal/tasks/install.yml index ea3e7d9a9c..978d4f7f74 100644 --- a/ansible/roles/baremetal/tasks/install.yml +++ b/ansible/roles/baremetal/tasks/install.yml @@ -52,8 +52,8 @@ easy_install: name=pip become: True -- name: Install docker-py - pip: name=docker-py state=latest +- name: Install docker SDK for python + pip: name=docker state=latest become: True - name: Remove packages diff --git a/ansible/roles/prechecks/tasks/package_checks.yml b/ansible/roles/prechecks/tasks/package_checks.yml index 4da8264afd..8dccfea426 100644 --- a/ansible/roles/prechecks/tasks/package_checks.yml +++ b/ansible/roles/prechecks/tasks/package_checks.yml @@ -1,5 +1,5 @@ --- -- name: Checking docker-py version +- name: Checking docker SDK version command: "{{ ansible_python.executable }} -c \"import docker; print docker.__version__\"" register: result changed_when: false diff --git a/ansible/roles/prechecks/vars/main.yml b/ansible/roles/prechecks/vars/main.yml index 059735d153..e5c83b75e3 100644 --- a/ansible/roles/prechecks/vars/main.yml +++ b/ansible/roles/prechecks/vars/main.yml @@ -1,4 +1,4 @@ --- docker_version_min: '1.10.0' -docker_py_version_min: '1.8.1' +docker_py_version_min: '2.0.0' ansible_version_min: '2.2.0' diff --git a/contrib/dev/vagrant/bootstrap.sh b/contrib/dev/vagrant/bootstrap.sh index ed3ae90017..009a840f61 100644 --- a/contrib/dev/vagrant/bootstrap.sh +++ b/contrib/dev/vagrant/bootstrap.sh @@ -76,7 +76,7 @@ function prep_work { exit 1 fi - pip install --upgrade docker-py + pip install --upgrade docker } # Do some cleanup after the installation of kolla diff --git a/doc/quickstart.rst b/doc/quickstart.rst index c0f280ce6b..e7f7bb6578 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -105,7 +105,7 @@ Component Min Version Max Version Comment ===================== =========== =========== ========================= Ansible 2.2.0 none On deployment host Docker 1.10.0 none On target nodes -Docker Python 1.8.1 none On target nodes +Docker Python 2.0.0 none On target nodes Python Jinja2 2.8.0 none On deployment host ===================== =========== =========== ========================= @@ -242,7 +242,7 @@ Or using ``pip`` to install the latest version: :: - pip install -U docker-py + pip install -U docker OpenStack, RabbitMQ, and Ceph require all hosts to have matching times to diff --git a/requirements.txt b/requirements.txt index 596e54fde0..d4bf3626a6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. pbr!=2.1.0,>=2.0.0 # Apache-2.0 -docker-py>=1.8.1 # Apache-2.0 +docker>=2.0.0 # Apache-2.0 Jinja2!=2.9.0,!=2.9.1,!=2.9.2,!=2.9.3,!=2.9.4,>=2.8 # BSD License (3 clause) six>=1.9.0 # MIT oslo.config!=4.3.0,!=4.4.0,>=4.0.0 # Apache-2.0 diff --git a/tests/test_kolla_docker.py b/tests/test_kolla_docker.py index cc5f23edaf..e947039893 100644 --- a/tests/test_kolla_docker.py +++ b/tests/test_kolla_docker.py @@ -173,7 +173,7 @@ FAKE_DATA = { } -@mock.patch("docker.Client") +@mock.patch("docker.APIClient") def get_DockerWorker(mod_param, mock_dclient): module = mock.MagicMock() module.params = mod_param diff --git a/tools/setup_gate.sh b/tools/setup_gate.sh index cf834bacbd..a872f32a6c 100755 --- a/tools/setup_gate.sh +++ b/tools/setup_gate.sh @@ -118,7 +118,7 @@ function setup_ansible { mkdir /tmp/kolla # TODO(SamYaple): Move to virtualenv - sudo -H pip install -U "ansible>=2" "docker-py>=1.6.0" "python-openstackclient" "python-neutronclient" "ara" + sudo -H pip install -U "ansible>=2" "docker>=2.0.0" "python-openstackclient" "python-neutronclient" "ara" detect_distro setup_inventory