dlm: master - dlm_controld: fix long name in log entry
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=4283123f0b13eaf...
Commit: 4283123f0b13eafc46d825050c5142cf44be79c3
Parent: fb61984c9388cbbcc02c6a09c09948b21320412d
Author: Lidong Zhong <lzhong(a)suse.com>
AuthorDate: Fri Apr 25 10:52:52 2014 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 25 10:55:27 2014 -0500
dlm_controld: fix long name in log entry
When the length of name_in is NAME_ID_SIZE, the last byte of the name
and a whitespace will get lost.
(Modified by teigland(a)redhat.com to also
handle names longer than NAME_ID_SIZE.)
Signed-off-by: Lidong Zhong <lzhong(a)suse.com>
---
dlm_controld/logging.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/dlm_controld/logging.c b/dlm_controld/logging.c
index 9347e43..4aa3406 100644
--- a/dlm_controld/logging.c
+++ b/dlm_controld/logging.c
@@ -122,17 +122,23 @@ static void log_save_str(int len, char *log_buf, unsigned int *point,
void log_level(char *name_in, uint32_t level_in, const char *fmt, ...)
{
va_list ap;
- char name[NAME_ID_SIZE + 1];
+ char name[NAME_ID_SIZE + 2];
uint32_t level = level_in & 0x0000FFFF;
uint32_t extra = level_in & 0xFFFF0000;
int ret, pos = 0;
int len = LOG_STR_LEN - 2;
+ int namelen = 0;
int plock = extra & LOG_PLOCK;
memset(name, 0, sizeof(name));
- if (name_in)
- snprintf(name, NAME_ID_SIZE, "%s ", name_in);
+ if (name_in) {
+ namelen = snprintf(name, NAME_ID_SIZE + 1, "%s", name_in);
+ if (namelen > NAME_ID_SIZE)
+ namelen = NAME_ID_SIZE;
+ name[namelen] = ' ';
+ name[namelen+1] = '\0';
+ }
ret = snprintf(log_str + pos, len - pos, "%llu %s",
(unsigned long long)monotime(), name);
10 years
cluster: RHEL511 - rgmanager: Forcibly remove pid file if sending SIGQUIT
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=d77a25c817c...
Commit: d77a25c817c985f3200b1676c659683e3984564c
Parent: b5eb3050608dbf3dae895f9d5ef3bade5669ffb1
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Wed Apr 23 14:04:39 2014 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Wed Apr 23 14:07:15 2014 -0400
rgmanager: Forcibly remove pid file if sending SIGQUIT
If a daemon is sent SIGQUIT after SIGTERM fails to stop it, forcibly
remove the pid file after verifying the process no longer exists. This
fixes a bug that causes future starts to fail if a new process happens
to exist with the same pid when the resource is restarted.
Resolves: rhbz#1035034
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/resources/utils/ra-skelet.sh | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/rgmanager/src/resources/utils/ra-skelet.sh b/rgmanager/src/resources/utils/ra-skelet.sh
index f1c3d70..93a8ac3 100644
--- a/rgmanager/src/resources/utils/ra-skelet.sh
+++ b/rgmanager/src/resources/utils/ra-skelet.sh
@@ -132,7 +132,11 @@ stop_generic_sigkill() {
clog_service_stop $CLOG_FAILED_KILL
return $OCF_ERR_GENERIC
fi
-
+
+ # If we had to send a SIGQUIT, the pid file may not have been
+ # cleaned up by the daemon. Make sure it's removed so that future
+ # resource starts do not fail.
+ rm -f -- "$pid_file"
clog_service_stop $CLOG_SUCCEED_KILL
return 0
}
10 years
fence-agents: master - [cleanup] Create function fence_logout()
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=96d7a8...
Commit: 96d7a8383197e3d34c201139445ff177d870ff62
Parent: b770d0d321c65ac4d326e4bf9f2937a5af97e5d8
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Apr 23 17:48:14 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Apr 23 17:48:14 2014 +0200
[cleanup] Create function fence_logout()
This function replaces almost all logout functions. Exception is in
fence_sanbox2 where two lines are required for exit.
---
fence/agents/alom/fence_alom.py | 9 +--------
fence/agents/apc/fence_apc.py | 14 +-------------
fence/agents/bladecenter/fence_bladecenter.py | 11 +----------
fence/agents/brocade/fence_brocade.py | 16 +---------------
fence/agents/drac/fence_drac.py | 15 +--------------
fence/agents/drac5/fence_drac5.py | 12 +-----------
fence/agents/hds_cb/fence_hds_cb.py | 10 +---------
fence/agents/hpblade/fence_hpblade.py | 11 +----------
fence/agents/ilo_mp/fence_ilo_mp.py | 7 +------
fence/agents/ldom/fence_ldom.py | 13 +------------
fence/agents/lib/fencing.py.py | 16 +++++++++++++++-
fence/agents/lpar/fence_lpar.py | 12 ++----------
fence/agents/netio/fence_netio.py | 17 ++---------------
fence/agents/raritan/fence_raritan.py | 16 ++--------------
fence/agents/rsa/fence_rsa.py | 11 +----------
fence/agents/rsb/fence_rsb.py | 15 +--------------
fence/agents/virsh/fence_virsh.py | 10 ++--------
fence/agents/wti/fence_wti.py | 11 +----------
18 files changed, 36 insertions(+), 190 deletions(-)
diff --git a/fence/agents/alom/fence_alom.py b/fence/agents/alom/fence_alom.py
index d64838e..ef418c3 100644
--- a/fence/agents/alom/fence_alom.py
+++ b/fence/agents/alom/fence_alom.py
@@ -52,14 +52,7 @@ agent which can be used with ALOM connected machines."
# Operate the fencing device
conn = fence_login(options)
result = fence_action(conn, options, set_power_status, get_power_status, None)
-
- # Logout from system
- try:
- conn.send_eol("logout")
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "logout")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index c6a9aaf..c31a4b0 100644
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -252,19 +252,7 @@ will block any necessary fencing actions."
else:
result = fence_action(conn, options, set_power_status, get_power_status, get_power_status)
- ##
- ## Logout from system
- ##
- ## In some special unspecified cases it is possible that
- ## connection will be closed before we run close(). This is not
- ## a problem because everything is checked before.
- ######
- try:
- conn.send_eol("4")
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "4")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index b6cd005..6508012 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -104,16 +104,7 @@ and uses the command line interface to power on and off blades."
######
conn = fence_login(options, "(username: )")
result = fence_action(conn, options, set_power_status, get_power_status, get_blades_list)
-
- ##
- ## Logout from system
- ######
- try:
- conn.send_eol("exit")
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "exit")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/brocade/fence_brocade.py b/fence/agents/brocade/fence_brocade.py
index 716bad1..ac1c0c1 100644
--- a/fence/agents/brocade/fence_brocade.py
+++ b/fence/agents/brocade/fence_brocade.py
@@ -66,22 +66,8 @@ FC switch needs to be enabled. This can be done by running fence_brocade and spe
## Operate the fencing device
####
conn = fence_login(options)
-
result = fence_action(conn, options, set_power_status, get_power_status, None)
-
- ##
- ## Logout from system
- ##
- ## In some special unspecified cases it is possible that
- ## connection will be closed before we run close(). This is not
- ## a problem because everything is checked before.
- ######
- try:
- conn.send_eol("exit")
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "exit")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/drac/fence_drac.py b/fence/agents/drac/fence_drac.py
index 4c0dea8..4965779 100644
--- a/fence/agents/drac/fence_drac.py
+++ b/fence/agents/drac/fence_drac.py
@@ -61,20 +61,7 @@ To enable telnet on the DRAC: \
####
conn = fence_login(options)
result = fence_action(conn, options, set_power_status, get_power_status, None)
-
- ##
- ## Logout from system
- ##
- ## In some special unspecified cases it is possible that
- ## connection will be closed before we run close(). This is not
- ## a problem because everything is checked before.
- ######
- try:
- conn.send_eol("exit")
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "exit")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index ade299e..7687135 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -146,17 +146,7 @@ By default, the telnet interface is not enabled."
fail_usage("Failed: You have to enter module name (-n)")
result = fence_action(conn, options, set_power_status, get_power_status, get_list_devices)
-
- ##
- ## Logout from system
- ######
- try:
- conn.send_eol("exit")
- time.sleep(1)
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "exit", 1)
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/hds_cb/fence_hds_cb.py b/fence/agents/hds_cb/fence_hds_cb.py
index 8092de1..2256d4d 100755
--- a/fence/agents/hds_cb/fence_hds_cb.py
+++ b/fence/agents/hds_cb/fence_hds_cb.py
@@ -131,15 +131,7 @@ includes telnet support."
conn = fence_login(options)
result = fence_action(conn, options, set_power_status, get_power_status, get_blades_list)
- ##
- ## Logout from system
- ######
- try:
- conn.sendline("X")
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "X")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/hpblade/fence_hpblade.py b/fence/agents/hpblade/fence_hpblade.py
index ee59d5f..69aa30d 100644
--- a/fence/agents/hpblade/fence_hpblade.py
+++ b/fence/agents/hpblade/fence_hpblade.py
@@ -81,16 +81,7 @@ and uses the command line interface to power on and off blades."
options["eol"] = "\n"
conn = fence_login(options)
result = fence_action(conn, options, set_power_status, get_power_status, get_blades_list)
-
- ##
- ## Logout from system
- ######
- try:
- conn.send_eol("exit")
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "exit")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/ilo_mp/fence_ilo_mp.py b/fence/agents/ilo_mp/fence_ilo_mp.py
index 6cc2d9f..2e70ad3 100644
--- a/fence/agents/ilo_mp/fence_ilo_mp.py
+++ b/fence/agents/ilo_mp/fence_ilo_mp.py
@@ -57,12 +57,7 @@ def main():
## Fence operations
####
result = fence_action(conn, options, set_power_status, get_power_status)
-
- try:
- conn.send_eol("exit")
- except Exception:
- pass
-
+ fence_logout(conn, "exit")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/ldom/fence_ldom.py b/fence/agents/ldom/fence_ldom.py
index 5e046df..d58be31 100644
--- a/fence/agents/ldom/fence_ldom.py
+++ b/fence/agents/ldom/fence_ldom.py
@@ -101,18 +101,7 @@ root. Than prompt is $, so again, you must use parameter -c."
####
conn = fence_login(options)
result = fence_action(conn, options, set_power_status, get_power_status, get_power_status)
-
- ##
- ## Logout from system
- ######
- try:
- conn.send_eol("logout")
- conn.close()
- except exceptions.OSError:
- pass
- except pexpect.ExceptionPexpect:
- pass
-
+ fence_logout(conn, "logout")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 994d80c..0539a2f 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -6,6 +6,7 @@ import logging
import subprocess
import threading
import shlex
+import exceptions
import __main__
## do not add code here.
@@ -16,7 +17,7 @@ BUILD_DATE = "March, 2008"
#END_VERSION_GENERATION
__all__ = [ 'atexit_handler', 'check_input', 'process_input', 'all_opt', 'show_docs',
- 'fence_login', 'fence_action' ]
+ 'fence_login', 'fence_action', 'fence_logout' ]
EC_GENERIC_ERROR = 1
EC_BAD_ARGS = 2
@@ -1127,3 +1128,16 @@ def run_delay(options):
if options["--action"] in ["off", "reboot"]:
logging.info("Delay %s second(s) before logging in to the fence device", options["--delay"])
time.sleep(int(options["--delay"]))
+
+def fence_logout(conn, logout_string, sleep=0):
+ # Logout is not required part of fencing but we should attempt to do it properly
+ # In some cases our 'exit' command is faster and we can not close connection as it
+ # was already closed by fencing device
+ try:
+ conn.send_eol(logout_string)
+ time.sleep(sleep)
+ conn.close()
+ except exceptions.OSError:
+ pass
+ except pexpect.ExceptionPexpect:
+ pass
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index c487656..527b74b 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -149,16 +149,8 @@ def main():
####
conn = fence_login(options)
result = fence_action(conn, options, set_power_status, get_power_status, get_lpar_list)
-
- ##
- ## Logout from system
- ######
- try:
- conn.send("quit\r\n")
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "quit\r\n")
sys.exit(result)
+
if __name__ == "__main__":
main()
diff --git a/fence/agents/netio/fence_netio.py b/fence/agents/netio/fence_netio.py
index 4cf3b43..4f756f8 100755
--- a/fence/agents/netio/fence_netio.py
+++ b/fence/agents/netio/fence_netio.py
@@ -94,22 +94,9 @@ block any necessary fencing actions."
fail(EC_LOGIN_DENIED)
except pexpect.TIMEOUT:
fail(EC_LOGIN_DENIED)
- result = fence_action(conn, options, set_power_status, get_power_status, get_outlet_list)
-
- ##
- ## Logout from system
- ##
- ## In some special unspecified cases it is possible that
- ## connection will be closed before we run close(). This is not
- ## a problem because everything is checked before.
- ######
- try:
- conn.send("quit\n")
- conn.log_expect(options, "110 BYE", int(options["--shell-timeout"]))
- conn.close()
- except Exception:
- pass
+ result = fence_action(conn, options, set_power_status, get_power_status, get_outlet_list)
+ fence_logout(conn, "quit\n")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/raritan/fence_raritan.py b/fence/agents/raritan/fence_raritan.py
index 5224fc0..b895514 100644
--- a/fence/agents/raritan/fence_raritan.py
+++ b/fence/agents/raritan/fence_raritan.py
@@ -78,21 +78,9 @@ block any necessary fencing actions."
fail(EC_LOGIN_DENIED)
except pexpect.TIMEOUT:
fail(EC_LOGIN_DENIED)
- result = fence_action(conn, options, set_power_status, get_power_status)
-
- ##
- ## Logout from system
- ##
- ## In some special unspecified cases it is possible that
- ## connection will be closed before we run close(). This is not
- ## a problem because everything is checked before.
- ######
- try:
- conn.send("exit\n")
- conn.close()
- except Exception:
- pass
+ result = fence_action(conn, options, set_power_status, get_power_status)
+ fence_logout(conn, "exit\n")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py
index 1167907..7e38aea 100644
--- a/fence/agents/rsa/fence_rsa.py
+++ b/fence/agents/rsa/fence_rsa.py
@@ -62,16 +62,7 @@ will block any necessary fencing actions."
######
conn = fence_login(options)
result = fence_action(conn, options, set_power_status, get_power_status, None)
-
- ##
- ## Logout from system
- ######
- try:
- conn.send_eol("exit")
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "exit")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/rsb/fence_rsb.py b/fence/agents/rsb/fence_rsb.py
index 7aab0ae..32afc8f 100755
--- a/fence/agents/rsb/fence_rsb.py
+++ b/fence/agents/rsb/fence_rsb.py
@@ -67,20 +67,7 @@ will block any necessary fencing actions."
####
conn = fence_login(options)
result = fence_action(conn, options, set_power_status, get_power_status, None)
-
- ##
- ## Logout from system
- ##
- ## In some special unspecified cases it is possible that
- ## connection will be closed before we run close(). This is not
- ## a problem because everything is checked before.
- ######
- try:
- conn.send_eol("0")
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "0")
sys.exit(result)
if __name__ == "__main__":
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index b56fec2..5de395c 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -93,14 +93,8 @@ must allow ssh login in your sshd_config."
## Operate the fencing device
conn = fence_login(options)
result = fence_action(conn, options, set_power_status, get_power_status, get_outlets_status)
-
- ## Logout from system
- try:
- conn.sendline("quit")
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "quit")
sys.exit(result)
+
if __name__ == "__main__":
main()
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 290eaaa..0280e29 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -236,16 +236,7 @@ is running because the connection will block any necessary fencing actions."
conn = fence_login(options)
result = fence_action(conn, options, set_power_status, get_power_status, get_power_status)
-
- ##
- ## Logout from system
- ######
- try:
- conn.send("/X"+"\r\n")
- conn.close()
- except Exception:
- pass
-
+ fence_logout(conn, "/X\r\n")
sys.exit(result)
if __name__ == "__main__":
10 years
fence-agents: master - [cleanup] Remove unused import of modules
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=b770d0...
Commit: b770d0d321c65ac4d326e4bf9f2937a5af97e5d8
Parent: e44edad253cbd09636a81ac2d4d664218c511dd8
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Apr 23 17:47:15 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Apr 23 17:47:15 2014 +0200
[cleanup] Remove unused import of modules
---
fence/agents/cisco_ucs/fence_cisco_ucs.py | 1 -
fence/agents/lib/fencing.py.py | 2 +-
fence/agents/raritan/fence_raritan.py | 2 +-
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index fd4fa6c..b880d8d 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -3,7 +3,6 @@
import sys, re
import pycurl, StringIO
import logging
-import time
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 964e613..994d80c 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -1,7 +1,7 @@
#!/usr/bin/python -tt
import sys, getopt, time, os, uuid, pycurl, stat
-import pexpect, re, atexit, syslog
+import pexpect, re, syslog
import logging
import subprocess
import threading
diff --git a/fence/agents/raritan/fence_raritan.py b/fence/agents/raritan/fence_raritan.py
index efd5605..5224fc0 100644
--- a/fence/agents/raritan/fence_raritan.py
+++ b/fence/agents/raritan/fence_raritan.py
@@ -4,7 +4,7 @@ import sys, re, pexpect
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
-from fencing import fspawn, fail, fail_usage, TELNET_PATH, EC_LOGIN_DENIED, run_delay
+from fencing import fspawn, fail, TELNET_PATH, EC_LOGIN_DENIED, run_delay
#BEGIN_VERSION_GENERATION
RELEASE_VERSION=""
10 years
fence-agents: master - [cleanup] Add broad exception specification for each except
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=e44eda...
Commit: e44edad253cbd09636a81ac2d4d664218c511dd8
Parent: d2cdfc62d32402f264a8828cd519f0182e2a5645
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Apr 23 17:46:42 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Apr 23 17:46:42 2014 +0200
[cleanup] Add broad exception specification for each except
---
fence/agents/alom/fence_alom.py | 2 +-
fence/agents/apc/fence_apc.py | 2 +-
fence/agents/bladecenter/fence_bladecenter.py | 2 +-
fence/agents/brocade/fence_brocade.py | 2 +-
fence/agents/cisco_ucs/fence_cisco_ucs.py | 2 +-
fence/agents/drac/fence_drac.py | 2 +-
fence/agents/drac5/fence_drac5.py | 2 +-
fence/agents/dummy/fence_dummy.py | 2 +-
fence/agents/eaton_snmp/fence_eaton_snmp.py | 2 +-
fence/agents/hds_cb/fence_hds_cb.py | 2 +-
fence/agents/hpblade/fence_hpblade.py | 2 +-
fence/agents/ilo_mp/fence_ilo_mp.py | 2 +-
fence/agents/lib/fencing.py.py | 2 +-
fence/agents/lpar/fence_lpar.py | 2 +-
fence/agents/netio/fence_netio.py | 2 +-
fence/agents/raritan/fence_raritan.py | 2 +-
fence/agents/rsa/fence_rsa.py | 2 +-
fence/agents/rsb/fence_rsb.py | 2 +-
fence/agents/sanbox2/fence_sanbox2.py | 8 ++++----
fence/agents/virsh/fence_virsh.py | 2 +-
fence/agents/wti/fence_wti.py | 2 +-
21 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/fence/agents/alom/fence_alom.py b/fence/agents/alom/fence_alom.py
index c2af527..d64838e 100644
--- a/fence/agents/alom/fence_alom.py
+++ b/fence/agents/alom/fence_alom.py
@@ -57,7 +57,7 @@ agent which can be used with ALOM connected machines."
try:
conn.send_eol("logout")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index 4b4c2bc..c6a9aaf 100644
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -262,7 +262,7 @@ will block any necessary fencing actions."
try:
conn.send_eol("4")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index 0f59f55..b6cd005 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -111,7 +111,7 @@ and uses the command line interface to power on and off blades."
try:
conn.send_eol("exit")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/brocade/fence_brocade.py b/fence/agents/brocade/fence_brocade.py
index 3bbb74c..716bad1 100644
--- a/fence/agents/brocade/fence_brocade.py
+++ b/fence/agents/brocade/fence_brocade.py
@@ -79,7 +79,7 @@ FC switch needs to be enabled. This can be done by running fence_brocade and spe
try:
conn.send_eol("exit")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index 57c8d4e..fd4fa6c 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -136,7 +136,7 @@ used with Cisco UCS to fence machines."
if result == None:
## Cookie is absenting in response
fail(EC_LOGIN_DENIED)
- except:
+ except Exception:
fail(EC_LOGIN_DENIED)
options["cookie"] = result.group(1)
diff --git a/fence/agents/drac/fence_drac.py b/fence/agents/drac/fence_drac.py
index 3cd7653..4c0dea8 100644
--- a/fence/agents/drac/fence_drac.py
+++ b/fence/agents/drac/fence_drac.py
@@ -72,7 +72,7 @@ To enable telnet on the DRAC: \
try:
conn.send_eol("exit")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index 6f70dad..ade299e 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -154,7 +154,7 @@ By default, the telnet interface is not enabled."
conn.send_eol("exit")
time.sleep(1)
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/dummy/fence_dummy.py b/fence/agents/dummy/fence_dummy.py
index f460746..5256aa8 100644
--- a/fence/agents/dummy/fence_dummy.py
+++ b/fence/agents/dummy/fence_dummy.py
@@ -21,7 +21,7 @@ def get_power_status_file(conn, options):
try:
status_file = open(options["--status-file"], 'r')
- except:
+ except Exception:
return "off"
status = status_file.read()
diff --git a/fence/agents/eaton_snmp/fence_eaton_snmp.py b/fence/agents/eaton_snmp/fence_eaton_snmp.py
index 884fd6d..59a6147 100644
--- a/fence/agents/eaton_snmp/fence_eaton_snmp.py
+++ b/fence/agents/eaton_snmp/fence_eaton_snmp.py
@@ -141,7 +141,7 @@ def get_power_status(conn, options):
return "off"
else:
return None
- except:
+ except Exception:
return None
def set_power_status(conn, options):
diff --git a/fence/agents/hds_cb/fence_hds_cb.py b/fence/agents/hds_cb/fence_hds_cb.py
index 6caee7f..8092de1 100755
--- a/fence/agents/hds_cb/fence_hds_cb.py
+++ b/fence/agents/hds_cb/fence_hds_cb.py
@@ -137,7 +137,7 @@ includes telnet support."
try:
conn.sendline("X")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/hpblade/fence_hpblade.py b/fence/agents/hpblade/fence_hpblade.py
index 636c77d..ee59d5f 100644
--- a/fence/agents/hpblade/fence_hpblade.py
+++ b/fence/agents/hpblade/fence_hpblade.py
@@ -88,7 +88,7 @@ and uses the command line interface to power on and off blades."
try:
conn.send_eol("exit")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/ilo_mp/fence_ilo_mp.py b/fence/agents/ilo_mp/fence_ilo_mp.py
index 1d874c1..6cc2d9f 100644
--- a/fence/agents/ilo_mp/fence_ilo_mp.py
+++ b/fence/agents/ilo_mp/fence_ilo_mp.py
@@ -60,7 +60,7 @@ def main():
try:
conn.send_eol("exit")
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 845372b..964e613 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -1102,7 +1102,7 @@ def run_command(options, command, timeout = None, env = None):
try:
process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
- except OSError, ex:
+ except OSError:
fail_usage("Unable to run %s\n" % command)
thread = threading.Thread(target = process.wait)
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index 304ebe4..c487656 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -156,7 +156,7 @@ def main():
try:
conn.send("quit\r\n")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/netio/fence_netio.py b/fence/agents/netio/fence_netio.py
index 3b8247b..4cf3b43 100755
--- a/fence/agents/netio/fence_netio.py
+++ b/fence/agents/netio/fence_netio.py
@@ -107,7 +107,7 @@ block any necessary fencing actions."
conn.send("quit\n")
conn.log_expect(options, "110 BYE", int(options["--shell-timeout"]))
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/raritan/fence_raritan.py b/fence/agents/raritan/fence_raritan.py
index 7704c41..efd5605 100644
--- a/fence/agents/raritan/fence_raritan.py
+++ b/fence/agents/raritan/fence_raritan.py
@@ -90,7 +90,7 @@ block any necessary fencing actions."
try:
conn.send("exit\n")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py
index e163397..1167907 100644
--- a/fence/agents/rsa/fence_rsa.py
+++ b/fence/agents/rsa/fence_rsa.py
@@ -69,7 +69,7 @@ will block any necessary fencing actions."
try:
conn.send_eol("exit")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/rsb/fence_rsb.py b/fence/agents/rsb/fence_rsb.py
index e9e37de..7aab0ae 100755
--- a/fence/agents/rsb/fence_rsb.py
+++ b/fence/agents/rsb/fence_rsb.py
@@ -78,7 +78,7 @@ will block any necessary fencing actions."
try:
conn.send_eol("0")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/sanbox2/fence_sanbox2.py b/fence/agents/sanbox2/fence_sanbox2.py
index c53f1ef..996a501 100644
--- a/fence/agents/sanbox2/fence_sanbox2.py
+++ b/fence/agents/sanbox2/fence_sanbox2.py
@@ -34,7 +34,7 @@ def get_power_status(conn, options):
conn.send_eol("admin end")
conn.send_eol("exit")
conn.close()
- except:
+ except Exception:
pass
fail(EC_TIMED_OUT)
@@ -60,7 +60,7 @@ def set_power_status(conn, options):
conn.send_eol("admin end")
conn.send_eol("exit")
conn.close()
- except:
+ except Exception:
pass
fail(EC_TIMED_OUT)
@@ -72,7 +72,7 @@ def set_power_status(conn, options):
conn.send_eol("admin end")
conn.send_eol("exit")
conn.close()
- except:
+ except Exception:
pass
fail(EC_TIMED_OUT)
@@ -97,7 +97,7 @@ def get_list_devices(conn, options):
conn.send_eol("admin end")
conn.send_eol("exit")
conn.close()
- except:
+ except Exception:
pass
fail(EC_TIMED_OUT)
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index 9f94f58..b56fec2 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -98,7 +98,7 @@ must allow ssh login in your sshd_config."
try:
conn.sendline("quit")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index a7e1c8f..290eaaa 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -243,7 +243,7 @@ is running because the connection will block any necessary fencing actions."
try:
conn.send("/X"+"\r\n")
conn.close()
- except:
+ except Exception:
pass
sys.exit(result)
10 years
fence-agents: master - fencing: Add support for --delay for all python SNMP fence agents
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=d2cdfc...
Commit: d2cdfc62d32402f264a8828cd519f0182e2a5645
Parent: a957c2004a0fa423de2c3ae6c8bbb50907cb8a79
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Apr 23 17:45:53 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Apr 23 17:45:53 2014 +0200
fencing: Add support for --delay for all python SNMP fence agents
---
fence/agents/lib/fencing_snmp.py.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
index 5f03e80..a034bd2 100644
--- a/fence/agents/lib/fencing_snmp.py.py
+++ b/fence/agents/lib/fencing_snmp.py.py
@@ -5,7 +5,7 @@
import re, pexpect
import logging
from fencing import *
-from fencing import fail, fail_usage, EC_TIMED_OUT
+from fencing import fail, fail_usage, EC_TIMED_OUT, run_delay
__all__ = [ 'FencingSnmp' ]
@@ -19,6 +19,7 @@ BUILD_DATE = ""
class FencingSnmp:
def __init__(self, options):
self.options = options
+ run_delay(options)
def quote_for_run(self, string):
return string.replace(r"'", "'\\''")
10 years
fence-agents: master - fencing: Add support for --delay for all python non-SNMP fence agents
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=a957c2...
Commit: a957c2004a0fa423de2c3ae6c8bbb50907cb8a79
Parent: c0498f38d29d8a89dbc44baac06f575be10148f6
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Apr 23 17:44:37 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Apr 23 17:44:37 2014 +0200
fencing: Add support for --delay for all python non-SNMP fence agents
---
fence/agents/amt/fence_amt.py | 4 +++-
fence/agents/cisco_ucs/fence_cisco_ucs.py | 8 ++------
fence/agents/eps/fence_eps.py | 3 ++-
fence/agents/ipmilan/fence_ipmilan.py | 4 +++-
fence/agents/lib/fencing.py.py | 11 +++++++----
fence/agents/netio/fence_netio.py | 3 ++-
fence/agents/ovh/fence_ovh.py | 4 +++-
fence/agents/raritan/fence_raritan.py | 6 ++----
fence/agents/rhevm/fence_rhevm.py | 3 ++-
fence/agents/vmware/fence_vmware.py | 4 +++-
fence/agents/vmware_soap/fence_vmware_soap.py | 6 +++---
fence/agents/xenapi/fence_xenapi.py | 3 +++
12 files changed, 35 insertions(+), 24 deletions(-)
diff --git a/fence/agents/amt/fence_amt.py b/fence/agents/amt/fence_amt.py
index 4a3f0e2..876a7c9 100644
--- a/fence/agents/amt/fence_amt.py
+++ b/fence/agents/amt/fence_amt.py
@@ -5,7 +5,7 @@ import atexit
from pipes import quote
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
-from fencing import fail_usage, is_executable, SUDO_PATH, run_command
+from fencing import fail_usage, is_executable, SUDO_PATH, run_command, run_delay
#BEGIN_VERSION_GENERATION
RELEASE_VERSION="Fence agent for Intel AMT"
@@ -104,6 +104,8 @@ which can be used with Intel AMT. This agent calls support software amttool\
docs["vendorurl"] = "http://www.intel.com/"
show_docs(options, docs)
+ run_delay(options)
+
if not is_executable(options["--amttool-path"]):
fail_usage("Amttool not found or not accessible")
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index afe2c0d..57c8d4e 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -7,7 +7,7 @@ import time
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
-from fencing import fail, EC_STATUS, EC_LOGIN_DENIED
+from fencing import fail, EC_STATUS, EC_LOGIN_DENIED, run_delay
#BEGIN_VERSION_GENERATION
RELEASE_VERSION="New Cisco UCS Agent - test release on steroids"
@@ -127,11 +127,7 @@ used with Cisco UCS to fence machines."
docs["vendorurl"] = "http://www.cisco.com"
show_docs(options, docs)
- ## 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
- if options["--action"] in ["off", "reboot"]:
- time.sleep(int(options["--delay"]))
-
+ run_delay(options)
### Login
try:
res = send_command(options, "<aaaLogin inName=\"" + options["--username"] +
diff --git a/fence/agents/eps/fence_eps.py b/fence/agents/eps/fence_eps.py
index 740a9e5..42dce72 100644
--- a/fence/agents/eps/fence_eps.py
+++ b/fence/agents/eps/fence_eps.py
@@ -9,7 +9,7 @@ import logging
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
-from fencing import fail, fail_usage, EC_LOGIN_DENIED, EC_TIMED_OUT
+from fencing import fail, fail_usage, EC_LOGIN_DENIED, EC_TIMED_OUT, run_delay
#BEGIN_VERSION_GENERATION
RELEASE_VERSION="ePowerSwitch 8M+ (eps)"
@@ -119,6 +119,7 @@ page feature must be enabled and properly configured."
docs["vendorurl"] = "http://www.epowerswitch.com"
show_docs(options, docs)
+ run_delay(options)
#Run fence action. Conn is None, beacause we always need open new http connection
result = fence_action(None, options, set_power_status, get_power_status, get_power_status)
diff --git a/fence/agents/ipmilan/fence_ipmilan.py b/fence/agents/ipmilan/fence_ipmilan.py
index d7b0f18..9c63242 100644
--- a/fence/agents/ipmilan/fence_ipmilan.py
+++ b/fence/agents/ipmilan/fence_ipmilan.py
@@ -5,7 +5,7 @@ import atexit
from pipes import quote
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
-from fencing import SUDO_PATH, fail_usage, is_executable, run_command
+from fencing import SUDO_PATH, fail_usage, is_executable, run_command, run_delay
#BEGIN_VERSION_GENERATION
RELEASE_VERSION=""
@@ -150,6 +150,8 @@ This agent calls support software ipmitool (http://ipmitool.sf.net/)."
("fence_idrac", "Fence agent for Dell iDRAC")]
show_docs(options, docs)
+ run_delay(options)
+
if not is_executable(options["--ipmitool-path"]):
fail_usage("Ipmitool not found or not accessible")
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 474eb3b..845372b 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -972,10 +972,7 @@ def fence_login(options, re_login_string = r"(login\s*: )|(Login Name: )|(usern
options["--command-prompt"] = [ options["--command-prompt"] ]
## 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
- if options["--action"] in ["off", "reboot"]:
- logging.info("Delay %s second(s) before logging in to the fence device", options["--delay"])
- time.sleep(int(options["--delay"]))
+ run_delay(options)
try:
re_login = re.compile(re_login_string, re.IGNORECASE)
@@ -1124,3 +1121,9 @@ def run_command(options, command, timeout = None, env = None):
logging.debug("%s %s %s\n", str(status), str(pipe_stdout), str(pipe_stderr))
return (status, pipe_stdout, pipe_stderr)
+
+def run_delay(options):
+ ## Delay is important for two-node clusters fencing but we do not need to delay 'status' operations
+ if options["--action"] in ["off", "reboot"]:
+ logging.info("Delay %s second(s) before logging in to the fence device", options["--delay"])
+ time.sleep(int(options["--delay"]))
diff --git a/fence/agents/netio/fence_netio.py b/fence/agents/netio/fence_netio.py
index 4708ff6..3b8247b 100755
--- a/fence/agents/netio/fence_netio.py
+++ b/fence/agents/netio/fence_netio.py
@@ -4,7 +4,7 @@ import sys, re, pexpect
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
-from fencing import fspawn, fail, EC_LOGIN_DENIED, TELNET_PATH
+from fencing import fspawn, fail, EC_LOGIN_DENIED, TELNET_PATH, run_delay
#BEGIN_VERSION_GENERATION
RELEASE_VERSION=""
@@ -80,6 +80,7 @@ block any necessary fencing actions."
## Operate the fencing device
## We can not use fence_login(), username and passwd are sent on one line
####
+ run_delay(options)
try:
conn = fspawn(options, TELNET_PATH)
conn.send("set binary\n")
diff --git a/fence/agents/ovh/fence_ovh.py b/fence/agents/ovh/fence_ovh.py
index 585b7d0..4cad818 100644
--- a/fence/agents/ovh/fence_ovh.py
+++ b/fence/agents/ovh/fence_ovh.py
@@ -17,7 +17,7 @@ from suds.client import Client
from suds.xsd.doctor import ImportDoctor, Import
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
-from fencing import fail, fail_usage, EC_LOGIN_DENIED
+from fencing import fail, fail_usage, EC_LOGIN_DENIED, run_delay
OVH_RESCUE_PRO_NETBOOT_ID = '28'
OVH_HARD_DISK_NETBOOT_ID = '1'
@@ -112,6 +112,8 @@ Poweroff is simulated with a reboot into rescue-pro mode."
# Save datetime just before changing netboot
before_netboot_reboot = datetime.now()
+ run_delay(options)
+
if options["--action"] == 'off':
# Reboot in Rescue-pro
netboot_reboot(options, OVH_RESCUE_PRO_NETBOOT_ID)
diff --git a/fence/agents/raritan/fence_raritan.py b/fence/agents/raritan/fence_raritan.py
index 3318fbf..7704c41 100644
--- a/fence/agents/raritan/fence_raritan.py
+++ b/fence/agents/raritan/fence_raritan.py
@@ -2,10 +2,9 @@
import sys, re, pexpect
import atexit
-import time
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
-from fencing import fspawn, fail, fail_usage, TELNET_PATH, EC_LOGIN_DENIED
+from fencing import fspawn, fail, fail_usage, TELNET_PATH, EC_LOGIN_DENIED, run_delay
#BEGIN_VERSION_GENERATION
RELEASE_VERSION=""
@@ -59,8 +58,7 @@ block any necessary fencing actions."
show_docs(options, docs)
# add support also for delay before login which is very useful for 2-node clusters
- if options["--action"] in ["off", "reboot"]:
- time.sleep(int(options["--delay"]))
+ run_delay(options)
##
## Operate the fencing device
diff --git a/fence/agents/rhevm/fence_rhevm.py b/fence/agents/rhevm/fence_rhevm.py
index cd75c3b..f8c834d 100644
--- a/fence/agents/rhevm/fence_rhevm.py
+++ b/fence/agents/rhevm/fence_rhevm.py
@@ -6,7 +6,7 @@ import logging
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
-from fencing import fail, EC_STATUS
+from fencing import fail, EC_STATUS, run_delay
#BEGIN_VERSION_GENERATION
RELEASE_VERSION="New RHEV-M Agent - test release on steroids"
@@ -125,6 +125,7 @@ used with RHEV-M REST API to fence virtual machines."
##
## Fence operations
####
+ run_delay(options)
result = fence_action(None, options, set_power_status, get_power_status, get_list)
sys.exit(result)
diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py
index 63e809a..96aafb6 100644
--- a/fence/agents/vmware/fence_vmware.py
+++ b/fence/agents/vmware/fence_vmware.py
@@ -27,7 +27,7 @@ import logging
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
-from fencing import fail, fail_usage, EC_TIMED_OUT
+from fencing import fail, fail_usage, EC_TIMED_OUT, run_delay
#BEGIN_VERSION_GENERATION
RELEASE_VERSION="VMware Agent using VI Perl API and/or VIX vmrun command"
@@ -322,6 +322,8 @@ This agent supports only vmrun from version 2.0.0 (VIX API 1.6.0)."
docs["vendorurl"] = "http://www.vmware.com"
show_docs(options, docs)
+ run_delay(options)
+
# Check vmware type and set path
vmware_check_vmware_type(options)
diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
index feba447..66e7eb9 100644
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
@@ -1,6 +1,6 @@
#!/usr/bin/python -tt
-import sys, time
+import sys
import shutil, tempfile, suds
import logging
import atexit
@@ -10,6 +10,7 @@ from suds.client import Client
from suds.sudsobject import Property
from fencing import *
from fencing import fail, EC_STATUS, EC_LOGIN_DENIED, EC_INVALID_PRIVILEGES, EC_WAITING_ON, EC_WAITING_OFF
+from fencing import run_delay
#BEGIN_VERSION_GENERATION
RELEASE_VERSION="New VMWare Agent - test release on steroids"
@@ -18,8 +19,7 @@ BUILD_DATE="April, 2011"
#END_VERSION_GENERATION
def soap_login(options):
- if options["--action"] in ["off", "reboot"]:
- time.sleep(int(options["--delay"]))
+ run_delay(options)
if options.has_key("--ssl"):
url = "https://"
diff --git a/fence/agents/xenapi/fence_xenapi.py b/fence/agents/xenapi/fence_xenapi.py
index 0a4f838..25db7c7 100644
--- a/fence/agents/xenapi/fence_xenapi.py
+++ b/fence/agents/xenapi/fence_xenapi.py
@@ -35,6 +35,7 @@ import sys
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
+from fencing import run_delay
import XenAPI
#BEGIN_VERSION_GENERATION
@@ -217,6 +218,8 @@ the status of virtual machines running on the host."
docs["vendorurl"] = "http://www.xenproject.org"
show_docs(options, docs)
+ run_delay(options)
+
xen_session = connect_and_login(options)
# Operate the fencing device
10 years
fence-agents: master - fencing: Introduce new device option 'no_status'
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=c0498f...
Commit: c0498f38d29d8a89dbc44baac06f575be10148f6
Parent: 33aa9709b40af9727a6bf66f8c0e5ed3ef4572ca
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Apr 23 17:41:33 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Apr 23 17:41:33 2014 +0200
fencing: Introduce new device option 'no_status'
Some fence agents are not able to obtain status e.g. fence_ovh or fence_kdump,
with this patch this can be reflected in metadata. Also fix for fence_ovh.
---
fence/agents/lib/fencing.py.py | 10 +++++++++-
fence/agents/ovh/fence_ovh.py | 3 ++-
tests/data/metadata/fence_ovh.xml | 1 -
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index ff4cf7f..474eb3b 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -125,6 +125,10 @@ all_opt = {
"getopt" : "",
"help" : "",
"order" : 1 },
+ "no_status" : {
+ "getopt" : "",
+ "help" : "",
+ "order" : 1 },
"passwd" : {
"getopt" : "p:",
"longopt" : "password",
@@ -524,7 +528,8 @@ def metadata(avail_opt, options, docs):
if avail_opt.count("fabric_fencing") == 0:
print "\t<action name=\"reboot\" />"
- print "\t<action name=\"status\" />"
+ if avail_opt.count("no_status") == 0:
+ print "\t<action name=\"status\" />"
print "\t<action name=\"list\" />"
print "\t<action name=\"monitor\" />"
print "\t<action name=\"metadata\" />"
@@ -694,6 +699,9 @@ def check_input(device_opt, opt):
else:
acceptable_actions.extend(["reboot"])
+ if 1 == device_opt.count("no_status"):
+ acceptable_actions.remove("status")
+
if 0 == acceptable_actions.count(options["--action"]):
fail_usage("Failed: Unrecognised action '" + options["--action"] + "'")
diff --git a/fence/agents/ovh/fence_ovh.py b/fence/agents/ovh/fence_ovh.py
index 0f460df..585b7d0 100644
--- a/fence/agents/ovh/fence_ovh.py
+++ b/fence/agents/ovh/fence_ovh.py
@@ -83,11 +83,12 @@ def remove_tmp_dir(tmp_dir):
shutil.rmtree(tmp_dir)
def main():
- device_opt = [ "login", "passwd", "port", "email" ]
+ device_opt = [ "login", "passwd", "port", "email", "no_status" ]
atexit.register(atexit_handler)
define_new_opts()
+ all_opt["action"]["help"] = "-o, --action=[action] Action: reboot (default), off or on"
options = check_input(device_opt, process_input(device_opt))
docs = { }
diff --git a/tests/data/metadata/fence_ovh.xml b/tests/data/metadata/fence_ovh.xml
index 2c08dcb..522da6c 100644
--- a/tests/data/metadata/fence_ovh.xml
+++ b/tests/data/metadata/fence_ovh.xml
@@ -93,7 +93,6 @@
<action name="on" automatic="0"/>
<action name="off" />
<action name="reboot" />
- <action name="status" />
<action name="list" />
<action name="monitor" />
<action name="metadata" />
10 years
fence-agents: master - [cleanup] Removing unused part which was replaced by proper 'default' values for 'ipport'
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=33aa97...
Commit: 33aa9709b40af9727a6bf66f8c0e5ed3ef4572ca
Parent: ea615b438ee7bcef77bed9add7a7fe8760a1b7fc
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Apr 16 17:26:34 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Apr 23 17:39:23 2014 +0200
[cleanup] Removing unused part which was replaced by proper 'default' values for 'ipport'
---
fence/agents/lib/fencing.py.py | 10 ----------
1 files changed, 0 insertions(+), 10 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index b4ecea7..ff4cf7f 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -747,16 +747,6 @@ def check_input(device_opt, opt):
if options.has_key("--snmp-priv-passwd-script"):
options["--snmp-priv-passwd"] = os.popen(options["--snmp-priv-passwd-script"]).read().rstrip()
- if options.has_key("--ipport") == False:
- if options.has_key("--ssh"):
- options["--ipport"] = 22
- elif options.has_key("--ssl"):
- options["--ipport"] = 443
- elif device_opt.count("web"):
- options["--ipport"] = 80
- else:
- options["--ipport"] = 23
-
if options.has_key("--plug") and len(options["--plug"].split(",")) > 1 and \
options.has_key("--method") and options["--method"] == "cycle":
fail_usage("Failed: Cannot use --method cycle for more than 1 plug")
10 years
fence-agents: master - [cleanup] Remove method log_command() from FencingSnmp as it was replaced by logging.debug()
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=ea615b...
Commit: ea615b438ee7bcef77bed9add7a7fe8760a1b7fc
Parent: c84df1578d288fb23e2cd72e1704f7c4234b7fd4
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Apr 16 17:21:57 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Apr 23 17:39:06 2014 +0200
[cleanup] Remove method log_command() from FencingSnmp as it was replaced by logging.debug()
---
fence/agents/lib/fencing_snmp.py.py | 8 ++------
1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
index 997e2da..5f03e80 100644
--- a/fence/agents/lib/fencing_snmp.py.py
+++ b/fence/agents/lib/fencing_snmp.py.py
@@ -20,10 +20,6 @@ class FencingSnmp:
def __init__(self, options):
self.options = options
- # Log message if user set verbose option
- def log_command(self, message):
- logging.debug("%s\n", message)
-
def quote_for_run(self, string):
return string.replace(r"'", "'\\''")
@@ -88,7 +84,7 @@ class FencingSnmp:
def run_command(self, command, additional_timemout=0):
try:
- self.log_command(command)
+ logging.debug("%s\n", command)
(res_output, res_code) = pexpect.run(command,
int(self.options["--shell-timeout"]) +
@@ -98,7 +94,7 @@ class FencingSnmp:
if res_code == None:
fail(EC_TIMED_OUT)
- self.log_command(res_output)
+ logging.debug("%s\n", res_output)
if (res_code!=0) or (re.search("^Error ", res_output, re.MULTILINE) != None):
fail_usage("Returned %d: %s"% (res_code, res_output))
10 years