summaryrefslogtreecommitdiff
path: root/cloud/lxc
diff options
context:
space:
mode:
authorKevin Carter <kcarter@linux.com>2016-08-23 03:19:17 -0500
committerRené Moser <mail@renemoser.net>2016-08-23 10:19:17 +0200
commit0749ce6faa6af15027934f13d75fa3f351867679 (patch)
treedbf6b409cc8596c6621f9a5515e9ae57e18ee4be /cloud/lxc
parent8485b39ab305fe6073313a13ea547a0c7462415b (diff)
downloadansible-modules-extras-0749ce6faa6af15027934f13d75fa3f351867679.tar.gz
Remove the subsystem lock loop (#2647)
This change removes the loop watching for "/var/lock/subsys/lxc" from the lxc-container module. This change simply runs the command within a container using the lxc CLI tools which should be responcible for locking and unlocking on their own. Closes-Issue: https://github.com/ansible/ansible-modules-extras/issues/690 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
Diffstat (limited to 'cloud/lxc')
-rw-r--r--cloud/lxc/lxc_container.py32
1 files changed, 5 insertions, 27 deletions
diff --git a/cloud/lxc/lxc_container.py b/cloud/lxc/lxc_container.py
index 906b1d75..22c72f43 100644
--- a/cloud/lxc/lxc_container.py
+++ b/cloud/lxc/lxc_container.py
@@ -682,45 +682,23 @@ class LxcContainerManagement(object):
else:
return return_dict
- def _run_command(self, build_command, unsafe_shell=False, timeout=600):
+ def _run_command(self, build_command, unsafe_shell=False):
"""Return information from running an Ansible Command.
This will squash the build command list into a string and then
execute the command via Ansible. The output is returned to the method.
This output is returned as `return_code`, `stdout`, `stderr`.
- Prior to running the command the method will look to see if the LXC
- lockfile is present. If the lockfile "/var/lock/subsys/lxc" the method
- will wait upto 10 minutes for it to be gone; polling every 5 seconds.
-
:param build_command: Used for the command and all options.
:type build_command: ``list``
:param unsafe_shell: Enable or Disable unsafe sell commands.
:type unsafe_shell: ``bol``
- :param timeout: Time before the container create process quites.
- :type timeout: ``int``
"""
- lockfile = '/var/lock/subsys/lxc'
-
- for _ in xrange(timeout):
- if os.path.exists(lockfile):
- time.sleep(1)
- else:
- return self.module.run_command(
- ' '.join(build_command),
- use_unsafe_shell=unsafe_shell
- )
- else:
- message = (
- 'The LXC subsystem is locked and after 5 minutes it never'
- ' became unlocked. Lockfile [ %s ]' % lockfile
- )
- self.failure(
- error='LXC subsystem locked',
- rc=0,
- msg=message
- )
+ return self.module.run_command(
+ ' '.join(build_command),
+ use_unsafe_shell=unsafe_shell
+ )
def _config(self):
"""Configure an LXC container.