Hazard's stuff

17 Jun, 2023

Example Huawei OPS route monitoring script that changes VXLAN VTEP configuration if route goes away

— Posted by hazard @ 2023-06-17 23:42
To avoid using peer-link between Huawei CloudEngine switches in PtP VXLAN environment and therefore save 4 x 100G ports, I made a Python script for Huawei OPS that changes VTEP peer IP in case route to primary VTEP disappears (e.g. primary switch fails). It was much more of an effort than it should been, due to inadequate API documentation & examples which sometimes specify wrong parameter values. Non-working Python error reporting on Huawei VRP (at least on OS release I used) didn't help either. Details below.

The script is configured using up to 100 changevtep_targetsN environment variables. Below is an example config that monitors routes used by VNI 10 and used by VNI 20 (note that /30 prefix size is implied). When these routes will get added or removed from the routing table the script will configure VNI peer-list under Nve1 interface with specified VTEPs. Note that you will need to disable MAC address learning as CloudEngine learns MAC addresses from VXLAN packets from any IP address, even if it is not in peer-list.
 script-assistant python change_vtep_on_route_change.py
 environment changevtep_targets0 vni=10;monitor_net=;add=;remove=
 environment changevtep_targets1 vni=20;monitor_net=;add=;remove=
Multiple targets can also be specified in the same environment variable using / separator.

Get the script source from GitHub