fence-agents: master - fence agents: autodetect of EOL in fence agents
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 52eee63e2aad2434b996c4c19efe350510a9399b
Parent: 87cbe09e06ce8a5fb578cffe21b3d2137d5f0e17
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon May 21 11:12:41 2012 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon May 21 11:12:41 2012 +0200
fence agents: autodetect of EOL in fence agents
Fence agents diffes in EOL they accept. EOL \r\n is quite universal but in some cases
it is translated to \n\n what makes login process impossible to complete as it ends like
(capitals are fence agent response)
Login: USER\n
Password: \n
Login: PASSWORD\n
Until now there was a device option that handles that login_eol_lf but we found out that there are few
APC devices which does not work correctly with \r\n and needs \n. So we have to autodetect it, this feature was
added to standard library. As it can also helps with common problem when you have to write exactly
conn.send("message" + "\r\n"). Method conn.sendline("") uses EOL according to platform, so we have decided to create
new method conn.send_eol("message") which uses correct EOL. We need conn.sendline in communication with other local
application so we should not reuse it for this purpose.
Resolves: rhbz#810949
---
fence/agents/alom/fence_alom.py | 6 ++--
fence/agents/apc/fence_apc.py | 44 ++++++++++++------------
fence/agents/bladecenter/fence_bladecenter.py | 18 +++++-----
fence/agents/drac5/fence_drac5.py | 12 +++---
fence/agents/ilo_mp/fence_ilo_mp.py | 12 +++---
fence/agents/ldom/fence_ldom.py | 10 +++---
fence/agents/lib/fencing.py.py | 43 ++++++++++++++---------
fence/agents/rsa/fence_rsa.py | 6 ++--
fence/agents/rsb/fence_rsb.py | 10 +++---
fence/agents/sanbox2/fence_sanbox2.py | 32 +++++++++---------
fence/agents/wti/fence_wti.py | 2 +-
11 files changed, 102 insertions(+), 93 deletions(-)
diff --git a/fence/agents/alom/fence_alom.py b/fence/agents/alom/fence_alom.py
index 6223608..a964be5 100644
--- a/fence/agents/alom/fence_alom.py
+++ b/fence/agents/alom/fence_alom.py
@@ -18,7 +18,7 @@ BUILD_DATE=""
def get_power_status(conn, options):
result = ""
try:
- conn.sendline("showplatform")
+ conn.send_eol("showplatform")
conn.log_expect(options, options["-c"], int(options["-Y"]))
status = re.search("standby",conn.before.lower())
result=(status!=None and "off" or "on")
@@ -32,7 +32,7 @@ def get_power_status(conn, options):
def set_power_status(conn, options):
try:
cmd_line=(options["-o"]=="on" and "poweron" or "poweroff -f -y")
- conn.sendline(cmd_line)
+ conn.send_eol(cmd_line)
conn.log_expect(options, options["-c"],int(options["-g"]))
#Get the machine some time between poweron and poweroff
time.sleep(int(options["-g"]))
@@ -73,7 +73,7 @@ agent which can be used with ALOM connected machines."
# Logout from system
try:
- conn.sendline("logout")
+ conn.send_eol("logout")
conn.close()
except exceptions.OSError:
pass
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index d10dd5f..61463d0 100644
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -28,7 +28,7 @@ def get_power_status(conn, options):
exp_result = 0
outlets = {}
try:
- conn.send("1\r\n")
+ conn.send_eol("1")
conn.log_expect(options, options["-c"], int(options["-Y"]))
version = 0
@@ -57,15 +57,15 @@ def get_power_status(conn, options):
if switch == 0:
if version == 2:
if admin == 0:
- conn.send("2\r\n")
+ conn.send_eol("2")
else:
- conn.send("3\r\n")
+ conn.send_eol("3")
else:
- conn.send("2\r\n")
+ conn.send_eol("2")
conn.log_expect(options, options["-c"], int(options["-Y"]))
- conn.send("1\r\n")
+ conn.send_eol("1")
else:
- conn.send(options["-s"]+"\r\n")
+ conn.send_eol(options["-s"])
while True:
exp_result = conn.log_expect(options, [ options["-c"], "Press <ENTER>" ], int(options["-Y"]))
@@ -75,7 +75,7 @@ def get_power_status(conn, options):
res = show_re.search(x)
if (res != None):
outlets[res.group(2)] = (res.group(3), res.group(4))
- conn.send("\r\n")
+ conn.send_eol("")
if exp_result == 0:
break
conn.send(chr(03))
@@ -102,7 +102,7 @@ def set_power_status(conn, options):
}[options["-o"]]
try:
- conn.send("1\r\n")
+ conn.send_eol("1")
conn.log_expect(options, options["-c"], int(options["-Y"]))
version = 0
@@ -137,41 +137,41 @@ def set_power_status(conn, options):
if switch == 0:
if version == 2:
if admin2 == 0:
- conn.send("2\r\n")
+ conn.send_eol("2")
else:
- conn.send("3\r\n")
+ conn.send_eol("3")
else:
- conn.send("2\r\n")
+ conn.send_eol("2")
conn.log_expect(options, options["-c"], int(options["-Y"]))
if (None == re.compile('.*2- Outlet Restriction.*', re.IGNORECASE | re.S).match(conn.before)):
admin3 = 0
else:
admin3 = 1
- conn.send("1\r\n")
+ conn.send_eol("1")
else:
- conn.send(options["-s"] + "\r\n")
+ conn.send_eol(options["-s"])
while 1 == conn.log_expect(options, [ options["-c"], "Press <ENTER>" ], int(options["-Y"])):
- conn.send("\r\n")
- conn.send(options["-n"]+"\r\n")
+ conn.send_eol("")
+ conn.send_eol(options["-n"]+"")
conn.log_expect(options, options["-c"], int(options["-Y"]))
if switch == 0:
if admin2 == 1:
- conn.send("1\r\n")
+ conn.send_eol("1")
conn.log_expect(options, options["-c"], int(options["-Y"]))
if admin3 == 1:
- conn.send("1\r\n")
+ conn.send_eol("1")
conn.log_expect(options, options["-c"], int(options["-Y"]))
else:
- conn.send("1\r\n")
+ conn.send_eol("1")
conn.log_expect(options, options["-c"], int(options["-Y"]))
- conn.send(action+"\r\n")
+ conn.send_eol(action)
conn.log_expect(options, "Enter 'YES' to continue or <ENTER> to cancel :", int(options["-Y"]))
- conn.send("YES\r\n")
+ conn.send_eol("YES")
conn.log_expect(options, "Press <ENTER> to continue...", int(options["-Y"]))
- conn.send("\r\n")
+ conn.send_eol("")
conn.log_expect(options, options["-c"], int(options["-Y"]))
conn.send(chr(03))
conn.log_expect(options, "- Logout", int(options["-Y"]))
@@ -230,7 +230,7 @@ will block any necessary fencing actions."
## a problem because everything is checked before.
######
try:
- conn.sendline("4")
+ conn.send_eol("4")
conn.close()
except exceptions.OSError:
pass
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index c699b75..958ceb0 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -26,7 +26,7 @@ def get_power_status(conn, options):
try:
node_cmd = "system:blade\[" + options["-n"] + "\]>"
- conn.send("env -T system:blade[" + options["-n"] + "]\r\n")
+ conn.send_eol("env -T system:blade[" + options["-n"] + "]")
i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["-Y"]))
if i == 1:
## Given blade number does not exist
@@ -34,10 +34,10 @@ def get_power_status(conn, options):
return "off"
else:
fail(EC_STATUS)
- conn.send("power -state\r\n")
+ conn.send_eol("power -state")
conn.log_expect(options, node_cmd, int(options["-Y"]))
status = conn.before.splitlines()[-1]
- conn.send("env -T system\r\n")
+ conn.send_eol("env -T system")
conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
@@ -55,7 +55,7 @@ def set_power_status(conn, options):
try:
node_cmd = "system:blade\[" + options["-n"] + "\]>"
- conn.send("env -T system:blade[" + options["-n"] + "]\r\n")
+ conn.send_eol("env -T system:blade[" + options["-n"] + "]")
i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["-Y"]))
if i == 1:
## Given blade number does not exist
@@ -64,9 +64,9 @@ def set_power_status(conn, options):
else:
fail(EC_GENERIC_ERROR)
- conn.send("power -"+options["-o"]+"\r\n")
+ conn.send_eol("power -"+options["-o"])
conn.log_expect(options, node_cmd, int(options["-Y"]))
- conn.send("env -T system\r\n")
+ conn.send_eol("env -T system")
conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
@@ -78,9 +78,9 @@ def get_blades_list(conn, options):
try:
node_cmd = "system>"
- conn.send("env -T system\r\n")
+ conn.send_eol("env -T system")
conn.log_expect(options, node_cmd, int(options["-Y"]))
- conn.send("list -l 2\r\n")
+ conn.send_eol("list -l 2")
conn.log_expect(options, node_cmd, int(options["-Y"]))
lines = conn.before.split("\r\n")
@@ -130,7 +130,7 @@ and uses the command line interface to power on and off blades."
## Logout from system
######
try:
- conn.send("exit\r\n")
+ conn.send_eol("exit")
conn.close()
except exceptions.OSError:
pass
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index f3102cd..3e9a8d2 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -25,9 +25,9 @@ BUILD_DATE="March, 2008"
def get_power_status(conn, options):
try:
if options["model"] == "DRAC CMC":
- conn.sendline("racadm serveraction powerstatus -m " + options["-m"])
+ conn.send_eol("racadm serveraction powerstatus -m " + options["-m"])
elif options["model"] == "DRAC 5":
- conn.sendline("racadm serveraction powerstatus")
+ conn.send_eol("racadm serveraction powerstatus")
conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
@@ -49,9 +49,9 @@ def set_power_status(conn, options):
try:
if options["model"] == "DRAC CMC":
- conn.sendline("racadm serveraction " + action + " -m " + options["-m"])
+ conn.send_eol("racadm serveraction " + action + " -m " + options["-m"])
elif options["model"] == "DRAC 5":
- conn.sendline("racadm serveraction " + action)
+ conn.send_eol("racadm serveraction " + action)
conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
@@ -63,7 +63,7 @@ def get_list_devices(conn, options):
try:
if options["model"] == "DRAC CMC":
- conn.sendline("getmodinfo")
+ conn.send_eol("getmodinfo")
list_re = re.compile("^([^\s]*?)\s+Present\s*(ON|OFF)\s*.*$")
conn.log_expect(options, options["-c"], int(options["-g"]))
@@ -133,7 +133,7 @@ By default, the telnet interface is not enabled."
## Logout from system
######
try:
- conn.sendline("exit")
+ conn.send_eol("exit")
time.sleep(1)
conn.close()
except exceptions.OSError:
diff --git a/fence/agents/ilo_mp/fence_ilo_mp.py b/fence/agents/ilo_mp/fence_ilo_mp.py
index 1618216..3af3048 100644
--- a/fence/agents/ilo_mp/fence_ilo_mp.py
+++ b/fence/agents/ilo_mp/fence_ilo_mp.py
@@ -12,7 +12,7 @@ BUILD_DATE=""
def get_power_status(conn, options):
try:
- conn.send("show /system1\r\n")
+ conn.send_eol("show /system1")
re_state = re.compile('EnabledState=(.*)', re.IGNORECASE)
conn.log_expect(options, re_state, int(options["-Y"]))
@@ -31,9 +31,9 @@ def get_power_status(conn, options):
def set_power_status(conn, options):
try:
if options["-o"] == "on":
- conn.send("start /system1\r\n")
+ conn.send_eol("start /system1")
else:
- conn.send("stop -f /system1\r\n")
+ conn.send_eol("stop -f /system1")
conn.log_expect(options, options["-c"], int(options["-g"]))
@@ -46,7 +46,7 @@ def set_power_status(conn, options):
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
- "secure", "identity_file", "cmd_prompt", "ipport", "login_eol_lf",
+ "secure", "identity_file", "cmd_prompt", "ipport",
"separator", "inet4_only", "inet6_only",
"power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
@@ -64,7 +64,7 @@ def main():
show_docs(options, docs)
conn = fence_login(options)
- conn.send("SMCLP\r\n")
+ conn.send_eol("SMCLP")
##
## Fence operations
@@ -72,7 +72,7 @@ def main():
result = fence_action(conn, options, set_power_status, get_power_status)
try:
- conn.send("exit\r\n")
+ conn.send_eol("exit")
except exceptions.OSError:
pass
except pexpect.ExceptionPexpect:
diff --git a/fence/agents/ldom/fence_ldom.py b/fence/agents/ldom/fence_ldom.py
index 507a97a..c971c04 100644
--- a/fence/agents/ldom/fence_ldom.py
+++ b/fence/agents/ldom/fence_ldom.py
@@ -22,11 +22,11 @@ COMMAND_PROMPT_NEW="[PEXPECT]"
# Start comunicating after login. Prepare good environment.
def start_communication(conn, options):
- conn.sendline ("PS1='"+COMMAND_PROMPT_NEW+"'")
+ conn.send_eol ("PS1='"+COMMAND_PROMPT_NEW+"'")
res=conn.expect([pexpect.TIMEOUT, COMMAND_PROMPT_REG],int(options["-Y"]))
if res==0:
#CSH stuff
- conn.sendline("set prompt='"+COMMAND_PROMPT_NEW+"'")
+ conn.send_eol("set prompt='"+COMMAND_PROMPT_NEW+"'")
conn.log_expect(options, COMMAND_PROMPT_REG,int(options["-Y"]))
@@ -34,7 +34,7 @@ def get_power_status(conn, options):
try:
start_communication(conn,options)
- conn.sendline("ldm ls")
+ conn.send_eol("ldm ls")
conn.log_expect(options,COMMAND_PROMPT_REG,int(options["-Y"]))
@@ -71,7 +71,7 @@ def set_power_status(conn, options):
cmd_line="ldm "+(options["-o"]=="on" and "start" or "stop -f")+" \""+options["-n"]+"\""
- conn.sendline(cmd_line)
+ conn.send_eol(cmd_line)
conn.log_expect(options,COMMAND_PROMPT_REG,int(options["-g"]))
@@ -126,7 +126,7 @@ root. Than prompt is $, so again, you must use parameter -c."
## Logout from system
######
try:
- conn.sendline("logout")
+ conn.send_eol("logout")
conn.close()
except exceptions.OSError:
pass
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 5748391..2a62242 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -175,11 +175,6 @@ all_opt = {
"required" : "0",
"shortdesc" : "Force ribcl version to use",
"order" : 1 },
- "login_eol_lf" : {
- "getopt" : "",
- "help" : "",
- "order" : 1
- },
"cmd_prompt" : {
"getopt" : "c:",
"longopt" : "command-prompt",
@@ -407,12 +402,20 @@ all_opt = {
common_opt = [ "retry_on", "delay" ]
class fspawn(pexpect.spawn):
+ def __init__(self, options, command):
+ pexpect.spawn.__init__(self, command)
+ self.opt = options
+
def log_expect(self, options, pattern, timeout):
result = self.expect(pattern, timeout)
if options["log"] >= LOG_MODE_VERBOSE:
options["debug_fh"].write(self.before + self.after)
return result
+ # send EOL according to what was detected in login process (telnet)
+ def send_eol(self, message):
+ self.send(message + self.opt["eol"])
+
def atexit_handler():
try:
sys.stdout.close()
@@ -864,10 +867,7 @@ def fence_login(options):
if (options.has_key("-4")):
force_ipvx="-4 "
- if (options["device_opt"].count("login_eol_lf")):
- login_eol = "\n"
- else:
- login_eol = "\r\n"
+ options["eol"] = "\r\n"
## Do the delay of the fence device before logging in
## Delay is important for two-node clusters fencing but we do not need to delay 'status' operations
@@ -881,7 +881,7 @@ def fence_login(options):
if options.has_key("-z"):
command = '%s %s %s %s' % (SSL_PATH, force_ipvx, options["-a"], options["-u"])
try:
- conn = fspawn(command)
+ conn = fspawn(options, command)
except pexpect.ExceptionPexpect, ex:
## SSL telnet is part of the fencing package
sys.stderr.write(str(ex) + "\n")
@@ -891,7 +891,7 @@ def fence_login(options):
if options.has_key("ssh_options"):
command += ' ' + options["ssh_options"]
try:
- conn = fspawn(command)
+ conn = fspawn(options, command)
except pexpect.ExceptionPexpect, ex:
sys.stderr.write(str(ex) + "\n")
sys.stderr.write("Due to limitations, binary dependencies on fence agents "
@@ -920,7 +920,7 @@ def fence_login(options):
if options.has_key("ssh_options"):
command += ' ' + options["ssh_options"]
try:
- conn = fspawn(command)
+ conn = fspawn(options, command)
except pexpect.ExceptionPexpect, ex:
sys.stderr.write(str(ex) + "\n")
sys.stderr.write("Due to limitations, binary dependencies on fence agents "
@@ -939,7 +939,7 @@ def fence_login(options):
fail_usage("Failed: You have to enter passphrase (-p) for identity file")
else:
try:
- conn = fspawn(TELNET_PATH)
+ conn = fspawn(options, TELNET_PATH)
conn.send("set binary\n")
conn.send("open %s -%s\n"%(options["-a"], options["-u"]))
except pexpect.ExceptionPexpect, ex:
@@ -948,11 +948,20 @@ def fence_login(options):
"are not in the spec file and must be installed separately." + "\n")
sys.exit(EC_GENERIC_ERROR)
- conn.log_expect(options, re_login, int(options["-y"]))
- conn.send(options["-l"] + login_eol)
- conn.log_expect(options, re_pass, int(options["-Y"]))
+ result = conn.log_expect(options, re_login, int(options["-y"]))
+ conn.send_eol(options["-l"])
+
+ ## automatically change end of line separator
+ screen = conn.read_nonblocking(size=100, timeout=int(options["-Y"]))
+ if (re_login.search(screen) != None):
+ options["eol"] = "\n"
+ conn.send_eol(options["-l"])
+ result = conn.log_expect(options, re_pass, int(options["-y"]))
+ elif (re_pass.search(screen) == None):
+ conn.log_expect(options, re_pass, int(options["-Y"]))
+
try:
- conn.send(options["-p"] + login_eol)
+ conn.send_eol(options["-p"])
conn.log_expect(options, options["-c"], int(options["-Y"]))
except KeyError:
fail(EC_PASSWORD_MISSING)
diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py
index 845bddb..e9f87cd 100644
--- a/fence/agents/rsa/fence_rsa.py
+++ b/fence/agents/rsa/fence_rsa.py
@@ -19,7 +19,7 @@ BUILD_DATE=""
def get_power_status(conn, options):
try:
- conn.send("power state\r\n")
+ conn.send_eol("power state")
conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
@@ -36,7 +36,7 @@ def get_power_status(conn, options):
def set_power_status(conn, options):
try:
- conn.send("power " + options["-o"] + "\r\n")
+ conn.send_eol("power " + options["-o"])
conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
@@ -84,7 +84,7 @@ will block any necessary fencing actions."
## Logout from system
######
try:
- conn.sendline("exit")
+ conn.send_eol("exit")
conn.close()
except exceptions.OSError:
pass
diff --git a/fence/agents/rsb/fence_rsb.py b/fence/agents/rsb/fence_rsb.py
index fe1ec60..7ce1906 100755
--- a/fence/agents/rsb/fence_rsb.py
+++ b/fence/agents/rsb/fence_rsb.py
@@ -33,13 +33,13 @@ def set_power_status(conn, options):
try:
conn.send("2")
conn.log_expect(options, options["-c"], int(options["-Y"]))
- conn.sendline(action)
+ conn.send_eol(action)
conn.log_expect(options, ["want to power off", "'yes' or 'no'"], int(options["-Y"]))
- conn.send("yes\r")
+ conn.send_eol("yes")
conn.log_expect(options, "any key to continue", int(options["-g"]))
- conn.send("\r")
+ conn.send_eol("")
conn.log_expect(options, options["-c"], int(options["-Y"]))
- conn.sendline("0")
+ conn.send_eol("0")
conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
@@ -100,7 +100,7 @@ will block any necessary fencing actions."
## a problem because everything is checked before.
######
try:
- conn.sendline("0")
+ conn.send_eol("0")
conn.close()
except exceptions.OSError:
pass
diff --git a/fence/agents/sanbox2/fence_sanbox2.py b/fence/agents/sanbox2/fence_sanbox2.py
index 47f3bc8..92c5d4a 100644
--- a/fence/agents/sanbox2/fence_sanbox2.py
+++ b/fence/agents/sanbox2/fence_sanbox2.py
@@ -24,14 +24,14 @@ def get_power_status(conn, options):
'offline' : "off"
}
try:
- conn.send("show port " + options["-n"] + "\n")
+ conn.send_eol("show port " + options["-n"])
conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
try:
- conn.send("admin end\n")
- conn.send("exit\n")
+ conn.send_eol("admin end")
+ conn.send_eol("exit")
conn.close()
except:
pass
@@ -51,28 +51,28 @@ def set_power_status(conn, options):
}[options["-o"]]
try:
- conn.send("set port " + options["-n"] + " state " + action + "\n")
+ conn.send_eol("set port " + options["-n"] + " state " + action)
conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
try:
- conn.send("admin end\n")
- conn.send("exit\n")
+ conn.send_eol("admin end")
+ conn.send_eol("exit")
conn.close()
except:
pass
fail(EC_TIMED_OUT)
try:
- conn.send("set port " + options["-n"] + " state " + action + "\n")
+ conn.send_eol("set port " + options["-n"] + " state " + action)
conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
try:
- conn.send("admin end\n")
- conn.send("exit\n")
+ conn.send_eol("admin end")
+ conn.send_eol("exit")
conn.close()
except:
pass
@@ -82,7 +82,7 @@ def get_list_devices(conn, options):
outlets = { }
try:
- conn.send("show port" + "\n")
+ conn.send_eol("show port")
conn.log_expect(options, options["-c"], int(options["-Y"]))
list_re = re.compile("^\s+(\d+?)\s+(Online|Offline)\s+", re.IGNORECASE)
@@ -98,8 +98,8 @@ def get_list_devices(conn, options):
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
try:
- conn.send("admin end\n")
- conn.send("exit\n")
+ conn.send_eol("admin end")
+ conn.send_eol("exit")
conn.close()
except:
pass
@@ -110,7 +110,7 @@ def get_list_devices(conn, options):
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"io_fencing", "ipaddr", "login", "passwd", "passwd_script",
- "cmd_prompt", "port", "ipport", "login_eol_lf", "separator",
+ "cmd_prompt", "port", "ipport", "separator",
"power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
@@ -138,7 +138,7 @@ because the connection will block any necessary fencing actions."
##
conn = fence_login(options)
- conn.send("admin start\n")
+ conn.send_eol("admin start")
conn.log_expect(options, options["-c"], int(options["-Y"]))
if (re.search("\(admin\)", conn.before, re.MULTILINE) == None):
@@ -153,8 +153,8 @@ because the connection will block any necessary fencing actions."
## Logout from system
######
try:
- conn.send("admin end\n")
- conn.send("exit\n")
+ conn.send_eol("admin end")
+ conn.send_eol("exit\n")
conn.close()
except exceptions.OSError:
pass
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 8caa4c2..b7c41f3 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -124,7 +124,7 @@ is running because the connection will block any necessary fencing actions."
if 0 == options.has_key("-x"):
try:
try:
- conn = fspawn(TELNET_PATH)
+ conn = fspawn(options, TELNET_PATH)
conn.send("set binary\n")
conn.send("open %s -%s\n"%(options["-a"], options["-u"]))
except pexpect.ExceptionPexpect, ex:
11 years, 11 months
fence-agents: master - fence agents: Fix unique attribute for agents which are not based on fencing library
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 87cbe09e06ce8a5fb578cffe21b3d2137d5f0e17
Parent: 0d93c7c45ae8ec446751b082819b5821b8861b90
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon May 21 10:16:02 2012 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon May 21 10:16:02 2012 +0200
fence agents: Fix unique attribute for agents which are not based on fencing library
Resolves: rhbz#822507
---
fence/agents/brocade/fence_brocade.pl | 14 +++++++-------
fence/agents/drac/fence_drac.pl | 22 +++++++++++-----------
fence/agents/egenera/fence_egenera.pl | 14 +++++++-------
fence/agents/kdump/fence_kdump.c | 16 ++++++++--------
fence/agents/scsi/fence_scsi.pl | 12 ++++++------
5 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/fence/agents/brocade/fence_brocade.pl b/fence/agents/brocade/fence_brocade.pl
index c820779..e3d1612 100644
--- a/fence/agents/brocade/fence_brocade.pl
+++ b/fence/agents/brocade/fence_brocade.pl
@@ -84,37 +84,37 @@ After a fence operation has taken place the fenced machine can no longer connec
</longdesc>
<vendor-url>http://www.brocade.com</vendor-url>
<parameters>
- <parameter name="action" unique="1" required="1">
+ <parameter name="action" unique="0" required="1">
<getopt mixed="-o <action>" />
<content type="string" default="disable" />
<shortdesc lang="en">Fencing Action</shortdesc>
</parameter>
- <parameter name="ipaddr" unique="1" required="1">
+ <parameter name="ipaddr" unique="0" required="1">
<getopt mixed="-a <ip>" />
<content type="string" />
<shortdesc lang="en">IP Address or Hostname</shortdesc>
</parameter>
- <parameter name="login" unique="1" required="1">
+ <parameter name="login" unique="0" required="1">
<getopt mixed="-l <name>" />
<content type="string" />
<shortdesc lang="en">Login Name</shortdesc>
</parameter>
- <parameter name="passwd" unique="1" required="0">
+ <parameter name="passwd" unique="0" required="0">
<getopt mixed="-p <password>" />
<content type="string" />
<shortdesc lang="en">Login password or passphrase</shortdesc>
</parameter>
- <parameter name="passwd_script" unique="1" required="0">
+ <parameter name="passwd_script" unique="0" required="0">
<getopt mixed="-S <script>" />
<content type="string" />
<shortdesc lang="en">Script to retrieve password</shortdesc>
</parameter>
- <parameter name="port" unique="1" required="1">
+ <parameter name="port" unique="0" required="1">
<getopt mixed="-n <id>" />
<content type="string" />
<shortdesc lang="en">Physical plug number or name of virtual machine</shortdesc>
</parameter>
- <parameter name="help" unique="1" required="0">
+ <parameter name="help" unique="0" required="0">
<getopt mixed="-h" />
<content type="string" />
<shortdesc lang="en">Display help and exit</shortdesc>
diff --git a/fence/agents/drac/fence_drac.pl b/fence/agents/drac/fence_drac.pl
index 5e1b966..825391f 100644
--- a/fence/agents/drac/fence_drac.pl
+++ b/fence/agents/drac/fence_drac.pl
@@ -143,57 +143,57 @@ fence_drac is an I/O Fencing agent which can be used with the Dell Remote Access
</longdesc>
<vendor-url>http://www.dell.com</vendor-url>
<parameters>
- <parameter name="action" unique="1" required="1">
+ <parameter name="action" unique="0" required="1">
<getopt mixed="-o <action>" />
<content type="string" default="reboot" />
<shortdesc lang="en">Fencing Action</shortdesc>
</parameter>
- <parameter name="ipaddr" unique="1" required="1">
+ <parameter name="ipaddr" unique="0" required="1">
<getopt mixed="-a <ip>" />
<content type="string" />
<shortdesc lang="en">IP Address or Hostname</shortdesc>
</parameter>
- <parameter name="login" unique="1" required="1">
+ <parameter name="login" unique="0" required="1">
<getopt mixed="-l <name>" />
<content type="string" />
<shortdesc lang="en">Login Name</shortdesc>
</parameter>
- <parameter name="passwd" unique="1" required="0">
+ <parameter name="passwd" unique="0" required="0">
<getopt mixed="-p <password>" />
<content type="string" />
<shortdesc lang="en">Login password or passphrase</shortdesc>
</parameter>
- <parameter name="passwd_script" unique="1" required="0">
+ <parameter name="passwd_script" unique="0" required="0">
<getopt mixed="-S <script>" />
<content type="string" />
<shortdesc lang="en">Script to retrieve password</shortdesc>
</parameter>
- <parameter name="cmd_prompt" unique="1" required="0">
+ <parameter name="cmd_prompt" unique="0" required="0">
<getopt mixed="-c <prompt>" />
<content type="string" />
<shortdesc lang="en">Force fence_drac to use cmd_prompt as the command prompt</shortdesc>
</parameter>
- <parameter name="drac_version" unique="1" required="0">
+ <parameter name="drac_version" unique="0" required="0">
<getopt mixed="-d <version>" />
<content type="string" />
<shortdesc lang="en">Force fence_drac to treat the device as though it was for the specified drac version</shortdesc>
</parameter>
- <parameter name="module_name" unique="1" required="0">
+ <parameter name="module_name" unique="0" required="0">
<getopt mixed="-m <modulename>" />
<content type="string"/>
<shortdesc lang="en">The module name of the blade when using DRAC/MC firmware.</shortdesc>
</parameter>
- <parameter name="debug" unique="1" required="0">
+ <parameter name="debug" unique="0" required="0">
<getopt mixed="-D <dumpfile>" />
<content type="string"/>
<shortdesc lang="en">Debug file of the telnet interaction</shortdesc>
</parameter>
- <parameter name="delay" unique="1" required="0">
+ <parameter name="delay" unique="0" required="0">
<getopt mixed="-f <seconds>" />
<content type="string" default="0"/>
<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
</parameter>
- <parameter name="help" unique="1" required="0">
+ <parameter name="help" unique="0" required="0">
<getopt mixed="-h" />
<content type="string" />
<shortdesc lang="en">Display help and exit</shortdesc>
diff --git a/fence/agents/egenera/fence_egenera.pl b/fence/agents/egenera/fence_egenera.pl
index 6270cee..30eaca1 100644
--- a/fence/agents/egenera/fence_egenera.pl
+++ b/fence/agents/egenera/fence_egenera.pl
@@ -83,37 +83,37 @@ fence_egenera is an I/O Fencing agent which can be used with the Egenera Blade
</longdesc>
<vendor-url>http://www.bull.com</vendor-url>
<parameters>
- <parameter name="action" unique="1" required="1">
+ <parameter name="action" unique="0" required="1">
<getopt mixed="-o <action>" />
<content type="string" default="reboot" />
<shortdesc lang="en">Fencing Action</shortdesc>
</parameter>
- <parameter name="cserver" unique="1" required="1">
+ <parameter name="cserver" unique="0" required="1">
<getopt mixed="-c <cserver>" />
<content type="string" />
<shortdesc lang="en">The cserver to ssh to. cserver can be in the form user@hostname to specify a different user to login as.</shortdesc>
</parameter>
- <parameter name="pserver" unique="1" required="1">
+ <parameter name="pserver" unique="0" required="1">
<getopt mixed="-p <pserver>" />
<content type="string" />
<shortdesc lang="en">The pserver to operate on.</shortdesc>
</parameter>
- <parameter name="user" unique="1" required="1">
+ <parameter name="user" unique="0" required="1">
<getopt mixed="-u <name>" />
<content type="string" default="root" />
<shortdesc lang="en">Login Name</shortdesc>
</parameter>
- <parameter name="lpan" unique="1" required="1">
+ <parameter name="lpan" unique="0" required="1">
<getopt mixed="-l <lpan>" />
<content type="string" />
<shortdesc lang="en">The lpan to operate on.</shortdesc>
</parameter>
- <parameter name="delay" unique="1" required="0">
+ <parameter name="delay" unique="0" required="0">
<getopt mixed="-f <seconds>" />
<content type="string" default="0"/>
<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
</parameter>
- <parameter name="help" unique="1" required="0">
+ <parameter name="help" unique="0" required="0">
<getopt mixed="-h" />
<content type="string" />
<shortdesc lang="en">Display help and exit</shortdesc>
diff --git a/fence/agents/kdump/fence_kdump.c b/fence/agents/kdump/fence_kdump.c
index e224db3..fa1f6a4 100644
--- a/fence/agents/kdump/fence_kdump.c
+++ b/fence/agents/kdump/fence_kdump.c
@@ -181,56 +181,56 @@ do_action_metadata (const char *self)
fprintf (stdout, "<parameters>\n");
- fprintf (stdout, "\t<parameter name=\"nodename\" unique=\"1\" required=\"0\">\n");
+ fprintf (stdout, "\t<parameter name=\"nodename\" unique=\"0\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-n, --nodename\" />\n");
fprintf (stdout, "\t\t<content type=\"string\" />\n");
fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
"Name or IP address of node to be fenced");
fprintf (stdout, "\t</parameter>\n");
- fprintf (stdout, "\t<parameter name=\"ipport\" unique=\"1\" required=\"0\">\n");
+ fprintf (stdout, "\t<parameter name=\"ipport\" unique=\"0\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-p, --ipport\" />\n");
fprintf (stdout, "\t\t<content type=\"string\" default=\"7410\" />\n");
fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
"Port number");
fprintf (stdout, "\t</parameter>\n");
- fprintf (stdout, "\t<parameter name=\"family\" unique=\"1\" required=\"0\">\n");
+ fprintf (stdout, "\t<parameter name=\"family\" unique=\"0\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-f, --family\" />\n");
fprintf (stdout, "\t\t<content type=\"string\" default=\"auto\" />\n");
fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
"Network family");
fprintf (stdout, "\t</parameter>\n");
- fprintf (stdout, "\t<parameter name=\"action\" unique=\"1\" required=\"0\">\n");
+ fprintf (stdout, "\t<parameter name=\"action\" unique=\"0\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-o, --action\" />\n");
fprintf (stdout, "\t\t<content type=\"string\" default=\"off\" />\n");
fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
"Fencing action");
fprintf (stdout, "\t</parameter>\n");
- fprintf (stdout, "\t<parameter name=\"timeout\" unique=\"1\" required=\"0\">\n");
+ fprintf (stdout, "\t<parameter name=\"timeout\" unique=\"0\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-t, --timeout\" />\n");
fprintf (stdout, "\t\t<content type=\"string\" default=\"60\" />\n");
fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
"Timeout in seconds");
fprintf (stdout, "\t</parameter>\n");
- fprintf (stdout, "\t<parameter name=\"verbose\" unique=\"1\" required=\"0\">\n");
+ fprintf (stdout, "\t<parameter name=\"verbose\" unique=\"0\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-v, --verbose\" />\n");
fprintf (stdout, "\t\t<content type=\"boolean\" />\n");
fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
"Print verbose output");
fprintf (stdout, "\t</parameter>\n");
- fprintf (stdout, "\t<parameter name=\"version\" unique=\"1\" required=\"0\">\n");
+ fprintf (stdout, "\t<parameter name=\"version\" unique=\"0\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-V, --version\" />\n");
fprintf (stdout, "\t\t<content type=\"boolean\" />\n");
fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
"Print version");
fprintf (stdout, "\t</parameter>\n");
- fprintf (stdout, "\t<parameter name=\"usage\" unique=\"1\" required=\"0\">\n");
+ fprintf (stdout, "\t<parameter name=\"usage\" unique=\"0\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-h, --help\" />\n");
fprintf (stdout, "\t\t<content type=\"boolean\" />\n");
fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
diff --git a/fence/agents/scsi/fence_scsi.pl b/fence/agents/scsi/fence_scsi.pl
index 87a599c..ef7d14d 100644
--- a/fence/agents/scsi/fence_scsi.pl
+++ b/fence/agents/scsi/fence_scsi.pl
@@ -702,42 +702,42 @@ sub print_metadata ()
" shortdesc=\"fence agent for SCSI-3 persistent reservations\">\n";
print "<longdesc>fence_scsi</longdesc>\n";
print "<parameters>\n";
- print "\t<parameter name=\"aptpl\" unique=\"1\" required=\"0\">\n";
+ print "\t<parameter name=\"aptpl\" unique=\"0\" required=\"0\">\n";
print "\t\t<getopt mixed=\"-a\"/>\n";
print "\t\t<content type=\"boolean\"/>\n";
print "\t\t<shortdesc lang=\"en\">" .
"Use APTPL flag for registrations" .
"</shortdesc>\n";
print "\t</parameter>\n";
- print "\t<parameter name=\"devices\" unique=\"1\" required=\"0\">\n";
+ print "\t<parameter name=\"devices\" unique=\"0\" required=\"0\">\n";
print "\t\t<getopt mixed=\"-d\"/>\n";
print "\t\t<content type=\"string\"/>\n";
print "\t\t<shortdesc lang=\"en\">" .
"List of devices to be used for fencing action" .
"</shortdesc>\n";
print "\t</parameter>\n";
- print "\t<parameter name=\"logfile\" unique=\"1\" required=\"0\">\n";
+ print "\t<parameter name=\"logfile\" unique=\"0\" required=\"0\">\n";
print "\t\t<getopt mixed=\"-f\"/>\n";
print "\t\t<content type=\"string\"/>\n";
print "\t\t<shortdesc lang=\"en\">" .
"File to write error/debug messages" .
"</shortdesc>\n";
print "\t</parameter>\n";
- print "\t<parameter name=\"key\" unique=\"1\" required=\"0\">\n";
+ print "\t<parameter name=\"key\" unique=\"0\" required=\"0\">\n";
print "\t\t<getopt mixed=\"-k\"/>\n";
print "\t\t<content type=\"string\"/>\n";
print "\t\t<shortdesc lang=\"en\">" .
"Key value to be used for fencing action" .
"</shortdesc>\n";
print "\t</parameter>\n";
- print "\t<parameter name=\"action\" unique=\"1\" required=\"0\">\n";
+ print "\t<parameter name=\"action\" unique=\"0\" required=\"0\">\n";
print "\t\t<getopt mixed=\"-o\"/>\n";
print "\t\t<content type=\"string\" default=\"off\"/>\n";
print "\t\t<shortdesc lang=\"en\">" .
"Fencing action" .
"</shortdesc>\n";
print "\t</parameter>\n";
- print "\t<parameter name=\"nodename\" unique=\"1\" required=\"0\">\n";
+ print "\t<parameter name=\"nodename\" unique=\"0\" required=\"0\">\n";
print "\t\t<getopt mixed=\"-n\"/>\n";
print "\t\t<content type=\"string\"/>\n";
print "\t\t<shortdesc lang=\"en\">" .
11 years, 11 months
cluster: STABLE32 - rgmanager: Fix a crash when dbus notifications are enabled
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 8f73b914907ad17d41be3b849cd936f77e8a6248
Parent: fda037ad25a058d0fe2a61b6972a5663276d1005
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Fri May 18 07:30:31 2012 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Fri May 18 07:30:31 2012 -0400
rgmanager: Fix a crash when dbus notifications are enabled
dbus doesn't lock internal data unless dbus_threads_init
is called.
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/daemons/update-dbus.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/rgmanager/src/daemons/update-dbus.c b/rgmanager/src/daemons/update-dbus.c
index e706746..474140e 100644
--- a/rgmanager/src/daemons/update-dbus.c
+++ b/rgmanager/src/daemons/update-dbus.c
@@ -69,6 +69,7 @@ rgm_dbus_init(void)
return 0;
}
+ dbus_threads_init_default();
dbus_error_init(&err);
dbc = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
11 years, 11 months
dlm: master - dlm_tool status: format
by David Teigland
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: cd549713be75a7539e5c5ba3584b5b2796bfb652
Parent: cef3fc9b1c8096a18d61166abb9e5e0eb2fdc1d7
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu May 17 12:00:53 2012 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu May 17 15:16:04 2012 -0500
dlm_tool status: format
format the output to be more readable
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/daemon_cpg.c | 10 +-
dlm_controld/lib.c | 221 ++++++++++++++++++++++++++++++++++++++++-
dlm_controld/libdlmcontrol.h | 2 +
dlm_tool/main.c | 2 +-
4 files changed, 224 insertions(+), 11 deletions(-)
diff --git a/dlm_controld/daemon_cpg.c b/dlm_controld/daemon_cpg.c
index 3ee5f7b..fee0ef6 100644
--- a/dlm_controld/daemon_cpg.c
+++ b/dlm_controld/daemon_cpg.c
@@ -2053,7 +2053,7 @@ static int print_state_daemon_node(struct node_daemon *node, char *str)
snprintf(str, DLMC_STATE_MAXSTR-1,
"member=%d "
"killed=%d "
- "left_reason=%d "
+ "left_reason=%s "
"need_fencing=%d "
"delay_fencing=%d "
"fence_pid=%d "
@@ -2069,7 +2069,7 @@ static int print_state_daemon_node(struct node_daemon *node, char *str)
"fence_monotime=%llu ",
node->daemon_member,
node->killed,
- node->left_reason,
+ reason_str(node->left_reason),
node->need_fencing,
node->delay_fencing,
node->fence_pid,
@@ -2121,7 +2121,8 @@ static int print_state_daemon(char *str)
"quorate=%d "
"fence_pid=%d "
"fence_in_progress_unknown=%d "
- "zombie_count=%d ",
+ "zombie_count=%d "
+ "monotime=%llu ",
daemon_member_count,
daemon_joined_count,
daemon_remove_count,
@@ -2130,7 +2131,8 @@ static int print_state_daemon(char *str)
cluster_quorate,
daemon_fence_pid,
fence_in_progress_unknown,
- zombie_count);
+ zombie_count,
+ (unsigned long long)monotime());
return strlen(str) + 1;
}
diff --git a/dlm_controld/lib.c b/dlm_controld/lib.c
index d1d3a23..1b78407 100644
--- a/dlm_controld/lib.c
+++ b/dlm_controld/lib.c
@@ -11,6 +11,7 @@
#include <unistd.h>
#include <stdint.h>
#include <errno.h>
+#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -157,6 +158,14 @@ int dlmc_dump_plocks(char *name, char *buf)
return do_dump(DLMC_CMD_DUMP_PLOCKS, name, buf);
}
+static int nodeid_compare(const void *va, const void *vb)
+{
+ const int *a = va;
+ const int *b = vb;
+
+ return *a - *b;
+}
+
static void print_str(char *str, int len)
{
char *p;
@@ -175,18 +184,143 @@ static void print_str(char *str, int len)
printf(" %s\n", p);
}
+static unsigned int kv(char *str, const char *k)
+{
+ char valstr[64];
+ char *p;
+ int i;
+
+ p = strstr(str, k);
+ if (!p)
+ return 0;
+
+ p = strstr(p, "=") + 1;
+ if (!p)
+ return 0;
+
+ memset(valstr, 0, 64);
+
+ for (i = 0; i < 64; i++) {
+ if (*p == ' ')
+ break;
+ if (*p == '\0')
+ break;
+ if (*p == '\n')
+ break;
+ valstr[i] = *p;
+ p++;
+ }
+
+ return (unsigned int)strtoul(valstr, NULL, 0);
+}
+
+static char *ks(char *str, const char *k)
+{
+ static char valstr[64];
+ char *p;
+ int i;
+
+ p = strstr(str, k);
+ if (!p)
+ return 0;
+
+ p = strstr(p, "=") + 1;
+ if (!p)
+ return 0;
+
+ memset(valstr, 0, 64);
+
+ for (i = 0; i < 64; i++) {
+ if (*p == ' ')
+ break;
+ if (*p == '\0')
+ break;
+ if (*p == '\n')
+ break;
+ valstr[i] = *p;
+ p++;
+ }
+
+ return valstr;
+}
+
static void print_daemon(struct dlmc_state *st, char *str, char *bin, uint32_t flags)
{
- printf("our_nodeid %d\n", st->nodeid);
- print_str(str, st->str_len);
+ unsigned int cluster_ringid, daemon_ringid;
+ unsigned int fipu;
+
+ if (flags & DLMC_STATUS_VERBOSE) {
+ printf("our_nodeid %d\n", st->nodeid);
+ print_str(str, st->str_len);
+ return;
+ }
+
+ cluster_ringid = kv(str, "cluster_ringid");
+ daemon_ringid = kv(str, "daemon_ringid");
+
+ printf("cluster nodeid %d quorate %u ring seq %u %u\n",
+ st->nodeid,
+ kv(str, "quorate"),
+ cluster_ringid, daemon_ringid);
+
+ fipu = kv(str, "fence_in_progress_unknown");
+
+ printf("daemon now %u fence_pid %u %s\n",
+ kv(str, "monotime"),
+ kv(str, "fence_pid"),
+ fipu ? "fence_init" : "");
}
-static void print_daemon_node(struct dlmc_state *st, char *str, char *bin, uint32_t flags)
+static void format_daemon_node(struct dlmc_state *st, char *str, char *bin, uint32_t flags,
+ char *node_line, char *fence_line)
{
- printf("nodeid %d\n", st->nodeid);
- print_str(str, st->str_len);
+ unsigned int delay_fencing, result_wait, killed;
+
+ snprintf(node_line, DLMC_STATE_MAXSTR - 1,
+ "node %d %c add %u rem %u fail %u fence %u at %u %u\n",
+ st->nodeid,
+ kv(str, "member") ? 'M' : 'X',
+ kv(str, "add_time"),
+ kv(str, "rem_time"),
+ kv(str, "fail_monotime"),
+ kv(str, "fence_monotime"),
+ kv(str, "actor_done"),
+ kv(str, "fence_walltime"));
+
+ if (!kv(str, "need_fencing"))
+ return;
+
+ delay_fencing = kv(str, "delay_fencing");
+ result_wait = kv(str, "fence_result_wait");
+ killed = kv(str, "killed");
+
+ if (delay_fencing)
+ snprintf(fence_line, DLMC_STATE_MAXSTR - 1,
+ "fence %d %s delay actor %u fail %u fence %u now %u%s%s\n",
+ st->nodeid,
+ ks(str, "left_reason"),
+ kv(str, "actor_last"),
+ kv(str, "fail_walltime"),
+ kv(str, "fence_walltime"),
+ (unsigned int)time(NULL),
+ result_wait ? " result_wait" : "",
+ killed ? " killed" : "");
+ else
+ snprintf(fence_line, DLMC_STATE_MAXSTR - 1,
+ "fence %d %s pid %d actor %u fail %u fence %u now %u%s%s\n",
+ st->nodeid,
+ ks(str, "left_reason"),
+ kv(str, "fence_pid"),
+ kv(str, "actor_last"),
+ kv(str, "fail_walltime"),
+ kv(str, "fence_walltime"),
+ (unsigned int)time(NULL),
+ result_wait ? " result_wait" : "",
+ killed ? " killed" : "");
}
+#define MAX_SORT 64
+
int dlmc_print_status(uint32_t flags)
{
struct dlmc_header h;
@@ -195,7 +329,12 @@ int dlmc_print_status(uint32_t flags)
char maxstr[DLMC_STATE_MAXSTR];
char maxbin[DLMC_STATE_MAXBIN];
char *str, *bin;
+ int all_count, node_count, fence_count;
+ int all_ids[MAX_SORT], node_ids[MAX_SORT], fence_ids[MAX_SORT];
+ char *node_lines[MAX_SORT], *fence_lines[MAX_SORT];
+ char *node_line, *fence_line;
int fd, rv, off;
+ int i, j;
init_header(&h, DLMC_CMD_DUMP_STATUS, NULL, 0);
@@ -217,6 +356,15 @@ int dlmc_print_status(uint32_t flags)
bin = maxbin;
off = 0;
+ all_count = 0;
+ node_count = 0;
+ fence_count = 0;
+ memset(&all_ids, 0, sizeof(all_ids));
+ memset(&node_ids, 0, sizeof(node_ids));
+ memset(&fence_ids, 0, sizeof(fence_ids));
+ memset(node_lines, 0, sizeof(node_lines));
+ memset(fence_lines, 0, sizeof(fence_lines));
+
while (1) {
memset(&state, 0, sizeof(state));
memset(maxstr, 0, sizeof(maxstr));
@@ -244,9 +392,43 @@ int dlmc_print_status(uint32_t flags)
case DLMC_STATE_DAEMON:
print_daemon(st, str, bin, flags);
break;
+
case DLMC_STATE_DAEMON_NODE:
- print_daemon_node(st, str, bin, flags);
+
+ if (flags & DLMC_STATUS_VERBOSE) {
+ printf("nodeid %d\n", st->nodeid);
+ print_str(str, st->str_len);
+ } else {
+ node_line = malloc(DLMC_STATE_MAXSTR);
+ if (!node_line)
+ break;
+ fence_line = malloc(DLMC_STATE_MAXSTR);
+ if (!fence_line) {
+ free(node_line);
+ break;
+ }
+ memset(node_line, 0, DLMC_STATE_MAXSTR);
+ memset(fence_line, 0, DLMC_STATE_MAXSTR);
+
+ format_daemon_node(st, str, bin, flags,
+ node_line, fence_line);
+
+ all_ids[all_count++] = st->nodeid;
+
+ node_ids[node_count] = st->nodeid;
+ node_lines[node_count++] = node_line;
+ node_count++;
+
+ if (!fence_line[0]) {
+ free(fence_line);
+ } else {
+ fence_ids[fence_count] = st->nodeid;
+ fence_lines[fence_count] = fence_line;
+ fence_count++;
+ }
+ }
break;
+
default:
break;
}
@@ -255,6 +437,33 @@ int dlmc_print_status(uint32_t flags)
break;
}
+ if (all_count)
+ qsort(all_ids, all_count, sizeof(int), nodeid_compare);
+
+ if (all_count && fence_count) {
+ for (i = 0; i < all_count; i++) {
+ for (j = 0; j < fence_count; j++) {
+ if (all_ids[i] != fence_ids[j])
+ continue;
+ printf("%s", fence_lines[j]);
+ free(fence_lines[j]);
+ break;
+ }
+ }
+ }
+
+ if (all_count && node_count) {
+ for (i = 0; i < all_count; i++) {
+ for (j = 0; j < node_count; j++) {
+ if (all_ids[i] != node_ids[j])
+ continue;
+ printf("%s", node_lines[j]);
+ free(node_lines[j]);
+ break;
+ }
+ }
+ }
+
out_close:
close(fd);
out:
diff --git a/dlm_controld/libdlmcontrol.h b/dlm_controld/libdlmcontrol.h
index 068fe4e..8b504f7 100644
--- a/dlm_controld/libdlmcontrol.h
+++ b/dlm_controld/libdlmcontrol.h
@@ -78,6 +78,8 @@ struct dlmc_lockspace {
#define DLMC_NODES_MEMBERS 2
#define DLMC_NODES_NEXT 3
+#define DLMC_STATUS_VERBOSE 0x00000001
+
int dlmc_dump_debug(char *buf);
int dlmc_dump_config(char *buf);
int dlmc_dump_log_plock(char *buf);
diff --git a/dlm_tool/main.c b/dlm_tool/main.c
index bcaf8e4..608ee49 100644
--- a/dlm_tool/main.c
+++ b/dlm_tool/main.c
@@ -1424,7 +1424,7 @@ int main(int argc, char **argv)
break;
case OP_STATUS:
- dlmc_print_status(0);
+ dlmc_print_status(verbose ? DLMC_STATUS_VERBOSE : 0);
break;
case OP_DUMP:
11 years, 11 months
dlm: master - build: add gdb debuging sections to binaries
by David Teigland
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: bc586574bd252be678506cde92629c86b8f17fa8
Parent: 55971844663d6513ddcd0103425070d6583f6a63
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue May 15 08:55:32 2012 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Tue May 15 08:55:32 2012 +0200
build: add gdb debuging sections to binaries
dlm is very linux specific, might as well use gcc gdb extensions
to make debugging easier.
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
dlm_controld/Makefile | 2 +-
dlm_tool/Makefile | 2 +-
fence/Makefile | 2 +-
libdlm/Makefile | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index 413bf89..d279b0d 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -29,7 +29,7 @@ BIN_SOURCE = action.c \
rbtree.c
LIB_SOURCE = lib.c
-BIN_CFLAGS += -D_GNU_SOURCE -O2 -g \
+BIN_CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-Wall \
-Wformat \
-Wformat-security \
diff --git a/dlm_tool/Makefile b/dlm_tool/Makefile
index 17e16a6..fe43677 100644
--- a/dlm_tool/Makefile
+++ b/dlm_tool/Makefile
@@ -8,7 +8,7 @@ MAN_TARGET = dlm_tool.8
BIN_SOURCE = main.c
-BIN_CFLAGS += -D_GNU_SOURCE -O2 -g \
+BIN_CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-Wall \
-Wformat \
-Wformat-security \
diff --git a/fence/Makefile b/fence/Makefile
index b10233e..0f1a29c 100644
--- a/fence/Makefile
+++ b/fence/Makefile
@@ -8,7 +8,7 @@ BIN_TARGET = dlm_stonith
BIN_SOURCE = stonith_helper.c
-BIN_CFLAGS += -D_GNU_SOURCE -O2 -g \
+BIN_CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-Wall \
-Wformat \
-Wformat-security \
diff --git a/libdlm/Makefile b/libdlm/Makefile
index 01b2036..565a600 100644
--- a/libdlm/Makefile
+++ b/libdlm/Makefile
@@ -55,7 +55,7 @@ UDEV_TARGET = 51-dlm.rules
SOURCE = libdlm.c
-CFLAGS += -D_GNU_SOURCE -O2 -g \
+CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-Wall \
-Wformat \
-Wformat-security \
11 years, 11 months
dlm: master - dlm_controld: retry connection to corosync if we get a EAGAIN
by David Teigland
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: cef3fc9b1c8096a18d61166abb9e5e0eb2fdc1d7
Parent: bc586574bd252be678506cde92629c86b8f17fa8
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue May 15 09:11:34 2012 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Tue May 15 09:11:34 2012 +0200
dlm_controld: retry connection to corosync if we get a EAGAIN
this change is necessary only at the first api_initialize call to corosync.
corosync 2.0 returns
- CS_ERR_LIBRARY (2) when corosync is not running
- CS_ERR_TRY_AGAIN (6) when corosync has started but it's not ready
to provide services yet (IPC will refuse connections)
- CS_OK once it's ready or other errors for failures.
Resolves: rhbz#816200
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
dlm_controld/member.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/dlm_controld/member.c b/dlm_controld/member.c
index ecdfabc..d195ab1 100644
--- a/dlm_controld/member.c
+++ b/dlm_controld/member.c
@@ -11,6 +11,7 @@
#include <corosync/cfg.h>
#include <corosync/cmap.h>
#include <corosync/quorum.h>
+#include <errno.h>
static corosync_cfg_handle_t ch;
static quorum_handle_t qh;
@@ -295,9 +296,17 @@ int setup_cluster_cfg(void)
cs_error_t err;
unsigned int nodeid;
int fd;
+ int retry = 1;
+try_again:
err = corosync_cfg_initialize(&ch, &cfg_callbacks);
if (err != CS_OK) {
+ if ((err == CS_ERR_TRY_AGAIN) && (retry <= 10)) {
+ log_error("corosync has not completed initialization.. retry %d", retry);
+ sleep(1);
+ retry++;
+ goto try_again;
+ }
log_error("corosync cfg init error %d", err);
return -1;
}
11 years, 11 months
dlm: master - build: fix another build warning
by David Teigland
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 55971844663d6513ddcd0103425070d6583f6a63
Parent: 88a470605770e34515c82ba65cea5dc269b4664f
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue May 15 08:53:35 2012 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Tue May 15 08:53:35 2012 +0200
build: fix another build warning
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
fence/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/Makefile b/fence/Makefile
index 41af463..b10233e 100644
--- a/fence/Makefile
+++ b/fence/Makefile
@@ -8,7 +8,7 @@ BIN_TARGET = dlm_stonith
BIN_SOURCE = stonith_helper.c
-BIN_CFLAGS += -D_GNU_SOURCE -g \
+BIN_CFLAGS += -D_GNU_SOURCE -O2 -g \
-Wall \
-Wformat \
-Wformat-security \
11 years, 11 months
dlm: master - build: fix fortify build warning
by David Teigland
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 88a470605770e34515c82ba65cea5dc269b4664f
Parent: b9482faa728fe5b995b2352fb7c23c1e09cada58
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue May 15 08:52:09 2012 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Tue May 15 08:52:09 2012 +0200
build: fix fortify build warning
In file included from /usr/include/sys/types.h:26:0,
from dlm_daemon.h:13,
from plock.c:9:
/usr/include/features.h:314:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
it is still a good idea to build with -O2 for performance.
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
dlm_controld/Makefile | 2 +-
dlm_tool/Makefile | 2 +-
libdlm/Makefile | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index 2d46c35..413bf89 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -29,7 +29,7 @@ BIN_SOURCE = action.c \
rbtree.c
LIB_SOURCE = lib.c
-BIN_CFLAGS += -D_GNU_SOURCE -g \
+BIN_CFLAGS += -D_GNU_SOURCE -O2 -g \
-Wall \
-Wformat \
-Wformat-security \
diff --git a/dlm_tool/Makefile b/dlm_tool/Makefile
index 0f142ff..17e16a6 100644
--- a/dlm_tool/Makefile
+++ b/dlm_tool/Makefile
@@ -8,7 +8,7 @@ MAN_TARGET = dlm_tool.8
BIN_SOURCE = main.c
-BIN_CFLAGS += -D_GNU_SOURCE -g \
+BIN_CFLAGS += -D_GNU_SOURCE -O2 -g \
-Wall \
-Wformat \
-Wformat-security \
diff --git a/libdlm/Makefile b/libdlm/Makefile
index 5fa6195..01b2036 100644
--- a/libdlm/Makefile
+++ b/libdlm/Makefile
@@ -55,7 +55,7 @@ UDEV_TARGET = 51-dlm.rules
SOURCE = libdlm.c
-CFLAGS += -D_GNU_SOURCE -g \
+CFLAGS += -D_GNU_SOURCE -O2 -g \
-Wall \
-Wformat \
-Wformat-security \
@@ -75,7 +75,7 @@ CFLAGS += -D_GNU_SOURCE -g \
-fexceptions \
-fasynchronous-unwind-tables \
-fdiagnostics-show-option \
- -fPIC \
+ -fPIC
LIB_CFLAGS += $(CFLAGS) -D_REENTRANT
LLT_CFLAGS += $(CFLAGS)
11 years, 11 months
dlm: master - dlm: add missing include
by David Teigland
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: b9482faa728fe5b995b2352fb7c23c1e09cada58
Parent: 213749ea11fd9ed2fabb998d710d83cc69aebf8b
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue May 15 08:46:30 2012 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Tue May 15 08:46:30 2012 +0200
dlm: add missing include
this is probably a toolchain/header regression in rawhide,
but it doesn't hurt and we can keep moving forward.
Resolves: rhbz#816218
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
dlm_controld/rbtree.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/dlm_controld/rbtree.c b/dlm_controld/rbtree.c
index a1d78e7..9f49917 100644
--- a/dlm_controld/rbtree.c
+++ b/dlm_controld/rbtree.c
@@ -20,6 +20,7 @@
linux/lib/rbtree.c
*/
+#include <stdlib.h>
#include "rbtree.h"
static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
11 years, 11 months
cluster: STABLE32 - cman init: add extra documentation for FENCE_JOIN=""
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: fda037ad25a058d0fe2a61b6972a5663276d1005
Parent: 10ebf6e26eff7fd21ac245cac9876ef62ae049ca
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue May 15 16:37:13 2012 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Tue May 15 16:37:13 2012 +0200
cman init: add extra documentation for FENCE_JOIN=""
Related: rhbz#821016
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/init.d/cman.in | 3 +++
cman/init.d/cman.init.defaults.in | 3 +++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/cman/init.d/cman.in b/cman/init.d/cman.in
index dddfe6e..95323b4 100644
--- a/cman/init.d/cman.in
+++ b/cman/init.d/cman.in
@@ -135,6 +135,9 @@ fi
# set to "yes", then the script will attempt to join the fence domain.
# If FENCE_JOIN is set to any other value, the default behavior is
# to join the fence domain (equivalent to "yes").
+# When setting FENCE_JOIN to "no", it is important to check
+# DLM_CONTROLD_OPTS to reflect expected behavior regarding fencing
+# and quorum.
[ -z "$FENCE_JOIN" ] && FENCE_JOIN="yes"
# FENCED_OPTS -- allow extra options to be passed to fence daemon.
diff --git a/cman/init.d/cman.init.defaults.in b/cman/init.d/cman.init.defaults.in
index adde8d9..b981bab 100644
--- a/cman/init.d/cman.init.defaults.in
+++ b/cman/init.d/cman.init.defaults.in
@@ -58,6 +58,9 @@
# set to "yes", then the script will attempt to join the fence domain.
# If FENCE_JOIN is set to any other value, the default behavior is
# to join the fence domain (equivalent to "yes").
+# When setting FENCE_JOIN to "no", it is important to check
+# DLM_CONTROLD_OPTS to reflect expected behavior regarding fencing
+# and quorum.
#FENCE_JOIN="yes"
# FENCED_OPTS -- allow extra options to be passed to fence daemon.
11 years, 11 months