summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/migration-scripts/ospf/3-to-444
1 files changed, 44 insertions, 0 deletions
diff --git a/src/migration-scripts/ospf/3-to-4 b/src/migration-scripts/ospf/3-to-4
new file mode 100644
index 000000000..842e66896
--- /dev/null
+++ b/src/migration-scripts/ospf/3-to-4
@@ -0,0 +1,44 @@
+# Copyright (C) VyOS Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+# T9606: "parameters rfc1583-compatibility" moves to "compatible rfc1583",
+# matching FRR's "compatible" command family.
+
+from vyos.configtree import ConfigTree
+
+
+def compatible_migration(config: ConfigTree, ospf_base: list) -> None:
+ if not config.exists(ospf_base):
+ return
+
+ parameters = ospf_base + ['parameters']
+ if config.exists(parameters + ['rfc1583-compatibility']):
+ config.delete(parameters + ['rfc1583-compatibility'])
+
+ # do not leave an empty "parameters" node behind
+ if config.list_nodes(parameters) == []:
+ config.delete(parameters)
+
+ config.set(ospf_base + ['compatible', 'rfc1583'])
+
+
+def migrate(config: ConfigTree) -> None:
+ # OSPF in the default VRF
+ compatible_migration(config, ['protocols', 'ospf'])
+
+ # OSPF in every VRF
+ if config.exists(['vrf', 'name']):
+ for name in config.list_nodes(['vrf', 'name']):
+ compatible_migration(config, ['vrf', 'name', name, 'protocols', 'ospf'])