mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
chore: Update lxc_container to support py3 (#5304)
* chore: Update lxc_container to support py3 This change is mostly just a documentation change which will report the requirements correctly for python3-lxc. I've also removed the use of six which results in us changing `xrange` to `range`. Resolves: https://github.com/ansible-collections/community.general/issues/5294 Signed-off-by: Kevin Carter <kevin.carter@figment.io> Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Update changelogs/fragments/5280-lxc_container-py3.yaml Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Update changelogs/fragments/5280-lxc_container-py3.yaml Co-authored-by: Felix Fontein <felix@fontein.de> * Update 5280-lxc_container-py3.yaml * Update 5280-lxc_container-py3.yaml Signed-off-by: Kevin Carter <kevin.carter@figment.io> Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
202cabc769
commit
2eba5dc4e7
2 changed files with 14 additions and 10 deletions
5
changelogs/fragments/5280-lxc_container-py3.yaml
Normal file
5
changelogs/fragments/5280-lxc_container-py3.yaml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
bugfixes:
|
||||||
|
- lxc_container - the module has been updated to support Python 3 (https://github.com/ansible-collections/community.general/pull/5304).
|
||||||
|
|
||||||
|
deprecated_features:
|
||||||
|
- lxc_container - the module will no longer make any effort to support Python 2 (https://github.com/ansible-collections/community.general/pull/5304).
|
|
@ -164,9 +164,9 @@ options:
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
requirements:
|
requirements:
|
||||||
- 'lxc >= 1.0 # OS package'
|
- 'lxc >= 2.0 # OS package'
|
||||||
- 'python >= 2.6 # OS Package'
|
- 'python3 >= 3.5 # OS Package'
|
||||||
- 'lxc-python2 >= 0.1 # PIP Package from https://github.com/lxc/python2-lxc'
|
- 'python3-lxc # OS Package'
|
||||||
notes:
|
notes:
|
||||||
- Containers must have a unique name. If you attempt to create a container
|
- Containers must have a unique name. If you attempt to create a container
|
||||||
with a name that already exists in the users namespace the module will
|
with a name that already exists in the users namespace the module will
|
||||||
|
@ -184,10 +184,10 @@ notes:
|
||||||
tarball of the running container. The "archive" option supports LVM backed
|
tarball of the running container. The "archive" option supports LVM backed
|
||||||
containers and will create a snapshot of the running container when
|
containers and will create a snapshot of the running container when
|
||||||
creating the archive.
|
creating the archive.
|
||||||
- If your distro does not have a package for "python2-lxc", which is a
|
- If your distro does not have a package for C(python3-lxc), which is a
|
||||||
requirement for this module, it can be installed from source at
|
requirement for this module, it can be installed from source at
|
||||||
"https://github.com/lxc/python2-lxc" or installed via pip using the package
|
U(https://github.com/lxc/python3-lxc) or installed via pip using the
|
||||||
name lxc-python2.
|
package name C(lxc).
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
|
@ -434,7 +434,6 @@ else:
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE, BOOLEANS_TRUE
|
from ansible.module_utils.parsing.convert_bool import BOOLEANS_FALSE, BOOLEANS_TRUE
|
||||||
from ansible.module_utils.six.moves import xrange
|
|
||||||
from ansible.module_utils.common.text.converters import to_text, to_bytes
|
from ansible.module_utils.common.text.converters import to_text, to_bytes
|
||||||
|
|
||||||
|
|
||||||
|
@ -559,7 +558,7 @@ popd
|
||||||
def create_script(command):
|
def create_script(command):
|
||||||
"""Write out a script onto a target.
|
"""Write out a script onto a target.
|
||||||
|
|
||||||
This method should be backward compatible with Python 2.4+ when executing
|
This method should be backward compatible with Python when executing
|
||||||
from within the container.
|
from within the container.
|
||||||
|
|
||||||
:param command: command to run, this can be a script and can use spacing
|
:param command: command to run, this can be a script and can use spacing
|
||||||
|
@ -939,7 +938,7 @@ class LxcContainerManagement(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.container = self.get_container_bind()
|
self.container = self.get_container_bind()
|
||||||
for dummy in xrange(timeout):
|
for dummy in range(timeout):
|
||||||
if self._get_state() != 'running':
|
if self._get_state() != 'running':
|
||||||
self.container.start()
|
self.container.start()
|
||||||
self.state_change = True
|
self.state_change = True
|
||||||
|
@ -992,7 +991,7 @@ class LxcContainerManagement(object):
|
||||||
:type timeout: ``int``
|
:type timeout: ``int``
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for dummy in xrange(timeout):
|
for dummy in range(timeout):
|
||||||
if not self._container_exists(container_name=self.container_name, lxc_path=self.lxc_path):
|
if not self._container_exists(container_name=self.container_name, lxc_path=self.lxc_path):
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue