在openstack里面有时候删除instance时,volume无法跟着删除,可以自己编写脚本来实现,
脚本代码如下:
#!/bin/bash for i in $(cat /root/host-del); do host_id=`nova list --all --ip $i |grep -w "$i" |awk '{print $2}'` volume_id=`cinder list --all |grep -w $host_id |awk '{print $2}'` echo -e "e[1;31m vm $i deleting...e[0m" nova delete $host_id 1>/dev/null sleep 3 for j in $volume_id do echo -e "e[1;31m vm $i attached volumes $volume_id deleting...e[0m" cinder delete $j 1>/dev/null sleep 2 done done
转载于:https://blog.51cto.com/coolsky/2149025