Skip to main content

Audit an OpenStack cloud for orphaned and wasteful resources

Project description

openstack-janitor

CI

A CLI that audits an OpenStack cloud for orphaned and wasteful resources.

Status: early development. Six detectors are working — see Detectors; more detectors and a clean command are coming — see Roadmap.

Install

From source:

git clone <this repo>
cd openstack-janitor
pip install -e .

Publishing to PyPI (pip install openstack-janitor) and a pipx-friendly release are planned once there's more than one detector.

Usage

janitor audit
janitor audit --cloud my-cloud
janitor audit --detector unattached-volumes --detector orphaned-ports
janitor audit --format json > findings.json
janitor audit --format html > report.html

--format table (the default) prints a rich table; json and html write machine-readable / shareable reports to stdout.

Example output when orphaned volumes are found:

$ janitor audit --cloud my-cloud
              openstack-janitor findings
┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Type          ┃ ID        ┃ Name    ┃ Project ┃ Reason                       ┃
┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ volume        │ a1b2c3d4… │ old-db  │ proj-1  │ volume is unattached         │
│               │           │         │         │ (status=available)          │
└───────────────┴───────────┴─────────┴─────────┴──────────────────────────────┘
$ echo $?
1

janitor audit exits 0 when nothing is found, 1 when findings were reported (so it's safe to wire into a cron job or CI check), 2 if an unknown --detector name is given, and 3 if connecting to the cloud fails.

Detectors

Name Flags
unattached-volumes Volumes in available status with no attachments.
unassociated-floating-ips Floating IPs not associated with any port.
orphaned-ports Ports with no device owner and no device id. Infrastructure ports (DHCP, routers, load balancer VIPs) always carry one of these, so they are never flagged; a pre-created port awaiting attachment will be.
old-snapshots Volume snapshots older than a threshold (default 90 days).
shutoff-instances Instances in SHUTOFF status whose last update is older than a threshold (default 30 days). There is no "shutoff since" field in the Compute API, so the age is a conservative lower bound — the detector may under-report but never over-reports.
unused-security-groups Security groups not attached to any port and not referenced as a remote_group_id by any rule. The per-project default group is always skipped.

All detectors are read-only. Resources without a parseable timestamp are never flagged by the age-based detectors. Thresholds become configurable once janitor.toml support lands (see Roadmap).

Authentication

openstack-janitor uses openstacksdk for authentication, so anything openstacksdk understands works here too:

  • A named cloud from clouds.yaml via --cloud my-cloud (or the OS_CLOUD environment variable).
  • The standard OS_* environment variables (OS_AUTH_URL, OS_USERNAME, OS_PASSWORD, OS_PROJECT_NAME, etc.) if no cloud is specified.

See the openstacksdk configuration documentation for the full resolution order and file locations.

Roadmap

  • A clean command with a --dry-run default and explicit --yes to act.
  • janitor.toml for per-cloud configuration (which detectors run, age thresholds, exclusions).
  • Safety rails: tagging/exclusion lists so resources can be marked "do not touch" before clean ever deletes anything.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openstack_janitor-0.1.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openstack_janitor-0.1.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file openstack_janitor-0.1.0.tar.gz.

File metadata

  • Download URL: openstack_janitor-0.1.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for openstack_janitor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 da22a7707161884e6c8945a3ac50c66a7c23f88d0ee23c37ff9d6e6c6bef17e4
MD5 fb4dff519ce79ef6327891fd93649351
BLAKE2b-256 ef901d54641a9f6bc10af9a108a8da55133d68360ecc246bdd0923ce284f36e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for openstack_janitor-0.1.0.tar.gz:

Publisher: release.yml on mabunemeh/openstack-janitor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openstack_janitor-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openstack_janitor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7df59fee796476f72257ecfb8cb1013ce6820b8fbabe8607786c42dfedf50961
MD5 4655a594adb1e7953759f7ec69fb48d5
BLAKE2b-256 12be569f10e366cfd6e2e54bf92e1f6f33b24065ad53051a3c0572bbcec5340e

See more details on using hashes here.

Provenance

The following attestation bundles were made for openstack_janitor-0.1.0-py3-none-any.whl:

Publisher: release.yml on mabunemeh/openstack-janitor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page