public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* master - Fence: Added fence agent for Sun Advanced Lights Out Manager (ALOM)
@ 2008-09-22 17:27 Jan Friesse
  0 siblings, 0 replies; only message in thread
From: Jan Friesse @ 2008-09-22 17:27 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=fd443ee2baf7519d1f1b01bc683e0df003959d84
Commit:        fd443ee2baf7519d1f1b01bc683e0df003959d84
Parent:        a26502447c49fad4a11adef8fca13439b3292e99
Author:        Jan Friesse <jfriesse@redhat.com>
AuthorDate:    Mon Sep 22 18:20:22 2008 +0200
Committer:     Jan Friesse <jfriesse@redhat.com>
CommitterDate: Mon Sep 22 18:20:22 2008 +0200

Fence: Added fence agent for Sun Advanced Lights Out Manager (ALOM)

Because of strange behavior of ALOM SSH, which behaves more like
telnet, fencing.py library is changed too. There is new option
telnet_over_ssh (accessible only from source code of agent), which
supports this behavior.
---
 fence/agents/alom/Makefile      |    5 ++
 fence/agents/alom/fence_alom.py |   66 ++++++++++++++++++++++++++++
 fence/agents/lib/fencing.py.py  |   20 +++++++--
 fence/man/fence_alom.8          |   90 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 177 insertions(+), 4 deletions(-)

diff --git a/fence/agents/alom/Makefile b/fence/agents/alom/Makefile
new file mode 100644
index 0000000..6efc272
--- /dev/null
+++ b/fence/agents/alom/Makefile
@@ -0,0 +1,5 @@
+include ../../../make/defines.mk
+
+TARGET= fence_alom
+
+include $(OBJDIR)/make/fencebuild.mk
diff --git a/fence/agents/alom/fence_alom.py b/fence/agents/alom/fence_alom.py
new file mode 100644
index 0000000..275cadc
--- /dev/null
+++ b/fence/agents/alom/fence_alom.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+
+# The Following Agent Has Been Tested On ALOM???
+
+import sys, re, pexpect, time
+sys.path.append("@FENCEAGENTSLIBDIR@")
+from fencing import *
+
+#BEGIN_VERSION_GENERATION
+RELEASE_VERSION="Sun Advanced Lights Out Manager (ALOM)"
+REDHAT_COPYRIGHT=""
+BUILD_DATE=""
+#END_VERSION_GENERATION
+
+def get_power_status(conn, options):
+	result = ""
+	try:
+		conn.sendline("showplatform")
+                conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
+		status = re.search("standby",conn.before.lower())
+		result=(status!=None and "off" or "on")
+	except pexpect.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexpect.TIMEOUT:
+		fail(EC_TIMED_OUT)
+
+	return result
+
+def set_power_status(conn, options):
+	try:
+		cmd_line=(options["-o"]=="on" and "poweron" or "poweroff -f -y")
+		conn.sendline(cmd_line)
+		conn.log_expect(options, options["-c"],POWER_TIMEOUT)
+		#Get the machine some time between poweron and poweroff
+		time.sleep(POWER_TIMEOUT)
+		
+	except pexpect.EOF:
+		fail(EC_CONNECTION_LOST)
+	except pexpect.TIMEOUT:
+		fail(EC_TIMED_OUT)
+		
+def main():
+	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
+			"action", "ipaddr", "login", "passwd", "passwd_script",
+			"secure",  "test" ]
+
+	options = check_input(device_opt, process_input(device_opt))
+
+	# Default command is sc>
+	if (not options.has_key("-c")):
+            options["-c"] = "sc\>\ "
+
+	# Default to ssh
+	options["-x"] = 1
+	options["telnet_over_ssh"] = 1
+		
+	# Operate the fencing device
+	conn = fence_login(options)
+	fence_action(conn, options, set_power_status, get_power_status)
+
+	# Logout from system
+	conn.sendline("logout")
+	conn.close()
+
+if __name__ == "__main__":
+	main()
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 8eab0e5..85aa89e 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -393,10 +393,22 @@ def fence_login(options):
 			if options.has_key("ssh_options"):
 				command += ' ' + options["ssh_options"]
 			conn = fspawn(command)
-			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:", LOGIN_TIMEOUT)
+
+			if options.has_key("telnet_over_ssh"):
+				#This is for stupid ssh servers (like ALOM) which behave more like telnet (ignore name and display login prompt)
+				result = conn.log_expect(options, [ re_login, "Are you sure you want to continue connecting (yes/no)?" ], LOGIN_TIMEOUT)
+				if result == 1:
+					conn.sendline("yes") # Host identity confirm
+					conn.log_expect(options, re_login, LOGIN_TIMEOUT)
+
+				conn.sendline(options["-l"])
+				conn.log_expect(options, re_pass, LOGIN_TIMEOUT)
+			else:
+				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:", LOGIN_TIMEOUT)
+
 			conn.sendline(options["-p"])
 			conn.log_expect(options, options["-c"], LOGIN_TIMEOUT)
 		elif options.has_key("-x") and 1 == options.has_key("-k"):
diff --git a/fence/man/fence_alom.8 b/fence/man/fence_alom.8
new file mode 100644
index 0000000..3f3f5f7
--- /dev/null
+++ b/fence/man/fence_alom.8
@@ -0,0 +1,90 @@
+.\"  Copyright (C) 2008 Red Hat, Inc.  All rights reserved.
+.\"  
+.\"  This copyrighted material is made available to anyone wishing to use,
+.\"  modify, copy, or redistribute it subject to the terms and conditions
+.\"  of the GNU General Public License v.2.
+
+.TH fence_vmware 8
+
+.SH NAME
+fence_alom - I/O Fencing agent for Sun Advanced Lights Out Manager (ALOM)
+
+.SH SYNOPSIS
+.B 
+fence_alom
+[\fIOPTION\fR]...
+
+.SH DESCRIPTION
+fence_alom is an I/O Fencing agent which can be used with ALOM connected machines.
+
+fence_alom accepts options on the command line as well as from stdin.  
+Fenced sends parameters through stdin when it execs the agent.  fence_alom
+can be run by itself with command line options.  This is useful for testing 
+and for turning outlets on or off from scripts.
+
+.SH OPTIONS
+.TP
+\fB-a\fP \fIIPaddress\fR
+IP address or hostname of ALOM.
+.TP
+\fB-h\fP 
+Print out a help message describing available options, then exit.
+.TP
+\fB-l\fP \fIlogin\fR
+Login name.
+.TP
+\fB-o\fP \fIaction\fR
+The action required.  Reboot (default), Status, Off or On.
+.TP
+\fB-p\fP \fIpassword\fR
+Password for login.
+.TP
+\fB-B\fP \fIscript\fR
+Script to run to retrieve password.
+.TP
+\fB-x\fP
+Use secure connection over ssh (this is default, and can't be disabled) 
+.TP
+\fB-T\fP
+Test only.  Answer NO to the confirmation prompt instead of YES.
+.TP
+\fB-v\fP
+Verbose. Record session to stdout, or debug file if specified (see -D).
+.TP
+\fB-D\fP
+Specifies file, where will be written debug messages from session.
+.TP
+\fB-V\fP
+Print out a version message, then exit.
+
+.SH STDIN PARAMETERS
+.TP
+\fIagent = < param >\fR
+This option is used by fence_node(8) and is ignored by fence_alom.
+.TP
+\fIipaddr = < hostname | ip >\fR
+IP address or hostname of ALOM.
+.TP
+\fIoption = < param >\fR
+The action required.  Reboot (default), Off or On.
+.TP
+\fIpasswd = < param >\fR
+Password for login.
+.TP
+\fIpasswd_script = < param >\fR
+Script to run to retrieve password.
+.TP
+\fIsecure = < param >\fR
+Use secure connection over ssh (this is default, and can't be disabled) 
+.TP
+\fItest = < param >\fR
+Test only.  Answer NO to the confirmation prompt instead of YES.
+.TP
+\fIverbose = < param >\fR
+Verbose.  Record session to stdout, or debug file if specified (see debug).
+.TP
+\fIdebug = < param >\fR
+Specifies file, where will be written debug messages from session.
+
+.SH SEE ALSO
+fence(8), fence_node(8)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-22 16:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-22 17:27 master - Fence: Added fence agent for Sun Advanced Lights Out Manager (ALOM) Jan Friesse

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).