Created
August 13, 2018 11:03
-
-
Save flavio-fernandes/a773842c5b6748992482d74d6c1cb543 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
virt-addr() { | |
VM="$1" | |
vm_mac=$(virsh dumpxml $VM | grep "mac address" | sed "s/.*'\(.*\)'.*/\1/g") | |
arp -an | grep "${vm_mac}" | awk '{ gsub(/[\(\)]/,"",$2); print $2 }' | |
} | |
for x in $(virsh list --all | awk '{ if (NR > 2 && $2 != "") {print $2} }') ; do \ | |
v=$(virsh vncdisplay $x 2> /dev/null || true) | |
vip=$(virt-addr $x 2> /dev/null || true) | |
echo "vm name: $x vnc: ${v:--} ip: ${vip:--}" | |
virsh domiflist $x | awk '{ if (NR > 2) {print $0} }' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment