1#!/usr/bin/env python 2############################################################################# 3# Copyright (c) 2015-2018 Balabit 4# 5# This program is free software; you can redistribute it and/or modify it 6# under the terms of the GNU General Public License version 2 as published 7# by the Free Software Foundation, or (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program; if not, write to the Free Software 16# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17# 18# As an additional exemption you are allowed to compile & link against the 19# OpenSSL libraries as published by the OpenSSL project. See the file 20# COPYING for details. 21# 22############################################################################# 23 24 25def test_manipulating_config_between_reload(config, syslog_ng): 26 file_source = config.create_file_source(file_name="input.log") 27 file_destination = config.create_file_destination(file_name="output.log") 28 destination_group = config.create_statement_group(file_destination) 29 30 logpath = config.create_logpath(statements=[file_source, destination_group]) 31 32 syslog_ng.start(config) 33 34 # update positional value of file source 35 file_source.set_path("updated_input.log") 36 37 # add new option to file source 38 file_source.options["log_iw_size"] = "100" 39 40 # create new file source and add to separate source group 41 file_source2 = config.create_file_source(file_name="input2.log") 42 source_group2 = config.create_statement_group(file_source2) 43 44 # create new file destination and update first destination group 45 file_destination2 = config.create_file_destination(file_name="output2.log") 46 destination_group.append(file_destination2) 47 48 # update first logpath group with new source group 49 logpath.add_group(source_group2) 50 51 syslog_ng.reload(config) 52 53 # remove option from file source 54 file_source.options.pop("log_iw_size") 55 56 # remove file destination from destination group 57 destination_group.remove(file_destination2) 58 59 # remove second source group from logpath 60 logpath.logpath.remove(source_group2) 61 62 syslog_ng.reload(config) 63