Commit 6b96c961 authored by Senthil Kumaran S's avatar Senthil Kumaran S Committed by Neil Williams

LAVA-1227 - Handle cancellation within LXC

The actual udev rules file is created inside job's temporary directory and
symlinked to udev rules.d.

Change-Id: Ifd5fe2c024f1b6cf026fe6bb17139e2d2d90cb76
parent 161c1660
......@@ -295,17 +295,24 @@ class LxcCreateUdevRuleAction(DeployAction):
'slave_cert': slave_cert,
'ipv6': ipv6,
'job_id': job_id}
# The rules file will be something like
# /etc/udev/rules.d/100-lxc-hikey-2808.rules'
# The rules file will be created in job's temporary directory with
# the name something like '100-lava-lxc-hikey-2808.rules'
# where, 100 is just an arbitrary number which specifies loading
# priority for udevd
rules_file = os.path.join(UDEV_RULES_DIR,
'100-' + lxc_name + '.rules')
rules_file_name = '100-lava-' + lxc_name + '.rules'
rules_file = os.path.join(self.mkdtemp(), rules_file_name)
str_lxc_udev_rule = lxc_udev_rule(data)
with open(rules_file, 'a') as f_obj:
self.logger.debug("udev rules file '%s' created with:\n %s",
rules_file, str_lxc_udev_rule)
# Create symlink to rules file inside UDEV_RULES_DIR
# See
os.symlink(rules_file, os.path.join(UDEV_RULES_DIR,
self.logger.debug("'%s' symlinked to '%s'",
os.path.join(UDEV_RULES_DIR, rules_file_name),
# Reload udev rules.
reload_cmd = ['udevadm', 'control', '--reload-rules']
......@@ -177,7 +177,7 @@ class LxcProtocol(Protocol): # pylint: disable=too-many-instance-attributes
# Remove udev rule which added device to the container and then reload
# udev rules.
rules_file = os.path.join(UDEV_RULES_DIR,
'100-' + self.lxc_name + '.rules')
'100-lava-' + self.lxc_name + '.rules')
if os.path.exists(rules_file):
self.logger.debug("%s protocol: removed udev rules '%s'",
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment