summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAles Kozumplik <akozumpl@redhat.com>2010-02-17 17:32:55 +0100
committerAles Kozumplik <akozumpl@redhat.com>2010-02-18 10:08:43 +0100
commit575a274d306baeb5f19510d3aca2252feb724ecb (patch)
treec1f1583dec1e855f6a679c42b5cbc114e77f4532
parent99bc9b7d3e05d3ac5488d838caf3e832ef238347 (diff)
downloadanaconda-575a274d306baeb5f19510d3aca2252feb724ecb.tar.gz
anaconda-575a274d306baeb5f19510d3aca2252feb724ecb.tar.xz
anaconda-575a274d306baeb5f19510d3aca2252feb724ecb.zip
logging, fix: setting remote logging from kicstart
-rw-r--r--anaconda_log.py19
-rw-r--r--kickstart.py25
2 files changed, 36 insertions, 8 deletions
diff --git a/anaconda_log.py b/anaconda_log.py
index 31a8f7488..0aa2f2c3d 100644
--- a/anaconda_log.py
+++ b/anaconda_log.py
@@ -22,6 +22,8 @@
# Michael Fulbright <msf@redhat.com>
#
+import os
+import signal
import sys
import logging
from logging.handlers import SysLogHandler, SYSLOG_UDP_PORT
@@ -131,4 +133,21 @@ class AnacondaLog:
syslogHandler.setLevel(logging.DEBUG)
logger.addHandler(syslogHandler)
+ def updateRemote(self, remote_syslog):
+ """Updates the location of remote rsyslogd to forward to.
+
+ Requires updating rsyslogd config and sending SIGHUP to the daemon.
+ """
+ PIDFILE = "/var/run/syslogd.pid"
+ CFGFILE = "/etc/rsyslog.conf"
+ TEMPLATE = "*.* @@%s\n"
+
+ self.remote_syslog = remote_syslog
+ with open(CFGFILE, 'a') as cfgfile:
+ forward_line = TEMPLATE % remote_syslog
+ cfgfile.write(forward_line)
+ with open(PIDFILE, 'r') as pidfile:
+ pid = int(pidfile.read())
+ os.kill(pid, signal.SIGHUP)
+
logger = AnacondaLog()
diff --git a/kickstart.py b/kickstart.py
index 6f05738d9..8862119ff 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -56,7 +56,8 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
import logging
log = logging.getLogger("anaconda")
stdoutLog = logging.getLogger("anaconda.stdout")
-from anaconda_log import logger, logLevelMap, setHandlersLevel
+from anaconda_log import logger, logLevelMap, setHandlersLevel,\
+ DEFAULT_TTY_LEVEL
class AnacondaKSScript(Script):
def run(self, chroot, serial, intf = None):
@@ -513,13 +514,21 @@ class LogVolData(commands.logvol.F12_LogVolData):
class Logging(commands.logging.FC6_Logging):
def execute(self, anaconda):
- setHandlersLevel(log, logLevelMap[self.level])
-
- if self.host != "" and self.port != "":
- logger.addSysLogHandler(log, self.host, port=int(self.port))
- elif self.host != "":
- logger.addSysLogHandler(log, self.host)
-
+ if logger.tty_loglevel == DEFAULT_TTY_LEVEL:
+ # not set from the command line
+ level = logLevelMap[self.level]
+ logger.tty_loglevel = level
+ storage_log = logging.getLogger("storage")
+ setHandlersLevel(log, level)
+ setHandlersLevel(storage_log, level)
+
+ if logger.remote_syslog == None and len(self.host) > 0:
+ # not set from the command line, ok to use kickstart
+ remote_server = self.host
+ if self.port:
+ remote_server = "%s:%s" %(self.host, self.port)
+ logger.updateRemote(remote_server)
+
class NetworkData(commands.network.F8_NetworkData):
def execute(self, anaconda):
if self.bootProto: