summaryrefslogtreecommitdiff
path: root/src/migration-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'src/migration-scripts')
-rwxr-xr-xsrc/migration-scripts/ntp/1-to-267
-rwxr-xr-xsrc/migration-scripts/qos/1-to-242
2 files changed, 73 insertions, 36 deletions
diff --git a/src/migration-scripts/ntp/1-to-2 b/src/migration-scripts/ntp/1-to-2
new file mode 100755
index 000000000..4a701e7e5
--- /dev/null
+++ b/src/migration-scripts/ntp/1-to-2
@@ -0,0 +1,67 @@
+#!/usr/bin/env python3
+
+# Copyright (C) 2023 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/>.
+
+# T3008: move from ntpd to chrony and migrate "system ntp" to "service ntp"
+
+import sys
+
+from vyos.configtree import ConfigTree
+
+if (len(sys.argv) < 1):
+ print("Must specify file name!")
+ sys.exit(1)
+
+file_name = sys.argv[1]
+
+with open(file_name, 'r') as f:
+ config_file = f.read()
+
+config = ConfigTree(config_file)
+
+base_path = ['system', 'ntp']
+new_base_path = ['service', 'ntp']
+if not config.exists(base_path):
+ # Nothing to do
+ sys.exit(0)
+
+# copy "system ntp" to "service ntp"
+config.copy(base_path, new_base_path)
+config.delete(base_path)
+
+# chrony does not support the preempt option, drop it
+for server in config.list_nodes(new_base_path + ['server']):
+ server_base = new_base_path + ['server', server]
+ if config.exists(server_base + ['preempt']):
+ config.delete(server_base + ['preempt'])
+
+# Rename "allow-clients" -> "allow-client"
+if config.exists(new_base_path + ['allow-clients']):
+ config.rename(new_base_path + ['allow-clients'], 'allow-client')
+
+# By default VyOS 1.3 allowed NTP queries for all networks - in chrony we
+# explicitly disable this behavior and clients need to be specified using the
+# allow-client CLI option. In order to be fully backwards compatible, we specify
+# 0.0.0.0/0 and ::/0 as allow networks if not specified otherwise explicitly.
+if not config.exists(new_base_path + ['allow-client']):
+ config.set(new_base_path + ['allow-client', 'address'], value='0.0.0.0/0', replace=False)
+ config.set(new_base_path + ['allow-client', 'address'], value='::/0', replace=False)
+
+try:
+ with open(file_name, 'w') as f:
+ f.write(config.to_string())
+except OSError as e:
+ print("Failed to save the modified config: {}".format(e))
+ sys.exit(1)
diff --git a/src/migration-scripts/qos/1-to-2 b/src/migration-scripts/qos/1-to-2
index 6f4c08a50..41026cbd6 100755
--- a/src/migration-scripts/qos/1-to-2
+++ b/src/migration-scripts/qos/1-to-2
@@ -98,49 +98,19 @@ config.set(['qos'])
config.copy(base, ['qos', 'policy'])
config.delete(base)
-# TODO
-# - remove burst from network emulator
-
-def change_cli_bandwidth(config, path):
- if config.exists(path + ['bandwidth']):
- bw = config.return_value(path + ['bandwidth'])
- if bw.endswith('%'):
- bw = bandwidth_percent_to_val(interface, bw.rstrip('%'))
- config.set(path + ['bandwidth'], value=bw)
- return
-
# Now map the interface policy binding to the new CLI syntax
+if len(iface_config):
+ config.set(['qos', 'interface'])
+ config.set_tag(['qos', 'interface'])
+
for interface, interface_config in iface_config.items():
+ config.set(['qos', 'interface', interface])
+ config.set_tag(['qos', 'interface', interface])
if 'ingress' in interface_config:
config.set(['qos', 'interface', interface, 'ingress'], value=interface_config['ingress'])
if 'egress' in interface_config:
config.set(['qos', 'interface', interface, 'egress'], value=interface_config['egress'])
- # QoS policy <-> interface binding is now established - we now can adjust some
- # CLI values like bandwidth in percent
- for direction in ['ingress', 'egress']:
- if direction not in interface_config:
- continue
- # Convert % bandwidth values to absolute values
- for policy in config.list_nodes(['qos', 'policy']):
- for policy_name in config.list_nodes(['qos', 'policy', policy]):
- if policy_name == interface_config[direction]:
- policy_base = ['qos', 'policy', policy, policy_name]
- # This is for the toplevel bandwidth node on a policy
- change_cli_bandwidth(config, policy_base)
-
- # This is for class based bandwidth value
- if config.exists(policy_base + ['class']):
- for cls in config.list_nodes(policy_base + ['class']):
- cls_base = policy_base + ['class', cls]
- change_cli_bandwidth(config, cls_base)
-
- # This is for the bandwidth value specified under the
- # policy "default" tree
- if config.exists(policy_base + ['default']):
- default_base = policy_base + ['default']
- change_cli_bandwidth(config, default_base)
-
# Remove "burst" CLI node from network emulator
netem_base = ['qos', 'policy', 'network-emulator']
if config.exists(netem_base):