adds some code
This commit is contained in:
35
scripts/smoke.sh
Executable file
35
scripts/smoke.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
API="${API:-http://127.0.0.1:8000/api/v1}"
|
||||
TOKEN="${TOKEN:-changeme}"
|
||||
HDR=(-H "Authorization: Bearer ${TOKEN}")
|
||||
|
||||
vm_id=${VM_ID:-smoke-vm}
|
||||
ct_id=${CT_ID:-smoke-ct}
|
||||
|
||||
create_vm() {
|
||||
curl -sfS "${HDR[@]}" -X POST "${API}/vms" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "{\"id\":\"${vm_id}\",\"name\":\"${vm_id}\",\"cpus\":1,\"memory_mb\":512,\"disks\":[{\"name\":\"root\",\"size_gb\":1,\"pool\":\"local\"}],\"nics\":[{\"bridge\":\"vmbr0\"}]}"
|
||||
}
|
||||
|
||||
create_ct() {
|
||||
curl -sfS "${HDR[@]}" -X POST "${API}/containers" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "{\"id\":\"${ct_id}\",\"name\":\"${ct_id}\",\"template\":\"debian-bookworm\",\"rootfs_pool\":\"local\",\"rootfs_size_g\":1,\"nics\":[{\"bridge\":\"vmbr0\"}],\"limits\":{\"cpus\":1,\"memory_mb\":256},\"unprivileged\":true}"
|
||||
}
|
||||
|
||||
cmd=${1:-}
|
||||
case "$cmd" in
|
||||
create-vm) create_vm ;;
|
||||
create-ct) create_ct ;;
|
||||
list)
|
||||
curl -sfS "${HDR[@]}" "${API}/vms" | jq .
|
||||
curl -sfS "${HDR[@]}" "${API}/containers" | jq .
|
||||
;;
|
||||
*)
|
||||
echo "Usage: API=... TOKEN=... $0 {create-vm|create-ct|list}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user