Skip to content

Commit 0eb4168

Browse files
committed
eigrp: T2472: improve code for later tests
1 parent 6f490b4 commit 0eb4168

File tree

4 files changed

+95
-10
lines changed

4 files changed

+95
-10
lines changed

data/templates/frr/eigrpd.frr.j2

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
!
2-
router eigrp {{ local_as }} {{ 'vrf ' ~ vrf if vrf is vyos_defined }}
2+
router eigrp {{ system_as }} {{ 'vrf ' ~ vrf if vrf is vyos_defined }}
33
{% if maximum_paths is vyos_defined %}
4-
maximum-paths {{ maximum_paths }}
4+
maximum-paths {{ maximum_paths }}
55
{% endif %}
66
{% if metric.weights is vyos_defined %}
7-
metric weights {{ metric.weights }}
7+
metric weights {{ metric.weights }}
88
{% endif %}
99
{% if network is vyos_defined %}
1010
{% for net in network %}
11-
network {{ net }}
11+
network {{ net }}
12+
{% endfor %}
13+
{% endif %}
14+
{% if passive_interface is vyos_defined %}
15+
{% for interface in passive_interface %}
16+
passive-interface {{ interface }}
1217
{% endfor %}
1318
{% endif %}
1419
{% if redistribute is vyos_defined %}
1520
{% for protocol in redistribute %}
16-
redistribute {{ protocol }}
21+
redistribute {{ protocol }}
1722
{% endfor %}
1823
{% endif %}
24+
{% if router_id is vyos_defined %}
25+
eigrp router-id {{ router_id }}
26+
{% endif %}
1927
{% if variance is vyos_defined %}
20-
variance {{ variance }}
21-
{% endif %}
28+
variance {{ variance }}
29+
{% endif %}
30+
exit
31+
!

interface-definitions/include/eigrp/protocol-common-config.xml.i

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- include start from eigrp/protocol-common-config.xml.i -->
2-
<leafNode name="local-as">
2+
<leafNode name="system-as">
33
<properties>
44
<help>Autonomous System Number (ASN)</help>
55
<valueHelp>
@@ -61,6 +61,7 @@
6161
<completionHelp>
6262
<script>${vyos_completion_dir}/list_interfaces</script>
6363
</completionHelp>
64+
<multi/>
6465
</properties>
6566
</leafNode>
6667
<leafNode name="redistribute">
@@ -108,7 +109,7 @@
108109
</properties>
109110
</leafNode>
110111
#include <include/router-id.xml.i>
111-
<!-- FRR timers not implemented yet -->
112+
<!-- FRR error: active time not implemented yet -->
112113
<leafNode name="variance">
113114
<properties>
114115
<help>Control load balancing variance</help>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright (C) 2024 VyOS maintainers and contributors
4+
#
5+
# This program is free software; you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License version 2 or later as
7+
# published by the Free Software Foundation.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import unittest
18+
19+
from base_vyostest_shim import VyOSUnitTestSHIM
20+
from vyos.configsession import ConfigSessionError
21+
from vyos.ifconfig import Section
22+
from vyos.utils.process import process_named_running
23+
24+
PROCESS_NAME = 'eigrpd'
25+
base_path = ['protocols', 'eigrp']
26+
system_as = '200'
27+
28+
class TestProtocolsEIGRP(VyOSUnitTestSHIM.TestCase):
29+
@classmethod
30+
def setUpClass(cls):
31+
super(TestProtocolsEIGRP, cls).setUpClass()
32+
33+
# Retrieve FRR daemon PID - it is not allowed to crash, thus PID must remain the same
34+
cls.daemon_pid = process_named_running(PROCESS_NAME)
35+
36+
# ensure we can also run this test on a live system - so lets clean
37+
# out the current configuration :)
38+
cls.cli_delete(cls, base_path)
39+
40+
def tearDown(self):
41+
self.cli_delete(base_path)
42+
self.cli_commit()
43+
44+
# check process health and continuity
45+
self.assertEqual(self.daemon_pid, process_named_running(PROCESS_NAME))
46+
47+
def test_basic(self):
48+
router_id = '5.6.7.8'
49+
50+
self.cli_set(base_path + ['router-id', router_id])
51+
52+
# system-as must be set
53+
with self.assertRaises(ConfigSessionError):
54+
self.cli_commit()
55+
self.cli_set(base_path + ['system-as', system_as])
56+
57+
# Commit changes
58+
self.cli_commit()
59+
60+
# Validate configuration
61+
frrconfig = self.getFRRconfig(f'router eigrp {system_as}', daemon=PROCESS_NAME)
62+
self.assertIn(f'router eigrp {system_as}', frrconfig)
63+
self.assertIn(f' router-id {router_id}', frrconfig)
64+
65+
if __name__ == '__main__':
66+
unittest.main(verbosity=2, failfast=True)

src/conf_mode/protocols_eigrp.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from vyos.config import Config
2121
from vyos.configdict import dict_merge
22+
from vyos.configverify import verify_vrf
2223
from vyos.template import render_to_string
2324
from vyos import ConfigError
2425
from vyos import frr
@@ -72,7 +73,14 @@ def get_config(config=None):
7273
return eigrp
7374

7475
def verify(eigrp):
75-
pass
76+
if not eigrp or 'deleted' in eigrp:
77+
return
78+
79+
if 'system_as' not in eigrp:
80+
raise ConfigError('EIGRP system-as must be defined!')
81+
82+
if 'vrf' in eigrp:
83+
verify_vrf(eigrp)
7684

7785
def generate(eigrp):
7886
if not eigrp or 'deleted' in eigrp:

0 commit comments

Comments
 (0)