I have a setup of ASR-1001x's with up to date software.
Between them there are several point-to-point GRE tunnels, each one with an IP SLA configured, and a track associated to that IP SLA. The IP SLAs check parameters such as RTT and/or packet loss.
I need to create dynamic configurations when multiple tracks fail for a number of IP SLAs, and the dynamic configuration is based on the first available tunnel. So if I have 10 IP SLAs configured, and Tunnels 1-3, 6 and 7 are in a down track state, I'd need to pick Tunnel 4 as the first available GRE tunnel for which to create my dynamic configurations.
I am able to create the dynamic configurations assuming that I know which first available GRE tunnel number is available. For example if it's Tunnel 4, I know that I'd need to create configurations including a string composed of the IP "10.10.10.($firstAvailable*4+1)", or 10.10.10.17, which needs to be pushed into the configurations.
I'm unsure how to go about this in EEM, and I must admit that I have very little experience in EEM. Here is pseudo code which could possibly solve this businesss requirement: