Developer Guide¶
Prerequisites¶
- Python 3.10 or later
toxfor running tests and linting
Project Layout¶
shakenfist_agent/
main.py # CLI entry point
log.py # Console logging
commandline/
daemon.py # vsock listener and command handlers
protos/
agent.proto # Protobuf definitions
common.proto # Shared protobuf definitions
*_pb2.py # Generated stubs (do not edit)
tests/
test_daemon.py # Unit tests
Building¶
The project uses pyproject.toml with setuptools_scm for
version management. Versions are derived from git tags:
Running Tests¶
Adding a New Command¶
-
Define the protobuf messages. Add request and reply message types to
shakenfist_agent/protos/agent.proto. Add the request to theHypervisorToAgentCommand.requestoneof and the reply toAgentToHypervisorCommand.reply. -
Regenerate stubs. The proto files and generated stubs are maintained in the main shakenfist repository. Use
_copy_stubs.shto sync them. -
Implement the handler. Add a
_handle_<command>method toVSockAgentJobincommandline/daemon.py. Useself._send_responses()to send the reply. -
Register the dispatch. Add a
HasFieldcheck for your new request type in_attempt_decode(). -
Write tests. Add a test method to
DaemonAgentV2TestCaseintests/test_daemon.py. Tests construct protobuf messages, serialize them into the job's buffer, call_attempt_decode(), and verify the mocked_send_responses()calls.
Dependencies¶
The agent runs inside guest VMs with minimal environments, so the dependency list is kept deliberately small:
| Package | Purpose |
|---|---|
| click | CLI framework |
| distro | OS distribution detection |
| psutil | Boot time, I/O priority |
| symbolicmode | Symbolic chmod (e.g. ugo+rw) |
| setproctitle | Set process name in ps output |
| protobuf / grpcio | Protocol buffer serialization |
Several dependencies that were previously used (linux-utils,
oslo.concurrency, shakenfist-utilities) have been replaced
with lightweight inline implementations to reduce install size
and improve compatibility with newer Python versions.