A Python client library to interact with Firecracker microVMs
Project description
firecracker-python
firecracker-python is a simple Python library that makes it easy to manage Firecracker microVMs. It provides a simple way to create, configure, and manage microVMs.
Some features are still being developed and will be added in the future. You can track these in the TODO.md file.
Table of Contents
How to Install
To install from PyPI, you need to have a personal access token with read access to the repository.
pip3 install firecracker-python
Or install from source, by cloning the repository and installing the package using pip:
git clone https://github.com/myugan/firecracker-python.git
cd firecracker-python
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
pip3 install -e .
Key Features
- Easily create microVMs with default or custom settings
- View a list of all running microVMs
- Access and modify microVM settings
- Remove one or all microVMs
- Connect to microVMs using SSH
- Set up port forwarding in microVMs
Getting Started
To get started with firecracker-python, check out the getting started guide
Usage
Here are some examples of how to use the library.
Create a microVM with custom configuration and list them all
from firecracker import MicroVM
# Create a new microVM with custom configuration
vm = MicroVM(vcpu=2, memory="4096")
# Or
vm = MicroVM(vcpu=2, memory="4G")
vm.create()
# List all running microVMs
vms = MicroVM.list() # Static method to list all VMs
for vm in vms:
print(f"VM with id {vm['id']} has IP {vm['ip_addr']} and is in state {vm['state']}")
Delete a microVM by id or all microVMs
from firecracker import MicroVM
# Create a new microVM
vm = MicroVM()
vm.create()
# Delete the microVM just created
vm.delete()
# Delete a specific microVM by ID
vm.delete(id="<specific_id>")
# Delete all microVMs
vm.delete(all=True)
Enable port forwarding
During initialization:
from firecracker import MicroVM
# Single port
vm = MicroVM(expose_ports=True, host_port=10222, dest_port=22)
# Multiple ports
# vm = MicroVM(expose_ports=True, host_port=[10222, 10280], dest_port=[22, 80])
vm.create()
After creation you can also expose ports using the port_forward function:
from firecracker import MicroVM
vm = MicroVM()
vm.create()
# Forward a single port
vm.port_forward(host_port=10222, dest_port=22)
# 'Port forwarding added successfully'
# Forward multiple ports
vm.port_forward(host_port=[10222, 10280], dest_port=[22, 80])
# 'Port forwarding added successfully'
# Remove port forwarding
vm.port_forward(host_port=10222, dest_port=22, remove=True)
# 'Port forwarding removed successfully'
Note: When using port forwarding, you need to specify both
host_portanddest_port. The number of host ports must match the number of destination ports.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a Pull Request (PR).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file firecracker-python-0.0.5.tar.gz.
File metadata
- Download URL: firecracker-python-0.0.5.tar.gz
- Upload date:
- Size: 151.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5af6ee0eeeaa348dae831d3eda9850dd4b6fa5cfa72eeb4e28093665ee19d08
|
|
| MD5 |
733fb0f3a940e649690353d5b31ccc02
|
|
| BLAKE2b-256 |
54304bdcfdd025614fc3976232f23ab9e39f253b7364310b71b3fbb4cb8be275
|
Provenance
The following attestation bundles were made for firecracker-python-0.0.5.tar.gz:
Publisher:
pypi-release.yml on myugan/firecracker-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
firecracker_python-0.0.5.tar.gz -
Subject digest:
e5af6ee0eeeaa348dae831d3eda9850dd4b6fa5cfa72eeb4e28093665ee19d08 - Sigstore transparency entry: 432763869
- Sigstore integration time:
-
Permalink:
myugan/firecracker-python@41237f8a075fb29719d459c8466caf348e0fbd72 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/myugan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@41237f8a075fb29719d459c8466caf348e0fbd72 -
Trigger Event:
push
-
Statement type:
File details
Details for the file firecracker_python-0.0.5-py3-none-any.whl.
File metadata
- Download URL: firecracker_python-0.0.5-py3-none-any.whl
- Upload date:
- Size: 36.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee3d72aacc5351711faf5e793f5698b5165a0373625ee681fccd1b78a0a21b63
|
|
| MD5 |
516cf4ed28cde83c12a2c6c45564bd8c
|
|
| BLAKE2b-256 |
cd152c61367e43a0af8cf85691710e32c02f33bf3e0371c0093a80ef0fd45a1c
|
Provenance
The following attestation bundles were made for firecracker_python-0.0.5-py3-none-any.whl:
Publisher:
pypi-release.yml on myugan/firecracker-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
firecracker_python-0.0.5-py3-none-any.whl -
Subject digest:
ee3d72aacc5351711faf5e793f5698b5165a0373625ee681fccd1b78a0a21b63 - Sigstore transparency entry: 432763890
- Sigstore integration time:
-
Permalink:
myugan/firecracker-python@41237f8a075fb29719d459c8466caf348e0fbd72 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/myugan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@41237f8a075fb29719d459c8466caf348e0fbd72 -
Trigger Event:
push
-
Statement type: