<#assign softpolice = ingqos.soft >
<#assign applyqos = ingqos.applyqos >
<#assign protect = vpls.has_protect >


<#if applyqos>
exit all
configure qos sap-ingress ${ingqos.id} create
exit all
configure qos sap-ingress ${ingqos.id} description "${ingqos.description}"
exit all
configure qos sap-ingress ${ingqos.id} queue 1 create
exit all
configure qos sap-ingress ${ingqos.id} queue 2 create
exit all
configure qos sap-ingress ${ingqos.id} queue 11 multipoint create
exit all
configure qos sap-ingress ${ingqos.id} fc "ef" create
exit all
configure qos sap-ingress ${ingqos.id} fc "ef" queue 2
exit all
configure qos sap-ingress ${ingqos.id} default-fc ef
exit all


configure qos sap-egress ${egrqos.id} create
exit all
configure qos sap-egress ${egrqos.id} description "${egrqos.description}"
exit all
configure qos sap-egress ${egrqos.id} queue 1 create
exit all
configure qos sap-egress ${egrqos.id} queue 2 create
exit all
configure qos sap-egress ${egrqos.id} queue 2 percent-rate 100.00 cir 100.00 port-limit
exit all
configure qos sap-egress ${egrqos.id} fc "ef" create
exit all
configure qos sap-egress ${egrqos.id} fc "ef" queue 2
exit all



<#if softpolice>
configure qos sap-ingress ${ingqos.id} queue 2 rate max cir ${ingqos.bandwidth?string.computer}000
<#else>
configure qos sap-ingress ${ingqos.id} queue 2 rate ${ingqos.bandwidth?string.computer}000 cir ${ingqos.bandwidth?string.computer}000
</#if>

</#if>
exit all


<#if lsps??>
configure router interface "${vpls.loopback_ifce}"
address ${vpls.loopback_address}/32
loopback
no shutdown
exit all
</#if>


<#if paths??>
# mpls path
<#list paths as path>
configure router mpls path "${path.name}" shutdown
<#list path.hops as hop>
configure router mpls path "${path.name}" hop ${hop.order} ${hop.address} strict
</#list>
configure router mpls path "${path.name}" no shutdown
</#list>
</#if>



<#if lsps??>
# mpls LSP
<#list lsps as lsp>
configure router mpls lsp "${lsp.primary}" shutdown
configure router mpls lsp "${lsp.primary}" to ${lsp.to}
configure router mpls lsp "${lsp.primary}" primary "${lsp.path}" priority 5 5
configure router mpls lsp "${lsp.primary}" metric 65000
configure router mpls lsp "${lsp.primary}" no shutdown
</#list>
</#if>

<#if protect>
configure router mpls path "loose" no shutdown
<#list lsps as lsp>
configure router mpls lsp "${lsp.protect}" shutdown
configure router mpls lsp "${lsp.protect}" to ${lsp.to}
configure router mpls lsp "${lsp.protect}" metric 65100
configure router mpls lsp "${lsp.protect}" primary "loose" priority 4 4
configure router mpls lsp "${lsp.protect}" no shutdown
</#list>
</#if>



<#if sdps??>
<#list sdps as sdp>
# service distribution point - forwards packets to the MPLS tunnel
configure service sdp ${sdp.primary_id} mpls create
exit all
configure service sdp ${sdp.primary_id} shutdown
configure service sdp ${sdp.primary_id} description "${sdp.description}"
configure service sdp ${sdp.primary_id} far-end ${sdp.far_end}
configure service sdp ${sdp.primary_id} lsp "${sdp.primary_lsp_name}"
configure service sdp ${sdp.primary_id} keep-alive shutdown
configure service sdp ${sdp.primary_id} no shutdown
exit all
</#list>

<#if protect>
<#list sdps as sdp>
configure service sdp ${sdp.protect_id} mpls create
exit all
configure service sdp ${sdp.protect_id} shutdown
configure service sdp ${sdp.protect_id} description "${sdp.protect_description}"
configure service sdp ${sdp.protect_id} far-end ${sdp.far_end}
configure service sdp ${sdp.protect_id} lsp "${sdp.protect_lsp_name}"
configure service sdp ${sdp.protect_id} keep-alive shutdown
configure service sdp ${sdp.protect_id} no shutdown
exit all
</#list>
</#if>
</#if>



# vpls service
configure service vpls ${vpls.primary_id} customer 1 create
exit all
configure service vpls ${vpls.primary_id} shutdown
configure service vpls ${vpls.primary_id} description "${vpls.description}"
configure service vpls ${vpls.primary_id} service-name "${vpls.name}"
configure service vpls ${vpls.primary_id} service-mtu 9114
configure service vpls ${vpls.primary_id} fdb-table-size 4096
configure service vpls ${vpls.primary_id} stp shutdown

configure service vpls ${vpls.primary_id} endpoint "${vpls.endpoint}" create
exit all
configure service vpls ${vpls.primary_id} endpoint "${vpls.endpoint}" restrict-protected-src discard-frame
configure service vpls ${vpls.primary_id} endpoint "${vpls.endpoint}" no suppress-standby-signaling
exit all


# saps
<#list ifces as ifce>
configure service vpls ${vpls.primary_id} sap ${ifce.name}:${ifce.vlan} create
exit all
configure service vpls ${vpls.primary_id} sap ${ifce.name}:${ifce.vlan} auto-learn-mac-protect
configure service vpls ${vpls.primary_id} sap ${ifce.name}:${ifce.vlan} restrict-protected-src discard-frame
configure service vpls ${vpls.primary_id} sap ${ifce.name}:${ifce.vlan} description "${ifce.description}"
<#if applyqos>
configure service vpls ${vpls.primary_id} sap ${ifce.name}:${ifce.vlan} ingress qos ${ingqos.id}
configure service vpls ${vpls.primary_id} sap ${ifce.name}:${ifce.vlan} egress qos ${egrqos.id}
</#if>
configure service vpls ${vpls.primary_id} sap ${ifce.name}:${ifce.vlan} no shutdown
</#list>


<#if sdps??>
# vpls sdps
<#list sdps as sdp>
configure service vpls ${vpls.primary_id} spoke-sdp ${sdp.primary_id}:${vpls.primary_id} vc-type vlan endpoint "${vpls.endpoint}" create
exit all
configure service vpls ${vpls.primary_id} spoke-sdp ${sdp.primary_id}:${vpls.primary_id} restrict-protected-src discard-frame
configure service vpls ${vpls.primary_id} spoke-sdp ${sdp.primary_id}:${vpls.primary_id} precedence primary
configure service vpls ${vpls.primary_id} spoke-sdp ${sdp.primary_id}:${vpls.primary_id} no shutdown
exit all
</#list>
</#if>


<#if protect>

<#list sdps as sdp>
configure service vpls ${vpls.primary_id} spoke-sdp ${sdp.protect_id}:${vpls.protect_id} vc-type vlan endpoint "${vpls.endpoint}" create
exit all
configure service vpls ${vpls.primary_id} spoke-sdp ${sdp.protect_id}:${vpls.protect_id} egress qos 3 port-redirect-group "best-effort-vc" instance 1
configure service vpls ${vpls.primary_id} spoke-sdp ${sdp.protect_id}:${vpls.protect_id} restrict-protected-src discard-frame
configure service vpls ${vpls.primary_id} spoke-sdp ${sdp.protect_id}:${vpls.protect_id} no shutdown
exit all
</#list>

</#if>


configure service vpls ${vpls.primary_id} no shutdown
