Add API for swap configuration (#5770)

* Add API for swap configuration

Add HTTP API for swap size and swappiness to /os/config/swap. Individual
options can be set in JSON and are calling the DBus API added in OS
Agent 1.7.x, available since OS 15.0. Check for presence of OS of the
required version and return 404 if the criteria are not met.

* Fix type hints and reboot_required logic

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fix formatting after adding suggestions from GH

* Address @mdegat01 review comments

- Improve swap options validation
- Add swap to the 'all' property of dbus agent
- Use APINotFound with reason instead of HTTPNotFound
- Reorder API routes

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Jan Čermák
2025-03-27 17:53:46 +01:00
committed by GitHub
parent 9222a3c9c0
commit 0a684bdb12
11 changed files with 381 additions and 2 deletions

View File

@@ -283,6 +283,7 @@ async def fixture_os_agent_services(
"agent_apparmor": None,
"agent_cgroup": None,
"agent_datadisk": None,
"agent_swap": None,
"agent_system": None,
"agent_boards": None,
"agent_boards_yellow": None,