XenServer获取所有VM虚拟机IP及对应MAC地址
XenServer5.6下编写,用于获取所有VM虚拟机IP和对应MAC地址,Shell脚本如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #!/bin/bash #http://www.onovps.com if [[ ! -e mac-ip.txt ]]; then touch mac-ip.txt else > mac-ip.txt fi for vps in `xe vm-list |awk '/name/ {print $4}'` do case $vps in *"Control"* ) continue ;; esac writeline=`xe vif-list vm-name-label=$vps params=MAC|awk '/MAC/ {print $5}'` writeline+=" " writeline+=`xe vm-list name-label=$vps params=networks|awk '/network/ {print $5}'` echo $writeline >> mac-ip.txt done |
目录 返回
首页