diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-01-11 10:27:13 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2022-01-11 10:28:00 +0100 |
commit | 54675c2cc9aa9c1315478107cce14e5ba23d865e (patch) | |
tree | 2ec5a4430922771c46a0ab16ffe896f09e0edf13 /src/migration-scripts | |
parent | e89f48269e96f0b558dd3d427c4cc89abd585c3f (diff) | |
download | vyos-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/migration-scripts')
-rwxr-xr-x | src/migration-scripts/policy/1-to-2 | 49 |
1 files changed, 49 insertions, 0 deletions
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) |