[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] Cluster Project branch, RHEL4, updated. gfs-kernel_2_6_9_76-47-gbcfdaa6



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=bcfdaa69b501fef4d01abcf1104d87d00484da66

The branch, RHEL4 has been updated
       via  bcfdaa69b501fef4d01abcf1104d87d00484da66 (commit)
      from  ceee2fe27ece59ef6b3643ab1e7a4cce6688727c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit bcfdaa69b501fef4d01abcf1104d87d00484da66
Author: Marek 'marx' Grac <mgrac redhat com>
Date:   Tue Apr 22 17:52:01 2008 +0200

    fence/agents: New fencings agents
    
    There are new fencing agents based on a new library. They need a 'pexpect' package.
    If it is possible there is support for both telnet and ssh.
    In this patch there are agents for: APC, BladeCenter, Drac 5, ILo and WTI.
    
    Fence agents that support ssh in 4.7 are iLO, DRAC5, WTI, APC, and BladeCenter

-----------------------------------------------------------------------

Summary of changes:
 fence/agents/apc/apc.py                 |   94 +++++++++
 fence/agents/bladecenter/bladecenter.py |   84 ++++++++
 fence/agents/drac/drac5.py              |   73 +++++++
 fence/agents/ilo/ilo.py                 |   71 +++++++
 fence/agents/lib/fencing.py             |  339 +++++++++++++++++++++++++++++++
 fence/agents/wti/wti.py                 |  103 ++++++++++
 6 files changed, 764 insertions(+), 0 deletions(-)
 create mode 100755 fence/agents/apc/apc.py
 create mode 100755 fence/agents/bladecenter/bladecenter.py
 create mode 100755 fence/agents/drac/drac5.py
 create mode 100755 fence/agents/ilo/ilo.py
 create mode 100644 fence/agents/lib/fencing.py
 create mode 100755 fence/agents/wti/wti.py

diff --git a/fence/agents/apc/apc.py b/fence/agents/apc/apc.py
new file mode 100755
index 0000000..bcea997
--- /dev/null
+++ b/fence/agents/apc/apc.py
@@ -0,0 +1,94 @@
+#!/usr/bin/python
+
+##
+## Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
+##
+## The Following Agent Has Been Tested On:
+##
+##  Model       Firmware
+## +---------------------------------------------+
+##  AP7951	AOS v2.7.0, PDU APP v2.7.3
+##
+## @note: ssh is very slow on AP7951 device
+#####
+
+import sys, re, pexpect
+sys.path.append("../lib/")
+from fencing import *
+
+def get_power_status(conn, options):
+	result = ""
+	try:
+		conn.send("1\r\n")
+		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+		conn.send("2\r\n")
+		while 1 == conn.log_expect(options, [ options["-c"],  "Press <ENTER>" ], SHELL_TIMEOUT):
+			result += conn.before
+			conn.send("\r\n")
+		result += conn.before
+		conn.send(chr(03))		
+		conn.log_expect(options, "- Logout", SHELL_TIMEOUT)
+		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+	except pexpect.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexpect.TIMEOUT:
+		fail(EC_TIMED_OUT)
+
+	status = re.compile("\s*"+options["-n"]+"-.*(ON|OFF)", re.IGNORECASE).search(result).group(1)
+	return status.lower().strip()
+
+def set_power_status(conn, options):
+	action = {
+		'on' : "1",
+		'off': "2"
+	}[options["-o"]]
+
+	try:
+		conn.send("1\r\n")
+		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+		conn.send("2\r\n")
+		while 1 == conn.log_expect(options, [ options["-c"],  "Press <ENTER>" ], SHELL_TIMEOUT):
+			conn.send("\r\n")
+		conn.send(options["-n"]+"\r\n")
+		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+		conn.send(action+"\r\n")
+		conn.log_expect(options, "Enter 'YES' to continue or <ENTER> to cancel :", SHELL_TIMEOUT)
+		conn.send("YES\r\n")
+		conn.log_expect(options, "Press <ENTER> to continue...", SHELL_TIMEOUT)
+		conn.send("\r\n")
+		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+		conn.send(chr(03))
+		conn.log_expect(options, "- Logout", SHELL_TIMEOUT)
+		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+	except pexcept.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexcept.TIMEOUT:
+		fail(EC_TIMED_OUT)
+
+def main():
+	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
+			"action", "ipaddr", "login", "passwd", "passwd_script",
+			"secure", "port", "test" ]
+
+	options = check_input(device_opt, process_input(device_opt))
+
+	## 
+	## Fence agent specific defaults
+	#####
+	if 0 == options.has_key("-c"):
+		options["-c"] = "\n>"
+
+	##
+	## Operate the fencing device
+	####
+	conn = fence_login(options)
+	fence_action(conn, options, set_power_status, get_power_status)
+
+	##
+	## Logout from system
+	######
+	conn.sendline("4")
+	conn.close()
+
+if __name__ == "__main__":
+	main()
diff --git a/fence/agents/bladecenter/bladecenter.py b/fence/agents/bladecenter/bladecenter.py
new file mode 100755
index 0000000..cbc7daa
--- /dev/null
+++ b/fence/agents/bladecenter/bladecenter.py
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+
+##
+## Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
+##
+## The Following Agent Has Been Tested On:
+##
+##  Model                 Firmware
+## +--------------------+---------------------------+
+## (1) Main application	  BRET85K, rev 16  
+##     Boot ROM           BRBR67D, rev 16
+##     Remote Control     BRRG67D, rev 16
+##
+#####
+
+import sys, re, pexpect
+sys.path.append("../lib/")
+from fencing import *
+
+def get_power_status(conn, options):
+	try:
+		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.send("power -state\r\n")
+		conn.log_expect(options, node_cmd, SHELL_TIMEOUT)
+		status = conn.before.splitlines()[-1]
+		conn.send("env -T system\r\n")
+		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+	except pexpect.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexpect.TIMEOUT:
+		fail(EC_TIMED_OUT)
+
+	return status.lower().strip()
+
+def set_power_status(conn, options):
+	action = {
+		'on' : "powerup",
+		'off': "powerdown"
+	}[options["-o"]]
+
+	try:
+		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.send("power -"+options["-o"]+"\r\n")
+		conn.log_expect(options, node_cmd, SHELL_TIMEOUT)
+		conn.send("env -T system\r\n")
+		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+	except pexcept.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexcept.TIMEOUT:
+		fail(EC_TIMED_OUT)
+
+def main():
+	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
+			"action", "ipaddr", "login", "passwd", "passwd_script",
+			"cmd_prompt", "secure", "port" ]
+
+	options = check_input(device_opt, process_input(device_opt))
+
+	## 
+	## Fence agent specific defaults
+	#####
+	if 0 == options.has_key("-c"):
+		options["-c"] = "system>"
+
+	##
+	## Operate the fencing device
+	######
+	conn = fence_login(options)
+	fence_action(conn, options, set_power_status, get_power_status)
+
+	##
+	## Logout from system
+	######
+	conn.send("exit\r\n")
+	conn.close()
+
+if __name__ == "__main__":
+	main()
diff --git a/fence/agents/drac/drac5.py b/fence/agents/drac/drac5.py
new file mode 100755
index 0000000..63012fc
--- /dev/null
+++ b/fence/agents/drac/drac5.py
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+
+##
+## Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
+##
+## The Following Agent Has Been Tested On:
+##
+##  DRAC Version       Firmware
+## +-----------------+---------------------------+
+##  DRAC 5             1.0  (Build 06.05.12)
+##  DRAC 5             1.21 (Build 07.05.04)
+##
+## @note: drac_version, modulename were removed
+#####
+
+import sys, re, pexpect
+sys.path.append("../lib/")
+from fencing import *
+
+def get_power_status(conn, options):
+	try:
+		conn.sendline("racadm serveraction powerstatus")
+		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+	except pexpect.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexpect.TIMEOUT:
+		fail(EC_TIMED_OUT)
+				
+	status = re.compile("Server power status: (.*)", re.IGNORECASE).search(conn.before).group(1)
+	return status.lower().strip()
+
+def set_power_status(conn, options):
+	action = {
+		'on' : "powerup",
+		'off': "powerdown"
+	}[options["-o"]]
+
+	try:
+		conn.sendline("racadm serveraction " + action)
+		conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+	except pexcept.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexcept.TIMEOUT:
+		fail(EC_TIMED_OUT)
+
+def main():
+	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
+			"action", "ipaddr", "login", "passwd", "passwd_script",
+			"cmd_prompt", "secure",
+			"drac_version", "module_name" ]
+
+	options = check_input(device_opt, process_input(device_opt))
+
+	## 
+	## Fence agent specific defaults
+	#####
+	if 0 == options.has_key("-c"):
+		options["-c"] = "\$"
+
+	##
+	## Operate the fencing device
+	######
+	conn = fence_login(options)
+	fence_action(conn, options, set_power_status, get_power_status)
+
+	##
+	## Logout from system
+	######
+	conn.sendline("exit")
+	conn.close()
+
+if __name__ == "__main__":
+	main()
diff --git a/fence/agents/ilo/ilo.py b/fence/agents/ilo/ilo.py
new file mode 100755
index 0000000..1f3e330
--- /dev/null
+++ b/fence/agents/ilo/ilo.py
@@ -0,0 +1,71 @@
+#!/usr/bin/python
+
+##
+## Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
+##
+## The Following Agent Has Been Tested On:
+##
+##  iLO Version       
+## +---------------------------------------------+
+##  iLO Advanced 1.91 
+##
+## @note: We can't use conn.sendline because we need to send CR/LF
+#####
+
+import sys, re, pexpect
+sys.path.append("../lib/")
+from fencing import *
+
+def get_power_status(conn, options):
+	try:
+		conn.send("POWER\r\n")
+		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+	except pexpect.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexpect.TIMEOUT:
+		fail(EC_TIMED_OUT)
+				
+	status = re.compile("server power is currently: (.*)", re.IGNORECASE).search(conn.before).group(1)
+	return status.lower().strip()
+
+def set_power_status(conn, options):
+	action = {
+		'on' : "powerup",
+		'off': "powerdown"
+	}[options["-o"]]
+
+	try:
+		conn.send("power " + options["-o"] + "\r\n")
+		conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+	except pexcept.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexcept.TIMEOUT:
+		fail(EC_TIMED_OUT)
+
+def main():
+	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
+			"action", "ipaddr", "login", "passwd", "passwd_script",
+			"secure", "ribcl" ]
+
+	options = check_input(device_opt, process_input(device_opt))
+
+	## 
+	## Fence agent specific defaults
+	#####
+	if 0 == options.has_key("-c"):
+		options["-c"] = "</>hpiLO->"
+
+	##
+	## Operate the fencing device
+	####
+	conn = fence_login(options)
+	fence_action(conn, options, set_power_status, get_power_status)
+
+	##
+	## Logout from system
+	######
+	conn.send("quit\r\n")
+	conn.close()
+
+if __name__ == "__main__":
+	main()
diff --git a/fence/agents/lib/fencing.py b/fence/agents/lib/fencing.py
new file mode 100644
index 0000000..39d1285
--- /dev/null
+++ b/fence/agents/lib/fencing.py
@@ -0,0 +1,339 @@
+#!/usr/bin/python
+
+##
+## Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
+##
+#####
+import sys, getopt, time, os
+import pexpect, re
+import telnetlib
+
+POWER_TIMEOUT = 20
+SHELL_TIMEOUT = 3
+LOGIN_TIMEOUT = 5
+
+LOG_MODE_VERBOSE = 100
+LOG_MODE_QUIET = 0
+
+EC_BAD_ARGS        = 2
+EC_LOGIN_DENIED    = 3
+EC_CONNECTION_LOST = 4
+EC_TIMED_OUT       = 5
+EC_WAITING_ON      = 6
+EC_WAITING_OFF     = 7
+
+all_opt = {
+	"help"    : {
+		"getopt" : "h",
+		"help" : "-h             Display this help and exit",
+		"order" : 54 },
+	"version" : { 
+		"getopt" : "V",
+		"help" : "-V             Output version information and exit",
+		"order" : 53 },
+	"quiet"   : {
+		"getopt" : "q",
+		"help" : "-q             Quiet mode",
+		"order" : 50 },
+	"verbose" : {
+		"getopt" : "v",
+		"help" : "-v             Verbose mode",
+		"order" : 51 },
+	"debug" : {
+		"getopt" : "D:",
+		"help" : "-D <debugfile> Debugging to output file",
+		"order" : 52 },
+	"agent"   : {
+		"getopt" : "",
+		"help" : "",
+		"order" : 1 },
+	"action" : {
+		"getopt" : "o:",
+		"help" : "-o <action>    Action: status, reboot (default), off or on",
+		"order" : 1 },
+	"ipaddr" : {
+		"getopt" : "a:",
+		"help" : "-a <ip>        IP address or hostname of fencing device",
+		"order" : 1 },
+	"login" : {
+		"getopt" : "l:",
+		"help" : "-l <name>      Login name",
+		"order" : 1 },
+	"no_login" : {
+		"getopt" : "",
+		"help" : "",
+		"order" : 1 },
+	"passwd" : {
+		"getopt" : "p:",
+		"help" : "-p <password>  Login password",
+		"order" : 1 },
+	"passwd_script" : {
+		"getopt" : "S:",
+		"help" : "-S <script>    Script to run to retrieve password",
+		"order" : 1 },
+	"module_name" : {
+		"getopt" : "m:",
+		"help" : "-m <module>    DRAC/MC module name",
+		"order" : 1 },
+	"drac_version" : {
+		"getopt" : "d:",
+		"help" : "-D <version>   Force DRAC version to use",
+		"order" : 1 },
+	"ribcl" : {
+		"getopt" : "r:",
+		"help" : "-r <version>   Force ribcl version to use",
+		"order" : 1 },
+	"cmd_prompt" : {
+		"getopt" : "c:",
+		"help" : "-c <prompt>    Force command prompt",
+		"order" : 1 },
+	"secure" : {
+		"getopt" : "x",
+		"help" : "-x             Use ssh connection",
+		"order" : 1 },
+	"port" : {
+		"getopt" : "n:",
+		"help" : "-n <id>        Physical plug number on device",
+		"order" : 1 },
+	"test" : {
+		"getopt" : "T",
+		"help" : "",
+		"order" : 1,
+		"obsolete" : "use -o status instead" }
+}
+
+class fspawn(pexpect.spawn):
+	def log_expect(self, options, pattern, timeout):
+		result = self.expect(pattern, timeout)
+		if options["log"] >= LOG_MODE_VERBOSE:
+			options["debug_fh"].write(self.before + self.after)
+		return result
+
+def version(command, release, build_date, copyright):
+	print command, " ", release, " ", build_date;
+	if len(copyright) > 0:
+		print copyright
+
+def fail_usage(message = ""):
+	if len(message) > 0:
+		sys.stderr.write(message+"\n")
+	sys.stderr.write("Please use '-h' for usage\n")
+	sys.exit(EC_BAD_ARGS)
+
+def fail(error_code):
+	message = {
+		EC_LOGIN_DENIED : "Unable to connect/login to fencing device",
+		EC_CONNECTION_LOST : "Connection lost",
+		EC_TIMED_OUT : "Connection timed out",
+		EC_WAITING_ON : "Failed: Timed out waiting to power ON",
+		EC_WAITING_OFF : "Failed: Timed out waiting to power OFF"
+	}[error_code] + "\n"
+	sys.stderr.write(message)
+	sys.exit(error_code)
+
+def usage(avail_opt):
+	global all_opt
+
+	print "Usage:"
+	print "\t" + os.path.basename(sys.argv[0]) + " [options]"
+	print "Options:"
+
+	sorted_list = [ (key, all_opt[key]) for key in avail_opt ]
+	sorted_list.sort(lambda x, y: cmp(x[1]["order"], y[1]["order"]))
+
+	for key, value in sorted_list:
+		if len(value["help"]) != 0:
+			print "   " + value["help"]
+
+def process_input(avail_opt):
+	global all_opt
+
+	##
+	## Set standard environment
+	#####
+	os.unsetenv("LANG")
+
+	##
+	## Prepare list of options for getopt
+	#####
+	getopt_string = ""
+	for k in avail_opt:
+		if all_opt.has_key(k):
+			getopt_string += all_opt[k]["getopt"]
+		else:
+			fail_usage("Parse error: unknown option '"+k+"'");
+
+	##
+	## Read options from command line or standard input
+	#####
+	if len(sys.argv) > 1:
+		try:
+			opt, args = getopt.gnu_getopt(sys.argv[1:], getopt_string)
+		except getopt.GetoptError, error:
+			fail_usage("Parse error: " + error.msg)
+
+		## Compatibility Layer
+		#####
+		z = dict(opt)
+		if z.has_key("-T") == 1:
+			z["-o"] = "status"
+
+		opt = z
+		##
+		#####
+	else:
+		opt = { }
+		name = ""
+		for line in sys.stdin.readlines():
+			line = line.strip()
+			if ((line.startswith("#")) or (len(line) == 0)): pass
+
+			(name, value) = (line + "=").split("=", 1)
+			value = value[:-1]
+
+			## Compatibility Layer
+			######
+			if name == "blade":
+				name = "port"
+			elif name == "option":
+				name = "action"
+			elif name == "fm":
+				name = "port"
+			elif name == "hostname":
+				name = "ipaddr"
+
+			##
+			######
+			if avail_opt.count(name) == 0:
+				fail_usage("Parse error: Unknown option '"+line+"'")
+
+			if all_opt[name]["getopt"].endswith(":"):
+				opt["-"+all_opt[name]["getopt"].rstrip(":")] = value
+			else:
+				opt["-"+all_opt[name]["getopt"].rstrip(":")] = 1
+	return opt
+
+##
+## This function checks input and answers if we want to have same answers 
+## in each of the fencing agents. It looks for possible errors and run
+## password script to set a correct password
+######
+def check_input(device_opt, opt):
+	options = dict(opt)
+
+	if options.has_key("-h"): 
+		usage(device_opt)
+		sys.exit(0)
+
+	if options.has_key("-V"):
+		print "Version: 0.3 - 2008/03/19"
+		sys.exit(0)
+
+	if options.has_key("-v"):
+		options["log"] = LOG_MODE_VERBOSE
+	else:
+		options["log"] = LOG_MODE_QUIET
+
+	if 0 == options.has_key("-o"):
+		options["-o"] = "reboot"
+
+	if 0 == ["on", "off", "reboot", "status"].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):
+		fail_usage("Failed: You have to set login name")
+
+	if 0 == options.has_key("-a"):
+		fail_usage("Failed: You have to enter fence address")
+
+	if 0 == (options.has_key("-p") or options.has_key("-S")):
+		fail_usage("Failed: You have to enter password or password script")
+
+	if 1 == (options.has_key("-p") and options.has_key("-S")):
+		fail_usage("Failed: You have to enter password or password script")
+
+	if (0 == options.has_key("-n")) and (device_opt.count("plug_no")):
+		fail_usage("Failed: You have to enter plug number")
+
+	if options.has_key("-S"):
+		options["-p"] = os.popen(options["-S"]).read().rstrip()
+
+	if options.has_key("-D"):
+		try:
+			options["debug_fh"] = file (options["-D"], "w")
+		except IOError:
+			fail_usage("Failed: Unable to create file "+options["-D"])
+
+	if options.has_key("-v") and options.has_key("debug_fh") == 0:
+		options["debug_fh"] = sys.stderr
+
+	return options
+	
+def wait_power_status(tn, options, get_power_fn):
+	for x in range(POWER_TIMEOUT):
+		if get_power_fn(tn, options) != options["-o"]:
+			time.sleep(1)
+		else:
+			return 1
+	return 0
+
+def fence_action(tn, options, set_power_fn, get_power_fn):
+	status = get_power_fn(tn, options)
+
+	if options["-o"] == "on":
+		if status == "on":
+			print "Success: Already ON"
+		else:
+			set_power_fn(tn, options)
+			if wait_power_status(tn, options, get_power_fn):
+				print "Success: Powered ON"
+			else:
+				fail(EC_WAITING_ON)
+	elif options["-o"] == "off":
+		if status == "off":
+			print "Success: Already OFF"
+		else:
+			set_power_fn(tn, options)
+			if wait_power_status(tn, options, get_power_fn):
+				print "Success: Powered OFF"
+			else:
+				fail(EC_WAITING_OFF)
+	elif options["-o"] == "reboot":
+		if status != "off":
+			options["-o"] = "off"
+			set_power_fn(tn, options)
+			if wait_power_status(tn, options, get_power_fn) == 0:
+				fail(EC_WAITING_OFF)
+		options["-o"] = "on"
+		set_power_fn(tn, options)
+		if wait_power_status(tn, options, get_power_fn) == 0:
+			fail(EC_WAITING_ON)
+		print "Success: Rebooted"
+	elif options["-o"] == "status":
+		print "Status: " + status.upper()
+
+def fence_login(options):
+	try:
+		re_login = re.compile("(login: )|(Login Name:  )|(username: )|(User Name :)", re.IGNORECASE)
+		re_pass  = re.compile("password", re.IGNORECASE)
+
+		if options.has_key("-x"):
+			conn = fspawn ('ssh ' + options["-l"] + "@" + options["-a"])
+			result = conn.log_expect(options, [ "ssword: ", "Are you sure you want to continue connecting (yes/no)?" ], LOGIN_TIMEOUT)
+			if result == 1:
+				conn.sendline("yes")
+				conn.log_expect(options, "ssword: ", SHELL_TIMEOUT)
+			conn.sendline(options["-p"])
+			conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+		else:
+			conn = fspawn ('telnet ' + options["-a"])
+			conn.log_expect(options, re_login, LOGIN_TIMEOUT)
+			conn.send(options["-l"]+"\r\n")
+			conn.log_expect(options, re_pass, SHELL_TIMEOUT)
+			conn.send(options["-p"]+"\r\n")
+			conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+	except pexpect.EOF:
+		fail(EC_LOGIN_DENIED) 
+	except pexpect.TIMEOUT:
+		fail(EC_LOGIN_DENIED)
+	return conn
diff --git a/fence/agents/wti/wti.py b/fence/agents/wti/wti.py
new file mode 100755
index 0000000..926d347
--- /dev/null
+++ b/fence/agents/wti/wti.py
@@ -0,0 +1,103 @@
+#!/usr/bin/python
+
+##
+## Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
+##
+## The Following Agent Has Been Tested On:
+##
+##  Version            Firmware
+## +-----------------+---------------------------+
+##  WTI RSM-8R4         ?? unable to find out ??
+##  WTI MPC-??? 	?? unable to find out ??
+##  WTI IPS-800-CE     v1.40h		(no username)
+#####
+
+import sys, re, pexpect
+sys.path.append("../lib/")
+from fencing import *
+
+def get_power_status(conn, options):
+	try:
+		conn.send("/S"+"\r\n")
+		conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+	except pexpect.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexpect.TIMEOUT:
+		fail(EC_TIMED_OUT)
+	
+	plug_section = 0
+	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]:
+				return plug_line[status_index]
+		elif (plug_section == 1):
+			plug_section = 2
+			pass
+		elif (line.upper().startswith("PLUG")):
+			plug_section = 1
+			plug_header = [x.strip().lower() for x in line.split("|")]
+			plug_index = plug_header.index("plug")
+			status_index = plug_header.index("status")
+
+	return "PROBLEM"
+
+def set_power_status(conn, options):
+	action = {
+		'on' : "/on",
+		'off': "/off"
+	}[options["-o"]]
+
+	try:
+		conn.send(action + " " + options["-n"] + ",y\r\n")
+		conn.log_expect(options, options["-c"], POWER_TIMEOUT)
+	except pexcept.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexcept.TIMEOUT:
+		fail(EC_TIMED_OUT)
+
+def main():
+	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
+			"action", "ipaddr", "login", "passwd", "passwd_script",
+			"cmd_prompt", "secure", "port", "no_login", "test" ]
+
+	options = check_input(device_opt, process_input(device_opt))
+
+	## 
+	## Fence agent specific defaults
+	#####
+	if 0 == options.has_key("-c"):
+		options["-c"] = [ "RSM>", "MPC>", "IPS>" ]
+
+	##
+	## Operate the fencing device
+	##
+	## @note: if there is not a login name then we assume that it is WTI-IPS
+	##        where no login name is used
+	#####	
+	if (0 == options.has_key("-l")):
+		try:
+			conn = fspawn ('telnet ' + options["-a"])
+			conn.log_expect(options, "Password: ", SHELL_TIMEOUT)
+			conn.send(options["-p"]+"\r\n")
+			conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+		except pexpect.EOF:
+			fail(EC_LOGIN_DENIED) 
+		except pexpect.TIMEOUT:
+			fail(EC_LOGIN_DENIED)		
+	else:
+		conn = fence_login(options)
+
+	fence_action(conn, options, set_power_status, get_power_status)
+
+	##
+	## Logout from system
+	######
+	conn.send("/X"+"\r\n")
+	conn.close()
+
+if __name__ == "__main__":
+	main()


hooks/post-receive
--
Cluster Project


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]