summaryrefslogtreecommitdiff
path: root/src/migration-scripts
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2025-11-28 14:00:42 +0200
committerGitHub <noreply@github.com>2025-11-28 14:00:42 +0200
commitf4d46db92f9d95c2264c219304172b7b45094bb3 (patch)
treedca004f52a6859681eada179160a56a5b9f61f51 /src/migration-scripts
parent4c3060b9f0bff246455eaf6704cd14dde444c77d (diff)
parenta3b37e68379745708981e8f31bc70c0ed9e8239d (diff)
downloadvyos-1x-f4d46db92f9d95c2264c219304172b7b45094bb3.tar.gz
vyos-1x-f4d46db92f9d95c2264c219304172b7b45094bb3.zip
Merge pull request #4824 from alexandr-san4ez/T4251-current
syslog: T4251: Rename "permitted-peers" to "permitted-peer" and improve TLS checks
Diffstat (limited to 'src/migration-scripts')
-rw-r--r--src/migration-scripts/system/29-to-3052
1 files changed, 52 insertions, 0 deletions
diff --git a/src/migration-scripts/system/29-to-30 b/src/migration-scripts/system/29-to-30
new file mode 100644
index 000000000..7babde3f3
--- /dev/null
+++ b/src/migration-scripts/system/29-to-30
@@ -0,0 +1,52 @@
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
+#
+# 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/>.
+
+# T4251:
+# - drop "tls enable" node (make "tls" a standalone key)
+# - split "tls permitted-peers" list by commas into multiple "tls permitted-peer" entries
+
+from vyos.configtree import ConfigTree
+
+base = ['system', 'syslog', 'remote']
+
+
+def migrate(config: ConfigTree) -> None:
+ if not config.exists(base):
+ return
+
+ # Iterate over all remote syslog server entries (like 172.18.0.5)
+ for remote_addr in config.list_nodes(base):
+ remote_base = base + [remote_addr]
+ tls_base = remote_base + ['tls']
+
+ # (1) Remove "tls enable" -> migrate to simple "tls"
+ enable_path = tls_base + ['enable']
+ if config.exists(enable_path):
+ # Remove obsolete "enable" node
+ config.delete(enable_path)
+
+ # (2) Split "tls permitted-peers" (comma-separated string)
+ permitted_peers_path = tls_base + ['permitted-peers']
+ if config.exists(permitted_peers_path):
+ peers_str = config.return_value(permitted_peers_path)
+ # Split CSV values and normalize whitespace
+ peers = [p.strip() for p in peers_str.split(',') if p.strip()]
+
+ # Create a new "permitted-peer" entry per item
+ for peer in peers:
+ config.set(tls_base + ['permitted-peer'], value=peer, replace=False)
+
+ # Remove the old combined node
+ config.delete(permitted_peers_path)