Commit Graph

87 Commits

Author SHA1 Message Date
Sven Sager
1172954ad7 feat(revpiconfig): Add CmdLineTxt class for managing cmdline.txt
Introduced the `CmdLineTxt` class to handle parsing, modifying, and
writing operations on the `cmdline.txt` file with thread safety.
Implemented methods for setting, removing keys, and ensuring safe file
operations.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-06-26 08:41:49 +02:00
Sven Sager
fedb0f8924 feat(revpiconfig): Add thread safety for config.txt file operations
Introduced a threading lock to safeguard read and write operations on
the `config.txt` file. This ensures thread-safe access and prevents
potential race conditions during concurrent execution.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-06-26 06:41:59 +02:00
Sven Sager
b4f817b477 feat(examples): Add revpi-config CLI tool for RevPi configuration
Introduced a new Python-based command-line tool `revpi-config` to manage
Revolution Pi features via D-Bus. The tool supports enabling,
disabling, checking status, and availability for various features.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-06-04 08:10:52 +02:00
Sven Sager
66046b6a9d feat(dbus): Update systemd unit state check to include 'activating'
Previously, the check only considered 'active' as a valid ActiveState.
This update ensures the system also accounts for units in the
'activating' state, improving compatibility with transitional states in
systemd services.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-27 14:54:44 +02:00
Sven Sager
9ec1e04d2b feat(dbus): Update service key for systemd-timesyncd to 'ntp'
Renamed the key 'systemd-timesyncd' to 'ntp' in the services mapping.
This improves naming consistency and aligns it with the expected service
identifier. No functional changes were introduced.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-27 14:54:14 +02:00
Sven Sager
1cb1062138 feat(dbus): Update feature key from 'dphys-swapfile' to 'swapfile'
Renamed the feature key for swapfile configuration to ensure consistency
and simplify naming.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-27 14:28:07 +02:00
Sven Sager
8d01eee66d feat(dbus): Update status change notification in feature toggle methods
Added calls to `StatusChanged` in `Disable` and `Enable` methods to
notify when a feature's state is updated. This ensures proper tracking
and external communication of feature status changes.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-27 14:28:07 +02:00
Sven Sager
40059d6068 feat(dbus): Add InterfaceSoftwareServices to bus provider initialization
This change integrates the InterfaceSoftwareServices class into the list
of interfaces initialized by the bus provider. It ensures the new
interface is properly registered and available for use, improving
system functionality and extensibility.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-27 14:18:37 +02:00
Sven Sager
50789853e9 feat(dbus): Add D-Bus interface for managing software services
Introduce `InterfaceSoftwareServices` to handle service enable/disable
actions, status, and availability via D-Bus. Consolidate `avahi` service
configuration into the new interface by removing redundant logic from
`revpi_config.py`.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-27 14:18:37 +02:00
Sven Sager
d2e2f1c7f3 refactor(dbus): Move simple_systemd to systemd_helper
Moved the `simple_systemd` function to a dedicated `systemd_helper`
module to improve code organization and reusability. Updated imports
accordingly in affected files.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-27 14:18:37 +02:00
Sven Sager
32574e0815 refactor: DBus interface includes bus instance
Updated `InterfaceRevpiConfig` to require a bus parameter, ensuring
proper initialization. Introduced a constructor in `DbusInterface` to
store the bus instance.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-27 12:37:15 +02:00
Sven Sager
a29979ad78 feat(dbus): Add AvailabilityChanged signal to .RevpiConfig
This signal provides a mechanism for notifying changes in availability
status. It will complement the existing `StatusChanged` signal and
enhance the system's event-handling capabilities.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-27 07:58:40 +02:00
Sven Sager
431f9308de feat(dbus): Add StatusChanged DBus signal to interface configuration
Introduced the `StatusChanged` signal in `.RevpiConfig` interface to
notify changes in feature status. Emitting this signal in `Enable` and
`Disable` methods ensures real-time updates for feature state changes.
This enhances communication and monitoring within the DBus middleware.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-26 15:21:08 +02:00
Sven Sager
dc2d1ab3a0 ci: Test in a bookworm container
In order to be able to provide all functions of the DBus during testing,
the CI uses the Python 3.11 version in a Bookworm container for
testing. This is the version that is pre-installed in Debian Bookworm.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-23 09:54:30 +02:00
Sven Sager
983c6cefea ci: Start dbus session bus for testing
A dbus session bus must be started for testing. The command
`dbus-run-session` creates a session for the following command. As a
result, `pytest` runs with its own session bus for the tests.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-23 09:54:30 +02:00
Sven Sager
a977884e17 ci: Set machine-id for dbus
Systemd does not exist in the docker file. So we just set an machine-id,
which the dbus-daemon can use to start a session.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-23 09:54:30 +02:00
Sven Sager
20fb85a3f0 ci: Install system dependencies for testing
Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-23 09:52:43 +02:00
Sven Sager
f4efb1daae fix: Add missing reuse license information
Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-23 09:36:41 +02:00
Sven Sager
fb181f8810 ci: Add Revolution Pi pipelines
Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-22 13:14:22 +02:00
Sven Sager
3dee7784e2 ci: Add GitLab python pipelines
Signed-off-by: Sven Sager <s.sager@kunbus.com>
2025-05-22 13:14:22 +02:00
cc560770ce feat(revpiconfig): Make unit config changes asynchronous
Refactored unit enable/disable actions to run in separate threads,
ensuring non-blocking operations. This enhances performance and avoids
potential delays during systemd operations.
v0.0.5
2025-04-22 13:42:33 +02:00
4df903783c fix(revpiconfig): Ensure systemd reloads after unit changes
Added systemd reload calls after unit enable/disable to reflect changes.
Adjusted DBus method calls to capture and utilize change outputs
effectively. This improves reliability in applying unit modifications.
2025-04-22 12:35:43 +02:00
8db1f59cfe doc(revpiconfig): Docstrings for get_rfkill_index and simple_systemd
The new docstrings provide detailed explanations of the purpose,
parameters, and return values for both functions, improving code
readability and maintainability. This ensures better understanding for
future contributors and reduces ambiguity.
v0.0.4
2025-04-22 11:06:32 +02:00
7051eba9b9 doc(revpiconfig): Add docstrings to enums in revpi_config.py
This update introduces detailed docstrings for the `ComputeModuleTypes`
and `ConfigActions` enumeration classes. The docstrings provide
descriptions for each class and their attributes, improving code
readability and maintainability.
2025-04-22 11:06:32 +02:00
04780bd0dd doc(revpiconfig): Add docstrings to RevPiConfig class and methods
Enhance documentation for the `RevPiConfig` class, its methods, and
properties to improve code readability and ease of use. The added
docstrings provide clear explanations of the class's purpose,
attributes, and functionality for developers and users. This update
supports better maintainability and understanding of the codebase.
2025-04-22 11:06:32 +02:00
41fb2b3c61 doc(revpiconfig): Add detailed docstrings to ConfigTxt methods
Enhance the `ConfigTxt` class with comprehensive docstrings for all
methods, providing clear explanations of their functionality,
parameters, and return values. This improves code readability and
facilitates easier maintenance and understanding for future developers.
2025-04-22 11:06:32 +02:00
41d9b13e71 fix(dbus): Update systemd interface and path handling
Revised DBus interactions to explicitly use `org.freedesktop.systemd1`
interface and path. This ensures that the correct interfaces are used
and bypasses ".systemd1" magic from the library `pydbus`.
2025-04-22 10:59:59 +02:00
463a61a001 fix(dbus): Update DBus policy file path and interface name
Change the comment to reflect the new DBus policy file location. Adjust
the interface name to use `PiControl` instead of `picontrol` for
consistency.
2025-04-22 10:37:36 +02:00
1fab228272 refactor: Rename WiFi to WLAN for consistent terminology
Updated variable names, function names, and comments to replace "WiFi"
with "WLAN" throughout the codebase. This ensures alignment with
standardized terminology and improves clarity in functionality and
configuration handling. Adjusted related configurations and interface
mappings accordingly.
v0.0.3
2025-04-21 13:34:10 +02:00
fc82ec0eb9 feat(revpiconfig): Replace rfkill subprocess calls with sysfs writes
Updated Bluetooth and WiFi rfkill handling by replacing subprocess calls
to "rfkill" with direct writes to sysfs files. This change simplifies
the implementation and improves performance by avoiding external
command execution.
2025-04-21 13:25:56 +02:00
de1774f60e feat(cli): Add CLI support for RevPi configuration object (revpi-config)
This implements a new command "config" in the CLI to handle RevPi
configuration. It includes parsing and subparser setup for
configuration-related operations. The change improves usability by
extending CLI functionality to manage RevPi configuration objects.
2025-04-21 10:55:32 +02:00
8c145ef2ff feat(cli): Add CLI command for configuring Revpi features
Introduced a new CLI command to enable, disable, check the status, and
list available features for Revpi using D-Bus calls. This implementation
provides a structured interface for managing Revpi configurations via
command-line actions.
2025-04-21 10:55:11 +02:00
0ecd86bd64 feat(cli): Add get_properties helper function for DBus interactions
This function facilitates retrieving specific properties from a DBus
interface, improving code modularity and reusability. It supports both
system and session bus types, streamlining access to DBus resources.
2025-04-21 10:54:47 +02:00
555c781aed feat(dbus): Add InterfaceRevpiConfig to DBus interfaces list
Added the InterfaceRevpiConfig class to the list of DBus interfaces in
`bus_provider.py`. This ensures the new system configuration interface
is properly registered and accessible.
2025-04-21 10:21:36 +02:00
604cb61870 feat(dbus): Add Bluetooth configuration functionality
Introduce functionality to enable, disable, and check the status and
availability of Bluetooth devices using the `configure_bluetooth`
method. Integrate Bluetooth configuration into the feature management
system by mapping it in `interface_config.py`.
2025-04-21 10:17:56 +02:00
69e370f964 refactor(revpiconfig: Change Wi-Fi detection and rfkill index logic
Replaced inline rfkill index detection with a standalone
`get_rfkill_index` function for improved modularity. Removed
`_cm_with_wifi` and `_wlan_rfkill_index` attributes, utilizing
`_wlan_class_path` for Wi-Fi presence checks. Adjusted property and
output logic to incorporate the new function.
2025-04-21 10:05:20 +02:00
6eb7eeea40 feat(dbus): Add Wi-Fi configuration support to the system config
Introduces the `configure_wifi` function to handle Wi-Fi actions such as
enabling, disabling, and checking status. Updates the `ieee80211`
feature to use the new function, integrating Wi-Fi management into the
existing configuration framework.
2025-04-21 09:28:01 +02:00
18e6fb3d14 feat(revpiconfig): Enhance Wi-Fi detection and add rfkill index support
Improved logic to detect built-in and third-party Wi-Fi interfaces,
including integration of `rfkill` index retrieval for Wi-Fi devices.
This enhances support for various hardware setups and allows better
control over Wi-Fi functionality.
2025-04-21 09:05:47 +02:00
fe614d026a feat(dbus): Add support for configuring 'revpi-con-can' feature
Introduce the `configure_con_can` function to manage enabling,
disabling, status checking, and availability of the 'revpi-con-can'
feature. Update the `AVAILABLE_FEATURES` dictionary to integrate
'revpi-con-can' as a configurable feature.
2025-04-21 09:05:47 +02:00
870a55042e feat(dbus): Add support for configuring the external antenna
Introduce the `configure_external_antenna` function to manage external
antenna settings, including enable, disable, and status checks. Update
the feature configuration in `interface_config` to include this
functionality. This enhances WiFi-related configuration options.
2025-04-21 09:05:47 +02:00
2848fdcf54 feat(revpiconfig): Add ConfigTxt class for managing config.txt file
Introduced the ConfigTxt class to handle parsing, editing, and saving of
config.txt files. This includes methods for adding, clearing, and
retrieving configuration values, as well as handling dtoverlays and
dtparams. Enhanced system configuration capabilities by providing
structured support for config file operations.
2025-04-21 09:05:47 +02:00
d0f641f2b5 feat(dbus): Add dphys-swapfile configuration functionality
Implemented `configure_dphys_swapfile` to manage the dphys-swapfile
service, including automatic swapfile removal when the service is
disabled. Updated feature registry to support dphys-swapfile
configuration.
2025-04-21 09:05:47 +02:00
e8eba43647 feat(dbus): Add avahi-daemon configuration to system services
Introduce a `configure_avahi_daemon` function to manage the avahi-daemon
service and socket with proper post actions. Update the interface
configuration to enable avahi management using the new function.
2025-04-21 09:05:47 +02:00
0d601f623c feat(dbus): Remove 'var-log.mount' feature
The 'var-log.mount' feature was dropped and has been removed from
the AVAILABLE_FEATURES dictionary.
2025-04-21 09:05:47 +02:00
66735a9eba refactor(dbus): Move system configuration methods to revpi_config.py
Centralized `ConfigActions`, `configure_gui`, and `simple_systemd` into
`revpi_config.py` to eliminate duplication and improve maintainability.
Updated `interface_config.py` to import these methods, ensuring
consistent functionality across modules.
2025-04-21 09:05:47 +02:00
7525c9f653 feat(revpiconfig): Add RevPiConfig class for device information handling
This commit introduces a new `RevPiConfig` class to manage RevPi device
configuration details, such as model, serial, compute module type, WiFi,
and ConBridge detection. It parses CPU info from `/proc/cpuinfo` and
leverages helper methods for hardware-specific checks, enhancing the
middleware's ability to identify and manage hardware features.
2025-04-21 09:05:46 +02:00
3909fab379 feat(dbus): Add GUI configuration handling to interface_config.py
Introduced the `configure_gui` function to manage GUI enabling,
disabling, availability, and status retrieval. Updated the
`AVAILABLE_FEATURES` dictionary to include GUI management functionality,
leveraging systemd and os module operations.
2025-04-20 15:34:16 +02:00
9ce36c78e7 feat(dbus): Add D-Bus interface for system configuration in middleware
Introduced `InterfaceRevpiConfig` to manage feature actions like
enable/disable, status, and availability using D-Bus. Includes support
for predefined features with systemd integration and exception handling
for unsupported features.
2025-04-20 15:18:27 +02:00
c24c78761f fix(cli): Change absolute imports to relative imports 2025-04-20 15:12:09 +02:00
3cc64f514f feat(dbus): Add grep function to search for patterns in a file
The new `grep` function reads a specified file and returns lines
containing a given pattern. It handles file not found errors and logs
unexpected exceptions, improving resilience in file operations.
2025-04-20 15:11:43 +02:00