Gitweb:
http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=5c8d1f...
Commit: 5c8d1f68bc3e7a21338e1aa1a7fdea3a6febebf1
Parent: d8872849a6a45537ffe70c5643187f3753e19ddd
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon Feb 11 14:33:09 2013 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Feb 11 14:33:09 2013 +0100
fence agents: Fence agents errors are logged to syslog
Related: rhbz#879761
---
fence/agents/lib/fencing.py.py | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 98e8fd2..37be50e 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
import sys, getopt, time, os, uuid, pycurl
-import pexpect, re, atexit
+import pexpect, re, atexit, syslog
import __main__
## do not add code here.
@@ -387,6 +387,7 @@ def atexit_handler():
os.close(1)
except IOError:
sys.stderr.write("%s failed to close standard output\n"%(sys.argv[0]))
+ syslog.syslog(syslog.LOG_ERR, "Failed to close standard output")
sys.exit(EC_GENERIC_ERROR)
def add_dependency_options(options):
@@ -422,6 +423,7 @@ def fail(error_code):
EC_PASSWORD_MISSING : "Failed: You have to set login password"
}[error_code] + "\n"
sys.stderr.write(message)
+ syslog.syslog(syslog.LOG_ERR, message)
sys.exit(EC_GENERIC_ERROR)
def usage(avail_opt):
@@ -578,6 +580,7 @@ def process_input(avail_opt):
if avail_opt.count(name) == 0:
sys.stderr.write("Parse error: Ignoring unknown option
'"+line+"'\n")
+ syslog.syslog(syslog.LOG_WARNING, "Parse error: Ignoring unknown option
'"+line)
continue
if all_opt[name]["getopt"].endswith(":"):
@@ -815,11 +818,13 @@ def fence_action(tn, options, set_power_fn, get_power_fn,
get_outlet_list = None
# an error occured during power ON phase in reboot
# fence action was completed succesfully even in that case
sys.stderr.write(str(ex))
+ syslog.syslog(syslog.LOG_NOTICE, str(ex))
pass
if power_on == False:
# this should not fail as node was fenced succesfully
sys.stderr.write('Timed out waiting to power ON\n')
+ syslog.syslog(syslog.LOG_NOTICE, "Timed out waiting to power ON")
print "Success: Rebooted"
elif options["--action"] == "status":
@@ -834,6 +839,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn,
get_outlet_list = None
fail(EC_TIMED_OUT)
except pycurl.error, ex:
sys.stderr.write(ex[1] + "\n")
+ syslog.syslog(syslog.LOG_ERR, ex[1])
fail(EC_TIMED_OUT)
return result
@@ -866,6 +872,7 @@ def fence_login(options):
except pexpect.ExceptionPexpect, ex:
## SSL telnet is part of the fencing package
sys.stderr.write(str(ex) + "\n")
+ syslog.syslog(syslog.LOG_ERR, str(ex))
sys.exit(EC_GENERIC_ERROR)
elif options.has_key("--ssh") and 0 ==
options.has_key("--identity-file"):
command = '%s %s %s@%s -p %s' % (SSH_PATH, force_ipvx,
options["--username"], options["--ip"],
options["--ipport"])
@@ -875,6 +882,7 @@ def fence_login(options):
conn = fspawn(options, command)
except pexpect.ExceptionPexpect, ex:
sys.stderr.write(str(ex) + "\n")
+ syslog.syslog(syslog.LOG_ERR, str(ex))
sys.stderr.write("Due to limitations, binary dependencies on fence agents
"
"are not in the spec file and must be installed separately." +
"\n")
sys.exit(EC_GENERIC_ERROR)
@@ -904,6 +912,7 @@ def fence_login(options):
conn = fspawn(options, command)
except pexpect.ExceptionPexpect, ex:
sys.stderr.write(str(ex) + "\n")
+ syslog.syslog(syslog.LOG_ERR, str(ex))
sys.stderr.write("Due to limitations, binary dependencies on fence agents
"
"are not in the spec file and must be installed separately." +
"\n")
sys.exit(EC_GENERIC_ERROR)
@@ -927,6 +936,7 @@ def fence_login(options):
conn.send("open %s -%s\n"%(options["--ip"],
options["--ipport"]))
except pexpect.ExceptionPexpect, ex:
sys.stderr.write(str(ex) + "\n")
+ syslog.syslog(syslog.LOG_ERR, str(ex))
sys.stderr.write("Due to limitations, binary dependencies on fence agents
"
"are not in the spec file and must be installed separately." +
"\n")
sys.exit(EC_GENERIC_ERROR)