Commit 96fcb81a authored by Antonio Terceiro's avatar Antonio Terceiro
Browse files

lava-dispatcher-host: allow passing full device node names

This is mostly a convenience for when testing manually on the command
line, because udev itself will no include /dev/.
parent 713a3e86
......@@ -56,7 +56,9 @@ def share_device_with_container(options, setup_logger=None):
setup_logger(data["logging_info"])
logger = logging.getLogger("dispatcher")
container = data["container"]
device = "/dev/" + options.device
device = options.device
if not device.startswith("/dev/"):
device = "/dev/" + device
if not os.path.exists(device):
logger.warning("Can't share {device}: file not found".format(device=device))
return
......
......@@ -150,3 +150,12 @@ def test_unknown_container_type(mocker):
share_device_with_container(
Namespace(device="foo/bar", serial_number="1234567890")
)
def test_only_adds_slash_dev_if_needed(mocker):
share = mocker.patch("lava_dispatcher_host.share_device_with_container_lxc")
add_device_container_mapping("1", {"serial_number": "1234567890"}, "mycontainer")
share_device_with_container(
Namespace(device="/dev/foo/bar", serial_number="1234567890")
)
share.assert_called_once_with("mycontainer", "/dev/foo/bar")
Supports Markdown
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