docker modules: various adjustments (#51700)
* Move docker_ module_utils into subpackage. * Remove docker_ prefix from module_utils.docker modules. * Adding jurisdiction for module_utils/docker to $team_docker. * Making docker* unit tests community supported. * Linting. * Python < 2.6 is not supported. * Refactoring docker-py version comments. Moving them to doc fragments. Cleaning up some indentations.pull/4420/head
parent
88df4e22d3
commit
0c2bb3da04
|
@ -582,8 +582,7 @@ files:
|
|||
labels: windows
|
||||
maintainers: $team_windows_core
|
||||
support: core
|
||||
$module_utils/docker_common.py: *docker
|
||||
$module_utils/docker_swarm.py: *docker
|
||||
$module_utils/docker/: *docker
|
||||
$module_utils/ec2.py:
|
||||
support: core
|
||||
labels:
|
||||
|
@ -1289,6 +1288,7 @@ files:
|
|||
test/integration/targets/postgresql: *postgresql
|
||||
test/integration/targets/setup_acme:
|
||||
maintainers: resmo felixfontein
|
||||
test/integration/targets/setup_docker: *docker
|
||||
test/integration/targets/setup_mysql_db: *mysql
|
||||
test/integration/targets/setup_zabbix:
|
||||
maintainers: eikef D3DeFi
|
||||
|
@ -1304,8 +1304,13 @@ files:
|
|||
test/legacy/scaleway:
|
||||
<<: *scaleway
|
||||
support: community
|
||||
test/units/module_utils/docker/:
|
||||
<<: *docker
|
||||
support: community
|
||||
test/units/module_utils/facts/network/test_generic_bsd.py: *bsd
|
||||
test/units/modules/cloud/docker: *docker
|
||||
test/units/modules/cloud/docker:
|
||||
<<: *docker
|
||||
support: community
|
||||
test/units/modules/network:
|
||||
maintainers: $team_networking
|
||||
labels: networking
|
||||
|
|
|
@ -7,11 +7,11 @@ import json
|
|||
try:
|
||||
from docker.errors import APIError
|
||||
except ImportError:
|
||||
# missing docker-py handled in ansible.module_utils.docker_common
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient
|
||||
from ansible.module_utils.docker.common import AnsibleDockerClient
|
||||
|
||||
|
||||
class AnsibleDockerSwarmClient(AnsibleDockerClient):
|
|
@ -141,18 +141,10 @@ options:
|
|||
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.8.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- "docker-compose >= 1.7.0"
|
||||
- "Docker API >= 1.20"
|
||||
- "PyYAML >= 3.11"
|
||||
|
@ -468,7 +460,7 @@ except ImportError as exc:
|
|||
HAS_COMPOSE_EXC = str(exc)
|
||||
DEFAULT_TIMEOUT = 10
|
||||
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass
|
||||
from ansible.module_utils.docker.common import AnsibleDockerClient, DockerBaseClass
|
||||
|
||||
|
||||
AUTH_PARAM_MAPPING = {
|
||||
|
|
|
@ -68,14 +68,10 @@ options:
|
|||
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_2_documentation
|
||||
|
||||
requirements:
|
||||
- "python >= 2.7"
|
||||
- "docker >= 2.6.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
Version 2.6.0 or newer is only available with the C(docker) module."
|
||||
- "Docker API >= 1.30"
|
||||
|
||||
author:
|
||||
|
@ -162,10 +158,10 @@ import hashlib
|
|||
try:
|
||||
from docker.errors import APIError
|
||||
except ImportError:
|
||||
# missing docker-py handled in ansible.module_utils.docker_common
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass, compare_generic
|
||||
from ansible.module_utils.docker.common import AnsibleDockerClient, DockerBaseClass, compare_generic
|
||||
from ansible.module_utils._text import to_native, to_bytes
|
||||
|
||||
|
||||
|
|
|
@ -587,6 +587,7 @@ options:
|
|||
version_added: "2.4"
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
|
||||
author:
|
||||
- "Cove Schneider (@cove)"
|
||||
|
@ -599,16 +600,7 @@ author:
|
|||
- "Kassian Sun (@kassiansun)"
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.8.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- "Docker API >= 1.20"
|
||||
'''
|
||||
|
||||
|
@ -875,7 +867,7 @@ from datetime import timedelta
|
|||
from distutils.version import LooseVersion
|
||||
|
||||
from ansible.module_utils.basic import human_to_bytes
|
||||
from ansible.module_utils.docker_common import (
|
||||
from ansible.module_utils.docker.common import (
|
||||
AnsibleDockerClient,
|
||||
DockerBaseClass, sanitize_result, is_image_name_id,
|
||||
compare_generic, DifferenceTracker,
|
||||
|
@ -884,14 +876,14 @@ from ansible.module_utils.six import string_types
|
|||
|
||||
try:
|
||||
from docker import utils
|
||||
from ansible.module_utils.docker_common import docker_version
|
||||
from ansible.module_utils.docker.common import docker_version
|
||||
if LooseVersion(docker_version) >= LooseVersion('1.10.0'):
|
||||
from docker.types import Ulimit, LogConfig
|
||||
else:
|
||||
from docker.utils.types import Ulimit, LogConfig
|
||||
from docker.errors import APIError, NotFound
|
||||
except Exception:
|
||||
# missing docker-py handled in ansible.module_utils.docker
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
|
||||
|
@ -1546,7 +1538,7 @@ class TaskParameters(DockerBaseClass):
|
|||
elif key == 'retries':
|
||||
try:
|
||||
result[key] = int(result[key])
|
||||
except Exception as e:
|
||||
except Exception as dummy:
|
||||
self.fail('Cannot parse number of retries for healthcheck. '
|
||||
'Expected an integer, got "{0}".'.format(result[key]))
|
||||
|
||||
|
@ -2555,7 +2547,7 @@ class ContainerManager(DockerBaseClass):
|
|||
while True:
|
||||
try:
|
||||
response = self.client.remove_container(container_id, v=volume_state, link=link, force=force)
|
||||
except NotFound as exc:
|
||||
except NotFound as dummy:
|
||||
pass
|
||||
except APIError as exc:
|
||||
if 'Unpause the container before stopping or killing' in exc.explanation:
|
||||
|
|
|
@ -33,21 +33,13 @@ options:
|
|||
required: true
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
|
||||
author:
|
||||
- "Felix Fontein (@felixfontein)"
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.8.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- "Docker API >= 1.20"
|
||||
'''
|
||||
|
||||
|
@ -114,7 +106,7 @@ docker_container:
|
|||
}'
|
||||
'''
|
||||
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient
|
||||
from ansible.module_utils.docker.common import AnsibleDockerClient
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -92,21 +92,13 @@ options:
|
|||
default: no
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
|
||||
author:
|
||||
- Piotr Wojciechowski (@WojciechowskiPiotr)
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.10.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- "Docker API >= 1.21"
|
||||
'''
|
||||
|
||||
|
@ -186,20 +178,16 @@ docker_disk_usage:
|
|||
|
||||
'''
|
||||
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass
|
||||
from ansible.module_utils.docker.common import AnsibleDockerClient, DockerBaseClass
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
try:
|
||||
from docker.errors import APIError, NotFound
|
||||
from docker.errors import APIError
|
||||
except ImportError:
|
||||
# missing docker-py handled in ansible.module_utils.docker_common
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
try:
|
||||
from ansible.module_utils.docker_common import docker_version, clean_dict_booleans_for_docker_api
|
||||
except Exception as dummy:
|
||||
# missing docker-py handled in ansible.module_utils.docker
|
||||
pass
|
||||
from ansible.module_utils.docker.common import clean_dict_booleans_for_docker_api
|
||||
|
||||
|
||||
class DockerHostManager(DockerBaseClass):
|
||||
|
|
|
@ -176,18 +176,10 @@ options:
|
|||
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.8.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- "Docker API >= 1.20"
|
||||
|
||||
author:
|
||||
|
@ -276,7 +268,7 @@ image:
|
|||
import os
|
||||
import re
|
||||
|
||||
from ansible.module_utils.docker_common import (
|
||||
from ansible.module_utils.docker.common import (
|
||||
HAS_DOCKER_PY_2, HAS_DOCKER_PY_3, AnsibleDockerClient, DockerBaseClass, is_image_name_id,
|
||||
)
|
||||
from ansible.module_utils._text import to_native
|
||||
|
|
|
@ -33,18 +33,10 @@ options:
|
|||
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.8.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- "Docker API >= 1.20"
|
||||
|
||||
author:
|
||||
|
@ -161,10 +153,10 @@ images:
|
|||
try:
|
||||
from docker import utils
|
||||
except ImportError:
|
||||
# missing docker-py handled in ansible.module_utils.docker_common
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass, is_image_name_id
|
||||
from ansible.module_utils.docker.common import AnsibleDockerClient, DockerBaseClass, is_image_name_id
|
||||
|
||||
|
||||
class ImageManager(DockerBaseClass):
|
||||
|
|
|
@ -73,19 +73,11 @@ options:
|
|||
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.8.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- "Docker API >= 1.20"
|
||||
- 'Only to be able to logout (state=absent): the docker command line utility'
|
||||
- "Only to be able to logout, that is for I(state) = C(absent): the C(docker) command line utility"
|
||||
author:
|
||||
- Olaf Kilian (@olsaki) <olaf.kilian@symanex.com>
|
||||
- Chris Houseknecht (@chouseknecht)
|
||||
|
@ -134,7 +126,7 @@ import os
|
|||
import re
|
||||
|
||||
from ansible.module_utils._text import to_bytes, to_text
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient, DEFAULT_DOCKER_REGISTRY, DockerBaseClass, EMAIL_REGEX
|
||||
from ansible.module_utils.docker.common import AnsibleDockerClient, DEFAULT_DOCKER_REGISTRY, DockerBaseClass, EMAIL_REGEX
|
||||
|
||||
|
||||
class LoginManager(DockerBaseClass):
|
||||
|
|
|
@ -162,6 +162,7 @@ options:
|
|||
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
|
||||
author:
|
||||
- "Ben Keith (@keitwb)"
|
||||
|
@ -169,16 +170,7 @@ author:
|
|||
- "Dave Bendit (@DBendit)"
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.10.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- "The docker server >= 1.10.0"
|
||||
'''
|
||||
|
||||
|
@ -265,7 +257,7 @@ import re
|
|||
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
from ansible.module_utils.docker_common import (
|
||||
from ansible.module_utils.docker.common import (
|
||||
AnsibleDockerClient,
|
||||
DockerBaseClass,
|
||||
docker_version,
|
||||
|
@ -275,11 +267,10 @@ from ansible.module_utils.docker_common import (
|
|||
|
||||
try:
|
||||
from docker import utils
|
||||
from docker.errors import NotFound
|
||||
if LooseVersion(docker_version) >= LooseVersion('2.0.0'):
|
||||
from docker.types import IPAMPool, IPAMConfig
|
||||
except Exception:
|
||||
# missing docker-py handled in ansible.module_utils.docker_common
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -33,21 +33,13 @@ options:
|
|||
required: true
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
|
||||
author:
|
||||
- "Dave Bendit (@DBendit)"
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.8.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- "Docker API >= 1.21"
|
||||
'''
|
||||
|
||||
|
@ -110,7 +102,7 @@ docker_network:
|
|||
}'
|
||||
'''
|
||||
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient
|
||||
from ansible.module_utils.docker.common import AnsibleDockerClient
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -77,17 +77,9 @@ options:
|
|||
type: str
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.10.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- Docker API >= 1.25
|
||||
author:
|
||||
- Piotr Wojciechowski (@WojciechowskiPiotr)
|
||||
|
@ -143,16 +135,16 @@ node_facts:
|
|||
try:
|
||||
from docker.errors import APIError
|
||||
except ImportError:
|
||||
# missing docker-py handled in ansible.module_utils.docker_common
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
from ansible.module_utils.docker_common import (
|
||||
from ansible.module_utils.docker.common import (
|
||||
DockerBaseClass,
|
||||
)
|
||||
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
from ansible.module_utils.docker_swarm import AnsibleDockerSwarmClient
|
||||
from ansible.module_utils.docker.swarm import AnsibleDockerSwarmClient
|
||||
|
||||
|
||||
class TaskParameters(DockerBaseClass):
|
||||
|
|
|
@ -33,21 +33,13 @@ options:
|
|||
required: true
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
|
||||
author:
|
||||
- Piotr Wojciechowski (@wojciechowskipiotr)
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.10.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- "Docker API >= 1.24"
|
||||
'''
|
||||
|
||||
|
@ -77,12 +69,12 @@ node_facts:
|
|||
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
from ansible.module_utils.docker_swarm import AnsibleDockerSwarmClient
|
||||
from ansible.module_utils.docker.swarm import AnsibleDockerSwarmClient
|
||||
|
||||
try:
|
||||
from docker.errors import APIError, NotFound
|
||||
except ImportError:
|
||||
# missing docker-py handled in ansible.module_utils.docker_common
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -80,17 +80,13 @@ options:
|
|||
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_2_documentation
|
||||
|
||||
author:
|
||||
- "Felix Fontein (@felixfontein)"
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker >= 2.1.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
Version 2.1.0 or newer is only available with the C(docker) module."
|
||||
- "Docker API >= 1.25"
|
||||
'''
|
||||
|
||||
|
@ -173,12 +169,12 @@ builder_cache_space_reclaimed:
|
|||
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient
|
||||
from ansible.module_utils.docker.common import AnsibleDockerClient
|
||||
|
||||
try:
|
||||
from ansible.module_utils.docker_common import docker_version, clean_dict_booleans_for_docker_api
|
||||
from ansible.module_utils.docker.common import docker_version, clean_dict_booleans_for_docker_api
|
||||
except Exception as dummy:
|
||||
# missing docker-py handled in ansible.module_utils.docker
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -69,13 +69,10 @@ options:
|
|||
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_2_documentation
|
||||
|
||||
requirements:
|
||||
- "docker-py >= 2.1.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
Version 2.1.0 or newer is only available with the C(docker) module."
|
||||
- "docker >= 2.1.0"
|
||||
- "Docker API >= 1.25"
|
||||
|
||||
author:
|
||||
|
@ -161,10 +158,10 @@ import hashlib
|
|||
try:
|
||||
from docker.errors import APIError
|
||||
except ImportError:
|
||||
# missing docker-py handled in ansible.module_utils.docker_common
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass, compare_generic
|
||||
from ansible.module_utils.docker.common import AnsibleDockerClient, DockerBaseClass, compare_generic
|
||||
from ansible.module_utils._text import to_native, to_bytes
|
||||
|
||||
|
||||
|
|
|
@ -134,13 +134,9 @@ options:
|
|||
default: 'no'
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_2_documentation
|
||||
requirements:
|
||||
- python >= 2.7
|
||||
- "docker >= 2.6.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
Version 2.1.0 or newer is only available with the C(docker) module."
|
||||
- Docker API >= 1.25
|
||||
author:
|
||||
- Thierry Bouvet (@tbouvet)
|
||||
|
@ -214,18 +210,16 @@ actions:
|
|||
'''
|
||||
|
||||
import json
|
||||
from distutils.version import LooseVersion
|
||||
from time import sleep
|
||||
try:
|
||||
from docker.errors import APIError
|
||||
except ImportError:
|
||||
# missing docker-py handled in ansible.module_utils.docker_common
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
from ansible.module_utils.docker_common import (
|
||||
from ansible.module_utils.docker.common import (
|
||||
AnsibleDockerClient,
|
||||
DockerBaseClass,
|
||||
docker_version,
|
||||
)
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
|
|
@ -336,12 +336,9 @@ options:
|
|||
The default has been removed so that the user defined in the image is used if no user is specified here.
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_2_documentation
|
||||
requirements:
|
||||
- "docker-py >= 2.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
Version 2.1.0 or newer is only available with the C(docker) module."
|
||||
- "docker >= 2.0"
|
||||
- "Docker API >= 1.24"
|
||||
notes:
|
||||
- "Images will only resolve to the latest digest when using Docker API >= 1.30 and docker-py >= 3.2.0.
|
||||
|
@ -529,7 +526,7 @@ EXAMPLES = '''
|
|||
import time
|
||||
import shlex
|
||||
import operator
|
||||
from ansible.module_utils.docker_common import (
|
||||
from ansible.module_utils.docker.common import (
|
||||
AnsibleDockerClient,
|
||||
DifferenceTracker,
|
||||
DockerBaseClass,
|
||||
|
@ -544,7 +541,7 @@ try:
|
|||
from docker.utils import parse_repository_tag
|
||||
from docker.errors import APIError, DockerException
|
||||
except Exception:
|
||||
# missing docker-py handled in ansible.module_utils.docker
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -84,21 +84,13 @@ options:
|
|||
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
|
||||
author:
|
||||
- Alex Grönholm (@agronholm)
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.10.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- "The docker server >= 1.9.0"
|
||||
'''
|
||||
|
||||
|
@ -131,10 +123,10 @@ facts:
|
|||
try:
|
||||
from docker.errors import APIError
|
||||
except ImportError:
|
||||
# missing docker-py handled in ansible.module_utils.docker_common
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
from ansible.module_utils.docker_common import (
|
||||
from ansible.module_utils.docker.common import (
|
||||
DockerBaseClass,
|
||||
AnsibleDockerClient,
|
||||
DifferenceTracker,
|
||||
|
|
|
@ -30,21 +30,13 @@ options:
|
|||
|
||||
extends_documentation_fragment:
|
||||
- docker
|
||||
- docker.docker_py_1_documentation
|
||||
|
||||
author:
|
||||
- Felix Fontein (@felixfontein)
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "docker-py >= 1.8.0"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
- "Docker API >= 1.21"
|
||||
'''
|
||||
|
||||
|
@ -91,10 +83,10 @@ docker_volume:
|
|||
try:
|
||||
from docker.errors import NotFound
|
||||
except ImportError:
|
||||
# missing docker-py handled in ansible.module_utils.docker_common
|
||||
# missing docker-py handled in ansible.module_utils.docker.common
|
||||
pass
|
||||
|
||||
from ansible.module_utils.docker_common import AnsibleDockerClient
|
||||
from ansible.module_utils.docker.common import AnsibleDockerClient
|
||||
|
||||
|
||||
def get_existing_volume(client, volume_name):
|
||||
|
|
|
@ -102,3 +102,31 @@ notes:
|
|||
In general, it will use C($HOME/docker/config.json) if the C(DOCKER_CONFIG) environment variable is not specified,
|
||||
and use C($DOCKER_CONFIG/config.json) otherwise.
|
||||
'''
|
||||
|
||||
# Additional, more specific stuff for minimal docker-py version < 2.0
|
||||
|
||||
DOCKER_PY_1_DOCUMENTATION = r'''
|
||||
options: {}
|
||||
requirements:
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
For Python 2.6, C(docker-py) must be used. Otherwise, it is recommended to
|
||||
install the C(docker) Python module. Note that both modules should I(not)
|
||||
be installed at the same time. Also note that when both modules are installed
|
||||
and one of them is uninstalled, the other might no longer function and a
|
||||
reinstall of it is required."
|
||||
'''
|
||||
|
||||
# Additional, more specific stuff for minimal docker-py version >= 2.0.
|
||||
# Note that docker-py >= 2.0 requires Python 2.7 or newer.
|
||||
|
||||
DOCKER_PY_2_DOCUMENTATION = r'''
|
||||
options: {}
|
||||
requirements:
|
||||
- "Python >= 2.7"
|
||||
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
|
||||
module has been superseded by L(docker,https://pypi.org/project/docker/)
|
||||
(see L(here,https://github.com/docker/docker-py/issues/1310) for details).
|
||||
This module does I(not) work with docker-py."
|
||||
'''
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
|
||||
from ansible.module_utils.docker_common import (
|
||||
from ansible.module_utils.docker.common import (
|
||||
compare_dict_allow_more_present,
|
||||
compare_generic,
|
||||
)
|
|
@ -5,7 +5,7 @@ import json
|
|||
import pytest
|
||||
|
||||
from ansible.modules.cloud.docker import docker_volume
|
||||
from ansible.module_utils import docker_common
|
||||
from ansible.module_utils.docker import common
|
||||
|
||||
pytestmark = pytest.mark.usefixtures('patch_ansible_module')
|
||||
|
||||
|
@ -19,8 +19,8 @@ TESTCASE_DOCKER_VOLUME = [
|
|||
|
||||
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_DOCKER_VOLUME, indirect=['patch_ansible_module'])
|
||||
def test_create_volume_on_invalid_docker_version(mocker, capfd):
|
||||
mocker.patch.object(docker_common, 'HAS_DOCKER_PY', True)
|
||||
mocker.patch.object(docker_common, 'docker_version', '1.8.0')
|
||||
mocker.patch.object(common, 'HAS_DOCKER_PY', True)
|
||||
mocker.patch.object(common, 'docker_version', '1.8.0')
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
docker_volume.main()
|
||||
|
|
Loading…
Reference in New Issue