cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
546
Views
0
Helpful
2
Replies

Pulling model information from cisco devices with code

Eric R. Jones
Level 4
Level 4

Hello, we have Cisco Catalyst Version 2.3.5.6 and I'm creating templates and trying to use PnP for Day 0 deployments. We have some code to define if a device series is a 9400 or 9300. You'll see the if statement 5th line down and it references __device.series where I'm assuming the switch information is contained in some type of DB. I didn't write this snippet but would like to know where this line would check for this data? I'm asking because I don't see a command being run to "show" this data like "show model" etc... Or is __device.series a function within jinja or velocity code that has this data?

aaa new-model

aaa group server radius ISE_GROUP
server name yvaise02
server name svaise02
{% if "9400" in __device.series %}
ip vrf forwarding Mgmt-vrf
ip radius source-interface GigabitEthernet0/0
{% elif "9300" in __device.series %}
ip radius source-interface Vlan88
{% endif %}

2 Replies 2

@Eric R. Jones 

 "__device" is a System Variables. In combination with a parameter, it can retrive informations related to the parameter specified.

You can have the full information here

https://github.com/kebaldwi/DNAC-TEMPLATES/blob/master/TUTORIALS/Variables.md

 

"Lastly let's take a look at using a different system variable. This very simple 4-line template will check the snmp location field on a device, and if it is empty, it will fill in the field with the location specified by the subdomain in the device FQDN. For example, if the hostname is switch1.boston.mycompany.com, it will place "boston" in the snmp location field. This is a very simple example, but it does show how to pull information from a system variable and manipulate it for your own needs."

 

 

{% if __device.snmpLocation == ''  %}
    {% set snmp_location  = __device.hostname | split(".") %}
    snmp-server location {{ snmp_location[1] }}
{% endif %}

Ok I understand that. I need to learn how to use this to streamline my templates. The reason I'm asking is we got an error in our template when trying to setup PnP and I was on the last step before running "claim". Once we removed this snippet of code the error cleared, and we progressed. When using just the template it works fine. Only issue is when using PnP.

Thank you for the information and the link.