diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-11-27 10:32:01 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-11-27 10:32:01 +0100 |
commit | 09064990b9e3ed0a19c1ca4257b385f92d25af2a (patch) | |
tree | 504c955dc1da1bcddf535559855ef084ee57b0b0 | |
parent | 2e9116e9661ce355dedf5f9d0a2afb1fdbedf786 (diff) | |
download | vyos-1x-09064990b9e3ed0a19c1ca4257b385f92d25af2a.tar.gz vyos-1x-09064990b9e3ed0a19c1ca4257b385f92d25af2a.zip |
ospfv3: T3753: adjust to CLI options new in FRR 8.0
-rw-r--r-- | data/templates/frr/ospf6d.frr.tmpl | 8 | ||||
-rw-r--r-- | interface-definitions/protocols-ospfv3.xml.in | 21 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_protocols_ospfv3.py | 5 | ||||
-rwxr-xr-x | src/migration-scripts/ospf/0-to-1 | 52 |
4 files changed, 78 insertions, 8 deletions
diff --git a/data/templates/frr/ospf6d.frr.tmpl b/data/templates/frr/ospf6d.frr.tmpl index a8c53738f..c6527ed6c 100644 --- a/data/templates/frr/ospf6d.frr.tmpl +++ b/data/templates/frr/ospf6d.frr.tmpl @@ -2,6 +2,9 @@ {% if interface is defined and interface is not none %} {% for iface, iface_config in interface.items() %} interface {{ iface }} +{% if iface_config.area is defined and iface_config.area is not none %} + ipv6 ospf6 area {{ iface_config.area }} +{% endif %} {% if iface_config.cost is defined and iface_config.cost is not none %} ipv6 ospf6 cost {{ iface_config.cost }} {% endif %} @@ -45,11 +48,6 @@ interface {{ iface }} router ospf6 {% if area is defined and area is not none %} {% for area_id, area_config in area.items() %} -{% if area_config.interface is defined and area_config.interface is not none %} -{% for interface in area_config.interface %} - interface {{ interface }} area {{ area_id }} -{% endfor %} -{% endif %} {% if area_config.area_type is defined and area_config.area_type is not none %} {% for type, type_config in area_config.area_type.items() %} area {{ area_id }} {{ type }} {{ 'no-summary' if type_config.no_summary is defined }} diff --git a/interface-definitions/protocols-ospfv3.xml.in b/interface-definitions/protocols-ospfv3.xml.in index fffeeb9a5..c7a94d58c 100644 --- a/interface-definitions/protocols-ospfv3.xml.in +++ b/interface-definitions/protocols-ospfv3.xml.in @@ -61,7 +61,6 @@ </completionHelp> </properties> </leafNode> - #include <include/generic-interface-multi.xml.i> <tagNode name="range"> <properties> <help>Specify IPv6 prefix (border routers only)</help> @@ -121,6 +120,26 @@ </constraint> </properties> <children> + <leafNode name="area"> + <properties> + <help>Enable OSPF on this interface</help> + <completionHelp> + <path>protocols ospfv3 area</path> + </completionHelp> + <valueHelp> + <format>u32</format> + <description>OSPF area ID as decimal notation</description> + </valueHelp> + <valueHelp> + <format>ipv4</format> + <description>OSPF area ID in IP address notation</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 0-4294967295"/> + <validator name="ip-address"/> + </constraint> + </properties> + </leafNode> #include <include/ospf/intervals.xml.i> #include <include/ospf/interface-common.xml.i> <leafNode name="ifmtu"> diff --git a/smoketest/scripts/cli/test_protocols_ospfv3.py b/smoketest/scripts/cli/test_protocols_ospfv3.py index c0673629e..8e12990d5 100755 --- a/smoketest/scripts/cli/test_protocols_ospfv3.py +++ b/smoketest/scripts/cli/test_protocols_ospfv3.py @@ -49,7 +49,7 @@ class TestProtocolsOSPFv3(VyOSUnitTestSHIM.TestCase): interfaces = Section.interfaces('ethernet') for interface in interfaces: - self.cli_set(base_path + ['area', default_area, 'interface', interface]) + self.cli_set(base_path + ['interface', interface, 'area', default_area]) # commit changes self.cli_commit() @@ -63,7 +63,8 @@ class TestProtocolsOSPFv3(VyOSUnitTestSHIM.TestCase): self.assertIn(f' area {default_area} export-list {acl_name}', frrconfig) for interface in interfaces: - self.assertIn(f' interface {interface} area {default_area}', frrconfig) + if_config = self.getFRRconfig(f'interface {interface}') + self.assertIn(f'ipv6 ospf6 area {default_area}', if_config) self.cli_delete(['policy', 'access-list6', acl_name]) diff --git a/src/migration-scripts/ospf/0-to-1 b/src/migration-scripts/ospf/0-to-1 new file mode 100755 index 000000000..ff3a84b2c --- /dev/null +++ b/src/migration-scripts/ospf/0-to-1 @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2021 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/>. + +# T3753: upgrade to FRR8 and move CLI options to better fit with the new FRR CLI + +from sys import argv +from vyos.configtree import ConfigTree + +if (len(argv) < 1): + print("Must specify file name!") + exit(1) + +file_name = argv[1] + +with open(file_name, 'r') as f: + config_file = f.read() + +ospfv3_base = ['protocols', 'ospfv3'] +config = ConfigTree(config_file) + +if config.exists(ospfv3_base): + area_base = ospfv3_base + ['area'] + if config.exists(area_base): + for area in config.list_nodes(area_base): + if not config.exists(area_base + [area, 'interface']): + continue + + for interface in config.return_values(area_base + [area, 'interface']): + config.set(ospfv3_base + ['interface', interface, 'area', area]) + config.set_tag(ospfv3_base + ['interface']) + + config.delete(area_base + [area, 'interface']) + +try: + with open(file_name, 'w') as f: + f.write(config.to_string()) +except OSError as e: + print(f'Failed to save the modified config: {e}') + exit(1) |