feat: find_ssh_public_key() utility and MultipassClient.ensure_running() — v0.4.0 - #8
Open
miciav wants to merge 24 commits into
Open
feat: find_ssh_public_key() utility and MultipassClient.ensure_running() — v0.4.0#8miciav wants to merge 24 commits into
miciav wants to merge 24 commits into
Conversation
- Fix SnapshotInfo.from_snapshots_json to match actual Multipass CLI format
(nested dict info.{instance}.{snap_name} instead of flat list)
- Fix cpu_count parsing to handle empty string on stopped VMs
- Update integration tests disk size 3G→5G (Ubuntu 22.04 minimum)
- Add 8 new integration test scenarios: resources, suspend/resume,
file transfer, snapshot/restore, clone, cloud-init, error handling
- Update unit test fixtures to use correct snapshot JSON format
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds cloud_init_config to launch() accepting a dict (serialized to JSON) or a raw YAML string. Temp files are written to Path.home() instead of /tmp so Multipass installed via snap can access them. File is deleted automatically after launch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a new find_ssh_public_key() helper that searches ~/.ssh/ for public keys in priority order (ed25519, rsa, ecdsa, dsa) and returns the stripped key string ready for cloud-init ssh_authorized_keys, or None if absent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…thod Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cloud-init requires the user-data file to start with '#cloud-config' to process it as cloud-config. Using json.dumps() produced JSON without that header, so cloud-init silently ignored the file and SSH keys were never injected into the VM's authorized_keys. Add pyyaml>=6.0 as a dependency and use yaml.dump() to produce valid cloud-config YAML. Update the test to assert the header is present and the serialized content parses back correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds exec_structured(argv, *, env, cwd) to MultipassVM. The method builds the bash prologue (cd + export) from structured parameters internally, so callers above the SDK never need to construct shell strings. Bumps version to 0.5.0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… sibling SDKs - Add VmConfig dataclass for reusable launch configuration (mirrors azure-vm-sdk, proxmox-sdk) - Add CloudInitConfig dataclass with to_dict() serialization - Add MultipassClient.launch_many() with parallel launch and rollback - MultipassClient.launch() now accepts VmConfig or inline params - Add e2e.py CLI script (multipass-vm-e2e) for lifecycle testing - Add testing.py module re-exporting FakeBackend - Enhance CommandBackend protocol and FakeBackend with cwd/env support - Fix exec_structured() to include set -e for shell safety - Fix snapshots() to filter by current VM - Bump version to 0.6.0 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add feature tests: exec_structured, stop/start, restart, transfer, clone, snapshot/restore. Each is individually skippable via --skip. Feature tests only run on single-VM mode (--count 1) by default. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…_structured, e2e, testing.py Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…hangs on writer-less pty)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
find_ssh_public_key()— newsrc/multipass/utils.pyutility that scans~/.ssh/for the first available SSH public key (priority: ed25519 → rsa → ecdsa → dsa); returns strippedstrorNone; exported from the top-level packageMultipassClient.ensure_running()— idempotent VM lifecycle method: launches if not found, purges+relaunches if deleted, starts if stopped/suspended, no-ops if already running; accepts the same parameters aslaunch()Test Plan
uv run pytest tests/unit/ -v— 79 tests, 0 failuresfind_ssh_public_key()returns correct key content, strips whitespace, respects priority order, returnsNonewhen no keys or no~/.ssh/dirensure_running()covers all state transitions: not found, running (no-op), stopped, suspended, deleted (purge+launch)ensure_running()forwards all launch params (cpus, memory, disk, image, cloud_init_config)🤖 Generated with Claude Code