2021-02-17 03:13:51 +00:00
|
|
|
|
2020-05-10 23:59:30 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
vmname="$1"
|
|
|
|
|
2020-05-13 18:56:43 +00:00
|
|
|
if echo "$vmname" | grep -vqE '^(cvm|capsul)-[a-z0-9]{10}$'; then
|
2020-05-10 23:59:30 +00:00
|
|
|
echo "vmname $vmname must match "'"^capsul-[a-z0-9]{10}$"'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-02-17 03:13:51 +00:00
|
|
|
# this will let us know if the vm exists or not
|
|
|
|
exists="false"
|
|
|
|
if virsh domuuid "$vmname" | grep -vqE '^[\t\s\n]*$'; then
|
|
|
|
exists="true"
|
2020-05-10 23:59:30 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# this gets the ipv4
|
2021-02-17 03:13:51 +00:00
|
|
|
ipv4="$(virsh domifaddr "$vmname" | awk '/vnet/ {print $4}' | cut -d'/' -f1)"
|
|
|
|
|
|
|
|
echo "$exists $ipv4"
|