Prepare, configure, and manage Firecracker microVMs in seconds!
virtualization linux microvm firecracker

feat: add inspect command to view Firecracker MicroVM details and update dependencies

+114 -12
+1
Cargo.lock
··· 1006 1006 "names", 1007 1007 "num_cpus", 1008 1008 "owo-colors", 1009 + "serde_json", 1009 1010 "sqlx", 1010 1011 "tokio", 1011 1012 ]
+57 -9
README.md
··· 37 37 sudo apt-get install fireup 38 38 ``` 39 39 40 - ## Subcommands 41 - - `init`: Initializes a new configuration file `fire.toml` in the current directory. 42 - - `up`: Starts the Firecracker microVM, preparing assets and configuring the network if needed. 43 - - `down`: Stops the running Firecracker microVM. 44 - - `status`: Checks the status of the Firecracker microVM (running, stopped, or errored). 45 - - `logs`: Displays the logs of the Firecracker microVM from the log file. 46 - - `ssh`: Connects to the Firecracker microVM via SSH. 47 - - `reset`: Resets the Firecracker microVM, stopping it and preparing it for a fresh start. 48 - - `help`: Prints help information for the CLI or specific subcommands. 40 + ## Usage 41 + 42 + ```bash 43 + 44 + _______ __ __ 45 + / ____(_)_______ / / / /___ 46 + / /_ / / ___/ _ \/ / / / __ \ 47 + / __/ / / / / __/ /_/ / /_/ / 48 + /_/ /_/_/ \___/\____/ .___/ 49 + /_/ 50 + 51 + 52 + Usage: fireup [OPTIONS] [COMMAND] 53 + 54 + Commands: 55 + init Create a new MicroVM configuration `fire.toml` in the current directory 56 + ps List all Firecracker MicroVM instances 57 + start Start Firecracker MicroVM 58 + stop Stop Firecracker MicroVM 59 + restart Restart Firecracker MicroVM 60 + up Start a new Firecracker MicroVM 61 + down Stop Firecracker MicroVM 62 + status Check the status of Firecracker MicroVM 63 + logs View the logs of the Firecracker MicroVM 64 + ssh SSH into the Firecracker MicroVM 65 + reset Reset the Firecracker MicroVM 66 + rm Delete the Firecracker MicroVM 67 + serve Start fireup HTTP API server 68 + inspect Inspect the Firecracker MicroVM details 69 + help Print this message or the help of the given subcommand(s) 70 + 71 + Options: 72 + --debian Prepare Debian MicroVM 73 + --alpine Prepare Alpine MicroVM 74 + --nixos Prepare NixOS MicroVM 75 + --fedora Prepare Fedora MicroVM 76 + --gentoo Prepare Gentoo MicroVM 77 + --slackware Prepare Slackware MicroVM 78 + --opensuse Prepare OpenSUSE MicroVM 79 + --opensuse-tumbleweed Prepare OpenSUSE Tumbleweed MicroVM 80 + --almalinux Prepare AlmaLinux MicroVM 81 + --rockylinux Prepare RockyLinux MicroVM 82 + --archlinux Prepare ArchLinux MicroVM 83 + --ubuntu Prepare Ubuntu MicroVM 84 + --vcpu <n> Number of vCPUs 85 + --memory <m> Memory size in MiB 86 + --vmlinux <path> Path to the kernel image 87 + --rootfs <path> Path to the root filesystem image 88 + --bridge <name> Name of the bridge interface [default: br0] 89 + --tap <name> Name of the tap interface [default: ] 90 + --mac-address <MAC> MAC address for the network interface 91 + --api-socket <path> Path to the Firecracker API socket 92 + --boot-args <ARGS> Override boot arguments 93 + --ssh-keys <SSH_KEYS> Comma-separated list of SSH public keys to add to the VM 94 + -h, --help Print help 95 + -V, --version Print version 96 + ```
+1
crates/firecracker-up/Cargo.toml
··· 30 30 "macros", 31 31 ] } 32 32 chrono = "0.4.42" 33 + serde_json = "1.0.145"
+42
crates/firecracker-up/src/cmd/inspect.rs
··· 1 + use std::process; 2 + 3 + use anyhow::Error; 4 + use firecracker_state::{ repo}; 5 + use serde_json::json; 6 + 7 + pub async fn inspect_microvm(id: &str) -> Result<(), Error> { 8 + let pool = firecracker_state::create_connection_pool().await?; 9 + let vm = repo::virtual_machine::find(&pool, id).await?; 10 + if vm.is_none() { 11 + println!("[!] No virtual machine found with the name: {}", id); 12 + process::exit(1); 13 + } 14 + 15 + let vm = vm.unwrap(); 16 + let vm = json!({ 17 + "id": vm.id, 18 + "name": vm.name, 19 + "image": vm.distro, 20 + "vcpu": vm.vcpu, 21 + "memory": vm.memory, 22 + "vmlinux": vm.vmlinux, 23 + "rootfs": vm.rootfs, 24 + "bootargs": vm.bootargs, 25 + "bridge": vm.bridge, 26 + "tap": vm.tap, 27 + "api_socket": vm.api_socket, 28 + "mac_address": vm.mac_address, 29 + "ssh_keys": vm.ssh_keys, 30 + "status": vm.status, 31 + "pid": vm.pid, 32 + "ip_address": vm.ip_address, 33 + "project_dir": vm.project_dir, 34 + "created_at": vm.created_at.to_rfc3339(), 35 + "updated_at": vm.updated_at.to_rfc3339(), 36 + }); 37 + 38 + let vm_json = serde_json::to_string_pretty(&vm)?; 39 + println!("{}", vm_json); 40 + 41 + Ok(()) 42 + }
+1
crates/firecracker-up/src/cmd/mod.rs
··· 1 1 pub mod down; 2 2 pub mod init; 3 + pub mod inspect; 3 4 pub mod logs; 4 5 pub mod ps; 5 6 pub mod reset;
+12 -3
crates/firecracker-up/src/main.rs
··· 4 4 use owo_colors::OwoColorize; 5 5 6 6 use crate::cmd::{ 7 - down::down, init::init, logs::logs, ps::list_all_instances, reset::reset, rm::remove, 8 - serve::serve, ssh::ssh, start::start, status::status, stop::stop, up::up, 7 + down::down, init::init, logs::logs, ps::list_all_instances, reset::reset, rm::remove, serve::serve, ssh::ssh, start::start, status::status, stop::stop, up::up, 8 + inspect::inspect_microvm, 9 9 }; 10 10 11 11 pub mod cmd; ··· 31 31 .version(env!("CARGO_PKG_VERSION")) 32 32 .about(&banner) 33 33 .subcommand(Command::new("init").about( 34 - "Create a new Firecracker MicroVM configuration `fire.toml` in the current directory", 34 + "Create a new MicroVM configuration `fire.toml` in the current directory", 35 35 )) 36 36 .subcommand( 37 37 Command::new("ps") ··· 140 140 .about("Start fireup HTTP API server") 141 141 .arg(arg!(--host <host> "Host to bind the server")) 142 142 .arg(arg!(--port <port> "Port to bind the server")), 143 + ) 144 + .subcommand( 145 + Command::new("inspect") 146 + .arg(arg!(<name> "Name or ID of the Firecracker MicroVM to inspect").required(true)) 147 + .about("Inspect the Firecracker MicroVM details"), 143 148 ) 144 149 .arg(arg!(--debian "Prepare Debian MicroVM").default_value("false")) 145 150 .arg(arg!(--alpine "Prepare Alpine MicroVM").default_value("false")) ··· 300 305 remove(&name).await? 301 306 } 302 307 Some(("serve", _)) => serve().await?, 308 + Some(("inspect", args)) => { 309 + let name = args.get_one::<String>("name").cloned().unwrap(); 310 + inspect_microvm(&name).await?; 311 + } 303 312 _ => { 304 313 let debian = matches.get_one::<bool>("debian").copied().unwrap_or(false); 305 314 let alpine = matches.get_one::<bool>("alpine").copied().unwrap_or(false);