feature: Added management command to find orphaned databases
Description
This adds a find_orphan_dbs
management command that searches for databases that exist in a datastore but are not registered in the OCIM database.
I suspect this may happen because of some failure while deprovisioning databases (by either archiving or deleting the respective instances).
Testing instructions
Orphaned MySQL
- Create a MySQL database (
create database DB_NAME
) -
./manage.py find_orphan_dbs mysql --host MYSQL_HOST -u MYSQL_USER -p
(will be prompted for password) - Verify that
DB_NAME
is identified as orphan instderr
- Verify that correct SQL for dropping the database is generated to
stdout
Orphaned MongoDB
- Create a MongoDB database (
use DB_NAME; db.insert({})
) -
./manage.py find_orphan_dbs mongo --host MONGO_HOST -u MONGO_HOST -p
(will be prompted for password) - Verify that
DB_NAME
is identified as orphan instderr
- Verify that correct mongo-shell script for dropping the database is generated to
stdout