RHub & Notification Framework Post Deployment Activities

Python Script - Database cleanup

The following python script can be used for listing, counting and deleting all rhub flows in a chub instance. The key ‘organization_name’ is made mandatory for rhub flows in-order to integrate multiple organizations in the Central Hub. CHub version prior to v8.0.0 did not include the said key in rhub-flows. The rhub-flows created under older versions will cause query operation failure in the latest versions. In order to resolve this conflict, we delete all rhub-flows and related embedded documents from mongodb and start anew. The script can be used for database cleanup.

The script is made using python and can be run from user’ system itself. It calls chub apis to perform the said operations. The script is equipped to obtain keycloak token and add to header of the necessary api calls for validation. For that the user must specify the url address of the host and credentials under variables smartops_url and request_body respectively.

Note: Comment out the lines from 53 to rest of the script if the user just wants to list and count the number of flows without deletion.

In case the script is unable to delete rhub-flows because of ‘organization_name' not found error, please enter the mongo shell of the primary in mongodb replicaset and enter following commands.

use chub

db.getCollection("rhub-flows").updateMany({}, {"$set": {"organization_name": "ustglobal"}})

 

The above command will manually enter the ‘organization_name’ key into the available rhub-flows and the user can run the python script to perform cleanup as the next step.