Small helper scripts for OpenStack administration.
- Python 3.10+
- OpenStack credentials in the usual
OS_*environment variables openstacksdkforopenstack-domain-quota-usage.pyandopenstack-project-cleanup.py- OpenStack CLI for
openstack-image-share.py
pip install -r requirements.txtSummarizes quota usage across projects in a domain: cores, RAM in GiB, and volume storage in TiB.
source openrc.sh
python3 openstack-domain-quota-usage.pyUseful options:
python3 openstack-domain-quota-usage.py --workers 4
python3 openstack-domain-quota-usage.py --limit-cores 400 --limit-ram 800 --limit-storage 20Domain/project selection uses OS_DOMAIN_ID, OS_DOMAIN_NAME, OS_PROJECT_DOMAIN_NAME, or OS_USER_DOMAIN_NAME.
Accepts a shared Glance image across visible projects. With --add-image, also runs openstack image add project before accepting, which requires authenticating as the image owner.
source openrc.sh
python3 openstack-image-share.py IMAGE_ID
python3 openstack-image-share.py --add-image IMAGE_IDLists all project resources to be cleaned up, then asks once before deleting them. Uses openstacksdk (not the OpenStack CLI).
- Deletes servers, volumes, floating IPs, routers, ports, networks, then the
ssh_keykeypair. - Skips volumes attached to VMs with
delete_on_termination=True(removed when the VM is deleted). - Skips compute ports attached to VMs (removed when the VM is deleted).
- Detaches router interfaces before deleting routers.
- Skips networks named
public; only internal, vxlan, non-shared networks are eligible. - With
--wait(default in CI or with--yes), waits until deleted servers/volumes are gone before continuing.
source openrc.sh
python3 openstack-project-cleanup.py PROJECT_NAME
python3 openstack-project-cleanup.py --dry-run PROJECT_NAME
python3 openstack-project-cleanup.py --yes PROJECT_NAMEIn CI / non-TTY environments the script never prompts. Pass the project name and either --yes or --dry-run. Install openstacksdk and provide standard OS_* credentials in the job environment.
pip install openstacksdk
python3 openstack-project-cleanup.py --yes --wait --fail-fast --quiet PROJECT_NAMEUseful CI options:
--wait/--no-wait— wait for async server/volume deletes (default on in CI or with--yes)--wait-timeout/--wait-interval— wait polling controls (defaults: 600s / 5s)--command-timeout— OpenStack API request timeout (default: 120s)--fail-fast— abort on the first deletion failure--quiet— keep the plan table and final summary; suppress per-resource chatter--github— emit::error::/::warning::annotations and append a markdown table to$GITHUB_STEP_SUMMARY(on by default whenGITHUB_ACTIONSis set)
Exit codes:
| Code | Meaning |
|---|---|
0 |
Success, nothing to do, or dry-run OK |
1 |
OpenStack / operational failure |
2 |
Usage / non-interactive misuse (missing project name or missing --yes) |
Run any script with --help for all options.