Skip to main content

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. The wizard asks for confirmation before every write; --apply is the explicit write switch of the command-line mode.

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

  1. 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?.
  2. Pick the Recovery Plan (all plans of all PCs, with their clusters).
  3. The target Prism Central is read from the plan (its availability zone, or the clusters it names; same PC for plans inside one Prism Central). Only if the plan does not tell it, you are asked.
  4. Pick the source and the target cluster. The clusters named in the plan are preselected.
  5. Only the subnets of these two clusters are compared: mapped, not found in target, only in target, ambiguous, same name with different VLAN ID.
  6. Create the missing VLANs on both sides? - summary, then a second confirmation, then the VLANs are created.
  7. 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.

Menus: Up / Down, Enter to select, a digit jumps to the entry, Ctrl+C aborts.

Options

OptionDescription
-i, --interactiveWizard (default when no arguments are given)
--source HOST, --target HOSTSource / target Prism Central for report mode
--source-user, --target-userUsers; else NTNX_SOURCE_USER / NTNX_TARGET_USER / NTNX_USER, else asked for
-k, --insecureDo not verify the TLS certificate (self-signed)
--ignore-caseIgnore upper/lower case when matching names
--rename REGEX=>REPLRewrite source names before comparing, e.g. '^DC1-=>DC2-' (repeatable)
--include REGEX, --exclude REGEXOnly / not subnets whose name matches
--plan NAMERecovery Plan (on the source PC) for --dump / dry run / --apply
--dumpPrint the plan as JSON (read-only)
--applyWrite the mapping of all matching subnets into --plan
--csv FILESave the subnets without counterpart as CSV
-v, -vvMore output on stderr (info / debug incl. API calls)
--log-file FILELog the run with timestamps to a file
--state-file FILE, --no-saveOther file for the saved inputs / do not load or save them
-h, --helpShow 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. --rename only 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.