Ask Your Question

How to delete multiple instances ( bulk delete ) via curl or cli ?

asked 2014-09-18 09:04:19 -0500

neerbeer gravatar image

I've been doing testing and spinning up 100s of VMs via nova boot and through horizon.

Is there an way to do a bulk delete of multiple VMs ?

'nova delete $id ' only acts on one VM at a time. And horizon only allows 20 or so deletes at a time and I'd like to know how to do this without having to increase the horizon variable that will show 100 VMs per page.

AHA ( any help apprec )


edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2014-09-18 10:58:01 -0500

larsks gravatar image

This is more correct (and possibly faster, since it doesn't rely on a for loop):

nova list | awk '$2 && $2 != "ID" {print $2}' | xargs -n1 nova delete

In particular, the solution from dbxs uses the "name" field. If there are multiple instances with the same name, the "nova delete" operation will fali with:

Multiple server matches found for 'c0', use an ID to be more specific.
ERROR: Unable to delete any of the specified servers.
edit flag offensive delete link more

answered 2016-08-23 18:30:13 -0500

If using the unified openstack client you can do:

openstack server list -c ID -f value | xargs -n1 openstack server delete

edit flag offensive delete link more

answered 2014-09-18 09:27:01 -0500

dbaxps gravatar image

updated 2014-09-18 11:13:10 -0500

[root@icehouse1 ~(keystone_boris)]# cat ./test01
for V in `nova list | awk '{print $4}' | grep -v ^N | grep -v ^$`
echo $V ;
nova delete $V ;

Another version ( fixed per notice larsks)

[root@icehouse1 ~(keystone_boris)]# cat ./test01
for V in `nova list | awk '{print $2}' | grep -v ^ID | grep -v ^$`
echo $V ;
nova delete $V;
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools


Asked: 2014-09-18 09:04:19 -0500

Seen: 4,090 times

Last updated: Aug 23 '16