Add virtual-masiero network

This commit is contained in:
Doug Masiero 2025-05-21 14:57:59 -04:00
parent 755f6e938e
commit 47f8515e32
6 changed files with 39 additions and 20 deletions

View File

@ -41,7 +41,7 @@ EOF"
ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "echo 'y' | setup-alpine -e -f /tmp/alpine-answers"
# Wait for installation to complete
sleep 45
sleep 65
# Reboot via SSH
ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "reboot"
@ -56,4 +56,4 @@ if ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@${STAGING_IP} "echo
else
echo '{"status": "failure", "message": "Failed to install Alpine"}'
exit 1
fi
fi

View File

@ -15,7 +15,7 @@
"type": "String"
},
"network": {
"description": "Network to connect the VM to (wan-verizon or internal-moeny)",
"description": "Network to connect the VM to (wan-verizon, internal-moeny or virtual-masiero)",
"type": "String"
},
"ip_with_cidr": {
@ -75,4 +75,4 @@
"type": "String"
}
}
}
}

View File

@ -89,6 +89,13 @@ validate_network_relationships() {
if [[ "$gateway_ip" != "10.44.0.1" ]]; then
output_warning "internal-moeny network typically uses 10.44.0.1 as gateway, but got ${gateway_ip}"
fi
elif [[ "$network" == "virtual-masiero" ]]; then
if [[ ! "$ip_network" =~ ^10\.10\.0$ ]]; then
output_warning "virtual-masiero network typically uses 10.10.0/24 range, but got ${ip_network}.0/${cidr}"
fi
if [[ "$gateway_ip" != "10.10.0.1" ]]; then
output_warning "virtual-masiero network typically uses 10.10.0.1 as gateway, but got ${gateway_ip}"
fi
fi
}
@ -96,7 +103,7 @@ validate_network_relationships() {
validate_target_host() {
local host=$1
if [[ "$host" != "vortex" && "$host" != "astrocore" ]]; then
output_status "error" "Invalid target_host '$host'. Must be either vortex or astrocore"
output_status "error" "Invalid target_host '$host'. Must be either vortex or astrocore."
fi
}
@ -112,8 +119,8 @@ validate_hostname() {
# Function to validate network
validate_network() {
local network=$1
if [[ "$network" != "wan-verizon" && "$network" != "internal-moeny" ]]; then
output_status "error" "Invalid network '$network'. Must be either wan-verizon or internal-moeny"
if [[ "$network" != "wan-verizon" && "$network" != "internal-moeny" && "$network" != "virtual-masiero" ]]; then
output_status "error" "Invalid network '$network'. Must be either wan-verizon, internal-moeny or virtual-masiero."
fi
}
@ -221,4 +228,4 @@ validate_ip "$PT_nameserver2" "secondary nameserver"
validate_ip "$PT_nameserver3" "tertiary nameserver"
# If we get here, all validations passed
output_status "success" "All parameters validated successfully"
output_status "success" "All parameters validated successfully"

View File

@ -3,7 +3,7 @@
"parameters": {
"network": {
"type": "String",
"description": "Network type (internal-moeny or wan-verizon)"
"description": "Network type (internal-moeny, wan-verizon or virtual-masiero)"
}
}
}
}

View File

@ -9,8 +9,10 @@ if [ "$network" = "internal-moeny" ]; then
ping_ip="10.44.0.250"
elif [ "$network" = "wan-verizon" ]; then
ping_ip="100.40.223.190"
elif [ "$network" = "virtual-masiero" ]; then
ping_ip="10.10.0.250"
else
echo "{\"status\": \"error\", \"message\": \"Unsupported network type: $network. Must be either internal-moeny or wan-verizon.\"}"
echo "{\"status\": \"error\", \"message\": \"Unsupported network type: $network. Must be either internal-moeny, wan-verizon or virtual-masiero.\"}"
exit 1
fi
@ -21,4 +23,4 @@ if ping -c 1 -W 3 "$ping_ip" > /dev/null 2>&1; then
else
echo "{\"status\": \"success\", \"message\": \"IP $ping_ip is available.\"}"
exit 0
fi
fi

View File

@ -66,7 +66,7 @@ validate_network_relationships() {
# Validate network relationships
if [[ "$ip_network" != "$gateway_network" ]]; then
output_status "error" "IP ($ip) and gateway ($gateway_ip) must be in the same network"
output_status "error" "IP ($ip) and gateway ($gateway_ip) must be in the same network."
fi
# Network-specific validations
@ -90,6 +90,16 @@ validate_network_relationships() {
if [[ "$staging_ip" != "internal" ]]; then
output_warning "internal-moeny network typically uses 'internal' for staging_ip, but got '${staging_ip}'"
fi
elif [[ "$network" == "virtual-masiero" ]]; then
if [[ ! "$ip_network" =~ ^10\.10\.0$ ]]; then
output_warning "virtual-masiero network typically uses 10.10.0.0/24 range, but got ${ip_network}.0/${cidr}"
fi
if [[ "$gateway_ip" != "10.10.0.1" ]]; then
output_warning "virtual-masiero network typically uses 10.10.0.1 as gateway, but got ${gateway_ip}"
fi
if [[ "$staging_ip" != "internal" ]]; then
output_warning "virtual-masiero network typically uses 'internal' for staging_ip, but got '${staging_ip}'"
fi
fi
}
@ -97,7 +107,7 @@ validate_network_relationships() {
validate_target_host() {
local host=$1
if [[ "$host" != "vortex" && "$host" != "astrocore" ]]; then
output_status "error" "Invalid target_host '$host'. Must be either vortex or astrocore"
output_status "error" "Invalid target_host '$host'. Must be either vortex or astrocore."
fi
}
@ -114,7 +124,7 @@ validate_hostname() {
validate_network() {
local network=$1
if [[ "$network" != "wan-verizon" && "$network" != "internal-moeny" ]]; then
output_status "error" "Invalid network '$network'. Must be either wan-verizon or internal-moeny"
output_status "error" "Invalid network '$network'. Must be either wan-verizon or internal-moeny."
fi
}
@ -154,7 +164,7 @@ validate_iso_path() {
# Extract just the filename from the path
local filename=$(basename "$path")
if [[ ! "$filename" =~ ^ubuntu ]]; then
output_warning "ISO filename ('${filename}') should typically begin with 'ubuntu'"
output_warning "ISO filename ('${filename}') should typically begin with 'ubuntu.'"
fi
}
@ -162,7 +172,7 @@ validate_iso_path() {
validate_staging_ip() {
local staging_ip=$1
if [[ "$staging_ip" != "public" && "$staging_ip" != "internal" ]]; then
output_status "error" "Invalid staging_ip '$staging_ip'. Must be either public or internal"
output_status "error" "Invalid staging_ip '$staging_ip'. Must be either public or internal."
fi
}
@ -187,7 +197,7 @@ validate_disk_path() {
validate_os_variant() {
local variant=$1
if ! echo "$variant" | grep -qE '^ubuntu[0-9]{2}\.[0-9]{2}$'; then
output_status "error" "Invalid os_variant '$variant'. Must be in format 'ubuntuXX.XX' (e.g. ubuntu22.04)"
output_status "error" "Invalid os_variant '$variant'. Must be in format 'ubuntuXX.XX' (e.g. ubuntu22.04)."
fi
}
@ -197,7 +207,7 @@ validate_name_relationships() {
local hostname=$2
if [[ "$vm_name" != "$hostname" ]]; then
output_warning "vm_name ('${vm_name}') typically matches hostname ('${hostname}')"
output_warning "vm_name ('${vm_name}') typically matches hostname ('${hostname}')."
fi
}
@ -229,4 +239,4 @@ validate_ip "$PT_nameserver3" "tertiary nameserver"
validate_network_relationships "$PT_network" "$PT_ip_with_cidr" "$PT_gateway_ip" "$PT_staging_ip"
# If we get here, all validations passed
output_status "success" "All parameters validated successfully"
output_status "success" "All parameters validated successfully."