public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: RHEL55 - fencing: #519697 - List option for fencing agents
@ 2009-08-31 16:02 Marek Grác
0 siblings, 0 replies; only message in thread
From: Marek Grác @ 2009-08-31 16:02 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=a39b80511c6a44a838fb549297f4d696c5e299e2
Commit: a39b80511c6a44a838fb549297f4d696c5e299e2
Parent: 66c513bfc91bdd325c3620b4da9c66d5028fcf23
Author: Marek 'marx' Grac <mgrac@redhat.com>
AuthorDate: Mon Aug 31 16:40:04 2009 +0200
Committer: Marek 'marx' Grac <mgrac@redhat.com>
CommitterDate: Mon Aug 31 16:40:04 2009 +0200
fencing: #519697 - List option for fencing agents
---
fence/agents/apc/fence_apc.py | 26 +++++++---
fence/agents/bladecenter/fence_bladecenter.py | 28 ++++++++++-
fence/agents/cisco_mds/fence_cisco_mds.py | 4 +-
fence/agents/drac/fence_drac5.py | 27 ++++++++++-
fence/agents/eps/fence_eps.py | 26 ++++++----
fence/agents/ilo/fence_ilo.py | 2 +-
fence/agents/lib/fencing.py.py | 45 +++++++++++++++---
fence/agents/lpar/fence_lpar.py | 52 +++++++++++++++++++-
fence/agents/rsa/fence_rsa.py | 2 +-
fence/agents/virsh/fence_virsh.py | 4 +-
fence/agents/vmware/fence_vmware.py | 63 +++++++++++++++++++------
fence/agents/wti/fence_wti.py | 18 +++++--
12 files changed, 238 insertions(+), 59 deletions(-)
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index 2868c16..b178a50 100755
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -27,6 +27,7 @@ BUILD_DATE=""
def get_power_status(conn, options):
result = ""
+ outlets = {}
try:
conn.send("1\r\n")
conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
@@ -69,6 +70,12 @@ def get_power_status(conn, options):
while 1 == conn.log_expect(options, [ options["-c"], "Press <ENTER>" ], SHELL_TIMEOUT):
result += conn.before
+ lines = conn.before.split("\n");
+ show_re = re.compile('^\s*(\d+)- (.*?)\s+(ON|OFF)\s*$')
+ for x in lines:
+ res = show_re.search(x)
+ if (res != None):
+ outlets[res.group(1)] = (res.group(2), res.group(3))
conn.send("\r\n")
result += conn.before
conn.send(chr(03))
@@ -79,12 +86,15 @@ def get_power_status(conn, options):
except pexpect.TIMEOUT:
fail(EC_TIMED_OUT)
- try:
- status = re.compile("\s*"+options["-n"]+"-.*(ON|OFF)", re.IGNORECASE).search(result).group(1)
- except AttributeError:
- fail(EC_STATUS)
+ if ["list", "monitor"].count(options["-o"]) == 1:
+ return outlets
+ else:
+ try:
+ status = re.compile("\s*"+options["-n"]+"-.*(ON|OFF)", re.IGNORECASE).search(result).group(1)
+ except AttributeError:
+ fail(EC_STATUS)
- return status.lower().strip()
+ return status.lower().strip()
def set_power_status(conn, options):
action = {
@@ -175,7 +185,7 @@ def set_power_status(conn, options):
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
- "secure", "port", "switch", "test" ]
+ "secure", "port", "switch", "test", "separator" ]
atexit.register(atexit_handler)
@@ -190,7 +200,7 @@ def main():
options["-c"] = "\n>"
## Support for -n [switch]:[plug] notation that was used before
- if (-1 != options["-n"].find(":")):
+ if (options.has_key("-n") == 1) and (-1 != options["-n"].find(":")):
(switch, plug) = options["-n"].split(":", 1)
options["-s"] = switch;
options["-n"] = plug;
@@ -199,7 +209,7 @@ def main():
## Operate the fencing device
####
conn = fence_login(options)
- fence_action(conn, options, set_power_status, get_power_status)
+ fence_action(conn, options, set_power_status, get_power_status, get_power_status)
##
## Logout from system
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index 65158c4..da857ab 100755
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -64,10 +64,34 @@ def set_power_status(conn, options):
except pexpect.TIMEOUT:
fail(EC_TIMED_OUT)
+def get_blades_list(conn, options):
+ outlets = { }
+ try:
+ node_cmd = "system>"
+
+ conn.send("env -T system\r\n")
+ conn.log_expect(options, node_cmd, SHELL_TIMEOUT)
+ conn.send("list -l 2\r\n")
+ conn.log_expect(options, node_cmd, SHELL_TIMEOUT)
+
+ lines = conn.before.split("\r\n")
+ filter_re = re.compile("^\s*blade\[(\d+)\]\s+(.*?)\s*$")
+ for x in lines:
+ res = filter_re.search(x)
+ if res != None:
+ outlets[res.group(1)] = (res.group(2), "")
+
+ except pexpect.EOF:
+ fail(EC_CONNECTION_LOST)
+ except pexpect.TIMEOUT:
+ fail(EC_TIMED_OUT)
+
+ return outlets
+
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
- "cmd_prompt", "secure", "port", "identity_file" ]
+ "cmd_prompt", "secure", "port", "identity_file", "separator" ]
atexit.register(atexit_handler)
@@ -83,7 +107,7 @@ def main():
## Operate the fencing device
######
conn = fence_login(options)
- fence_action(conn, options, set_power_status, get_power_status)
+ fence_action(conn, options, set_power_status, get_power_status, get_blades_list)
##
## Logout from system
diff --git a/fence/agents/cisco_mds/fence_cisco_mds.py b/fence/agents/cisco_mds/fence_cisco_mds.py
index d1838f4..0817785 100644
--- a/fence/agents/cisco_mds/fence_cisco_mds.py
+++ b/fence/agents/cisco_mds/fence_cisco_mds.py
@@ -83,7 +83,7 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
- "test", "port", "no_login", "no_password",
+ "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"]
@@ -109,7 +109,7 @@ def main():
port_oid=cisco_port2oid(options["-n"])
# Operate the fencing device
- fence_action(FencingSnmp(options), options, set_power_status, get_power_status)
+ fence_action(FencingSnmp(options), options, set_power_status, get_power_status, get_outlets_status)
if __name__ == "__main__":
main()
diff --git a/fence/agents/drac/fence_drac5.py b/fence/agents/drac/fence_drac5.py
index 57f94b3..ec210c5 100755
--- a/fence/agents/drac/fence_drac5.py
+++ b/fence/agents/drac/fence_drac5.py
@@ -58,10 +58,33 @@ def set_power_status(conn, options):
except pexpect.TIMEOUT:
fail(EC_TIMED_OUT)
+def get_list_devices(conn, options):
+ outlets = { }
+
+ try:
+ if options["model"] == "DRAC CMC":
+ conn.sendline("getmodinfo")
+
+ list_re = re.compile("^([^\s]*?)\s+Present\s*(ON|OFF)\s*.*$")
+ 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)
+ elif options["model"] == "DRAC 5":
+ ## DRAC 5 can be used only for one computer
+ pass
+ except pexpect.EOF:
+ fail(EC_CONNECTION_LOST)
+ except pexpect.TIMEOUT:
+ fail(EC_TIMED_OUT)
+
+ return outlets
+
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
- "cmd_prompt", "secure", "drac_version", "module_name" ]
+ "cmd_prompt", "secure", "drac_version", "module_name",
+ "separator" ]
atexit.register(atexit_handler)
@@ -89,7 +112,7 @@ def main():
## Assume this is DRAC 5 by default as we don't want to break anything
options["model"]="DRAC 5"
- fence_action(conn, options, set_power_status, get_power_status)
+ fence_action(conn, options, set_power_status, get_power_status, get_list_devices)
##
## Logout from system
diff --git a/fence/agents/eps/fence_eps.py b/fence/agents/eps/fence_eps.py
index 19310b9..0d2a63a 100644
--- a/fence/agents/eps/fence_eps.py
+++ b/fence/agents/eps/fence_eps.py
@@ -66,17 +66,20 @@ def eps_run_command(options, params):
return result
def get_power_status(conn, options):
- result = ""
-
ret_val=eps_run_command(options,"")
- status=re.search("p"+options["-n"].lower()+"=(0|1)\s*\<br\>",ret_val.lower())
- if status==None:
- fail_usage("Failed: You have to enter existing physical plug!")
-
- result=(status.group(1)=="1" and "on" or "off")
+ result={}
+ status=re.findall("p(\d{2})=(0|1)\s*\<br\>",ret_val.lower())
+ for out_num,out_stat in status:
+ result[out_num]=("",(out_stat=="1" and "on" or "off"))
- return result
+ if (not (options["-o"] in ['monitor','list'])):
+ if (not (options["-n"] in result)):
+ fail_usage("Failed: You have to enter existing physical plug!")
+ else:
+ return result[options["-n"]][1]
+ else:
+ return result
def set_power_status(conn, options):
ret_val=eps_run_command(options,"P%s=%s"%(options["-n"],(options["-o"]=="on" and "1" or "0")))
@@ -92,7 +95,8 @@ def eps_define_new_opts():
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
- "test", "port", "hidden_page", "no_login", "no_password" ]
+ "test", "port", "hidden_page", "no_login", "no_password",
+ "separator" ]
atexit.register(atexit_handler)
@@ -103,8 +107,8 @@ def main():
if (not options.has_key("-c")):
options["-c"]="hidden.htm"
- #Run fence action. Conn is None, beacause we always need run new curl command
- fence_action(None, options, set_power_status, get_power_status)
+ #Run fence action. Conn is None, beacause we always need open new http connection
+ fence_action(None, options, set_power_status, get_power_status,get_power_status)
if __name__ == "__main__":
main()
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index e3652bf..7105253 100755
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -100,7 +100,7 @@ def main():
##
## Fence operations
####
- fence_action(conn, options, set_power_status, get_power_status)
+ fence_action(conn, options, set_power_status, get_power_status, None)
if __name__ == "__main__":
main()
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index f449037..e875c81 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -209,7 +209,11 @@ all_opt = {
"udpport" : {
"getopt" : "u:",
"help" : "-u <port> UDP/TCP port to use",
- "order" : 1}
+ "order" : 1},
+ "separator" : {
+ "getopt" : "C:",
+ "help" : "-C <char> Separator for CSV created by 'list' operation",
+ "order" : 100 }
}
class fspawn(pexpect.spawn):
@@ -363,6 +367,7 @@ def process_input(avail_opt):
######
def check_input(device_opt, opt):
options = dict(opt)
+ options["device_opt"] = device_opt
if options.has_key("-h"):
usage(device_opt)
@@ -381,7 +386,10 @@ def check_input(device_opt, opt):
if 0 == options.has_key("-o"):
options["-o"] = "reboot"
- if 0 == ["on", "off", "reboot", "status"].count(options["-o"].lower()):
+ # Convert action to lowercase
+ options["-o"]=options["-o"].lower()
+
+ if 0 == ["on", "off", "reboot", "status", "list", "monitor"].count(options["-o"].lower()):
fail_usage("Failed: Unrecognised action '" + options["-o"] + "'")
if (0 == options.has_key("-l")) and device_opt.count("login") and (device_opt.count("no_login") == 0):
@@ -405,7 +413,7 @@ def check_input(device_opt, opt):
if 0 == os.path.isfile(options["-k"]):
fail_usage("Failed: Identity file " + options["-k"] + " does not exist")
- if (0 == options.has_key("-n")) and (device_opt.count("port")):
+ if (0 == ["list", "monitor"].count(options["-o"].lower())) and (0 == options.has_key("-n")) and (device_opt.count("port")):
fail_usage("Failed: You have to enter plug number")
if options.has_key("-S"):
@@ -423,6 +431,9 @@ def check_input(device_opt, opt):
if options.has_key("-R"):
options["-P"] = os.popen(options["-R"]).read().rstrip()
+ if 0 == options.has_key("-C"):
+ options["-C"] = ","
+
## VMware
#######
if options.has_key("-B"):
@@ -431,12 +442,12 @@ def check_input(device_opt, opt):
if (device_opt.count("vmlogin") and (not options.has_key("-L"))):
fail_usage("Failed: You have to set login name for VMware ESX management console")
- if (options.has_key("-L") and (not (options.has_key("-P") or options.has_key("-C")))):
+ if (options.has_key("-L") and (not (options.has_key("-P") or options.has_key("-B")))):
fail_usage("Failed: You have to enter password or password script for VMware ESX management console")
- if (options.has_key("-L") and (not (options.has_key("-n")))):
+ if (["list", "monitor"].count(options["-o"])==0 and (options.has_key("-L") and (not (options.has_key("-n"))))):
fail_usage("Failed: You have to enter virtual machine name")
-
+
return options
def wait_power_status(tn, options, get_power_fn):
@@ -447,7 +458,25 @@ def wait_power_status(tn, options, get_power_fn):
return 1
return 0
-def fence_action(tn, options, set_power_fn, get_power_fn):
+def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None):
+ if (options["-o"] == "list") and (0 == options["device_opt"].count("port")) and (0 == options["device_opt"].count("partition")):
+ print "N/A"
+ return
+ elif (options["-o"] == "list" and get_outlet_list == None):
+ ## @todo: exception?
+ ## This is just temporal solution, we will remove default value
+ ## None as soon as all existing agent will support this operation
+ print "NOTICE: List option is not working on this device yet"
+ return
+ elif (options["-o"] == "list") or ((options["-o"] == "monitor") and 1 == options["device_opt"].count("port")):
+ outlets = get_outlet_list(tn, options)
+ ## keys can be numbers (port numbers) or strings (names of VM)
+ for o in outlets.keys():
+ (alias, status) = outlets[o]
+ if options["-o"] != "monitor":
+ print o + options["-C"] + alias
+ return
+
status = get_power_fn(tn, options)
if status != "on" and status != "off":
@@ -484,6 +513,8 @@ def fence_action(tn, options, set_power_fn, get_power_fn):
print "Success: Rebooted"
elif options["-o"] == "status":
print "Status: " + status.upper()
+ elif options["-o"] == "monitor":
+ 1
def fence_login(options):
try:
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index 11b0826..0836a10 100755
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -85,10 +85,56 @@ def set_power_status(conn, options):
except pexpect.TIMEOUT:
fail(EC_TIMED_OUT)
+def get_lpar_list(conn, options):
+ outlets = { }
+ if options["-H"] == "3":
+ try:
+ conn.send("query_partition_names -m " + options["-s"] + "\n")
+ conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+
+ ## We have to remove first 3 lines (command + header) and last line (part of new prompt)
+ ####
+ res = re.search("^.+?\n(.+?\n){2}(.*)\n.*$", conn.before, re.S)
+
+ if res == None:
+ fail_usage("Unable to parse output of list command")
+
+ lines = res.group(2).split("\n")
+ for x in lines:
+ outlets[x.rstrip()] = ("", "")
+ except pexpect.EOF:
+ fail(EC_CONNECTION_LOST)
+ except pexpect.TIMEOUT:
+ fail(EC_TIMED_OUT)
+ elif options["-H"] == "4":
+ try:
+ conn.send("lssyscfg -r lpar -m " + options["-s"] +
+ " -F name:state\n")
+ conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+
+ ## We have to remove first line (command) and last line (part of new prompt)
+ ####
+ res = re.search("^.+?\n(.*)\n.*$", conn.before, re.S)
+
+ if res == None:
+ fail_usage("Unable to parse output of list command")
+
+ lines = res.group(1).split("\n")
+ for x in lines:
+ s = x.split(":")
+ outlets[s[0]] = ("", s[1])
+ except pexpect.EOF:
+ fail(EC_CONNECTION_LOST)
+ except pexpect.TIMEOUT:
+ fail(EC_TIMED_OUT)
+
+ return outlets
+
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
- "secure", "partition", "managed", "hmc_version", "cmd_prompt" ]
+ "secure", "partition", "managed", "hmc_version", "cmd_prompt",
+ "separator" ]
atexit.register(atexit_handler)
@@ -109,7 +155,7 @@ def main():
if 0 == options.has_key("-s"):
fail_usage("Failed: You have to enter name of managed system")
- if 0 == options.has_key("-n"):
+ if (0 == ["list", "monitor"].count(options["-o"].lower())) and (0 == options.has_key("-n")):
fail_usage("Failed: You have to enter name of the partition")
if 1 == options.has_key("-H") and (options["-H"] != "3" and options["-H"] != "4"):
@@ -119,7 +165,7 @@ def main():
## Operate the fencing device
####
conn = fence_login(options)
- fence_action(conn, options, set_power_status, get_power_status)
+ fence_action(conn, options, set_power_status, get_power_status, get_lpar_list)
##
## Logout from system
diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py
index 51feb8a..6a01d6c 100755
--- a/fence/agents/rsa/fence_rsa.py
+++ b/fence/agents/rsa/fence_rsa.py
@@ -60,7 +60,7 @@ def main():
## Operate the fencing device
######
conn = fence_login(options)
- fence_action(conn, options, set_power_status, get_power_status)
+ fence_action(conn, options, set_power_status, get_power_status, None)
##
## Logout from system
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index f623ac7..aadb77b 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -63,7 +63,7 @@ def set_power_status(conn, options):
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
- "secure", "identity_file", "test", "port" ]
+ "secure", "identity_file", "test", "port", "separator" ]
atexit.register(atexit_handler)
@@ -79,7 +79,7 @@ def main():
## Operate the fencing device
conn = fence_login(options)
- fence_action(conn, options, set_power_status, get_power_status)
+ fence_action(conn, options, set_power_status, get_power_status, get_outlets_status)
## Logout from system
try:
diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py
index a20c51b..1ae7398 100755
--- a/fence/agents/vmware/fence_vmware.py
+++ b/fence/agents/vmware/fence_vmware.py
@@ -27,23 +27,27 @@ def start_communication(conn, options):
conn.log_expect(options,COMMAND_PROMPT_REG,SHELL_TIMEOUT)
# Prepare command line for vmware-cmd with parameters.
-def prepare_cmdline(conn,options):
- cmd_line=VMWARE_COMMAND+" -H "+options["-A"]+" -U "+options["-L"]+" -P "+options["-P"]+" '"+options["-n"]+"'"
- if options.has_key("-A"):
+def prepare_cmdline(conn,options,add_vm_name):
+ cmd_line=VMWARE_COMMAND+" -H '"+options["-A"]+"' -U '"+options["-L"]+"' -P '"+options["-P"]+"'"
+ if (add_vm_name):
+ cmd_line+=" '"+options["-n"]+"'"
+
+ if options.has_key("-v"):
cmd_line+=" -v"
+
return cmd_line
def get_power_status(conn, options):
result = ""
try:
start_communication(conn,options)
-
- cmd_line=prepare_cmdline(conn,options)
-
+
+ cmd_line=prepare_cmdline(conn,options,True)
+
cmd_line+=" getstate"
-
+
conn.sendline(cmd_line)
-
+
conn.log_expect(options,COMMAND_PROMPT_REG,SHELL_TIMEOUT)
status_err = re.search("vmcontrol\ error\ ([-+]?\d+)\:(.*)",conn.before.lower())
if (status_err!=None):
@@ -60,18 +64,47 @@ def get_power_status(conn, options):
return result
+def get_outlet_list(conn,options):
+ result={}
+
+ try:
+ start_communication(conn,options)
+
+ cmd_line=prepare_cmdline(conn,options,False)
+ cmd_line+=" -l"
+
+ conn.sendline(cmd_line)
+
+ conn.log_expect(options,COMMAND_PROMPT_REG,SHELL_TIMEOUT)
+ status_err = re.search("vmcontrol\ error\ ([-+]?\d+)\:(.*)",conn.before.lower())
+ if (status_err!=None):
+ fail_usage("VMware error "+status_err.group(1)+": "+status_err.group(2))
+
+ lines=conn.before.splitlines()
+
+ for line in lines[(options.has_key("-v") and 3 or 1):-1]:
+ if (line!=""):
+ result[line]=("","")
+
+ except pexpect.EOF:
+ fail(EC_CONNECTION_LOST)
+ except pexpect.TIMEOUT:
+ fail(EC_TIMED_OUT)
+
+ return result
+
def set_power_status(conn, options):
try:
start_communication(conn,options)
- cmd_line=prepare_cmdline(conn,options)
-
+ cmd_line=prepare_cmdline(conn,options,True)
+
cmd_line+=" "+(options["-o"]=="on" and "start" or "stop hard")
-
+
conn.sendline(cmd_line)
-
+
conn.log_expect(options,COMMAND_PROMPT_REG,POWER_TIMEOUT)
-
+
except pexpect.EOF:
fail(EC_CONNECTION_LOST)
except pexpect.TIMEOUT:
@@ -81,7 +114,7 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"secure", "identity_file", "test" , "vmipaddr", "vmlogin",
- "vmpasswd", "port", "vmpasswd_script" ]
+ "vmpasswd", "port", "vmpasswd_script", "separator" ]
atexit.register(atexit_handler)
@@ -101,7 +134,7 @@ def main():
## Operate the fencing device
####
conn = fence_login(options)
- fence_action(conn, options, set_power_status, get_power_status)
+ fence_action(conn, options, set_power_status, get_power_status, get_outlet_list)
##
## Logout from system
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 4aec6bc..e83a783 100755
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -9,7 +9,7 @@
## +-----------------+---------------------------+
## WTI RSM-8R4 ?? unable to find out ??
## WTI MPC-??? ?? unable to find out ??
-## WTI IPS-800-CE v1.40h (no username)
+## WTI IPS-800-CE v1.40h (no username) ('list' tested)
#####
import sys, re, pexpect, exceptions
@@ -32,14 +32,18 @@ def get_power_status(conn, options):
fail(EC_TIMED_OUT)
plug_section = 0
+ outlets = {}
for line in conn.before.splitlines():
if (plug_section == 2) and line.find("|") >= 0:
plug_line = [x.strip().lower() for x in line.split("|")]
if len(plug_line) < len(plug_header):
plug_section = -1
pass
- if options["-n"].lower() == plug_line[plug_index]:
+ if ["list", "monitor"].count(options["-o"]) == 0 and options["-n"].lower() == plug_line[plug_index]:
return plug_line[status_index]
+ else:
+ ## We already believe that first column contains plug number
+ outlets[plug_line[0]] = (plug_line[name_index], plug_line[status_index])
elif (plug_section == 1):
plug_section = 2
pass
@@ -47,9 +51,13 @@ def get_power_status(conn, options):
plug_section = 1
plug_header = [x.strip().lower() for x in line.split("|")]
plug_index = plug_header.index("plug")
+ name_index = plug_header.index("name")
status_index = plug_header.index("status")
- return "PROBLEM"
+ if ["list", "monitor"].count(options["-o"]) == 1:
+ return outlets
+ else:
+ return "PROBLEM"
def set_power_status(conn, options):
action = {
@@ -69,7 +77,7 @@ 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" ]
+ "test", "separator" ]
atexit.register(atexit_handler)
@@ -107,7 +115,7 @@ def main():
else:
conn = fence_login(options)
- fence_action(conn, options, set_power_status, get_power_status)
+ fence_action(conn, options, set_power_status, get_power_status, get_power_status)
##
## Logout from system
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-08-31 16:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-31 16:02 cluster: RHEL55 - fencing: #519697 - List option for fencing agents Marek Grác
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).