summaryrefslogtreecommitdiff
path: root/src/migration-scripts/monitoring/2-to-3
blob: cd85374d69b4963246cafd09e3b5cb1088c0439d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright (C) VyOS Inc.
#
# 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/>.

# T9329: The InfluxDB output used to unconditionally skip verification of the
# remote server certificate (`insecure_skip_verify = true`). Certificate
# verification is now enabled by default and can be configured via the new
# 'tls' node. Preserve the previous behavior for existing HTTPS endpoints by
# explicitly setting 'tls insecure'.

from vyos.configtree import ConfigTree

base = ['service', 'monitoring', 'telegraf', 'influxdb']


def migrate(config: ConfigTree) -> None:
    url_path = base + ['url']
    if not config.exists(url_path):
        # Nothing to do
        return

    # Prevent migration for already enabled TLS
    if config.exists(base + ['tls']):
        return

    url = config.return_value(url_path)
    if url.lower().startswith('https://'):
        config.set(base + ['tls', 'insecure'])