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