From 48cc27d9446abb4dfa5e78a42c591ac553e85d3e Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 26 Dec 2021 10:54:17 +0100 Subject: ospfv3: T4108: add support for auto-cost parameter --- data/templates/frr/ospf6d.frr.tmpl | 1 + interface-definitions/include/ospf/auto-cost.xml.i | 22 ++++++++++++++++++++++ .../include/ospf/protocol-common-config.xml.i | 21 +-------------------- .../include/ospfv3/protocol-common-config.xml.i | 1 + src/conf_mode/protocols_ospfv3.py | 15 +++++++++++++++ 5 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 interface-definitions/include/ospf/auto-cost.xml.i diff --git a/data/templates/frr/ospf6d.frr.tmpl b/data/templates/frr/ospf6d.frr.tmpl index 2e8f3da92..1149e640c 100644 --- a/data/templates/frr/ospf6d.frr.tmpl +++ b/data/templates/frr/ospf6d.frr.tmpl @@ -69,6 +69,7 @@ router ospf6 {{ 'vrf ' + vrf if vrf is defined and vrf is not none }} area {{ area_id }} import-list {{ area_config.import_list }} {% endif %} {% endfor %} + auto-cost reference-bandwidth {{ auto_cost.reference_bandwidth }} {% endif %} {% if distance is defined and distance is not none %} {% if distance.global is defined and distance.global is not none %} diff --git a/interface-definitions/include/ospf/auto-cost.xml.i b/interface-definitions/include/ospf/auto-cost.xml.i new file mode 100644 index 000000000..3e6cc8232 --- /dev/null +++ b/interface-definitions/include/ospf/auto-cost.xml.i @@ -0,0 +1,22 @@ + + + + Calculate interface cost according to bandwidth + + + + + Reference bandwidth method to assign cost (default: 100) + + u32:1-4294967 + Reference bandwidth cost in Mbits/sec + + + + + + 100 + + + + diff --git a/interface-definitions/include/ospf/protocol-common-config.xml.i b/interface-definitions/include/ospf/protocol-common-config.xml.i index ac165a157..655f30ad3 100644 --- a/interface-definitions/include/ospf/protocol-common-config.xml.i +++ b/interface-definitions/include/ospf/protocol-common-config.xml.i @@ -275,26 +275,6 @@ - - - Calculate OSPF interface cost according to bandwidth (default: 100) - - - - - Reference bandwidth method to assign OSPF cost - - u32:1-4294967 - Reference bandwidth cost in Mbits/sec - - - - - - 100 - - - Default route advertisment settings @@ -318,6 +298,7 @@ +#include Metric of redistributed routes diff --git a/interface-definitions/include/ospfv3/protocol-common-config.xml.i b/interface-definitions/include/ospfv3/protocol-common-config.xml.i index 00a6dcca7..6f9f8fd9d 100644 --- a/interface-definitions/include/ospfv3/protocol-common-config.xml.i +++ b/interface-definitions/include/ospfv3/protocol-common-config.xml.i @@ -89,6 +89,7 @@ +#include Administrative distance diff --git a/src/conf_mode/protocols_ospfv3.py b/src/conf_mode/protocols_ospfv3.py index 94455a458..ac86be4e6 100755 --- a/src/conf_mode/protocols_ospfv3.py +++ b/src/conf_mode/protocols_ospfv3.py @@ -25,6 +25,7 @@ from vyos.configdict import node_changed from vyos.configverify import verify_common_route_maps from vyos.template import render_to_string from vyos.ifconfig import Interface +from vyos.util import dict_search from vyos.util import get_interface_config from vyos.xml import defaults from vyos import ConfigError @@ -66,6 +67,20 @@ def get_config(config=None): ospfv3.update({'deleted' : ''}) return ospfv3 + # We have gathered the dict representation of the CLI, but there are default + # options which we need to update into the dictionary retrived. + # XXX: Note that we can not call defaults(base), as defaults does not work + # on an instance of a tag node. As we use the exact same CLI definition for + # both the non-vrf and vrf version this is absolutely safe! + default_values = defaults(base_path) + + # XXX: T2665: we currently have no nice way for defaults under tag nodes, + # clean them out and add them manually :( + del default_values['interface'] + + # merge in remaining default values + ospfv3 = dict_merge(default_values, ospfv3) + # We also need some additional information from the config, prefix-lists # and route-maps for instance. They will be used in verify(). # -- cgit v1.2.3