Esempio n. 1
0
def reconfigure_rsyslog():
    tmpl = construct_rsyslog_conf_template()
    # Write config to a temp file then move it to preserve atomicity
    with tempfile.TemporaryDirectory(prefix='rsyslog-conf-') as temp_dir:
        path = temp_dir + '/rsyslog.conf.temp'
        with open(path, 'w') as f:
            f.write(tmpl + '\n')
        shutil.move(path, '/var/lib/awx/rsyslog/rsyslog.conf')
    supervisor_service_command(command='restart', service='awx-rsyslogd')
Esempio n. 2
0
def test_produce_supervisor_command(mocker):
    communicate_mock = mocker.MagicMock(return_value=('Everything is fine',
                                                      ''))
    mock_process = mocker.MagicMock()
    mock_process.communicate = communicate_mock
    Popen_mock = mocker.MagicMock(return_value=mock_process)
    with mocker.patch.object(reload.subprocess, 'Popen', Popen_mock):
        reload.supervisor_service_command("restart")
        reload.subprocess.Popen.assert_called_once_with([
            'supervisorctl',
            'restart',
            'tower-processes:*',
        ],
                                                        stderr=-1,
                                                        stdin=-1,
                                                        stdout=-1)
Esempio n. 3
0
def reconfigure_rsyslog():
    tmpl = construct_rsyslog_conf_template()
    with open('/var/lib/awx/rsyslog/rsyslog.conf', 'w') as f:
        f.write(tmpl + '\n')
    supervisor_service_command(command='restart', service='awx-rsyslogd')