Skip to content

Commit

Permalink
- template for trcps/re
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Nobrega committed Mar 18, 2019
1 parent ad3d0e0 commit 2bb8204
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion template/set-flow-route.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
{%- if vrf == 'trcps' %}
routing-instances {
trcps {
routing-options {
flow {
route {{ flowRouteName }} {
match {
{%- if dstPrefix is defined and dstPrefix !=None %}
destination {{dstPrefix}};
{%- endif %}
{%- if dstPort is defined and dstPort !=None %}
destination-port {{ dstPort }};
{%- endif %}
{%- if dscp is defined and dscp !=None %}
dscp {{dscp}};
{%- endif %}
{%- if fragment is defined and fragment !=None %}
fragment {{fragment}};
{%- endif %}
{%- if icmp_code is defined and icmp_code !=None %}
icmp-code {{icmp_code}};
{%- endif %}
{%- if icmp_type is defined and icmp_type !=None %}
icmp-type {{icmp_type}};
{%- endif %}
{%- if packet_length is defined and packet_length !=None %}
packet-length {{packet_length}};
{%- endif %}
{%- if port is defined and port !=None %}
port {{port}};
{%- endif %}
{%- if protocol is defined and protocol !=None %}
protocol {{protocol}};
{%- endif %}
{%- if srcPrefix is defined and srcPrefix !=None %}
source {{srcPrefix}};
{%- endif %}
{%- if srcPort is defined and srcPortt !=None %}
source-port {{srcPort}};
{%- endif %}
{%- if tcp_flags is defined and tcp_flags !=None %}
tcp-flags {{tcp_flags}};
{%- endif %}
}
then {
{{action}};
}
}
}
}
{%- endif %}
{%- if vrf == 're' %}
routing-options {
flow {
route {{ flowRouteName }} {
Expand Down Expand Up @@ -44,4 +96,5 @@ routing-options {
}
}
}
}
}
{%- endif %}

1 comment on commit 2bb8204

@knewell
Copy link
Collaborator

@knewell knewell commented on 2bb8204 Mar 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to not repeat code and address arbitrary VRFs. Something like...

{%- if VRF is defined %}
routing-instances {
    {{VRF}} {
{%- endif %}
        routing-options {
            flow {
                route {{ flowRouteName }} {
                    match {
                        {%- if dstPrefix is defined and dstPrefix !=None %}
                        destination {{dstPrefix}};
                        {%- endif %}
                        {%- if dstPort is defined and dstPort !=None %}
                        destination-port {{ dstPort }};
                        {%- endif %}
                        {%- if dscp is defined and dscp !=None %}
                        dscp {{dscp}};
                        {%- endif %}
                        {%- if fragment is defined and fragment !=None %}
                        fragment {{fragment}};
                        {%- endif %}
                        {%- if icmp_code is defined and icmp_code !=None %}
                        icmp-code {{icmp_code}};
                        {%- endif %}
                        {%- if icmp_type is defined and icmp_type !=None %}
                        icmp-type {{icmp_type}};
                        {%- endif %}
                        {%- if packet_length is defined and packet_length !=None %}
                        packet-length {{packet_length}};
                        {%- endif %}
                        {%- if port is defined and port !=None %}
                        port {{port}};
                        {%- endif %}
                        {%- if protocol is defined and protocol !=None %}
                        protocol {{protocol}};
                        {%- endif %}
                        {%- if srcPrefix is defined and srcPrefix !=None %}
                        source {{srcPrefix}};
                        {%- endif %}
                        {%- if srcPort is defined and srcPortt !=None %}
                        source-port {{srcPort}};
                        {%- endif %}
                        {%- if tcp_flags is defined and tcp_flags !=None %}
                        tcp-flags {{tcp_flags}};
                        {%- endif %}
                    }
                    then {
                {{action}};
            }
        }
{%- if VRF is defined %}
    }
}
{%- endif %}

Please sign in to comment.