We often have situations when using BladeLogic whereby, for various reasons, we need to delete a block of Components that are attached to a Component Template. If there are only a handful of components, this can be easily done via the BladeLogic Console, but in real-world situations, we're more likely to be looking at many thousand components, relating to the extensive server estate being managed.
In order to facilitate this in an automated manner, I wrote a BLJython script (attached) which takes a Component Template in a specified Component Template Group, and deletes all of the Components attached to this Template.
To execute the script, you should first re-acquire your credentials, as if you have a lot of components, it could run for many hours! You will also need a working BLJython environment on the machine from which you're running the script.
The command to run the script looks like this:
bljython CleanComponents.py -g <group> -c <component_template> [-r <role>] [-p <profile>] [-h] [-t]
bljython CleanComponents.py --group <group> --component <component_template> [--role <role>] [--profile <profile>] [--help] [--test]
The command line parameters are as follows:
|Specify the BladeLogic group in which the target Component Template resides|
|Component Template from, which the Components should be deleted|
Display Usage Information.
Note that using this will cause other options to be ignored.
|The BladeLogic profile to use (default: defaultProfile)|
|The BladeLogic role to use (default: BLAdmins)|
Test mode - List all the components that would be deleted, but don't delete
Note that this is not particularly quick due to the need to make a BLCLI call
I would recommend always running this using the '-t' switch first, so that you get an idea of exactly what the impact of really running the script will be!
The code is reasonably well documented, but if you have any questions, please ask in the comments and I'll do my best to answer.