Skip to content

Commit

Permalink
T6953: add migration for old configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nvollmar committed Dec 18, 2024
1 parent f544c0c commit 0c1a202
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/migration-scripts/monitoring/1-to-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/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/>.

# Copyright 2022-2024 VyOS maintainers and contributors <[email protected]>
#
# 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/>.

# 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)

0 comments on commit 0c1a202

Please sign in to comment.