This script will allow you to use an external source to change the Site Separation settings of IP Fabric. To do so, the script will use Manual Site Separation. The option to generate rules based on hostname is also available
Since IP Fabric v4.3, the manual site separation is using Device Attributes. The script will update the relevant settings depending on your version.
With IP Fabric >=4.3, rules creation is still available, but not recommended.
Install ipfabric Python module and dependencies
pip install -r requirements.txt
to use ServiceNow:
python3 siteSeparation.py -snow
to use a source file to update Manual Site Separation / Device Attributes
python3 siteSeparation.py -f source_file.xlsx
to use a source file to create Site Rules -- NOT RECOMMENDED
python3 siteSeparation.py -f source_file.csv --upper_match
Find the required library in order for this script to work
Library | Description |
---|---|
ipfabric | Mandatory - IP Fabric python module |
httpx | Mandatory - HTTP client |
pandas | Mandatory - Data Analysis |
openpyxl | Optional - only needed to support XLSX file |
xlrd | Optional - only needed to support XLS file |
rich | Optional - Enhance terminal formatting |
There is an option to generate regex based on the hostnames, instead of just using hostname in the rules for the site separation.
GREX
is required for this option to work To install, you can follow these instructions
Find more information about GREX
- -f source_file, --file source_file
Source file, as a JSON/CSV/XLS/XLSX file containing hostname/site information. The hostname must match IP Fabric hostname.
- -snow, --servicenow
Script will collect for each device in IP Fabric the location in ServiceNow and store this as JSON
- -g, --generate
use to only generate a new host/site JSON file from SNow. This won't update IP Fabric
Group for Rules creation: This is not the recommended method to update Site Separation
- -u, --upper_match
(Rules creation) the hostname will be capitalised in the regex rules
- -e, --exact_match
(Rules creation) use this option to keep the case from the source (file or Snow)
- -grex, --grex
(Rules creation) instead of using list of hostname, we use GREX to find the regex matching that same list
- -reg_out, --regex_output
(Rules creation) use this option, with -u or -e or -grex, to generate the JSON containing the rules to be pushed. By using this option, you will not update the IP Fabric settings
- -k, --keep
(Rules creation) use this option, with -u or -e or -grex, if you want to KEEP existing rules: add new rules on top of the existing ones from the latest or working_snapshot **NOT RECOMMENDED as it could lead to duplicate rules and performance issue**
MIT