[ovs-dev] [PATCH] ovs-monitor-ipsec: Don't abort if syslog is not available.

Ben Pfaff blp at nicira.com
Fri Aug 26 20:59:19 UTC 2011


If /dev/log doesn't exist or cannot be contacted, ovs-monitor-ipsec would
abort with an exception.  This allows it to start up and run.

It's pretty common for a chroot used for testing not to have a syslogd
instance set up and running, so this limitation caused testing problems.

Reported-by: Simon Horman <horms at verge.net.au>
---
 debian/ovs-monitor-ipsec |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/debian/ovs-monitor-ipsec b/debian/ovs-monitor-ipsec
index 0a97c88..a9af8ec 100755
--- a/debian/ovs-monitor-ipsec
+++ b/debian/ovs-monitor-ipsec
@@ -29,6 +29,7 @@ import getopt
 import glob
 import logging, logging.handlers
 import os
+import socket
 import subprocess
 import sys
 
@@ -38,16 +39,18 @@ import ovs.util
 import ovs.daemon
 import ovs.db.idl
 
-
-# By default log messages as DAEMON into syslog
 s_log = logging.getLogger("ovs-monitor-ipsec")
-l_handler = logging.handlers.SysLogHandler(
-        "/dev/log",
-        facility=logging.handlers.SysLogHandler.LOG_DAEMON)
-l_formatter = logging.Formatter('%(filename)s: %(levelname)s: %(message)s')
-l_handler.setFormatter(l_formatter)
-s_log.addHandler(l_handler)
-
+try:
+    # By default log messages as DAEMON into syslog
+    l_handler = logging.handlers.SysLogHandler(
+            "/dev/log",
+            facility=logging.handlers.SysLogHandler.LOG_DAEMON)
+    l_formatter = logging.Formatter('%(filename)s: %(levelname)s: %(message)s')
+    l_handler.setFormatter(l_formatter)
+    s_log.addHandler(l_handler)
+except socket.error, e:
+    logging.basicConfig()
+    s_log.warn("failed to connect to syslog (%s)" % e)
 
 setkey = "/usr/sbin/setkey"
 
-- 
1.7.4.4




More information about the dev mailing list