mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-28 11:36:32 +00:00
Add nvme as supported feature option
This commit is contained in:
parent
b970f3c5fb
commit
7902aa5281
@ -67,6 +67,7 @@ class HostFeature(StrEnum):
|
|||||||
JOURNAL = "journal"
|
JOURNAL = "journal"
|
||||||
MOUNT = "mount"
|
MOUNT = "mount"
|
||||||
NETWORK = "network"
|
NETWORK = "network"
|
||||||
|
NVME = "nvme"
|
||||||
OS_AGENT = "os_agent"
|
OS_AGENT = "os_agent"
|
||||||
REBOOT = "reboot"
|
REBOOT = "reboot"
|
||||||
RESOLVED = "resolved"
|
RESOLVED = "resolved"
|
||||||
|
@ -125,6 +125,9 @@ class HostManager(CoreSysAttributes):
|
|||||||
if self.sys_dbus.udisks2.is_connected:
|
if self.sys_dbus.udisks2.is_connected:
|
||||||
features.append(HostFeature.DISK)
|
features.append(HostFeature.DISK)
|
||||||
|
|
||||||
|
if self.nvme.devices:
|
||||||
|
features.append(HostFeature.NVME)
|
||||||
|
|
||||||
# Support added in OS10. Propagation mode changed on mount in 10.2 to support this
|
# Support added in OS10. Propagation mode changed on mount in 10.2 to support this
|
||||||
if (
|
if (
|
||||||
self.sys_dbus.systemd.is_connected
|
self.sys_dbus.systemd.is_connected
|
||||||
|
@ -1,8 +1,17 @@
|
|||||||
"""Test supported features."""
|
"""Test supported features."""
|
||||||
|
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from supervisor.coresys import CoreSys
|
||||||
|
|
||||||
|
from tests.common import load_binary_fixture
|
||||||
|
|
||||||
|
|
||||||
def test_supported_features(coresys, dbus_is_connected):
|
@pytest.mark.usefixtures("dbus_is_connected")
|
||||||
|
def test_supported_features(coresys: CoreSys):
|
||||||
"""Test host features."""
|
"""Test host features."""
|
||||||
assert "network" in coresys.host.features
|
assert "network" in coresys.host.features
|
||||||
|
|
||||||
@ -12,3 +21,24 @@ def test_supported_features(coresys, dbus_is_connected):
|
|||||||
|
|
||||||
coresys.host.supported_features.cache_clear()
|
coresys.host.supported_features.cache_clear()
|
||||||
assert "network" not in coresys.host.features
|
assert "network" not in coresys.host.features
|
||||||
|
|
||||||
|
|
||||||
|
async def test_supported_features_nvme(coresys: CoreSys):
|
||||||
|
"""Test nvme supported feature."""
|
||||||
|
with patch(
|
||||||
|
"supervisor.host.nvme.manager.asyncio.create_subprocess_shell"
|
||||||
|
) as shell_mock:
|
||||||
|
shell_mock.return_value.returncode = 0
|
||||||
|
shell_mock.return_value.communicate.return_value = (b'{"Devices":[]}', b"")
|
||||||
|
await coresys.host.nvme.load()
|
||||||
|
|
||||||
|
assert "nvme" not in coresys.host.features
|
||||||
|
|
||||||
|
shell_mock.return_value.communicate.return_value = (
|
||||||
|
load_binary_fixture("nvme-list.json"),
|
||||||
|
b"",
|
||||||
|
)
|
||||||
|
await coresys.host.nvme.update()
|
||||||
|
coresys.host.supported_features.cache_clear()
|
||||||
|
|
||||||
|
assert "nvme" in coresys.host.features
|
||||||
|
Loading…
x
Reference in New Issue
Block a user