Giter Club home page Giter Club logo

Comments (1)

dmulyalin avatar dmulyalin commented on August 16, 2024

Hi, check out path formatters:

For your example try to use:

<group name="interfaces.{{ interface }}">
interface {{ interface }}

<group name="other**">
 ip dhcp snooping trust {{ ip_dhcp_snoop...

In addition have a look at group method attribute, that way you won't need all these start indicators, i.e. instead of:

<group name="port_security"> 
 switchport port-security {{ state | set("enable") | _start_ }}
 switchport port-security maximum {{ maximum | _start_ }}
</group>

the functional equivalent would be

<group name="port_security" method="table"> 
 switchport port-security {{ state | set("enable") }}
 switchport port-security maximum {{ maximum }}
</group>

Another trick that you can use and already used - dynamic path forming, that would allow you to flatten your template, for instance this template result should be the same as yours one:

<group name="interfaces.{{ interface }}.other">
interface {{ interface }}
 ip dhcp snooping trust {{ ip_dhcp_snooping | set("trust") }}
 shutdown {{ status | set("disabled")}}
 description {{ description }} 
 ! {{ _end_ }}
</group>

<group name="interfaces.{{ interface }}.switchport">
interface {{ interface }}
 switchport nonegotiate {{ nonegotiate  | set("enable") }}
 switchport trunk native vlan {{ native_vlan }}
 switchport mode {{ mode | _start_ }} 
 switchport access vlan {{ access_vlan }}
 switchport trunk allowed vlan {{ trunk_vlan }}
 ! {{ _end_ }}
</group>

<group name="interfaces.{{ interface }}.port_security">
interface {{ interface }}
 switchport port-security {{ state | set("enable") }}
 switchport port-security maximum {{ maximum }}
 ! {{ _end_ }}
</group>

<group name="interfaces.{{ interface }}.stp">
interface {{ interface }}
 spanning-tree portfast {{ portfast | set("enable") }} 
 spanning-tree portfast trunk {{ portfast_on_trunk | set("yes") }}
 spanning-tree bpduguard enable {{ bpduguard | set("yes") }}
 spanning-tree bpdufilter enable {{ bpdufilter | set("yes") }}
 spanning-tree guard root {{ guard_root | set("yes") }}
 spanning-tree guard loop {{ guard_loop | set("yes") }}
 ! {{ _end_ }}
</group>

<group name="interfaces.{{ interface }}.storm-control">
interface {{ interface }}
 storm-control action {{ action }}

<group name='broadcast'>
 storm-control broadcast level {{ units }} {{ value }}
</group>

<group name='multicast'>   
 storm-control multicast level {{ units }} {{ value }} 
</group>
 ! {{ _end_ }}
</group>

<group name="interfaces.{{ interface }}.neighbor_discovery">
interface {{ interface }}
 no lldp transmit {{ lldp_transmit | set("no") }}
 no lldp receive {{ lldp_receive | set("no") }}
 no cdp enable {{ cdp | set("disabled") }}
 ! {{ _end_ }}
</group>

<group name="interfaces.{{ interface }}.undef">
interface {{ interface }}
 {{ undefined_conf |  _line_  |  joinmatches(', ') }}
 ! {{ _end_ }}
</group>

Also, for description suggest to use ORPHRASE regex pattern, that way it would match description strings like "my long description" in addition to "short_description"

from ttp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.