Skip to content

Instantly share code, notes, and snippets.

@knikolla
Last active August 18, 2021 15:00
Show Gist options
  • Save knikolla/9a41964d613c8c43a1d925943278b52d to your computer and use it in GitHub Desktop.
Save knikolla/9a41964d613c8c43a1d925943278b52d to your computer and use it in GitHub Desktop.
Using `os purge` to delete OpenStack projects
alias kaizen="openstack --os-cloud kaizen"
kaizen project show $1
kaizen project set --disable $1
echo "Servers for $1"
kaizen server list --project $1
echo "Networks for $1"
kaizen network list --project $1
echo "Volumes for $1"
kaizen volume list --project $1
ospurge --os-cloud kaizen --purge-project $1 --timeout 800

Completely removing OpenStack projects with ospurge

This guide is for administrators, or users of an OpenStack cloud.

Install ospurge. I have forked it to in order to haver stricter owner verification for resources than the original.

pip3 uninstall ospurge
pip3 install git+https://github.com/knikolla/ospurge-fork

Either source your openrc file or provide the cloud name from a clouds.yaml using --os-cloud.

The command to purge a project as an administrator is ospurge --purge-project <project_name>. It is possible to purge your own project as a user by using the command ospurge --purge-own-project. If you want to see the resource that are going to be deleted before performing the action, also add the option --dry-run.

It is normal to see a warning of the type WARNING:root:2021-05-11 14:12:59,126:Can't determine owner of resource Munch. That is okay, ospurge will not attempt to delete resources it can't verify and is the purpose of the fork.

ospurge --purge-project <project_name_or_id>

Note that the above will delete the resources owned from a project but not the project itself. To disable a project (as an admin) run the following command

openstack project set --disable <project_name_or_id>

It is recommended to disable projects instead of deleting them, because deleted projects are directly removed from keystone.

@msdisme
Copy link

msdisme commented Jul 7, 2021

probably worth adding run: pip3 install python-openstackclient

@msdisme
Copy link

msdisme commented Aug 5, 2021

openstack server list --project /project name/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment