...
This commit is contained in:
parent
3dbd0d0aea
commit
dc9e75704d
@ -96,7 +96,7 @@ list_vms() {
|
||||
# Use VM_NAME from config, fallback to vm number
|
||||
display_name="${VM_NAME:-vm$vm_number}"
|
||||
|
||||
printf "%-8s %-15s %-15s %-18s %-8s %-15s %-20s\n" "$vm_number" "$vm_ip" "$display_name" "$(printf "%b" "$status")" "$pid" "${MEMORY_MB}MB" "$STARTED"
|
||||
printf "%-8s %-15s %-15s %-18s %-8s %-15s %-20s\n" "$vm_number" "$vm_ip" "$display_name" "$(echo -e "$status")" "$pid" "${MEMORY_MB}MB" "$STARTED"
|
||||
else
|
||||
printf "%-8s %-15s %-15s %-18s %-8s %-15s %-20s\n" "$vm_number" "$vm_ip" "vm$vm_number" "$(printf "%b" "${RED}ERROR${NC}")" "N/A" "N/A" "Config Error"
|
||||
fi
|
||||
@ -145,23 +145,23 @@ show_vm_status() {
|
||||
|
||||
# Check if VM is running
|
||||
if [ -n "$VM_PID" ] && kill -0 "$VM_PID" 2>/dev/null; then
|
||||
echo "Status: ${GREEN}RUNNING${NC} (PID: $VM_PID)"
|
||||
echo -e "Status: ${GREEN}RUNNING${NC} (PID: $VM_PID)"
|
||||
|
||||
# Show network info
|
||||
if ip link show "$TAP_NAME" &>/dev/null; then
|
||||
echo "Network: ${GREEN}TAP interface active${NC}"
|
||||
echo -e "Network: ${GREEN}TAP interface active${NC}"
|
||||
else
|
||||
echo "Network: ${RED}TAP interface not found${NC}"
|
||||
echo -e "Network: ${RED}TAP interface not found${NC}"
|
||||
fi
|
||||
|
||||
# Show socket info
|
||||
if [ -S "$VM_SOCKET" ]; then
|
||||
echo "API Socket: ${GREEN}Available${NC}"
|
||||
echo -e "API Socket: ${GREEN}Available${NC}"
|
||||
else
|
||||
echo "API Socket: ${RED}Not available${NC}"
|
||||
echo -e "API Socket: ${RED}Not available${NC}"
|
||||
fi
|
||||
else
|
||||
echo "Status: ${RED}STOPPED${NC}"
|
||||
echo -e "Status: ${RED}STOPPED${NC}"
|
||||
fi
|
||||
echo ""
|
||||
}
|
||||
|
@ -476,11 +476,13 @@ ssh_authorized_keys: []
|
||||
network:
|
||||
version: 2
|
||||
ethernets:
|
||||
eth0:
|
||||
ens3:
|
||||
dhcp4: false
|
||||
addresses:
|
||||
- $VM_STATIC_IP/24
|
||||
gateway4: 192.168.100.1
|
||||
routes:
|
||||
- to: default
|
||||
via: 192.168.100.1
|
||||
nameservers:
|
||||
addresses:
|
||||
- 8.8.8.8
|
||||
@ -499,10 +501,18 @@ packages:
|
||||
- net-tools
|
||||
|
||||
# Ensure SSH service is enabled and started
|
||||
# Also configure static IP as backup
|
||||
runcmd:
|
||||
- systemctl enable ssh
|
||||
- systemctl start ssh
|
||||
- systemctl status ssh
|
||||
- netplan apply
|
||||
- sleep 5
|
||||
- ip addr flush dev ens3
|
||||
- ip addr add $VM_STATIC_IP/24 dev ens3
|
||||
- ip route add default via 192.168.100.1
|
||||
- ip addr show ens3
|
||||
- ip route show
|
||||
|
||||
# Final message
|
||||
final_message: "Cloud-init setup complete. VM is ready for SSH access!"
|
||||
@ -659,6 +669,7 @@ KERNEL_PATH="$BASE_SUBVOL/vmlinuz"
|
||||
INITRD_PATH="$BASE_SUBVOL/initrd.img"
|
||||
|
||||
cloud-hypervisor \
|
||||
--api-socket "$VM_SOCKET" \
|
||||
--memory "size=${MEMORY_MB}M" \
|
||||
--cpus "boot=$CPU_CORES" \
|
||||
--kernel "$KERNEL_PATH" \
|
||||
@ -666,7 +677,7 @@ cloud-hypervisor \
|
||||
--cmdline "root=LABEL=cloudimg-rootfs ro console=tty1 console=ttyS0" \
|
||||
--disk "path=$VM_IMAGE_PATH" "path=$CLOUD_INIT_PATH,readonly=on" \
|
||||
--net "tap=$TAP_NAME,mac=$VM_MAC" \
|
||||
--serial "file=$VM_LOG_FILE" \
|
||||
--serial tty \
|
||||
--console off \
|
||||
--event-monitor "path=${VM_LOG_FILE}.events" &
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user