Files
easyqemu/EXAMPLES.sh
2026-01-07 02:01:17 +01:00

145 líneas
4.9 KiB
Bash
Archivo Ejecutable

#!/bin/bash
##############################################################################
# EasyQEMU Examples - Common usage scenarios
##############################################################################
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'
echo_example() {
echo -e "${BLUE}Example: $1${NC}"
echo -e "${GREEN}$2${NC}"
echo ""
}
cat << 'EOF'
╔═══════════════════════════════════════════════════════════════╗
║ EasyQEMU - Usage Examples ║
╚═══════════════════════════════════════════════════════════════╝
EOF
echo_example "1. Create a basic VM" \
"./easyqemu vm create --name myvm"
echo_example "2. Create a VM with custom specs" \
"./easyqemu vm create --name ubuntu --memory 4096 --cpus 4 --disk-size 50G"
echo_example "3. Create a VM with ISO" \
"./easyqemu vm create --name installer --cdrom /path/to/ubuntu.iso --boot cd"
echo_example "4. List all VMs" \
"./easyqemu vm list"
echo_example "5. Start a VM" \
"./easyqemu vm start <vm_id>"
echo_example "6. Show VM information" \
"./easyqemu vm info <vm_id>"
echo_example "7. Modify VM settings" \
"./easyqemu vm modify <vm_id> --memory 8192 --cpus 8"
echo_example "8. Create a volume" \
"./easyqemu volume create --name data --size 100G --format qcow2"
echo_example "9. List volumes" \
"./easyqemu volume list"
echo_example "10. Convert volume format (qcow2 to raw)" \
"./easyqemu volume convert --source disk.qcow2 --target disk.raw --format raw"
echo_example "11. Convert to VMDK (VMware format)" \
"./easyqemu volume convert --source disk.qcow2 --target disk.vmdk --format vmdk"
echo_example "12. Import existing disk" \
"./easyqemu volume import /path/to/disk.qcow2 imported-disk.qcow2"
echo_example "13. Export volume" \
"./easyqemu volume export mydisk.qcow2 /backup/mydisk.qcow2"
echo_example "14. Create snapshot" \
"./easyqemu snapshot create <vm_id> before_upgrade"
echo_example "15. List snapshots" \
"./easyqemu snapshot list <vm_id>"
echo_example "16. Restore snapshot" \
"./easyqemu snapshot apply <vm_id> before_upgrade"
echo_example "17. Delete snapshot" \
"./easyqemu snapshot delete <vm_id> before_upgrade"
echo_example "18. Save VM to repository" \
"./easyqemu repo save <vm_id> my_template"
echo_example "19. Load VM from repository" \
"./easyqemu repo load my_template new_vm_name"
echo_example "20. List repository entries" \
"./easyqemu repo list"
echo_example "21. Delete VM" \
"./easyqemu vm delete <vm_id>"
echo_example "22. Delete VM (force, no confirmation)" \
"./easyqemu vm delete <vm_id> -f"
echo_example "23. Get volume information" \
"./easyqemu volume info ~/.easyqemu/volumes/disk.qcow2"
echo_example "24. Delete volume" \
"./easyqemu volume delete mydisk.qcow2"
echo_example "25. Show help" \
"./easyqemu help"
cat << 'EOF'
╔═══════════════════════════════════════════════════════════════╗
║ Common Workflows ║
╚═══════════════════════════════════════════════════════════════╝
WORKFLOW 1: Create and Install Ubuntu
--------------------------------------
1. ./easyqemu vm create --name ubuntu --memory 4096 --cpus 4 --disk-size 50G --cdrom ubuntu.iso
2. ./easyqemu vm list (note the VM ID)
3. ./easyqemu vm start ubuntu_<timestamp>
4. Install OS in the VM
5. ./easyqemu vm modify ubuntu_<timestamp> --boot hd --cdrom ""
6. ./easyqemu vm start ubuntu_<timestamp>
WORKFLOW 2: Snapshot Before Major Changes
-----------------------------------------
1. ./easyqemu snapshot create <vm_id> before_changes
2. Make your changes in the VM
3. If successful: Keep it
4. If failed: ./easyqemu snapshot apply <vm_id> before_changes
WORKFLOW 3: Create Base VM Template
-----------------------------------
1. Create and configure a base VM
2. ./easyqemu repo save <vm_id> base_template
3. Create multiple VMs from template:
./easyqemu repo load base_template vm1
./easyqemu repo load base_template vm2
./easyqemu repo load base_template vm3
WORKFLOW 4: Convert Disk for VirtualBox
---------------------------------------
1. ./easyqemu volume convert --source ~/.easyqemu/volumes/myvm.qcow2 --target myvm.vdi --format vdi
2. Import myvm.vdi into VirtualBox
WORKFLOW 5: Migrate VM to Another System
----------------------------------------
1. ./easyqemu repo save <vm_id> my_vm
2. tar -czf my_vm.tar.gz -C ~/.easyqemu/repository my_vm
3. Transfer my_vm.tar.gz to other system
4. tar -xzf my_vm.tar.gz -C ~/.easyqemu/repository
5. ./easyqemu repo load my_vm
EOF