Tests of FRR templates which rendered by sonic-cfggen (#4875)
* Tests of FRR templates which rendered by sonic-cfggen
This commit is contained in:
parent
7d0ea7383d
commit
2b137fb540
@ -1,3 +1,4 @@
|
||||
{% from "common/functions.conf.j2" import get_ipv4_loopback_address, get_ipv6_loopback_address %}
|
||||
!
|
||||
! template: bgpd/bgpd.main.conf.j2
|
||||
!
|
||||
|
@ -0,0 +1,76 @@
|
||||
!
|
||||
! template: bgpd/bgpd.conf.j2
|
||||
!
|
||||
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
|
||||
! generated by templates/quagga/bgpd.conf.j2 with config DB data
|
||||
! file: bgpd.conf
|
||||
!
|
||||
! template: common/daemons.common.conf.j2
|
||||
!
|
||||
hostname new_hostname
|
||||
password zebra
|
||||
enable password zebra
|
||||
!
|
||||
log syslog informational
|
||||
log facility local4
|
||||
!
|
||||
! end of template: common/daemons.common.conf.j2!
|
||||
agentx
|
||||
!
|
||||
! template: bgpd/bgpd.main.conf.j2
|
||||
!
|
||||
! bgp multiple-instance
|
||||
!
|
||||
! BGP configuration
|
||||
!
|
||||
! TSA configuration
|
||||
!
|
||||
ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
|
||||
!
|
||||
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
|
||||
!
|
||||
route-map HIDE_INTERNAL permit 10
|
||||
set community local-AS
|
||||
!
|
||||
router bgp 55555
|
||||
!
|
||||
bgp log-neighbor-changes
|
||||
no bgp default ipv4-unicast
|
||||
!
|
||||
bgp bestpath as-path multipath-relax
|
||||
!
|
||||
bgp graceful-restart restart-time 480
|
||||
bgp graceful-restart
|
||||
bgp graceful-restart preserve-fw-state
|
||||
!
|
||||
bgp router-id 55.55.55.55
|
||||
!
|
||||
network 55.55.55.55/32
|
||||
!
|
||||
address-family ipv6
|
||||
network fc00::1/64
|
||||
exit-address-family
|
||||
!
|
||||
network 10.10.10.1/24
|
||||
address-family ipv6
|
||||
network fc01::1/64
|
||||
exit-address-family
|
||||
!
|
||||
address-family ipv4
|
||||
redistribute connected route-map HIDE_INTERNAL
|
||||
exit-address-family
|
||||
address-family ipv6
|
||||
redistribute connected route-map HIDE_INTERNAL
|
||||
exit-address-family
|
||||
!
|
||||
address-family ipv4
|
||||
maximum-paths 32
|
||||
exit-address-family
|
||||
address-family ipv6
|
||||
maximum-paths 32
|
||||
exit-address-family
|
||||
!
|
||||
! end of template: bgpd/bgpd.main.conf.j2
|
||||
!!
|
||||
! end of template: bgpd/bgpd.conf.j2
|
||||
!
|
@ -0,0 +1,33 @@
|
||||
{
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"hostname": "new_hostname",
|
||||
"bgp_asn": "55555",
|
||||
"sub_role": "FrontEnd"
|
||||
}
|
||||
},
|
||||
"LOOPBACK_INTERFACE": {
|
||||
"Loopback0|55.55.55.55/32": {},
|
||||
"Loopback0|fc00::1/128": {}
|
||||
},
|
||||
"VLAN_INTERFACE": {
|
||||
"Vlan10|10.10.10.1/24": {},
|
||||
"Vlan10|fc01::1/64": {}
|
||||
},
|
||||
"constants": {
|
||||
"bgp": {
|
||||
"multipath_relax": {
|
||||
"enabled": true
|
||||
},
|
||||
"graceful_restart": {
|
||||
"enabled": true,
|
||||
"restart_time": 480
|
||||
},
|
||||
"maximum_paths": {
|
||||
"enabled": true,
|
||||
"ipv4": 32,
|
||||
"ipv6": 32
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
!
|
||||
! template: bgpd/bgpd.main.conf.j2
|
||||
!
|
||||
! bgp multiple-instance
|
||||
!
|
||||
! BGP configuration
|
||||
!
|
||||
! TSA configuration
|
||||
!
|
||||
ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
|
||||
!
|
||||
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
|
||||
!
|
||||
route-map HIDE_INTERNAL permit 10
|
||||
set community local-AS
|
||||
!
|
||||
router bgp 55555
|
||||
!
|
||||
bgp log-neighbor-changes
|
||||
no bgp default ipv4-unicast
|
||||
!
|
||||
bgp bestpath as-path multipath-relax
|
||||
!
|
||||
bgp graceful-restart restart-time 480
|
||||
bgp graceful-restart
|
||||
bgp graceful-restart preserve-fw-state
|
||||
!
|
||||
bgp router-id 55.55.55.55
|
||||
!
|
||||
network 55.55.55.55/32
|
||||
!
|
||||
address-family ipv6
|
||||
network fc00::1/64
|
||||
exit-address-family
|
||||
!
|
||||
network 10.10.10.1/24
|
||||
address-family ipv6
|
||||
network fc01::1/64
|
||||
exit-address-family
|
||||
!
|
||||
address-family ipv4
|
||||
redistribute connected route-map HIDE_INTERNAL
|
||||
exit-address-family
|
||||
address-family ipv6
|
||||
redistribute connected route-map HIDE_INTERNAL
|
||||
exit-address-family
|
||||
!
|
||||
address-family ipv4
|
||||
maximum-paths 32
|
||||
exit-address-family
|
||||
address-family ipv6
|
||||
maximum-paths 32
|
||||
exit-address-family
|
||||
!
|
||||
! end of template: bgpd/bgpd.main.conf.j2
|
||||
!
|
@ -0,0 +1,32 @@
|
||||
{
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"bgp_asn": "55555",
|
||||
"sub_role": "FrontEnd"
|
||||
}
|
||||
},
|
||||
"LOOPBACK_INTERFACE": {
|
||||
"Loopback0|55.55.55.55/32": {},
|
||||
"Loopback0|fc00::1/128": {}
|
||||
},
|
||||
"VLAN_INTERFACE": {
|
||||
"Vlan10|10.10.10.1/24": {},
|
||||
"Vlan10|fc01::1/64": {}
|
||||
},
|
||||
"constants": {
|
||||
"bgp": {
|
||||
"multipath_relax": {
|
||||
"enabled": true
|
||||
},
|
||||
"graceful_restart": {
|
||||
"enabled": true,
|
||||
"restart_time": 480
|
||||
},
|
||||
"maximum_paths": {
|
||||
"enabled": true,
|
||||
"ipv4": 32,
|
||||
"ipv6": 32
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
!
|
||||
! template: bgpd/bgpd.main.conf.j2
|
||||
!
|
||||
! bgp multiple-instance
|
||||
!
|
||||
! BGP configuration
|
||||
!
|
||||
! TSA configuration
|
||||
!
|
||||
ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
|
||||
!
|
||||
router bgp 55555
|
||||
!
|
||||
bgp log-neighbor-changes
|
||||
no bgp default ipv4-unicast
|
||||
!
|
||||
bgp router-id 55.55.55.55
|
||||
!
|
||||
network 55.55.55.55/32
|
||||
!
|
||||
! end of template: bgpd/bgpd.main.conf.j2
|
||||
!
|
@ -0,0 +1,19 @@
|
||||
{
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"bgp_asn": "55555",
|
||||
"sub_role": ""
|
||||
}
|
||||
},
|
||||
"LOOPBACK_INTERFACE": {
|
||||
"Loopback0|55.55.55.55/32": {},
|
||||
"Loopback1|fc00::1/128": {}
|
||||
},
|
||||
"constants": {
|
||||
"bgp": {
|
||||
"multipath_relax": {},
|
||||
"graceful_restart": {},
|
||||
"maximum_paths": {}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
!
|
||||
! template: bgpd/bgpd.main.conf.j2
|
||||
!
|
||||
! bgp multiple-instance
|
||||
!
|
||||
! BGP configuration
|
||||
!
|
||||
! TSA configuration
|
||||
!
|
||||
ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
|
||||
!
|
||||
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
|
||||
!
|
||||
route-map HIDE_INTERNAL permit 10
|
||||
set community local-AS
|
||||
!
|
||||
router bgp 55555
|
||||
!
|
||||
bgp log-neighbor-changes
|
||||
no bgp default ipv4-unicast
|
||||
!
|
||||
bgp bestpath as-path multipath-relax
|
||||
!
|
||||
bgp graceful-restart restart-time 240
|
||||
bgp graceful-restart
|
||||
bgp graceful-restart preserve-fw-state
|
||||
!
|
||||
bgp router-id 55.55.55.55
|
||||
!
|
||||
network 55.55.55.55/32
|
||||
!
|
||||
address-family ipv6
|
||||
network fc00::1/64
|
||||
exit-address-family
|
||||
!
|
||||
network 10.10.10.1/24
|
||||
address-family ipv6
|
||||
network fc01::1/64
|
||||
exit-address-family
|
||||
!
|
||||
address-family ipv4
|
||||
redistribute connected route-map HIDE_INTERNAL
|
||||
exit-address-family
|
||||
address-family ipv6
|
||||
redistribute connected route-map HIDE_INTERNAL
|
||||
exit-address-family
|
||||
!
|
||||
address-family ipv4
|
||||
maximum-paths 64
|
||||
exit-address-family
|
||||
address-family ipv6
|
||||
maximum-paths 64
|
||||
exit-address-family
|
||||
!
|
||||
! end of template: bgpd/bgpd.main.conf.j2
|
||||
!
|
@ -0,0 +1,29 @@
|
||||
{
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"bgp_asn": "55555",
|
||||
"sub_role": "FrontEnd"
|
||||
}
|
||||
},
|
||||
"LOOPBACK_INTERFACE": {
|
||||
"Loopback0|55.55.55.55/32": {},
|
||||
"Loopback0|fc00::1/128": {}
|
||||
},
|
||||
"VLAN_INTERFACE": {
|
||||
"Vlan10|10.10.10.1/24": {},
|
||||
"Vlan10|fc01::1/64": {}
|
||||
},
|
||||
"constants": {
|
||||
"bgp": {
|
||||
"multipath_relax": {
|
||||
"enabled": true
|
||||
},
|
||||
"graceful_restart": {
|
||||
"enabled": true
|
||||
},
|
||||
"maximum_paths": {
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
!
|
||||
! Vnet BGP instance
|
||||
router bgp 555 vrf First
|
||||
no bgp default ipv4-unicast
|
||||
bgp log-neighbor-changes
|
||||
bgp bestpath as-path multipath-relax
|
||||
no bgp default ipv4-unicast
|
||||
bgp graceful-restart restart-time 240
|
||||
bgp graceful-restart
|
||||
bgp router-id 10.20.30.40
|
||||
neighbor 10.10.10.1 remote-as 10
|
||||
neighbor 10.10.10.1 description session1
|
||||
address-family ipv4 unicast
|
||||
neighbor 10.10.10.1 activate
|
||||
neighbor 10.10.10.1 soft-reconfiguration inbound
|
||||
maximum-paths 64
|
||||
exit-address-family
|
||||
address-family l2vpn evpn
|
||||
advertise ipv4 unicast
|
||||
exit-address-family
|
||||
router bgp 555 vrf Second
|
||||
no bgp default ipv4-unicast
|
||||
bgp log-neighbor-changes
|
||||
bgp bestpath as-path multipath-relax
|
||||
no bgp default ipv4-unicast
|
||||
bgp graceful-restart restart-time 240
|
||||
bgp graceful-restart
|
||||
bgp router-id 10.20.30.40
|
||||
neighbor 20.20.20.1 remote-as 20
|
||||
neighbor 20.20.20.1 description session2
|
||||
address-family ipv4 unicast
|
||||
neighbor 20.20.20.1 activate
|
||||
neighbor 20.20.20.1 soft-reconfiguration inbound
|
||||
maximum-paths 64
|
||||
exit-address-family
|
||||
address-family l2vpn evpn
|
||||
advertise ipv4 unicast
|
||||
exit-address-family
|
||||
!
|
@ -0,0 +1,42 @@
|
||||
{
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"bgp_asn": "555"
|
||||
}
|
||||
},
|
||||
"LOOPBACK_INTERFACE": {
|
||||
"Loopback0|10.20.30.40/32": {}
|
||||
},
|
||||
"VNET": {
|
||||
"First": {
|
||||
"vni": 10
|
||||
},
|
||||
"Second": {
|
||||
"vni": 20
|
||||
}
|
||||
},
|
||||
"INTERFACE": {
|
||||
"Ethernet0": {
|
||||
"vnet_name": "First"
|
||||
},
|
||||
"Ethernet0|10.10.10.10/24": {},
|
||||
"Ethernet8": {
|
||||
"vnet_name": "Second"
|
||||
},
|
||||
"Ethernet8|20.20.20.20/24": {},
|
||||
"Ethernet10": {},
|
||||
"Ethernet10|20.20.20.20/24": {}
|
||||
},
|
||||
"BGP_NEIGHBOR": {
|
||||
"10.10.10.1": {
|
||||
"asn": "10",
|
||||
"name": "session1",
|
||||
"local_addr": "10.10.10.10"
|
||||
},
|
||||
"20.20.20.1": {
|
||||
"asn": "20",
|
||||
"name": "session2",
|
||||
"local_addr": "20.20.20.20"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
! template: common/daemons.common.conf.j2
|
||||
!
|
||||
hostname test_hostname
|
||||
password zebra
|
||||
enable password zebra
|
||||
!
|
||||
log syslog informational
|
||||
log facility local4
|
||||
!
|
||||
! end of template: common/daemons.common.conf.j2
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"hostname": "test_hostname"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
{}
|
@ -0,0 +1,91 @@
|
||||
!
|
||||
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
|
||||
! generated by templates/frr.conf.j2 with config DB data
|
||||
! file: frr.conf
|
||||
!
|
||||
! template: common/daemons.common.conf.j2
|
||||
!
|
||||
hostname test_hostname
|
||||
password zebra
|
||||
enable password zebra
|
||||
!
|
||||
log syslog informational
|
||||
log facility local4
|
||||
!
|
||||
! end of template: common/daemons.common.conf.j2!
|
||||
agentx
|
||||
!
|
||||
! Enable link-detect (default disabled)
|
||||
interface Ethernet0
|
||||
link-detect
|
||||
!
|
||||
interface Ethernet4
|
||||
link-detect
|
||||
!
|
||||
interface PortChannel10
|
||||
link-detect
|
||||
!
|
||||
interface PortChannel20
|
||||
link-detect
|
||||
!
|
||||
!!
|
||||
!
|
||||
! set static default route to mgmt gateway as a backup to learned default
|
||||
ip route 0.0.0.0/0 10.10.10.1 200
|
||||
!!
|
||||
!
|
||||
! template: bgpd/bgpd.main.conf.j2
|
||||
!
|
||||
! bgp multiple-instance
|
||||
!
|
||||
! BGP configuration
|
||||
!
|
||||
! TSA configuration
|
||||
!
|
||||
ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32
|
||||
!
|
||||
ipv6 prefix-list PL_LoopbackV6 permit fc00::/64
|
||||
!
|
||||
route-map HIDE_INTERNAL permit 10
|
||||
set community local-AS
|
||||
!
|
||||
router bgp 55555
|
||||
!
|
||||
bgp log-neighbor-changes
|
||||
no bgp default ipv4-unicast
|
||||
!
|
||||
bgp bestpath as-path multipath-relax
|
||||
!
|
||||
bgp graceful-restart restart-time 480
|
||||
bgp graceful-restart
|
||||
bgp graceful-restart preserve-fw-state
|
||||
!
|
||||
bgp router-id 55.55.55.55
|
||||
!
|
||||
network 55.55.55.55/32
|
||||
!
|
||||
address-family ipv6
|
||||
network fc00::1/64
|
||||
exit-address-family
|
||||
!
|
||||
network 10.10.10.1/24
|
||||
address-family ipv6
|
||||
network fc01::1/64
|
||||
exit-address-family
|
||||
!
|
||||
address-family ipv4
|
||||
redistribute connected route-map HIDE_INTERNAL
|
||||
exit-address-family
|
||||
address-family ipv6
|
||||
redistribute connected route-map HIDE_INTERNAL
|
||||
exit-address-family
|
||||
!
|
||||
address-family ipv4
|
||||
maximum-paths 32
|
||||
exit-address-family
|
||||
address-family ipv6
|
||||
maximum-paths 32
|
||||
exit-address-family
|
||||
!
|
||||
! end of template: bgpd/bgpd.main.conf.j2
|
||||
!!
|
@ -0,0 +1,46 @@
|
||||
{
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"bgp_asn": "55555",
|
||||
"hostname": "test_hostname",
|
||||
"sub_role": "FrontEnd"
|
||||
}
|
||||
},
|
||||
"INTERFACE": {
|
||||
"Ethernet0|10.20.30.40/24": {},
|
||||
"Ethernet4|20.20.30.40/24": {}
|
||||
},
|
||||
"PORTCHANNEL": {
|
||||
"PortChannel10": {},
|
||||
"PortChannel20": {}
|
||||
},
|
||||
"MGMT_INTERFACE": {
|
||||
"eth0|10.10.10.10/24": {
|
||||
"gwaddr": "10.10.10.1"
|
||||
}
|
||||
},
|
||||
"LOOPBACK_INTERFACE": {
|
||||
"Loopback0|55.55.55.55/32": {},
|
||||
"Loopback0|fc00::1/128": {}
|
||||
},
|
||||
"VLAN_INTERFACE": {
|
||||
"Vlan10|10.10.10.1/24": {},
|
||||
"Vlan10|fc01::1/64": {}
|
||||
},
|
||||
"constants": {
|
||||
"bgp": {
|
||||
"multipath_relax": {
|
||||
"enabled": true
|
||||
},
|
||||
"graceful_restart": {
|
||||
"enabled": true,
|
||||
"restart_time": 480
|
||||
},
|
||||
"maximum_paths": {
|
||||
"enabled": true,
|
||||
"ipv4": 32,
|
||||
"ipv6": 32
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
17
src/sonic-bgpcfgd/tests/data/sonic-cfggen/isolate/isolate
Normal file
17
src/sonic-bgpcfgd/tests/data/sonic-cfggen/isolate/isolate
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
## vtysh only accepts script in stdin, so cannot be directly used in shebang
|
||||
## Cut the tail of this script and feed vtysh stdin
|
||||
sed -n -e '9,$p' < "$0" | vtysh "$@"
|
||||
## Exit with vtysh return code
|
||||
exit $?
|
||||
## vtysh script start from next line, which line number MUST equal in 'sed' command above
|
||||
configure terminal
|
||||
router bgp 12345
|
||||
neighbor 10.20.30.40 route-map ISOLATE out
|
||||
address-family ipv6
|
||||
neighbor fc00::1 route-map ISOLATE out
|
||||
exit-address-family
|
||||
exit
|
||||
exit
|
||||
clear ip bgp 10.20.30.40 soft out
|
||||
clear ip bgp fc00::1 soft out
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"bgp_asn": "12345"
|
||||
}
|
||||
},
|
||||
"BGP_NEIGHBOR": {
|
||||
"10.20.30.40": {},
|
||||
"fc00::1": {}
|
||||
}
|
||||
}
|
17
src/sonic-bgpcfgd/tests/data/sonic-cfggen/isolate/unisolate
Normal file
17
src/sonic-bgpcfgd/tests/data/sonic-cfggen/isolate/unisolate
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
## vtysh only accepts script in stdin, so cannot be directly used in shebang
|
||||
## Cut the tail of this script and feed vtysh stdin
|
||||
sed -n -e '9,$p' < "$0" | vtysh "$@"
|
||||
## Exit with vtysh return code
|
||||
exit $?
|
||||
## vtysh script start from next line, which line number MUST equal in 'sed' command above
|
||||
configure terminal
|
||||
router bgp 12345
|
||||
no neighbor 10.20.30.40 route-map ISOLATE out
|
||||
address-family ipv6
|
||||
no neighbor fc00::1 route-map ISOLATE out
|
||||
exit-address-family
|
||||
exit
|
||||
exit
|
||||
clear ip bgp 10.20.30.40 soft out
|
||||
clear ip bgp fc00::1 soft out
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"bgp_asn": "12345"
|
||||
}
|
||||
},
|
||||
"BGP_NEIGHBOR": {
|
||||
"10.20.30.40": {},
|
||||
"fc00::1": {}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
!
|
||||
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
|
||||
! generated by templates/frr/staticd.conf.j2 using config DB data
|
||||
! file: staticd.conf
|
||||
!
|
||||
! template: common/daemons.common.conf.j2
|
||||
!
|
||||
hostname new_hostname
|
||||
password zebra
|
||||
enable password zebra
|
||||
!
|
||||
log syslog informational
|
||||
log facility local4
|
||||
!
|
||||
! end of template: common/daemons.common.conf.j2!
|
||||
!
|
||||
! set static default route to mgmt gateway as a backup to learned default
|
||||
ip route 0.0.0.0/0 10.10.10.1 200
|
||||
!!
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"hostname": "new_hostname"
|
||||
}
|
||||
},
|
||||
"MGMT_INTERFACE": {
|
||||
"eth0|10.10.10.10/24": {
|
||||
"gwaddr": "10.10.10.1"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
!
|
||||
! set static default route to mgmt gateway as a backup to learned default
|
||||
ip route 0.0.0.0/0 10.10.10.1 200
|
||||
!
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"MGMT_INTERFACE": {
|
||||
"eth0|10.10.10.10/24": {
|
||||
"gwaddr": "10.10.10.1"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
route-map test_rm_name permit 2
|
||||
match ip address prefix-list PL_LoopbackV4
|
||||
set community 12345:555
|
||||
route-map test_rm_name deny 3
|
||||
!
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"constants": {
|
||||
"bgp": {
|
||||
"traffic_shift_community": "12345:555"
|
||||
}
|
||||
},
|
||||
"route_map_name": "test_rm_name",
|
||||
"ip_version": "V4"
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
no route-map test_rm permit 2
|
||||
no route-map test_rm deny 3
|
||||
!
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"route_map_name": "test_rm"
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
!
|
||||
! Enable link-detect (default disabled)
|
||||
interface Ethernet0
|
||||
link-detect
|
||||
!
|
||||
interface Ethernet4
|
||||
link-detect
|
||||
!
|
||||
interface PortChannel10
|
||||
link-detect
|
||||
!
|
||||
interface PortChannel20
|
||||
link-detect
|
||||
!
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"INTERFACE": {
|
||||
"Ethernet0|10.20.30.40/24": {},
|
||||
"Ethernet4|20.20.30.40/24": {}
|
||||
},
|
||||
"PORTCHANNEL": {
|
||||
"PortChannel10": {},
|
||||
"PortChannel20": {}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
!
|
||||
! Set ip source to loopback for bgp learned routes
|
||||
!
|
||||
route-map new_rm_name permit 10
|
||||
set src 10.20.30.40
|
||||
!
|
||||
ipv4 protocol bgp route-map new_rm_name
|
||||
!
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"rm_name": "new_rm_name",
|
||||
"lo_ip": "10.20.30.40",
|
||||
"ip_proto": "v4"
|
||||
}
|
36
src/sonic-bgpcfgd/tests/data/sonic-cfggen/zebra/zebra.conf
Normal file
36
src/sonic-bgpcfgd/tests/data/sonic-cfggen/zebra/zebra.conf
Normal file
@ -0,0 +1,36 @@
|
||||
!
|
||||
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
|
||||
! generated by templates/zebra/zebra.conf.j2 using config DB data
|
||||
! file: zebra.conf
|
||||
!
|
||||
! template: common/daemons.common.conf.j2
|
||||
!
|
||||
hostname new_hostname
|
||||
password zebra
|
||||
enable password zebra
|
||||
!
|
||||
log syslog informational
|
||||
log facility local4
|
||||
!
|
||||
! end of template: common/daemons.common.conf.j2!
|
||||
!
|
||||
vrf First
|
||||
vni 10
|
||||
!
|
||||
vrf Second
|
||||
vni 20
|
||||
!
|
||||
! Enable link-detect (default disabled)
|
||||
interface Ethernet0
|
||||
link-detect
|
||||
!
|
||||
interface Ethernet4
|
||||
link-detect
|
||||
!
|
||||
interface PortChannel10
|
||||
link-detect
|
||||
!
|
||||
interface PortChannel20
|
||||
link-detect
|
||||
!
|
||||
!!
|
@ -0,0 +1,23 @@
|
||||
{
|
||||
"DEVICE_METADATA": {
|
||||
"localhost": {
|
||||
"hostname": "new_hostname"
|
||||
}
|
||||
},
|
||||
"VNET": {
|
||||
"First": {
|
||||
"vni": 10
|
||||
},
|
||||
"Second": {
|
||||
"vni": 20
|
||||
}
|
||||
},
|
||||
"INTERFACE": {
|
||||
"Ethernet0|10.20.30.40/24": {},
|
||||
"Ethernet4|20.20.30.40/24": {}
|
||||
},
|
||||
"PORTCHANNEL": {
|
||||
"PortChannel10": {},
|
||||
"PortChannel20": {}
|
||||
}
|
||||
}
|
133
src/sonic-bgpcfgd/tests/test_sonic-cfggen.py
Normal file
133
src/sonic-bgpcfgd/tests/test_sonic-cfggen.py
Normal file
@ -0,0 +1,133 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
from app.config import ConfigMgr
|
||||
from .test_templates import compress_comments, write_result
|
||||
|
||||
|
||||
TEMPLATE_PATH = os.path.abspath('../../dockers/docker-fpm-frr/frr')
|
||||
DATA_PATH = "tests/data/sonic-cfggen/"
|
||||
CONSTANTS_PATH = os.path.abspath('../../files/image_config/constants/constants.yml')
|
||||
|
||||
|
||||
def run_test(name, template_path, json_path, match_path):
|
||||
template_path = os.path.join(TEMPLATE_PATH, template_path)
|
||||
json_path = os.path.join(DATA_PATH, json_path)
|
||||
cfggen = os.path.abspath("../sonic-config-engine/sonic-cfggen")
|
||||
command = [cfggen, "-T", TEMPLATE_PATH, "-t", template_path, "-y", json_path]
|
||||
p = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = p.communicate()
|
||||
assert p.returncode == 0, "sonic-cfggen for %s test returned %d code. stderr='%s'" % (name, p.returncode, stderr)
|
||||
raw_generated_result = stdout
|
||||
assert "None" not in raw_generated_result, "Test %s" % name
|
||||
canonical_generated_result = ConfigMgr.to_canonical(raw_generated_result)
|
||||
match_path = os.path.join(DATA_PATH, match_path)
|
||||
# only for development write_result(match_path, raw_generated_result)
|
||||
with open(match_path) as result_fp:
|
||||
raw_saved_result = result_fp.read()
|
||||
canonical_saved_result = ConfigMgr.to_canonical(raw_saved_result)
|
||||
assert canonical_saved_result == canonical_generated_result, "Test %s" % name
|
||||
|
||||
|
||||
def test_bgpd_main_conf_base():
|
||||
run_test("Base bgpd.main.conf.j2",
|
||||
"bgpd/bgpd.main.conf.j2",
|
||||
"bgpd.main.conf.j2/base.json",
|
||||
"bgpd.main.conf.j2/base.conf")
|
||||
|
||||
def test_bgpd_main_conf_comprehensive():
|
||||
run_test("Comprehensive bgpd.main.conf.j2",
|
||||
"bgpd/bgpd.main.conf.j2",
|
||||
"bgpd.main.conf.j2/all.json",
|
||||
"bgpd.main.conf.j2/all.conf")
|
||||
|
||||
def test_bgpd_main_conf_defaults():
|
||||
run_test("Defaults bgpd.main.conf.j2",
|
||||
"bgpd/bgpd.main.conf.j2",
|
||||
"bgpd.main.conf.j2/defaults.json",
|
||||
"bgpd.main.conf.j2/defaults.conf")
|
||||
|
||||
def test_tsa_isolate():
|
||||
run_test("tsa/bgpd.tsa.isolate.conf.j2",
|
||||
"bgpd/tsa/bgpd.tsa.isolate.conf.j2",
|
||||
"tsa/isolate.json",
|
||||
"tsa/isolate.conf")
|
||||
|
||||
def test_tsa_unisolate():
|
||||
run_test("tsa/bgpd.tsa.unisolate.conf.j2",
|
||||
"bgpd/tsa/bgpd.tsa.unisolate.conf.j2",
|
||||
"tsa/unisolate.json",
|
||||
"tsa/unisolate.conf")
|
||||
|
||||
def test_common_daemons():
|
||||
run_test("daemons.common.conf.j2",
|
||||
"common/daemons.common.conf.j2",
|
||||
"common/daemons.common.conf.json",
|
||||
"common/daemons.common.conf")
|
||||
|
||||
def test_common_functions():
|
||||
run_test("functions.conf.j2",
|
||||
"common/functions.conf.j2",
|
||||
"common/functions.conf.json",
|
||||
"common/functions.conf")
|
||||
|
||||
def test_staticd_default_route():
|
||||
run_test("staticd.default_route.conf.j2",
|
||||
"staticd/staticd.default_route.conf.j2",
|
||||
"staticd/staticd.default_route.conf.json",
|
||||
"staticd/staticd.default_route.conf")
|
||||
|
||||
def test_staticd():
|
||||
run_test("staticd.conf.j2",
|
||||
"staticd/staticd.conf.j2",
|
||||
"staticd/staticd.conf.json",
|
||||
"staticd/staticd.conf")
|
||||
|
||||
def test_zebra_interfaces():
|
||||
run_test("zebra.interfaces.conf.j2",
|
||||
"zebra/zebra.interfaces.conf.j2",
|
||||
"zebra/interfaces.json",
|
||||
"zebra/interfaces.conf")
|
||||
|
||||
def test_zebra_set_src():
|
||||
run_test("zebra.set_src.conf.j2",
|
||||
"zebra/zebra.set_src.conf.j2",
|
||||
"zebra/set_src.json",
|
||||
"zebra/set_src.conf")
|
||||
|
||||
def test_zebra():
|
||||
run_test("zebra.conf.j2",
|
||||
"zebra/zebra.conf.j2",
|
||||
"zebra/zebra.conf.json",
|
||||
"zebra/zebra.conf")
|
||||
|
||||
def test_isolate():
|
||||
run_test("isolate.j2",
|
||||
"isolate.j2",
|
||||
"isolate/isolate.json",
|
||||
"isolate/isolate")
|
||||
|
||||
def test_unisolate():
|
||||
run_test("unisolate.j2",
|
||||
"unisolate.j2",
|
||||
"isolate/unisolate.json",
|
||||
"isolate/unisolate")
|
||||
|
||||
def test_frr_conf():
|
||||
run_test("frr.conf.j2",
|
||||
"frr.conf.j2",
|
||||
"frr.conf.j2/all.json",
|
||||
"frr.conf.j2/all.conf")
|
||||
|
||||
def test_l3vpn_base():
|
||||
run_test("bgpd spine_chassis_frontend_router.conf.j2",
|
||||
"bgpd/bgpd.spine_chassis_frontend_router.conf.j2",
|
||||
"bgpd.spine_chassis_frontend_router.conf.j2/base.json",
|
||||
"bgpd.spine_chassis_frontend_router.conf.j2/base.conf")
|
||||
|
||||
def test_bgp_conf_all():
|
||||
run_test("bgpd/bgpd.conf",
|
||||
"bgpd/bgpd.conf.j2",
|
||||
"bgpd.conf.j2/all.json",
|
||||
"bgpd.conf.j2/all.conf")
|
@ -16,6 +16,8 @@ See usage string for detail description for arguments.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
sys.path.insert(0, "/usr/local/lib/python2.7/dist-packages")
|
||||
|
||||
# monkey patch re.compile to do lazy regular expression compilation.
|
||||
# This is done to improve import time of jinja2, yaml, natsort modules, because they
|
||||
|
Reference in New Issue
Block a user