cluster: STABLE3 - fencing: Timeout options added
Marek Grác
marx at fedoraproject.org
Fri Oct 9 11:44:00 UTC 2009
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=830d6fdf94593513d8c569afbb3f097ef73a1d98
Commit: 830d6fdf94593513d8c569afbb3f097ef73a1d98
Parent: 9de7fcd3dbefbfe56a317dc6fe94836fae9850da
Author: Marek 'marx' Grac <mgrac at redhat.com>
AuthorDate: Fri Oct 9 13:42:39 2009 +0200
Committer: Marek 'marx' Grac <mgrac at redhat.com>
CommitterDate: Fri Oct 9 13:42:39 2009 +0200
fencing: Timeout options added
Fencing agents based on fencing library have new set of timeout options.
Please read http://sources.redhat.com/cluster/wiki/FenceTiming for more
information.
---
fence/agents/alom/fence_alom.py | 9 ++--
fence/agents/apc/fence_apc.py | 37 +++++++-------
fence/agents/apc_snmp/fence_apc_snmp.py | 3 +-
fence/agents/bladecenter/fence_bladecenter.py | 28 +++++------
fence/agents/cisco_mds/fence_cisco_mds.py | 3 +-
fence/agents/drac5/fence_drac5.py | 9 ++--
fence/agents/ibmblade/fence_ibmblade.py | 3 +-
fence/agents/ifmib/fence_ifmib.py | 3 +-
fence/agents/ilo/fence_ilo.py | 13 +++--
fence/agents/ilo_mp/fence_ilo_mp.py | 5 +-
fence/agents/intelmodular/fence_intelmodular.py | 3 +-
fence/agents/ldom/fence_ldom.py | 11 ++--
fence/agents/lib/fencing.py.py | 60 ++++++++++++++++-------
fence/agents/lib/fencing_snmp.py.py | 2 +-
fence/agents/lpar/fence_lpar.py | 15 +++---
fence/agents/rsa/fence_rsa.py | 7 ++-
fence/agents/sanbox2/fence_sanbox2.py | 13 +++--
fence/agents/virsh/fence_virsh.py | 7 ++-
fence/agents/vmware/fence_vmware.py | 9 ++--
fence/agents/wti/fence_wti.py | 13 +++--
20 files changed, 147 insertions(+), 106 deletions(-)
diff --git a/fence/agents/alom/fence_alom.py b/fence/agents/alom/fence_alom.py
index d88f718..4fffa0a 100644
--- a/fence/agents/alom/fence_alom.py
+++ b/fence/agents/alom/fence_alom.py
@@ -19,7 +19,7 @@ def get_power_status(conn, options):
result = ""
try:
conn.sendline("showplatform")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
status = re.search("standby",conn.before.lower())
result=(status!=None and "off" or "on")
except pexpect.EOF:
@@ -33,9 +33,9 @@ def set_power_status(conn, options):
try:
cmd_line=(options["-o"]=="on" and "poweron" or "poweroff -f -y")
conn.sendline(cmd_line)
- conn.log_expect(options, options["-c"],POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"],int(options["-g"]))
#Get the machine some time between poweron and poweroff
- time.sleep(POWER_TIMEOUT)
+ time.sleep(int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
@@ -45,7 +45,8 @@ def set_power_status(conn, options):
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
- "secure", "test", "inet4_only", "inet6_only", "ipport" ]
+ "secure", "test", "inet4_only", "inet6_only", "ipport",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index a48877e..685a154 100755
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -29,7 +29,7 @@ def get_power_status(conn, options):
outlets = {}
try:
conn.send("1\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
version = 0
admin = 0
@@ -62,13 +62,13 @@ def get_power_status(conn, options):
conn.send("3\r\n")
else:
conn.send("2\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
conn.send("1\r\n")
else:
conn.send(options["-s"]+"\r\n")
while True:
- exp_result = conn.log_expect(options, [ options["-c"], "Press <ENTER>" ], SHELL_TIMEOUT)
+ exp_result = conn.log_expect(options, [ options["-c"], "Press <ENTER>" ], int(options["-Y"]))
lines = conn.before.split("\n");
show_re = re.compile('^\s*(\d+)- (.*?)\s+(ON|OFF)\s*')
for x in lines:
@@ -79,8 +79,8 @@ def get_power_status(conn, options):
if exp_result == 0:
break
conn.send(chr(03))
- conn.log_expect(options, "- Logout", SHELL_TIMEOUT)
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, "- Logout", int(options["-Y"]))
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -103,7 +103,7 @@ def set_power_status(conn, options):
try:
conn.send("1\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
version = 0
admin2 = 0
@@ -142,7 +142,7 @@ def set_power_status(conn, options):
conn.send("3\r\n")
else:
conn.send("2\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ 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:
@@ -151,31 +151,31 @@ def set_power_status(conn, options):
else:
conn.send(options["-s"] + "\r\n")
- while 1 == conn.log_expect(options, [ options["-c"], "Press <ENTER>" ], SHELL_TIMEOUT):
+ while 1 == conn.log_expect(options, [ options["-c"], "Press <ENTER>" ], int(options["-Y"])):
conn.send("\r\n")
conn.send(options["-n"]+"\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
if switch == 0:
if admin2 == 1:
conn.send("1\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
if admin3 == 1:
conn.send("1\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
else:
conn.send("1\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
conn.send(action+"\r\n")
- conn.log_expect(options, "Enter 'YES' to continue or <ENTER> to cancel :", SHELL_TIMEOUT)
+ conn.log_expect(options, "Enter 'YES' to continue or <ENTER> to cancel :", int(options["-Y"]))
conn.send("YES\r\n")
- conn.log_expect(options, "Press <ENTER> to continue...", SHELL_TIMEOUT)
+ conn.log_expect(options, "Press <ENTER> to continue...", int(options["-Y"]))
conn.send("\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
conn.send(chr(03))
- conn.log_expect(options, "- Logout", SHELL_TIMEOUT)
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, "- Logout", int(options["-Y"]))
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -185,7 +185,8 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"secure", "port", "switch", "test", "separator",
- "inet4_only", "inet6_only", "ipport" ]
+ "inet4_only", "inet6_only", "ipport",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/apc_snmp/fence_apc_snmp.py b/fence/agents/apc_snmp/fence_apc_snmp.py
index e66a6b0..7e8118e 100644
--- a/fence/agents/apc_snmp/fence_apc_snmp.py
+++ b/fence/agents/apc_snmp/fence_apc_snmp.py
@@ -169,7 +169,8 @@ def main():
"test", "port", "separator", "no_login", "no_password",
"snmp_version", "community", "snmp_auth_prot", "snmp_sec_level",
"snmp_priv_prot", "snmp_priv_passwd", "snmp_priv_passwd_script",
- "udpport","inet4_only","inet6_only"]
+ "udpport","inet4_only","inet6_only",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index eacac33..87819e4 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -27,15 +27,15 @@ def get_power_status(conn, options):
node_cmd = "system:blade\[" + options["-n"] + "\]>"
conn.send("env -T system:blade[" + options["-n"] + "]\r\n")
- i = conn.log_expect(options, [ node_cmd, "system>" ] , SHELL_TIMEOUT)
+ i = conn.log_expect(options, [ node_cmd, "system>" ] , int(options["-Y"]))
if i == 1:
## Given blade number does not exist
fail(EC_STATUS)
conn.send("power -state\r\n")
- conn.log_expect(options, node_cmd, SHELL_TIMEOUT)
+ conn.log_expect(options, node_cmd, int(options["-Y"]))
status = conn.before.splitlines()[-1]
conn.send("env -T system\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -53,11 +53,11 @@ def set_power_status(conn, options):
node_cmd = "system:blade\[" + options["-n"] + "\]>"
conn.send("env -T system:blade[" + options["-n"] + "]\r\n")
- conn.log_expect(options, node_cmd, SHELL_TIMEOUT)
+ conn.log_expect(options, node_cmd, int(options["-Y"]))
conn.send("power -"+options["-o"]+"\r\n")
- conn.log_expect(options, node_cmd, SHELL_TIMEOUT)
+ conn.log_expect(options, node_cmd, int(options["-Y"]))
conn.send("env -T system\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -69,9 +69,9 @@ def get_blades_list(conn, options):
node_cmd = "system>"
conn.send("env -T system\r\n")
- conn.log_expect(options, node_cmd, SHELL_TIMEOUT)
+ conn.log_expect(options, node_cmd, int(options["-Y"]))
conn.send("list -l 2\r\n")
- conn.log_expect(options, node_cmd, SHELL_TIMEOUT)
+ conn.log_expect(options, node_cmd, int(options["-Y"]))
lines = conn.before.split("\r\n")
filter_re = re.compile("^\s*blade\[(\d+)\]\s+(.*?)\s*$")
@@ -91,17 +91,15 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"cmd_prompt", "secure", "port", "identity_file", "separator",
- "inet4_only", "inet6_only", "ipport" ]
+ "inet4_only", "inet6_only", "ipport",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
- options = check_input(device_opt, process_input(device_opt))
+ all_opt["power_wait"]["default"] = "5"
+ all_opt["cmd_prompt"]["default"] = "system>"
- ##
- ## Fence agent specific defaults
- #####
- if 0 == options.has_key("-c"):
- options["-c"] = "system>"
+ options = check_input(device_opt, process_input(device_opt))
show_docs(options)
diff --git a/fence/agents/cisco_mds/fence_cisco_mds.py b/fence/agents/cisco_mds/fence_cisco_mds.py
index 944e593..d007b72 100644
--- a/fence/agents/cisco_mds/fence_cisco_mds.py
+++ b/fence/agents/cisco_mds/fence_cisco_mds.py
@@ -86,7 +86,8 @@ def main():
"test", "port", "separator", "no_login", "no_password",
"snmp_version", "community", "snmp_auth_prot", "snmp_sec_level",
"snmp_priv_prot", "snmp_priv_passwd", "snmp_priv_passwd_script",
- "udpport","inet4_only","inet6_only"]
+ "udpport","inet4_only","inet6_only",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index 231fd06..d7fbdaa 100755
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -29,7 +29,7 @@ def get_power_status(conn, options):
elif options["model"] == "DRAC 5":
conn.sendline("racadm serveraction powerstatus")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -52,7 +52,7 @@ def set_power_status(conn, options):
conn.sendline("racadm serveraction " + action + " -m " + options["-m"])
elif options["model"] == "DRAC 5":
conn.sendline("racadm serveraction " + action)
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -69,7 +69,7 @@ def get_list_devices(conn, options):
for line in conn.before.splitlines():
if (list_re.search(line)):
outlets[list_re.search(line).group(1)] = ("", list_re.search(line).group(2))
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
elif options["model"] == "DRAC 5":
## DRAC 5 can be used only for one computer
pass
@@ -84,7 +84,8 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"cmd_prompt", "secure", "drac_version", "module_name",
- "separator", "inet4_only", "inet6_only", "ipport" ]
+ "separator", "inet4_only", "inet6_only", "ipport",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/ibmblade/fence_ibmblade.py b/fence/agents/ibmblade/fence_ibmblade.py
index 700437d..4ff334e 100644
--- a/fence/agents/ibmblade/fence_ibmblade.py
+++ b/fence/agents/ibmblade/fence_ibmblade.py
@@ -61,7 +61,8 @@ def main():
"test", "port", "separator", "no_login", "no_password",
"snmp_version", "community", "snmp_auth_prot", "snmp_sec_level",
"snmp_priv_prot", "snmp_priv_passwd", "snmp_priv_passwd_script",
- "udpport","inet4_only","inet6_only"]
+ "udpport","inet4_only","inet6_only",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/ifmib/fence_ifmib.py b/fence/agents/ifmib/fence_ifmib.py
index 544d236..7645afa 100644
--- a/fence/agents/ifmib/fence_ifmib.py
+++ b/fence/agents/ifmib/fence_ifmib.py
@@ -106,7 +106,8 @@ def main():
"test", "port", "separator", "no_login", "no_password",
"snmp_version", "community", "snmp_auth_prot", "snmp_sec_level",
"snmp_priv_prot", "snmp_priv_passwd", "snmp_priv_passwd_script",
- "udpport","inet4_only","inet6_only"]
+ "udpport","inet4_only","inet6_only",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index 7483780..574f944 100755
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -27,7 +27,7 @@ def get_power_status(conn, options):
" PASSWORD = \"" + options["-p"] + "\">\r\n")
conn.send("<SERVER_INFO MODE = \"read\"><GET_HOST_POWER_STATUS/>\r\n")
conn.send("</SERVER_INFO></LOGIN>\r\n")
- conn.log_expect(options, "HOST_POWER=\"(.*?)\"", POWER_TIMEOUT)
+ conn.log_expect(options, "HOST_POWER=\"(.*?)\"", int(options["-g"]))
status = conn.match.group(1)
return status.lower().strip()
@@ -56,10 +56,13 @@ def set_power_status(conn, options):
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
- "ssl", "ribcl", "inet4_only", "inet6_only", "ipport" ]
+ "ssl", "ribcl", "inet4_only", "inet6_only", "ipport",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
+ all_opt["login_timeout"]["default"] = "10"
+
pinput = process_input(device_opt)
pinput["-z"] = 1
options = check_input(device_opt, pinput)
@@ -74,7 +77,7 @@ def main():
conn = fence_login(options)
try:
conn.send("<?xml version=\"1.0\"?>\r\n")
- conn.log_expect(options, [ "</RIBCL>", "<END_RIBCL/>" ], LOGIN_TIMEOUT)
+ conn.log_expect(options, [ "</RIBCL>", "<END_RIBCL/>" ], int(options["-y"]))
version = re.compile("<RIBCL VERSION=\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1)
if options.has_key("-r") == 0:
options["-r"] = float(version)
@@ -89,8 +92,8 @@ def main():
if options["-r"] >= 2:
conn.send("<RIB_INFO MODE=\"read\"><GET_FW_VERSION />\r\n")
conn.send("</RIB_INFO>\r\n")
- conn.log_expect(options, "<GET_FW_VERSION\s*\n", SHELL_TIMEOUT)
- conn.log_expect(options, "/>", SHELL_TIMEOUT)
+ conn.log_expect(options, "<GET_FW_VERSION\s*\n", int(options["-Y"]))
+ conn.log_expect(options, "/>", int(options["-Y"]))
options["fw_version"] = float(re.compile("FIRMWARE_VERSION\s*=\s*\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1))
options["fw_processor"] = re.compile("MANAGEMENT_PROCESSOR\s*=\s*\"(.*?)\"", re.IGNORECASE).search(conn.before).group(1)
conn.send("</LOGIN>\r\n")
diff --git a/fence/agents/ilo_mp/fence_ilo_mp.py b/fence/agents/ilo_mp/fence_ilo_mp.py
index baaf076..a676fb8 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):
conn.send("show /system1\n")
- conn.log_expect(options, "EnabledState=(.*)", POWER_TIMEOUT)
+ conn.log_expect(options, "EnabledState=(.*)", int(options["-Y"]))
status = conn.match.group(1)
@@ -32,7 +32,8 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"secure", "cmd_prompt", "ipport", "login_eol_lf",
- "separator", "inet4_only", "inet6_only" ]
+ "separator", "inet4_only", "inet6_only",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/intelmodular/fence_intelmodular.py b/fence/agents/intelmodular/fence_intelmodular.py
index 4969772..a03e4a6 100644
--- a/fence/agents/intelmodular/fence_intelmodular.py
+++ b/fence/agents/intelmodular/fence_intelmodular.py
@@ -68,7 +68,8 @@ def main():
"test", "port", "separator", "no_login", "no_password",
"snmp_version", "community", "snmp_auth_prot", "snmp_sec_level",
"snmp_priv_prot", "snmp_priv_passwd", "snmp_priv_passwd_script",
- "udpport","inet4_only","inet6_only"]
+ "udpport","inet4_only","inet6_only",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/ldom/fence_ldom.py b/fence/agents/ldom/fence_ldom.py
index d5e7285..4806982 100644
--- a/fence/agents/ldom/fence_ldom.py
+++ b/fence/agents/ldom/fence_ldom.py
@@ -23,11 +23,11 @@ COMMAND_PROMPT_NEW="[PEXPECT]"
# Start comunicating after login. Prepare good environment.
def start_communication(conn, options):
conn.sendline ("PS1='"+COMMAND_PROMPT_NEW+"'")
- res=conn.expect([pexpect.TIMEOUT, COMMAND_PROMPT_REG],SHELL_TIMEOUT)
+ res=conn.expect([pexpect.TIMEOUT, COMMAND_PROMPT_REG],int(options["-Y"]))
if res==0:
#CSH stuff
conn.sendline("set prompt='"+COMMAND_PROMPT_NEW+"'")
- conn.log_expect(options, COMMAND_PROMPT_REG,SHELL_TIMEOUT)
+ conn.log_expect(options, COMMAND_PROMPT_REG,int(options["-Y"]))
def get_power_status(conn, options):
@@ -36,7 +36,7 @@ def get_power_status(conn, options):
conn.sendline("ldm ls")
- conn.log_expect(options,COMMAND_PROMPT_REG,SHELL_TIMEOUT)
+ conn.log_expect(options,COMMAND_PROMPT_REG,int(options["-Y"]))
result={}
@@ -73,7 +73,7 @@ def set_power_status(conn, options):
conn.sendline(cmd_line)
- conn.log_expect(options,COMMAND_PROMPT_REG,POWER_TIMEOUT)
+ conn.log_expect(options,COMMAND_PROMPT_REG,int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
@@ -84,7 +84,8 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"secure", "identity_file", "test" , "port", "cmd_prompt",
- "separator", "inet4_only", "inet6_only", "ipport" ]
+ "separator", "inet4_only", "inet6_only", "ipport",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 96f25e0..fe83a3f 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -12,10 +12,6 @@ REDHAT_COPYRIGHT = ""
BUILD_DATE = "March, 2008"
#END_VERSION_GENERATION
-POWER_TIMEOUT = 20
-SHELL_TIMEOUT = 3
-LOGIN_TIMEOUT = 5
-
LOG_MODE_VERBOSE = 100
LOG_MODE_QUIET = 0
@@ -322,7 +318,31 @@ all_opt = {
"default" : ",",
"required" : "0",
"shortdesc" : "Separator for CSV created by operation list",
- "order" : 100 }
+ "order" : 100 },
+ "login_timeout" : {
+ "getopt" : "y:",
+ "longopt" : "login-timeout",
+ "help" : "--login-timeout <seconds> Wait X seconds for cmd prompt after login",
+ "default" : "5",
+ "order" : 200 },
+ "shell_timeout" : {
+ "getopt" : "Y:",
+ "longopt" : "shell-timeout",
+ "help" : "--shell-timeout <seconds> Wait X seconds for cmd prompt after issuing command",
+ "default" : "3",
+ "order" : 200 },
+ "power_timeout" : {
+ "getopt" : "g:",
+ "longopt" : "power-timeout",
+ "help" : "--power-timeout <seconds> Test X seconds for status change after ON/OFF",
+ "default" : "20",
+ "order" : 200 },
+ "power_wait" : {
+ "getopt" : "G:",
+ "longopt" : "power-wait",
+ "help" : "--power-wait <seconds> Wait X seconds after issuing ON/OFF",
+ "default" : "0",
+ "order" : 200 }
}
class fspawn(pexpect.spawn):
@@ -621,7 +641,7 @@ def check_input(device_opt, opt):
return options
def wait_power_status(tn, options, get_power_fn):
- for dummy in xrange(POWER_TIMEOUT):
+ for dummy in xrange(int(options["-g"])):
if get_power_fn(tn, options) != options["-o"]:
time.sleep(1)
else:
@@ -688,6 +708,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
print "Success: Already ON"
else:
set_power_fn(tn, options)
+ time.sleep(int(options["-G"]))
if wait_power_status(tn, options, get_power_fn):
print "Success: Powered ON"
else:
@@ -697,6 +718,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
print "Success: Already OFF"
else:
set_power_fn(tn, options)
+ time.sleep(int(options["-G"]))
if wait_power_status(tn, options, get_power_fn):
print "Success: Powered OFF"
else:
@@ -705,10 +727,12 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
if status != "off":
options["-o"] = "off"
set_power_fn(tn, options)
+ time.sleep(int(options["-G"]))
if wait_power_status(tn, options, get_power_fn) == 0:
fail(EC_WAITING_OFF)
options["-o"] = "on"
set_power_fn(tn, options)
+ time.sleep(int(options["-G"]))
if wait_power_status(tn, options, get_power_fn) == 0:
sys.stderr.write('Timed out waiting to power ON\n')
print "Success: Rebooted"
@@ -757,21 +781,21 @@ def fence_login(options):
if options.has_key("telnet_over_ssh"):
#This is for stupid ssh servers (like ALOM) which behave more like telnet (ignore name and display login prompt)
- result = conn.log_expect(options, [ re_login, "Are you sure you want to continue connecting (yes/no)?" ], LOGIN_TIMEOUT)
+ result = conn.log_expect(options, [ re_login, "Are you sure you want to continue connecting (yes/no)?" ], int(options["-y"]))
if result == 1:
conn.sendline("yes") # Host identity confirm
- conn.log_expect(options, re_login, LOGIN_TIMEOUT)
+ conn.log_expect(options, re_login, int(options["-y"]))
conn.sendline(options["-l"])
- conn.log_expect(options, re_pass, LOGIN_TIMEOUT)
+ conn.log_expect(options, re_pass, int(options["-y"]))
else:
- result = conn.log_expect(options, [ "ssword:", "Are you sure you want to continue connecting (yes/no)?" ], LOGIN_TIMEOUT)
+ result = conn.log_expect(options, [ "ssword:", "Are you sure you want to continue connecting (yes/no)?" ], int(options["-y"]))
if result == 1:
conn.sendline("yes")
- conn.log_expect(options, "ssword:", LOGIN_TIMEOUT)
+ conn.log_expect(options, "ssword:", int(options["-y"]))
conn.sendline(options["-p"])
- conn.log_expect(options, options["-c"], LOGIN_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-y"]))
elif options.has_key("-x") and 1 == options.has_key("-k"):
command = '%s %s %s@%s -i %s -p %s' % (SSH_PATH, force_ipvx, options["-l"], options["-a"], options["-k"], options["-u"])
if options.has_key("ssh_options"):
@@ -784,14 +808,14 @@ def fence_login(options):
"are not in the spec file and must be installed separately." + "\n")
sys.exit(EC_GENERIC_ERROR)
- result = conn.log_expect(options, [ options["-c"], "Are you sure you want to continue connecting (yes/no)?", "Enter passphrase for key '"+options["-k"]+"':" ], LOGIN_TIMEOUT)
+ result = conn.log_expect(options, [ options["-c"], "Are you sure you want to continue connecting (yes/no)?", "Enter passphrase for key '"+options["-k"]+"':" ], int(options["-y"]))
if result == 1:
conn.sendline("yes")
- conn.log_expect(options, [ options["-c"], "Enter passphrase for key '"+options["-k"]+"':"] , LOGIN_TIMEOUT)
+ conn.log_expect(options, [ options["-c"], "Enter passphrase for key '"+options["-k"]+"':"] , int(options["-y"]))
if result != 0:
if options.has_key("-p"):
conn.sendline(options["-p"])
- conn.log_expect(options, options["-c"], LOGIN_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-y"]))
else:
fail_usage("Failed: You have to enter passphrase (-p) for identity file")
else:
@@ -805,11 +829,11 @@ 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, LOGIN_TIMEOUT)
+ conn.log_expect(options, re_login, int(options["-y"]))
conn.send(options["-l"] + login_eol)
- conn.log_expect(options, re_pass, SHELL_TIMEOUT)
+ conn.log_expect(options, re_pass, int(options["-Y"]))
conn.send(options["-p"] + login_eol)
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_LOGIN_DENIED)
except pexpect.TIMEOUT:
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
index 1292b5b..d6f6ab4 100644
--- a/fence/agents/lib/fencing_snmp.py.py
+++ b/fence/agents/lib/fencing_snmp.py.py
@@ -80,7 +80,7 @@ class FencingSnmp:
try:
self.log_command(command)
- (res_output,res_code)=pexpect.run(command,SHELL_TIMEOUT+LOGIN_TIMEOUT+additional_timemout,True)
+ (res_output,res_code)=pexpect.run(command,int(options["-Y"])+int(options["-y"])+additional_timemout,True)
if (res_code==None):
fail(EC_TIMED_OUT)
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index 751ba7a..8a88121 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -24,7 +24,7 @@ def get_power_status(conn, options):
if options["-H"] == "3":
try:
conn.send("lssyscfg -r lpar -m " + options["-s"] + " -n " + options["-n"] + " -F name,state\n")
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -37,7 +37,7 @@ def get_power_status(conn, options):
elif options["-H"] == "4":
try:
conn.send("lssyscfg -r lpar -m "+ options["-s"] +" --filter 'lpar_names=" + options["-n"] + "'\n")
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -62,7 +62,7 @@ def set_power_status(conn, options):
try:
conn.send("chsysstate -o " + options["-o"] + " -r lpar -m " + options["-s"]
+ " -n " + options["-n"] + "\n")
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -78,7 +78,7 @@ def set_power_status(conn, options):
else:
conn.send("chsysstate -o shutdown -r lpar --immed" +
" -m " + options["-s"] + " -n " + options["-n"] + "\n")
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -89,7 +89,7 @@ def get_lpar_list(conn, options):
if options["-H"] == "3":
try:
conn.send("query_partition_names -m " + options["-s"] + "\n")
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
## We have to remove first 3 lines (command + header) and last line (part of new prompt)
####
@@ -109,7 +109,7 @@ def get_lpar_list(conn, options):
try:
conn.send("lssyscfg -r lpar -m " + options["-s"] +
" -F name:state\n")
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
## We have to remove first line (command) and last line (part of new prompt)
####
@@ -133,7 +133,8 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"secure", "partition", "managed", "hmc_version", "cmd_prompt",
- "separator", "inet4_only", "inet6_only", "ipport" ]
+ "separator", "inet4_only", "inet6_only", "ipport",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py
index dec626c..91dd5fd 100644
--- a/fence/agents/rsa/fence_rsa.py
+++ b/fence/agents/rsa/fence_rsa.py
@@ -20,7 +20,7 @@ BUILD_DATE="March, 2009"
def get_power_status(conn, options):
try:
conn.send("power state\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -32,7 +32,7 @@ def get_power_status(conn, options):
def set_power_status(conn, options):
try:
conn.send("power " + options["-o"] + "\r\n")
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -41,7 +41,8 @@ def set_power_status(conn, options):
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
- "cmd_prompt", "secure", "ipport" ]
+ "cmd_prompt", "secure", "ipport",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/sanbox2/fence_sanbox2.py b/fence/agents/sanbox2/fence_sanbox2.py
index 0b048a3..d1e65cf 100644
--- a/fence/agents/sanbox2/fence_sanbox2.py
+++ b/fence/agents/sanbox2/fence_sanbox2.py
@@ -25,7 +25,7 @@ def get_power_status(conn, options):
}
try:
conn.send("show port " + options["-n"] + "\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -52,7 +52,7 @@ def set_power_status(conn, options):
try:
conn.send("set port " + options["-n"] + " state " + action + "\n")
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -66,7 +66,7 @@ def set_power_status(conn, options):
try:
conn.send("set port " + options["-n"] + " state " + action + "\n")
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -83,7 +83,7 @@ def get_list_devices(conn, options):
try:
conn.send("show port" + "\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
list_re = re.compile("^\s+(\d+?)\s+(Online|Offline)\s+", re.IGNORECASE)
for line in conn.before.splitlines():
@@ -110,7 +110,8 @@ 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", "login_eol_lf", "separator",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
@@ -130,7 +131,7 @@ def main():
conn = fence_login(options)
conn.send("admin start\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
if (re.search("\(admin\)", conn.before, re.MULTILINE) == None):
## Someone else is in admin section, we can't enable/disable
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index eae7405..7ef71a3 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -18,7 +18,7 @@ BUILD_DATE=""
def get_outlets_status(conn, options):
try:
conn.sendline("virsh list --all")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -51,7 +51,7 @@ def set_power_status(conn, options):
try:
conn.sendline("virsh %s "%(options["-o"] == "on" and "start" or "destroy")+options["-n"])
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
time.sleep(1)
except pexpect.EOF:
@@ -63,7 +63,8 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"secure", "identity_file", "test", "port", "separator",
- "inet4_only", "inet6_only", "ipport" ]
+ "inet4_only", "inet6_only", "ipport",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py
index 070c2c4..63e9360 100644
--- a/fence/agents/vmware/fence_vmware.py
+++ b/fence/agents/vmware/fence_vmware.py
@@ -148,7 +148,7 @@ def vmware_run_command(options,add_login_params,additional_params,additional_tim
try:
vmware_log(options,command)
- (res_output,res_code)=pexpect.run(command,SHELL_TIMEOUT+LOGIN_TIMEOUT+additional_timeout,True)
+ (res_output,res_code)=pexpect.run(command,int(options["-Y"])+int(options["-y"])+additional_timeout,True)
if (res_code==None):
fail(EC_TIMED_OUT)
@@ -171,7 +171,7 @@ def vmware_get_outlets_vi(conn, options, add_vm_name):
if (add_vm_name):
all_machines=vmware_run_command(options,True,("--operation status --vmname '%s'"%(quote_for_run(options["-n"]))),0)
else:
- all_machines=vmware_run_command(options,True,"--operation list",POWER_TIMEOUT)
+ all_machines=vmware_run_command(options,True,"--operation list",int(options["-g"]))
all_machines_array=all_machines.splitlines()
@@ -237,7 +237,7 @@ def set_power_status(conn, options):
if (options["-o"]=="off"):
additional_params+=" hard"
- vmware_run_command(options,True,additional_params,POWER_TIMEOUT)
+ vmware_run_command(options,True,additional_params,int(options["-g"]))
# Returns True, if user uses supported vmrun version (currently >=2.0.0) otherwise False.
def vmware_is_supported_vmrun_version(options):
@@ -287,7 +287,8 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"test", "port", "separator", "exec", "vmware_type",
- "vmware_datacenter", "secure" ]
+ "vmware_datacenter", "secure",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 25cbccc..514bc9d 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -24,7 +24,7 @@ BUILD_DATE="March, 2008"
def get_power_status(conn, options):
try:
conn.send("/S"+"\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -66,7 +66,7 @@ def set_power_status(conn, options):
try:
conn.send(action + " " + options["-n"] + ",y\r\n")
- conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-g"]))
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -76,7 +76,8 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"cmd_prompt", "secure", "port", "no_login", "no_password",
- "test", "separator", "inet4_only", "inet6_only", "ipport" ]
+ "test", "separator", "inet4_only", "inet6_only", "ipport",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
@@ -108,18 +109,18 @@ def main():
re_login = re.compile("(login: )|(Login Name: )|(username: )|(User Name :)", re.IGNORECASE)
re_prompt = re.compile("|".join(map (lambda x: "(" + x + ")", options["-c"])), re.IGNORECASE)
- result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], SHELL_TIMEOUT)
+ result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["-Y"]))
if result == 0:
if options.has_key("-l"):
conn.send(options["-l"]+"\r\n")
- result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], SHELL_TIMEOUT)
+ result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["-Y"]))
else:
fail_usage("Failed: You have to set login name")
if result == 1:
if options.has_key("-p"):
conn.send(options["-p"]+"\r\n")
- conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
else:
fail_usage("Failed: You have to enter password or password script")
except pexpect.EOF:
More information about the cluster-commits
mailing list