Deleting OpenStack Instances¶
After the labs are completed for the semester, instances should be deleted. This is especially important if instances in essence are running monitoring labs, where they consume quite a lot of CPU-resources. In the case where the lab-instances are generated with organized instance names, e.g. "teamX..." the instances can be deleted easily using scripts:
Disassciating Floating IPs:
for instance in $(openstack server list --name "^team" -f value -c ID); do
for fip in $(openstack floating ip list --port $(openstack port list --device-id $instance -f value -c ID) -f value -c ID); do
openstack floating ip unset --port $fip
done
done
Deleting the Servers:
for instance in $(openstack server list --name "^team" -f value -c ID); do
openstack server delete $instance
done
Sometimes, it seems that OpenStack issues errors when attempting to delete servers that still have associated floating IPs. Therefore, it may be beneficial to first disassociate IPs first.