[docker-fpm-frr]: Generate separated staticd.conf for staticd (#3306)

* [docker-fpm-frr]: Generate separated staticd.conf for staticd

Generate staticd.conf by templates/staticd.conf.j2 with config DB data

* [docker-fpm-frr]: Remove default_route block from zebra.conf.j2

default_route block already moved to staticd.conf.j2

* [docker-fpm-frr]: Add test for staticd.conf.j2 template

* Add test for staticd.conf.j2 template

* Correct the sample output of zebra.conf.j2 template

* Fix a typo in test_zebra_frr

* [docker-fpm-frr]: Fix test_j2files test errors

* Fix test errors in test_j2files.py and test_j2files_t2_chassis_fe.py

* Fix typo in test_j2files_t2_chassis_fe.py
This commit is contained in:
shikenghua 2019-08-17 05:29:42 +08:00 committed by pavel-shirshov
parent 84b667fbaf
commit bf08a2caf3
10 changed files with 56 additions and 21 deletions

View File

@ -7,12 +7,13 @@ CONFIG_TYPE=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["docker_routing_co
if [ -z "$CONFIG_TYPE" ] || [ "$CONFIG_TYPE" == "separated" ]; then
sonic-cfggen -d -y /etc/sonic/deployment_id_asn_map.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/frr/bgpd.conf
sonic-cfggen -d -t /usr/share/sonic/templates/zebra.conf.j2 > /etc/frr/zebra.conf
sonic-cfggen -d -t /usr/share/sonic/templates/staticd.conf.j2 > /etc/frr/staticd.conf
echo "no service integrated-vtysh-config" > /etc/frr/vtysh.conf
rm -f /etc/frr/frr.conf
elif [ "$CONFIG_TYPE" == "unified" ]; then
sonic-cfggen -d -y /etc/sonic/deployment_id_asn_map.yml -t /usr/share/sonic/templates/frr.conf.j2 >/etc/frr/frr.conf
echo "service integrated-vtysh-config" > /etc/frr/vtysh.conf
rm -f /etc/frr/bgpd.conf /etc/frr/zebra.conf
rm -f /etc/frr/bgpd.conf /etc/frr/zebra.conf /etc/frr/staticd.conf
fi
sonic-cfggen -d -t /usr/share/sonic/templates/isolate.j2 > /usr/sbin/bgp-isolate

View File

@ -0,0 +1,29 @@
!
{% block banner %}
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
! generated by templates/frr/staticd.conf.j2 using config DB data
! file: staticd.conf
!
{% endblock banner %}
!
{% block sys_init %}
hostname {{ DEVICE_METADATA['localhost']['hostname'] }}
password zebra
enable password zebra
{% endblock sys_init %}
!
{% block default_route %}
! set static default route to mgmt gateway as a backup to learned default
{% for (name, prefix) in MGMT_INTERFACE|pfx_filter %}
{% if prefix | ipv4 %}
ip route 0.0.0.0/0 {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} 200
{% endif %}
{% endfor %}
{% endblock default_route %}
!
{% block logging %}
log syslog informational
log facility local4
{% endblock logging %}
!

View File

@ -36,15 +36,6 @@ link-detect
{% endfor %}
{% endblock interfaces %}
!
{% block default_route %}
! set static default route to mgmt gateway as a backup to learned default
{% for (name, prefix) in MGMT_INTERFACE|pfx_filter %}
{% if prefix | ipv4 %}
ip route 0.0.0.0/0 {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} 200
{% endif %}
{% endfor %}
{% endblock default_route %}
!
{% block source_loopback %}
{% set lo_ipv4_addrs = [] %}
{% set lo_ipv6_addrs = [] %}

View File

@ -0,0 +1,17 @@
!
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
! generated by templates/frr/staticd.conf.j2 using config DB data
! file: staticd.conf
!
!
hostname switch-t0
password zebra
enable password zebra
!
! set static default route to mgmt gateway as a backup to learned default
ip route 0.0.0.0/0 10.0.0.1 200
!
log syslog informational
log facility local4
!

View File

@ -23,8 +23,6 @@ interface PortChannel8
link-detect
!
!
! set static default route to mgmt gateway as a backup to learned default
!
! Set ip source to loopback for bgp learned routes
route-map RM_SET_SRC permit 10
set src 4.0.0.0

View File

@ -23,8 +23,6 @@ interface Ethernet8
link-detect
!
!
! set static default route to mgmt gateway as a backup to learned default
!
! Set ip source to loopback for bgp learned routes
route-map RM_SET_SRC permit 10
set src 4.0.0.0

View File

@ -23,8 +23,6 @@ interface Ethernet8
link-detect
!
!
! set static default route to mgmt gateway as a backup to learned default
!
! Set ip source to loopback for bgp learned routes
route-map RM_SET_SRC permit 10
set src 4.0.0.0

View File

@ -8,6 +8,7 @@ hostname switch-t0
password zebra
enable password zebra
!
!
! Enable link-detect (default disabled)
interface PortChannel01
link-detect
@ -22,9 +23,6 @@ interface PortChannel04
link-detect
!
!
! set static default route to mgmt gateway as a backup to learned default
ip route 0.0.0.0/0 10.0.0.1 200
!
! Set ip source to loopback for bgp learned routes
route-map RM_SET_SRC permit 10
set src 10.1.0.32

View File

@ -89,11 +89,16 @@ class TestJ2Files(TestCase):
self.assertTrue(r, "Diff:\n" + diff_output)
def test_zebra_frr(self):
conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-quagga', 'zebra.conf.j2')
conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-frr', 'zebra.conf.j2')
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + conf_template + ' > ' + self.output_file
self.run_script(argument)
self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'zebra_frr.conf'), self.output_file))
def test_staticd_frr(self):
conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-frr', 'staticd.conf.j2')
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + conf_template + ' > ' + self.output_file
self.run_script(argument)
self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 'staticd_frr.conf'), self.output_file))
def test_ipinip(self):
ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2')

View File

@ -35,7 +35,7 @@ class TestJ2FilesT2ChassisFe(TestCase):
self.assertTrue(filecmp.cmp(os.path.join(self.test_dir, 'sample_output', 't2-chassis-fe-pc-zebra.conf'), self.output_file))
# Test zebra.conf in FRR docker for a T2 chassis frontend (fe) switch with specified VNI
def test_t2_chassis_fe_pc_zebra_frr(self):
def test_t2_chassis_fe_vni_zebra_frr(self):
conf_template = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-frr', 'zebra.conf.j2')
argument = '-m ' + self.t2_chassis_fe_vni_minigraph + ' -p ' + self.t2_chassis_fe_port_config + ' -t ' + conf_template + ' > ' + self.output_file
self.run_script(argument)