neutron-删除负载均衡器
在清除垃圾数据的时候,删除负载均衡器,总是有很多依赖。写了一个脚本,连同依赖资源一起删除
#!/bin/bash
delete(){
local id
id=$1
local listener_id
local pool_id
local member_id
local healthmonitor_id
listener_id=`neutron lbaas-loadbalancer-show $id | grep listeners | awk -F '"' '{print $4}'`
pool_id=`neutron lbaas-loadbalancer-show $id | grep pools | awk -F '"' '{print $4}'`
member_id=`neutron lbaas-pool-show $pool_id | grep members | awk -F '"' '{print $4}'`
healthmonitor_id=`neutron lbaas-pool-show $pool_id | grep healthmonitor_id | awk '{print $4}'`
echo $listener_id $pool_id $member_id $healthmonitor_id
neutron lbaas-member-delete $member_id $pool_id
neutron lbaas-pool-delete $pool_id
neutron lbaas-healthmonitor-delete $healthmonitor_id
neutron lbaas-listener-delete $listener_id
neutron lbaas-loadbalancer-delete $id
}
for i in $@;do
delete $i
done
示例:
./lbass_delete.sh 3f677aa4-e0d7-4a2f-8804-1fb284aa8b5c 849ed4f2-3075-4b7e-bf4e-1a23c84f9445 a785ff36-dfcf-45b3-a3db-bfe0e5c12f45 aff173a9-4f52-48be-8295-2fc904ba4d6a