Conditioning in Template

NCCM supports condition-based Templating using “if,” “if else,” and “if elif else” conditional statements

A. ”If” Condition:

{% if Runtime.interface_name == "GigabitEthernet0/0"    %}
            IP address 192.168.1.1 255.0.0.0
             no shutdown
{%    endif    %}

B. ”If else” Condition:

{% if Runtime.interface_name == "GigabitEthernet0/0" %}
             IP address 192.168.1.1 255.0.0.0
             no    shutdown
{% else %}
             IP address    192.168.2.1    255.0.0.0
              no    shutdown
{%    endif    %}

C. ”If elif else” Condition:

{% if  Runtime.interface_name == "GigabitEthernet0/0" %}
              IP address 192.168.1.1 255.0.0.0
              no shutdown
{% elif Runtime.interface_name == "GigabitEthernet0/1"    %}
               IP address 192.168.1.1 255.0.0.0
               no shutdown
{% else %}
               IP address 192.168.2.1 255.0.0.0
               no shutdown
{% endif %}

Looping in Template:

NCCM supports loop-based Templating using “for” loop statements

”For Loop” Condition:

Last updated

Was this helpful?