Fix mknod creating of the device on runtime time (#2477)

This commit is contained in:
Pascal Vizeli 2021-01-28 17:07:33 +01:00 committed by GitHub
parent e024c3e38d
commit 521037e1a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -128,24 +128,37 @@ class DockerAddon(DockerInterface):
def devices(self) -> Optional[List[str]]: def devices(self) -> Optional[List[str]]:
"""Return needed devices.""" """Return needed devices."""
devices = set() devices = set()
map_strict = False
# Extend add-on config # Static devices
for device_path in self.addon.static_devices: for device_path in self.addon.static_devices:
if not self.sys_hardware.exists_device_node(device_path): if not self.sys_hardware.exists_device_node(device_path):
_LOGGER.debug("Ignore static device path %s", device_path) _LOGGER.debug("Ignore static device path %s", device_path)
continue continue
devices.add(f"{device_path.as_posix()}:{device_path.as_posix()}:rwm") devices.add(f"{device_path.as_posix()}:{device_path.as_posix()}:rwm")
# Dynamic devices
for device in self.addon.devices:
map_strict = True
devices.add(f"{device.path.as_posix()}:{device.path.as_posix()}:rwm")
# Auto mapping UART devices / LINKS # Auto mapping UART devices / LINKS
# Deprecated: In the future the add-on needs to create device links based on API data by itself if self.addon.with_uart:
if self.addon.with_uart and not self.addon.devices and not self.addon.with_udev:
for device in self.sys_hardware.filter_devices( for device in self.sys_hardware.filter_devices(
subsystem=UdevSubsystem.SERIAL subsystem=UdevSubsystem.SERIAL
): ):
if not device.by_id: devices.add(f"{device.path.as_posix()}:{device.path.as_posix()}:rwm")
if map_strict or not device.by_id:
continue continue
devices.add(f"{device.by_id.as_posix()}:{device.by_id.as_posix()}:rwm") devices.add(f"{device.by_id.as_posix()}:{device.by_id.as_posix()}:rwm")
# Auto mapping GPIO
if self.addon.with_gpio:
for device in self.sys_hardware.filter_devices(
subsystem=UdevSubsystem.SERIAL
):
devices.add(f"{device.path.as_posix()}:{device.path.as_posix()}:rwm")
# Return None if no devices is present # Return None if no devices is present
if devices: if devices:
return list(devices) return list(devices)