mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Fix undefined variables, basestring usage, and some associated python3 issues
This commit is contained in:
@@ -681,16 +681,20 @@ docker_container:
|
||||
}'
|
||||
'''
|
||||
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
|
||||
from ansible.module_utils.docker_common import *
|
||||
from ansible.module_utils.basic import human_to_bytes
|
||||
from ansible.module_utils.docker_common import HAS_DOCKER_PY_2, AnsibleDockerClient, DockerBaseClass
|
||||
from ansible.module_utils.six import string_types
|
||||
|
||||
try:
|
||||
from docker import utils
|
||||
if HAS_DOCKER_PY_2:
|
||||
from docker.types import Ulimit
|
||||
from docker.types import Ulimit, LogConfig
|
||||
else:
|
||||
from docker.utils.types import Ulimit
|
||||
from docker.utils.types import Ulimit, LogConfig
|
||||
except:
|
||||
# missing docker-py handled in ansible.module_utils.docker
|
||||
pass
|
||||
@@ -705,6 +709,7 @@ REQUIRES_CONVERSION_TO_BYTES = [
|
||||
|
||||
VOLUME_PERMISSIONS = ('rw', 'ro', 'z', 'Z')
|
||||
|
||||
|
||||
class TaskParameters(DockerBaseClass):
|
||||
'''
|
||||
Access and parse module parameters
|
||||
@@ -1087,14 +1092,14 @@ class TaskParameters(DockerBaseClass):
|
||||
# Any published port should also be exposed
|
||||
for publish_port in published_ports:
|
||||
match = False
|
||||
if isinstance(publish_port, basestring) and '/' in publish_port:
|
||||
if isinstance(publish_port, string_types) and '/' in publish_port:
|
||||
port, protocol = publish_port.split('/')
|
||||
port = int(port)
|
||||
else:
|
||||
protocol = 'tcp'
|
||||
port = int(publish_port)
|
||||
for exposed_port in exposed:
|
||||
if isinstance(exposed_port[0], basestring) and '-' in exposed_port[0]:
|
||||
if isinstance(exposed_port[0], string_types) and '-' in exposed_port[0]:
|
||||
start_port, end_port = exposed_port[0].split('-')
|
||||
if int(start_port) <= port <= int(end_port):
|
||||
match = True
|
||||
@@ -2125,8 +2130,6 @@ def main():
|
||||
cm = ContainerManager(client)
|
||||
client.module.exit_json(**cm.results)
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -250,8 +250,12 @@ image:
|
||||
type: dict
|
||||
sample: {}
|
||||
'''
|
||||
import re
|
||||
import os
|
||||
|
||||
from ansible.module_utils.docker_common import *
|
||||
from ansible.module_utils.docker_common import (HAS_DOCKER_PY_2, AnsibleDockerClient,
|
||||
DockerBaseClass)
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
try:
|
||||
if HAS_DOCKER_PY_2:
|
||||
@@ -519,8 +523,7 @@ class ImageManager(DockerBaseClass):
|
||||
params['container_limits'] = self.container_limits
|
||||
if self.buildargs:
|
||||
for key, value in self.buildargs.items():
|
||||
if not isinstance(value, basestring):
|
||||
self.buildargs[key] = str(value)
|
||||
self.buildargs[key] = to_native(value)
|
||||
params['buildargs'] = self.buildargs
|
||||
|
||||
for line in self.client.build(**params):
|
||||
@@ -604,8 +607,5 @@ def main():
|
||||
client.module.exit_json(**results)
|
||||
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user