/ociextirpater

My fancy pants cleanup tool for OCI compartments

Primary LanguagePython

README for ociextirpate

extirpate : ex·tir·pate : to completely erase or eradicate

What it is and does

The OCI Extirpater is a command line tool that deletes everything within a compartment in every OCI region.

How it does it

The tool uses the OCI SDK to

  1. find every compartment underneath the specified root
  2. find every object within that compartment
  3. delete the object

The code for each object type is actually quite small (see ociclients/template.py).

In short that code declares:

  • the class in the OCI SDK to be used
  • (optionally) the "composite class" to be used
  • the name (both singular and plural) for human-readable logging
  • the method in the class used to list and delete the object
  • (optionally) specific formatters to generate a "one-liner" for the object

A class may also override some of the stuff in OCIClient.py in cases where the client class works differently than typical.

Inspiration

This was inspired by Richard Garsthagen's work on OCI Super Delete.

I wanted to try my hand at something similar but that was less "code" and more "declaritive". Mostly because I thought it would be nice to be able to add new object types to be deleted by simply declaring them rather than needing to write a bunch of code.

In the end I'm not sure my approach was better or worse (OCIClient.py is practically unreadable) but it was a good learning experience!

What's next

  • adding more objects
  • trying to use the Search service instead of iterating over every object type