03-14-2023 08:12 AM
Hello,
is it possible to build jinja variable in DNA-C for erspan monitoring configuraiton?
name internal_erspan
monitor session 12 type erspan-source
source interface Gi1/0/6 - 7 , Gi1/0/13 , Gi1/0/20 , Gi1/0/27 , Gi1/0/29 , Gi1/0/31 , Gi1/0/34 , Gi1/0/36 , Gi1/0/39 - 48
destination
erspan-id 2
mtu 9000
ip address X.X.X.X
origin ip address X.X.X.Y
I have tried to do something like:
monitor session {{ session_id }} type erspan-source
source interface {{ test_interface }} both # where interface has been binded to source as portName with option to select multiple options
destination
erspan-id 2
mtu 9000
ip address X.X.X.X
origin ip address X.X.X.Y
but I got an output:
source interface [GigabitEthernet1/0/13, GigabitEthernet1/0/12, GigabitEthernet1/0/17, GigabitEthernet1/0/9, GigabitEthernet1/0/15, GigabitEthernet1/0/2, GigabitEthernet1/0/10, GigabitEthernet1/0/3, GigabitEthernet1/0/4, GigabitEthernet1/0/14, GigabitEthernet1/0/8, GigabitEthernet1/0/11, GigabitEthernet1/0/16, GigabitEthernet1/0/5, GigabitEthernet1/0/7, GigabitEthernet1/0/6] both
As is visible from output above, there are characters "[" and "]" and it is not consumed by switch of course.
I tried to remove it using:
source interface {{ test_interface|replace('[','')|replace(']','') }} both
source interface {{ test_interface|regex_replace('\[|\]','') }} both
source interface {{ test_interface.replace('[','').replace(']','').split(', ')|join(', ') }} both
source interface {{ test_interface.split(', ')|map('regex_replace', '\[|\]','')|join(', ') }} both
03-27-2023 03:06 AM
Hello Peter,
Yes it's possible to apply erspan monitoring configuraiton using jinja.
You can do this by using network templates as you already did. After replicating your configuration, it seems that the issue comes from the "source interface" command. More specifically, try to run it again without using "-" for interface range. You can include all the desired interfaces by separating them with commas.
After that, you provision the device and the configuration will be pushed.
If you find my reply solved your question or issue, kindly click the 'Accept as Solution' button and vote it as helpful.
You can also learn more about Cisco DNA Center through our live Ask the Experts (ATXs) session. Check out Cisco DNA Center ATXs Resources [https://community.cisco.com/t5/networking-knowledge-base/cisco-dna-center-ask-the-experts-resources/ta-p/4394489] to view the latest schedule for upcoming sessions, as well as the useful references, e.g. online guides, FAQs.
Kind Regards,
Nikolas
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide