Skip to content

Commit 71d6c60

Browse files
authored
Add detect_blocking_io option (#163)
* Add detect_blocking_io option * Include response field * Fix test and add to __all__
1 parent 9838977 commit 71d6c60

File tree

4 files changed

+138
-96
lines changed

4 files changed

+138
-96
lines changed

aiohasupervisor/models/__init__.py

Lines changed: 92 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -145,137 +145,139 @@
145145
UpdateType,
146146
)
147147
from aiohasupervisor.models.supervisor import (
148+
DetectBlockingIO,
148149
SupervisorInfo,
149150
SupervisorOptions,
150151
SupervisorStats,
151152
SupervisorUpdateOptions,
152153
)
153154

154155
__all__ = [
155-
"HostFeature",
156-
"SupervisorState",
157-
"UpdateChannel",
158-
"LogLevel",
159-
"UpdateType",
160-
"RootInfo",
161-
"AvailableUpdate",
162-
"AddonStage",
163-
"AddonStartup",
156+
"LOCATION_CLOUD_BACKUP",
157+
"LOCATION_LOCAL_STORAGE",
158+
"AccessPoint",
164159
"AddonBoot",
165160
"AddonBootConfig",
166-
"CpuArch",
167-
"Capability",
168-
"AppArmor",
169-
"SupervisorRole",
161+
"AddonSet",
162+
"AddonStage",
163+
"AddonStartup",
170164
"AddonState",
171-
"StoreAddon",
172-
"StoreAddonComplete",
173-
"InstalledAddon",
174-
"InstalledAddonComplete",
175-
"AddonsOptions",
176165
"AddonsConfigValidate",
166+
"AddonsOptions",
177167
"AddonsRebuild",
178168
"AddonsSecurityOptions",
179169
"AddonsStats",
180170
"AddonsUninstall",
181-
"Repository",
182-
"StoreInfo",
183-
"StoreAddonUpdate",
184-
"StoreAddRepository",
185-
"Check",
186-
"CheckOptions",
187-
"CheckType",
188-
"ContextType",
189-
"Issue",
190-
"IssueType",
191-
"ResolutionInfo",
192-
"Suggestion",
193-
"SuggestionType",
194-
"UnhealthyReason",
195-
"UnsupportedReason",
196-
"SupervisorInfo",
197-
"SupervisorOptions",
198-
"SupervisorStats",
199-
"SupervisorUpdateOptions",
200-
"HomeAssistantInfo",
201-
"HomeAssistantOptions",
202-
"HomeAssistantRebuildOptions",
203-
"HomeAssistantRestartOptions",
204-
"HomeAssistantStats",
205-
"HomeAssistantStopOptions",
206-
"HomeAssistantUpdateOptions",
207-
"RaucState",
208-
"BootSlotName",
209-
"BootSlot",
210-
"OSInfo",
211-
"OSUpdate",
212-
"MigrateDataOptions",
213-
"DataDisk",
214-
"SetBootSlotOptions",
215-
"GreenInfo",
216-
"GreenOptions",
217-
"YellowInfo",
218-
"YellowOptions",
219-
"LOCATION_CLOUD_BACKUP",
220-
"LOCATION_LOCAL_STORAGE",
221-
"AddonSet",
171+
"AppArmor",
172+
"AuthMethod",
173+
"AvailableUpdate",
222174
"Backup",
223175
"BackupAddon",
224176
"BackupComplete",
225177
"BackupContent",
226178
"BackupJob",
227179
"BackupLocationAttributes",
180+
"BackupType",
228181
"BackupsInfo",
229182
"BackupsOptions",
230-
"BackupType",
183+
"BootSlot",
184+
"BootSlotName",
185+
"CIFSMountRequest",
186+
"CIFSMountResponse",
187+
"Capability",
188+
"Check",
189+
"CheckOptions",
190+
"CheckType",
191+
"ContextType",
192+
"CpuArch",
193+
"DataDisk",
194+
"DetectBlockingIO",
195+
"Discovery",
196+
"DiscoveryConfig",
197+
"DockerNetwork",
231198
"DownloadBackupOptions",
232199
"Folder",
233200
"FreezeOptions",
234201
"FullBackupOptions",
235202
"FullRestoreOptions",
236-
"NewBackup",
237-
"PartialBackupOptions",
238-
"PartialRestoreOptions",
239-
"RemoveBackupOptions",
240-
"UploadBackupOptions",
241-
"Discovery",
242-
"DiscoveryConfig",
243-
"AccessPoint",
244-
"AuthMethod",
245-
"DockerNetwork",
246-
"InterfaceMethod",
247-
"InterfaceType",
203+
"GreenInfo",
204+
"GreenOptions",
205+
"HomeAssistantInfo",
206+
"HomeAssistantOptions",
207+
"HomeAssistantRebuildOptions",
208+
"HomeAssistantRestartOptions",
209+
"HomeAssistantStats",
210+
"HomeAssistantStopOptions",
211+
"HomeAssistantUpdateOptions",
212+
"HostFeature",
213+
"HostInfo",
214+
"HostOptions",
248215
"IPv4",
249216
"IPv4Config",
250217
"IPv6",
251218
"IPv6Config",
252-
"NetworkInfo",
253-
"NetworkInterface",
254-
"NetworkInterfaceConfig",
255-
"Vlan",
256-
"VlanConfig",
257-
"Wifi",
258-
"WifiConfig",
259-
"WifiMode",
260-
"HostInfo",
261-
"HostOptions",
262-
"RebootOptions",
263-
"Service",
264-
"ServiceState",
265-
"ShutdownOptions",
219+
"InstalledAddon",
220+
"InstalledAddonComplete",
221+
"InterfaceMethod",
222+
"InterfaceType",
223+
"Issue",
224+
"IssueType",
266225
"Job",
267226
"JobCondition",
268227
"JobError",
269228
"JobsInfo",
270229
"JobsOptions",
271-
"CIFSMountRequest",
272-
"CIFSMountResponse",
230+
"LogLevel",
231+
"MigrateDataOptions",
273232
"MountCifsVersion",
274-
"MountsInfo",
275-
"MountsOptions",
276233
"MountState",
277234
"MountType",
278235
"MountUsage",
236+
"MountsInfo",
237+
"MountsOptions",
279238
"NFSMountRequest",
280239
"NFSMountResponse",
240+
"NetworkInfo",
241+
"NetworkInterface",
242+
"NetworkInterfaceConfig",
243+
"NewBackup",
244+
"OSInfo",
245+
"OSUpdate",
246+
"PartialBackupOptions",
247+
"PartialRestoreOptions",
248+
"RaucState",
249+
"RebootOptions",
250+
"RemoveBackupOptions",
251+
"Repository",
252+
"ResolutionInfo",
253+
"RootInfo",
254+
"Service",
255+
"ServiceState",
256+
"SetBootSlotOptions",
257+
"ShutdownOptions",
258+
"StoreAddRepository",
259+
"StoreAddon",
260+
"StoreAddonComplete",
261+
"StoreAddonUpdate",
262+
"StoreInfo",
263+
"Suggestion",
264+
"SuggestionType",
265+
"SupervisorInfo",
266+
"SupervisorOptions",
267+
"SupervisorRole",
268+
"SupervisorState",
269+
"SupervisorStats",
270+
"SupervisorUpdateOptions",
271+
"UnhealthyReason",
272+
"UnsupportedReason",
273+
"UpdateChannel",
274+
"UpdateType",
275+
"UploadBackupOptions",
276+
"Vlan",
277+
"VlanConfig",
278+
"Wifi",
279+
"WifiConfig",
280+
"WifiMode",
281+
"YellowInfo",
282+
"YellowOptions",
281283
]

aiohasupervisor/models/supervisor.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
"""Models for supervisor component."""
22

33
from dataclasses import dataclass
4+
from enum import StrEnum
45
from ipaddress import IPv4Address
56

67
from .base import ContainerStats, Options, Request, ResponseData
78
from .root import LogLevel, UpdateChannel
89

10+
# --- ENUMS ----
11+
12+
13+
class DetectBlockingIO(StrEnum):
14+
"""DetectBlockingIO type."""
15+
16+
OFF = "off"
17+
ON = "on"
18+
ON_AT_STARTUP = "on_at_startup"
19+
20+
21+
# --- OBJECTS ----
22+
923

1024
@dataclass(frozen=True, slots=True)
1125
class SupervisorInfo(ResponseData):
@@ -26,6 +40,7 @@ class SupervisorInfo(ResponseData):
2640
diagnostics: bool | None
2741
auto_update: bool
2842
country: str | None
43+
detect_blocking_io: bool
2944

3045

3146
@dataclass(frozen=True, slots=True)
@@ -54,3 +69,4 @@ class SupervisorOptions(Options):
5469
force_security: bool | None = None
5570
auto_update: bool | None = None
5671
country: str | None = None
72+
detect_blocking_io: DetectBlockingIO | None = None

tests/fixtures/supervisor_info.json

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"auto_update": true,
1818
"country": null,
1919
"wait_boot": 5,
20+
"detect_blocking_io": false,
2021
"addons": [
2122
{
2223
"name": "Terminal & SSH",
@@ -40,11 +41,26 @@
4041
}
4142
],
4243
"addons_repositories": [
43-
{ "name": "Local add-ons", "slug": "local" },
44-
{ "name": "Music Assistant", "slug": "d5369777" },
45-
{ "name": "Official add-ons", "slug": "core" },
46-
{ "name": "ESPHome", "slug": "5c53de3b" },
47-
{ "name": "Home Assistant Community Add-ons", "slug": "a0d7b954" }
44+
{
45+
"name": "Local add-ons",
46+
"slug": "local"
47+
},
48+
{
49+
"name": "Music Assistant",
50+
"slug": "d5369777"
51+
},
52+
{
53+
"name": "Official add-ons",
54+
"slug": "core"
55+
},
56+
{
57+
"name": "ESPHome",
58+
"slug": "5c53de3b"
59+
},
60+
{
61+
"name": "Home Assistant Community Add-ons",
62+
"slug": "a0d7b954"
63+
}
4864
]
4965
}
5066
}

tests/test_supervisor.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from aiohasupervisor import SupervisorClient
1010
from aiohasupervisor.models import SupervisorOptions, SupervisorUpdateOptions
11+
from aiohasupervisor.models.supervisor import DetectBlockingIO
1112

1213
from . import load_fixture
1314
from .const import SUPERVISOR_URL
@@ -43,6 +44,7 @@ async def test_supervisor_info(
4344
assert info.logging == "info"
4445
assert info.ip_address == IPv4Address("172.30.32.2")
4546
assert info.country is None
47+
assert info.detect_blocking_io is False
4648

4749

4850
async def test_supervisor_stats(
@@ -107,7 +109,12 @@ async def test_supervisor_options(
107109
responses.post(f"{SUPERVISOR_URL}/supervisor/options", status=200)
108110
assert (
109111
await supervisor_client.supervisor.set_options(
110-
SupervisorOptions(debug=True, debug_block=True, country="NL")
112+
SupervisorOptions(
113+
debug=True,
114+
debug_block=True,
115+
country="NL",
116+
detect_blocking_io=DetectBlockingIO.ON_AT_STARTUP,
117+
)
111118
)
112119
is None
113120
)
@@ -123,6 +130,7 @@ async def test_supervisor_options(
123130
"debug": True,
124131
"debug_block": True,
125132
"country": "NL",
133+
"detect_blocking_io": "on_at_startup",
126134
}
127135

128136

0 commit comments

Comments
 (0)