Gitweb:
http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=c7ba00...
Commit: c7ba00daf03a19d7557e825e637a220b5cc4deae
Parent: b0303c783b9ee4d4214828d88344547549a04d11
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Oct 25 12:48:12 2012 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Oct 29 12:30:09 2012 +0100
fabric fence agents: Fix dealing with enable/disable and support on/off options for fabric
fence agents
---
fence/agents/cisco_mds/fence_cisco_mds.py | 16 +--------
fence/agents/ifmib/fence_ifmib.py | 17 +---------
fence/agents/lib/fencing.py.py | 50 ++++++++++++++---------------
fence/agents/sanbox2/fence_sanbox2.py | 2 +-
4 files changed, 29 insertions(+), 56 deletions(-)
diff --git a/fence/agents/cisco_mds/fence_cisco_mds.py
b/fence/agents/cisco_mds/fence_cisco_mds.py
index a007fde..e2a1e91 100644
--- a/fence/agents/cisco_mds/fence_cisco_mds.py
+++ b/fence/agents/cisco_mds/fence_cisco_mds.py
@@ -81,7 +81,7 @@ def get_outlets_status(conn, options):
def main():
global port_oid
- device_opt = [ "ipaddr", "login", "passwd",
"passwd_script",
+ device_opt = [ "fabric_fencing", "ipaddr", "login",
"passwd", "passwd_script",
"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",
@@ -90,20 +90,8 @@ def main():
atexit.register(atexit_handler)
snmp_define_defaults ()
- options=process_input(device_opt)
- # Emulate enable/disable functionality
- if (options.has_key("-o")):
- options["-o"]=options["-o"].lower()
-
- if (options["-o"]=="enable"):
- options["-o"]="on"
- if (options["-o"]=="disable"):
- options["-o"]="off"
- else:
- options["-o"]="off"
-
- options = check_input(device_opt, options)
+ options = check_input(device_opt, process_input(device_opt))
docs = { }
docs["shortdesc"] = "Fence agent for Cisco MDS"
diff --git a/fence/agents/ifmib/fence_ifmib.py b/fence/agents/ifmib/fence_ifmib.py
index a43bf38..0b0a71d 100644
--- a/fence/agents/ifmib/fence_ifmib.py
+++ b/fence/agents/ifmib/fence_ifmib.py
@@ -97,7 +97,7 @@ def get_outlets_status(conn, options):
def main():
global port_oid
- device_opt = [ "ipaddr", "login", "passwd",
"passwd_script",
+ device_opt = [ "fabric_fencing", "ipaddr", "login",
"passwd", "passwd_script",
"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",
@@ -108,20 +108,7 @@ def main():
snmp_define_defaults ()
all_opt["snmp_version"]["default"]="2c"
- options=process_input(device_opt)
-
- # Emulate enable/disable functionality
- if (options.has_key("-o")):
- options["-o"]=options["-o"].lower()
-
- if (options["-o"]=="enable"):
- options["-o"]="on"
- if (options["-o"]=="disable"):
- options["-o"]="off"
- else:
- options["-o"]="off"
-
- options = check_input(device_opt, options)
+ options = check_input(device_opt, process_input(device_opt))
docs = { }
docs["shortdesc"] = "Fence agent for IF MIB"
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index e26f9b3..c1851d1 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -89,13 +89,9 @@ all_opt = {
"shortdesc" : "Fencing Action",
"default" : "reboot",
"order" : 1 },
- "io_fencing" : {
- "getopt" : "o:",
- "longopt" : "action",
- "help" : "-o, --action=<action> Action: status, enable or
disable",
- "required" : "1",
- "shortdesc" : "Fencing Action",
- "default" : "disable",
+ "fabric_fencing" : {
+ "getopt" : "",
+ "help" : "",
"order" : 1 },
"ipaddr" : {
"getopt" : "a:",
@@ -522,13 +518,11 @@ def metadata(avail_opt, options, docs):
print "\t</parameter>"
print "</parameters>"
print "<actions>"
- if avail_opt.count("io_fencing") == 0:
- print "\t<action name=\"on\" />"
- print "\t<action name=\"off\" />"
+ print "\t<action name=\"on\" />"
+ print "\t<action name=\"off\" />"
+
+ if avail_opt.count("fabric_fencing") == 0:
print "\t<action name=\"reboot\" />"
- else:
- print "\t<action name=\"enable\" />"
- print "\t<action name=\"disable\" />"
print "\t<action name=\"status\" />"
print "\t<action name=\"list\" />"
@@ -629,8 +623,6 @@ def process_input(avail_opt):
name = "ipaddr"
elif name == "modulename":
name = "module_name"
- elif name == "action" and 1 == avail_opt.count("io_fencing"):
- name = "io_fencing"
elif name == "port" and 1 == avail_opt.count("drac_version"):
name = "module_name"
@@ -683,19 +675,30 @@ def check_input(device_opt, opt):
if 0 == options.has_key(getopt):
options[getopt] = all_opt[opt]["default"]
- options["-o"]=options["-o"].lower()
+ options["-o"] = options["-o"].lower()
if options.has_key("-v"):
options["log"] = LOG_MODE_VERBOSE
else:
options["log"] = LOG_MODE_QUIET
- if 0 == device_opt.count("io_fencing"):
- if 0 == ["on", "off", "reboot", "status",
"list", "monitor"].count(options["-o"].lower()):
- fail_usage("Failed: Unrecognised action '" + options["-o"] +
"'")
+ acceptable_actions = [ "on", "off", "status",
"list", "monitor" ]
+ if 0 == device_opt.count("fabric_fencing"):
+ ## Compatibility layer
+ #####
+ acceptable_actions.extend(["enable", "disable"])
else:
- if 0 == ["enable", "disable", "status", "list",
"monitor"].count(options["-o"].lower()):
- fail_usage("Failed: Unrecognised action '" + options["-o"] +
"'")
+ acceptable_actions.extend(["reboot"])
+
+ if 0 == acceptable_actions.count(options["-o"]):
+ fail_usage("Failed: Unrecognised action '" + options["-o"] +
"'")
+
+ ## Compatibility layer
+ #####
+ if options["-o"] == "enable":
+ options["-o"] = "on"
+ if options["-o"] == "disable":
+ options["-o"] = "off"
if (0 == options.has_key("-l")) and device_opt.count("login") and
(device_opt.count("no_login") == 0):
fail_usage("Failed: You have to set login name")
@@ -807,11 +810,6 @@ def fence_action(tn, options, set_power_fn, get_power_fn,
get_outlet_list = None
if status != "on" and status != "off":
fail(EC_STATUS)
-
- if options["-o"] == "enable":
- options["-o"] = "on"
- if options["-o"] == "disable":
- options["-o"] = "off"
if options["-o"] == "on":
if status == "on":
diff --git a/fence/agents/sanbox2/fence_sanbox2.py
b/fence/agents/sanbox2/fence_sanbox2.py
index fdbea06..51781f9 100644
--- a/fence/agents/sanbox2/fence_sanbox2.py
+++ b/fence/agents/sanbox2/fence_sanbox2.py
@@ -108,7 +108,7 @@ def get_list_devices(conn, options):
return outlets
def main():
- device_opt = [ "io_fencing", "ipaddr", "login",
"passwd", "passwd_script",
+ device_opt = [ "fabric_fencing", "ipaddr", "login",
"passwd", "passwd_script",
"cmd_prompt", "port", "ipport", "separator" ]
atexit.register(atexit_handler)