From fc6f15c0037a8abd4e84fad3b59c03b9c6008a24 Mon Sep 17 00:00:00 2001 From: Nicolas Vollmar Date: Wed, 18 Dec 2024 21:40:55 +0100 Subject: [PATCH] T6953: add migration for old configuration --- src/migration-scripts/monitoring/1-to-2 | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/migration-scripts/monitoring/1-to-2 diff --git a/src/migration-scripts/monitoring/1-to-2 b/src/migration-scripts/monitoring/1-to-2 new file mode 100644 index 00000000000..53ba93aa312 --- /dev/null +++ b/src/migration-scripts/monitoring/1-to-2 @@ -0,0 +1,35 @@ +# Copyright 2023-2024 VyOS maintainers and contributors +# +# 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 . + +# T6953: merge node and frr exporter under prometheus section + +from vyos.configtree import ConfigTree + +base = ['service', 'monitoring'] + +def migrate(config: ConfigTree) -> None: + if not config.exists(base): + # Nothing to do + return + + if config.exists(base + ['node-exporter']): + tmp = config.return_value(base + ['node-exporter']) + config.delete(base + ['node-exporter']) + config.set(base + ['prometheus', 'node-exporter'], value=tmp) + + if config.exists(base + ['frr-exporter']): + tmp = config.return_value(base + ['frr-exporter']) + config.delete(base + ['frr-exporter']) + config.set(base + ['prometheus', 'frr-exporter'], value=tmp)