diff options
| author | Christian Breunig <christian@breunig.cc> | 2024-02-14 20:29:05 +0100 | 
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2024-02-14 20:29:11 +0100 | 
| commit | 0eb4168aaec0ab3416d8b02eaa1be721b96ee7a8 (patch) | |
| tree | a17ad90477eac402118236ad124a9d421f2a649f | |
| parent | 6f490b48e7f9cd8d4da8207f70c1cf0f2a145f40 (diff) | |
| download | vyos-1x-0eb4168aaec0ab3416d8b02eaa1be721b96ee7a8.tar.gz vyos-1x-0eb4168aaec0ab3416d8b02eaa1be721b96ee7a8.zip | |
eigrp: T2472: improve code for later tests
| -rw-r--r-- | data/templates/frr/eigrpd.frr.j2 | 24 | ||||
| -rw-r--r-- | interface-definitions/include/eigrp/protocol-common-config.xml.i | 5 | ||||
| -rw-r--r-- | smoketest/scripts/cli/test_protocols_eigrp.py | 66 | ||||
| -rwxr-xr-x | src/conf_mode/protocols_eigrp.py | 10 | 
4 files changed, 95 insertions, 10 deletions
| diff --git a/data/templates/frr/eigrpd.frr.j2 b/data/templates/frr/eigrpd.frr.j2 index 3038a0b1d..d16963a51 100644 --- a/data/templates/frr/eigrpd.frr.j2 +++ b/data/templates/frr/eigrpd.frr.j2 @@ -1,21 +1,31 @@  ! -router eigrp {{ local_as }} {{ 'vrf ' ~ vrf if vrf is vyos_defined }} +router eigrp {{ system_as }} {{ 'vrf ' ~ vrf if vrf is vyos_defined }}  {% if maximum_paths is vyos_defined %} -maximum-paths {{ maximum_paths }} + maximum-paths {{ maximum_paths }}  {% endif %}  {% if metric.weights is vyos_defined %} -metric weights {{ metric.weights }} + metric weights {{ metric.weights }}  {% endif %}  {% if network is vyos_defined %}  {%     for net in network %} -network {{ net }} + network {{ net }} +{%     endfor %} +{% endif %} +{% if passive_interface is vyos_defined %} +{%     for interface in passive_interface %} + passive-interface {{ interface }}  {%     endfor %}  {% endif %}  {% if redistribute is vyos_defined %}  {%     for protocol in redistribute %} -redistribute {{ protocol }} + redistribute {{ protocol }}  {%     endfor %}  {% endif %} +{% if router_id is vyos_defined %} + eigrp router-id {{ router_id }} +{% endif %}  {% if variance is vyos_defined %} -variance {{ variance }} -{% endif %}
\ No newline at end of file + variance {{ variance }} +{% endif %} +exit +! diff --git a/interface-definitions/include/eigrp/protocol-common-config.xml.i b/interface-definitions/include/eigrp/protocol-common-config.xml.i index a21d18424..a8290f772 100644 --- a/interface-definitions/include/eigrp/protocol-common-config.xml.i +++ b/interface-definitions/include/eigrp/protocol-common-config.xml.i @@ -1,5 +1,5 @@  <!-- include start from eigrp/protocol-common-config.xml.i --> -<leafNode name="local-as"> +<leafNode name="system-as">    <properties>      <help>Autonomous System Number (ASN)</help>      <valueHelp> @@ -61,6 +61,7 @@      <completionHelp>        <script>${vyos_completion_dir}/list_interfaces</script>      </completionHelp> +    <multi/>    </properties>  </leafNode>  <leafNode name="redistribute"> @@ -108,7 +109,7 @@    </properties>  </leafNode>  #include <include/router-id.xml.i> -<!-- FRR timers not implemented yet --> +<!-- FRR error: active time not implemented yet -->  <leafNode name="variance">    <properties>      <help>Control load balancing variance</help> diff --git a/smoketest/scripts/cli/test_protocols_eigrp.py b/smoketest/scripts/cli/test_protocols_eigrp.py new file mode 100644 index 000000000..9ab908d25 --- /dev/null +++ b/smoketest/scripts/cli/test_protocols_eigrp.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2024 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program.  If not, see <http://www.gnu.org/licenses/>. + +import unittest + +from base_vyostest_shim import VyOSUnitTestSHIM +from vyos.configsession import ConfigSessionError +from vyos.ifconfig import Section +from vyos.utils.process import process_named_running + +PROCESS_NAME = 'eigrpd' +base_path = ['protocols', 'eigrp'] +system_as = '200' + +class TestProtocolsEIGRP(VyOSUnitTestSHIM.TestCase): +    @classmethod +    def setUpClass(cls): +        super(TestProtocolsEIGRP, cls).setUpClass() + +        # Retrieve FRR daemon PID - it is not allowed to crash, thus PID must remain the same +        cls.daemon_pid = process_named_running(PROCESS_NAME) + +        # ensure we can also run this test on a live system - so lets clean +        # out the current configuration :) +        cls.cli_delete(cls, base_path) + +    def tearDown(self): +        self.cli_delete(base_path) +        self.cli_commit() + +        # check process health and continuity +        self.assertEqual(self.daemon_pid, process_named_running(PROCESS_NAME)) + +    def test_basic(self): +        router_id = '5.6.7.8' + +        self.cli_set(base_path + ['router-id', router_id]) + +        # system-as must be set +        with self.assertRaises(ConfigSessionError): +            self.cli_commit() +        self.cli_set(base_path + ['system-as', system_as]) + +        # Commit changes +        self.cli_commit() + +        # Validate configuration +        frrconfig = self.getFRRconfig(f'router eigrp {system_as}', daemon=PROCESS_NAME) +        self.assertIn(f'router eigrp {system_as}', frrconfig) +        self.assertIn(f' router-id {router_id}', frrconfig) + +if __name__ == '__main__': +    unittest.main(verbosity=2, failfast=True) diff --git a/src/conf_mode/protocols_eigrp.py b/src/conf_mode/protocols_eigrp.py index 609b39065..c13e52a3d 100755 --- a/src/conf_mode/protocols_eigrp.py +++ b/src/conf_mode/protocols_eigrp.py @@ -19,6 +19,7 @@ from sys import argv  from vyos.config import Config  from vyos.configdict import dict_merge +from vyos.configverify import verify_vrf  from vyos.template import render_to_string  from vyos import ConfigError  from vyos import frr @@ -72,7 +73,14 @@ def get_config(config=None):      return eigrp  def verify(eigrp): -    pass +    if not eigrp or 'deleted' in eigrp: +        return + +    if 'system_as' not in eigrp: +        raise ConfigError('EIGRP system-as must be defined!') + +    if 'vrf' in eigrp: +        verify_vrf(eigrp)  def generate(eigrp):      if not eigrp or 'deleted' in eigrp: | 
