1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

an an rsyslogd config check to the logging test endpoint

This commit is contained in:
Ryan Petrello 2020-04-09 13:57:44 -04:00 committed by Christian Adams
parent 2a4b009f04
commit 1000dc10fb

View File

@ -4,6 +4,7 @@
# Python # Python
import collections import collections
import logging import logging
import subprocess
import sys import sys
import socket import socket
from socket import SHUT_RDWR from socket import SHUT_RDWR
@ -174,6 +175,14 @@ class SettingLoggingTest(GenericAPIView):
hostname = getattr(settings, 'LOG_AGGREGATOR_HOST', None) hostname = getattr(settings, 'LOG_AGGREGATOR_HOST', None)
protocol = getattr(settings, 'LOG_AGGREGATOR_PROTOCOL', None) protocol = getattr(settings, 'LOG_AGGREGATOR_PROTOCOL', None)
try:
subprocess.check_output(
['rsyslogd', '-N1', '-f', '/var/lib/awx/rsyslog/rsyslog.conf'],
stderr=subprocess.STDOUT
)
except subprocess.CalledProcessError as exc:
return Response({'error': exc.output}, status=status.HTTP_400_BAD_REQUEST)
# Check to ensure port is open at host # Check to ensure port is open at host
if protocol in ['udp', 'tcp']: if protocol in ['udp', 'tcp']:
port = getattr(settings, 'LOG_AGGREGATOR_PORT', None) port = getattr(settings, 'LOG_AGGREGATOR_PORT', None)