Recovery Plan network mapping
curl -O https://wissen.woitzel.eu/rp_netmap.py && python3 rp_netmap.py
What it does
Compares the subnets of one or more Prism Centrals by name, creates missing VLANs on both sides and writes the network mapping into a Recovery Plan. Python 3 only, no extra modules. Everything that writes asks for confirmation first.
Usage
# guided wizard (no arguments = wizard)
python3 rp_netmap.py
# report only (read-only): compare ALL subnets of source and target, list the plans
python3 rp_netmap.py --source pc-a.example.local --target pc-b.example.local -k
# show a plan as JSON (check network_mapping_list / cluster references)
python3 rp_netmap.py --source pc-a... --target pc-b... -k --plan "RP-Prod" --dump
# dry run, then write the mapping of ALL matching subnets into the plan
python3 rp_netmap.py --source pc-a... --target pc-b... -k --plan "RP-Prod"
python3 rp_netmap.py --source pc-a... --target pc-b... -k --plan "RP-Prod" --apply
Wizard flow
- Number of Prism Centrals (1 is enough if the plans run between clusters of one PC), TLS check, then host, user and password of every PC. A previous run offers Use the saved values?.
- Pick the Recovery Plan (all plans of all PCs, with their clusters).
- Pick the target Prism Central (only with more than one PC; may be the same as the source).
- Pick the source and the target cluster. The clusters named in the plan are preselected.
- Only the subnets of these two clusters are compared: mapped, not found in target, only in target, ambiguous, same name with different VLAN ID.
- Create the missing VLANs on both sides? - summary, then a second confirmation, then the VLANs are created.
- If every VLAN of the source cluster has a counterpart, the missing entries are offered for the plan's network mapping and written after a confirmation.
Options
| Option | Description |
|---|---|
-i, --interactive | Wizard (default when no arguments are given) |
--source HOST, --target HOST | Source / target Prism Central for report mode |
--source-user, --target-user | Users; else NTNX_SOURCE_USER / NTNX_TARGET_USER / NTNX_USER, else asked for |
-k, --insecure | Do not verify the TLS certificate (self-signed) |
--ignore-case | Ignore upper/lower case when matching names |
--rename REGEX=>REPL | Rewrite source names before comparing, e.g. '^DC1-=>DC2-' (repeatable) |
--include REGEX, --exclude REGEX | Only / not subnets whose name matches |
--plan NAME | Recovery Plan (on the source PC) for --dump / dry run / --apply |
--dump | Print the plan as JSON (read-only) |
--apply | Write the mapping of all matching subnets into --plan |
--csv FILE | Save the subnets without counterpart as CSV |
-v, -vv | More output on stderr (info / debug incl. API calls) |
--log-file FILE | Log the run with timestamps to a file |
--state-file FILE, --no-save | Other file for the saved inputs / do not load or save them |
-h, --help | Show the built-in help |
Passwords and saved inputs
Passwords are prompted (no echo), never passed as argument and never stored. Alternatively: NTNX_PASSWORD (all PCs), NTNX_SOURCE_PASSWORD / NTNX_TARGET_PASSWORD (first two PCs). Hosts, users and the TLS setting are saved to ./rp_netmap_last_run.json (chmod 600) in the directory the script is started from.
Notes
- Subnets are matched by name.
--renameonly applies to the source side. A name with several hits in the target is "ambiguous" and is never mapped. - New VLANs are plain VLAN subnets (name + VLAN ID, default virtual switch, no IP address management). The same VLAN ID may exist several times per cluster; only an already used name blocks the creation.
- Existing mapping entries of a plan are kept; only missing pairs are added. An entry that points to a different target network is reported, not changed.
- Plans inside one Prism Central (both sides the same availability zone): the entries are written source first, target second. Check the result in Prism after the first write.
- Report mode compares all subnets and needs exactly one source and one target PC; the wizard handles any number.