summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-01-11 10:27:13 +0100
committerChristian Poessinger <christian@poessinger.com>2022-01-11 10:28:00 +0100
commit54675c2cc9aa9c1315478107cce14e5ba23d865e (patch)
tree2ec5a4430922771c46a0ab16ffe896f09e0edf13 /src
parente89f48269e96f0b558dd3d427c4cc89abd585c3f (diff)
downloadvyos-1x-54675c2cc9aa9c1315478107cce14e5ba23d865e.tar.gz
vyos-1x-54675c2cc9aa9c1315478107cce14e5ba23d865e.zip
policy: T4170: rename "policy ipv6-route" -> "policy route6"
In order to have a consistent looking CLI we should rename this CLI node. There is: * access-list and access-list6 (policy) * prefix-list and prefix-list6 (policy) * route and route6 (static routes)
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/policy-route.py4
-rwxr-xr-xsrc/migration-scripts/policy/1-to-249
2 files changed, 51 insertions, 2 deletions
diff --git a/src/conf_mode/policy-route.py b/src/conf_mode/policy-route.py
index d098be68d..9edab4b47 100755
--- a/src/conf_mode/policy-route.py
+++ b/src/conf_mode/policy-route.py
@@ -51,7 +51,7 @@ def verify(policy):
if not policy:
return None
- for route in ['route', 'ipv6_route']:
+ for route in ['route', 'route6']:
if route in policy:
for name, pol_conf in policy[route].items():
if 'rule' in pol_conf:
@@ -98,7 +98,7 @@ def generate(policy):
return None
def apply_table_marks(policy):
- for route in ['route', 'ipv6_route']:
+ for route in ['route', 'route6']:
if route in policy:
for name, pol_conf in policy[route].items():
if 'rule' in pol_conf:
diff --git a/src/migration-scripts/policy/1-to-2 b/src/migration-scripts/policy/1-to-2
new file mode 100755
index 000000000..3e46227de
--- /dev/null
+++ b/src/migration-scripts/policy/1-to-2
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2022 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/>.
+
+# T4170: rename "policy ipv6-route" to "policy route6" to match common
+# IPv4/IPv6 schema
+
+from sys import argv
+from sys import exit
+
+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()
+
+base = ['policy', 'ipv6-route']
+config = ConfigTree(config_file)
+
+if not config.exists(base):
+ # Nothing to do
+ exit(0)
+
+config.rename(base, 'route6')
+config.set_tag(['policy', 'route6'])
+
+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)