bash script using CSV to bulk rename objects
I’ve created a bash script to bulk rename objects listed in a CSV file. You need to run it on a MDS with the Management API enabled.
- Auto-detect API version of MDS.
- Use CSV file for defining all objects to rename.
- Bulk rename of TCP service objects is supported.
- Bulk rename of UDP service objects is supported.
- Bulk rename of Hosts objects is supported.
- Bulk rename of Networks is supported.
- Bulk rename of Service Groups is supported.
- Bulk rename of Network Groups is supported.
- Auto publish or no publish after successfully renaming the objects.
- Auto discard complete session when return value of API call to rename object is not 0 (0=SUCCESS).
- Display errors/warnings when session is discarded.
Create a seperate CSV file for each object type you want to rename. This means you cannot mix object types like TCP and UDP services into one CSV file. When running the script you have to specify which object type the CSV file contains.
Each CSV file has to start with a special line:
From that point you can add new lines with current name<comma>new name
Example CSV file with host objects:
./rename_objects.sh johndoe DMS-CP-1 CHG4726 hosts rename_hosts.csv nopublish
This allows user johndoe to login to the domain DMS-CP-1. It will use changenumber CHG4726 for session name and description. Furthermore you tell that it will find host objects in the CSV file rename_hosts.csv. Last but not least the nopublish action will force a logout of the API session after succesfully renaming the objects. This will allow you to takeover the session in SmartConsole for manual verification and a manual publish if you’re satisfied with the results.
You can download rename_objects.sh on your MDS using the following CLI one-liner:
curl_cli -o rename_objects.sh tools.checkpoint.engineer/rename_objects.sh && chmod +x rename_objects.sh
or in a browser:
0.1 Initial version