use the provided network_name when creating a capsul

This commit is contained in:
forest 2021-07-12 12:19:56 -05:00
parent be54117736
commit b459e56f3a
1 changed files with 13 additions and 1 deletions

View File

@ -9,6 +9,8 @@ template_file="/tank/img/$2"
vcpus="$3"
memory="$4"
pubkeys="$5"
network_name="$6"
public_ipv4="$7"
root_volume_size="25G"
if echo "$vmname" | grep -vqE '^capsul-[a-z0-9]{10}$'; then
@ -38,6 +40,16 @@ echo "$pubkeys" | while IFS= read -r line; do
fi
done
if echo "$network_name" | grep -vqE "^[a-zA-Z0-9_-]+"; then
echo "network_name \"$network_name\" must match ^[a-zA-Z0-9_-]+"
exit 1
fi
if echo "$public_ipv4" | grep -vqE "^[0-9.]+$"; then
echo "public_ipv4 \"$public_ipv4\" must match ^[0-9.]+$"
exit 1
fi
disk="/tank/vm/$vmname.qcow2"
cdrom="/tank/vm/$vmname.iso"
xml="/tank/vm/$vmname.xml"
@ -66,7 +78,7 @@ virt-install \
--os-variant generic \
--virt-type kvm \
--graphics vnc,listen=127.0.0.1 \
--network network=public3,filterref=clean-traffic,model=virtio \
--network network=$network_name,filterref=clean-traffic,model=virtio \
--import \
--print-xml > "$xml"