public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jan Friesse <honzaf@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: STABLE2 - fence: New fence agent for Logical Domains (LDOMs)
Date: Thu, 25 Sep 2008 19:06:00 -0000	[thread overview]
Message-ID: <20080925094703.F0094120438@lists.fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=27ab4fdb8adc64f51663102d1e1a537d175c0403
Commit:        27ab4fdb8adc64f51663102d1e1a537d175c0403
Parent:        2fd99f351d7d694c3b7773500bc7994a6cb3196e
Author:        Jan Friesse <jfriesse@redhat.com>
AuthorDate:    Thu Sep 25 11:30:13 2008 +0200
Committer:     Jan Friesse <jfriesse@redhat.com>
CommitterDate: Thu Sep 25 11:45:46 2008 +0200

fence: New fence agent for Logical Domains (LDOMs)

It's tested on LDOM 1.0.3. Because interface is backward
compatible, it will work with 1.0, 1.0.1 and .2 too.
It's tested with bash and csh shells on host machine.
---
 fence/agents/ldom/Makefile      |    5 ++
 fence/agents/ldom/fence_ldom.py |  101 ++++++++++++++++++++++++++++++++++
 fence/man/Makefile              |    1 +
 fence/man/fence_ldom.8          |  114 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 221 insertions(+), 0 deletions(-)

diff --git a/fence/agents/ldom/Makefile b/fence/agents/ldom/Makefile
new file mode 100644
index 0000000..a288025
--- /dev/null
+++ b/fence/agents/ldom/Makefile
@@ -0,0 +1,5 @@
+include ../../../make/defines.mk
+
+TARGET= fence_ldom
+
+include $(OBJDIR)/make/fencebuild.mk
diff --git a/fence/agents/ldom/fence_ldom.py b/fence/agents/ldom/fence_ldom.py
new file mode 100644
index 0000000..8b2c210
--- /dev/null
+++ b/fence/agents/ldom/fence_ldom.py
@@ -0,0 +1,101 @@
+#!/usr/bin/python
+
+##
+## The Following Agent Has Been Tested On - LDOM 1.0.3
+## The interface is backward compatible so it will work 
+## with 1.0, 1.0.1 and .2 too.
+## 
+#####
+
+import sys, re, pexpect
+sys.path.append("@FENCEAGENTSLIBDIR@")
+from fencing import *
+
+#BEGIN_VERSION_GENERATION
+RELEASE_VERSION="Logical Domains (LDoms) fence Agent"
+REDHAT_COPYRIGHT=""
+BUILD_DATE=""
+#END_VERSION_GENERATION
+
+COMMAND_PROMPT_REG="\[PEXPECT\]$"
+COMMAND_PROMPT_NEW="[PEXPECT]"
+
+# Start comunicating after login. Prepare good environment.
+def start_communication(conn, options):
+	conn.sendline ("PS1='"+COMMAND_PROMPT_NEW+"'")
+	res=conn.expect([pexpect.TIMEOUT, COMMAND_PROMPT_REG],SHELL_TIMEOUT)
+	if res==0:
+		#CSH stuff
+		conn.sendline("set prompt='"+COMMAND_PROMPT_NEW+"'")
+		conn.log_expect(options, COMMAND_PROMPT_REG,SHELL_TIMEOUT)
+	
+
+def get_power_status(conn, options):
+	result = ""
+	try:
+		start_communication(conn,options)
+		
+		conn.sendline("ldm ls")
+		    
+		conn.log_expect(options,COMMAND_PROMPT_REG,SHELL_TIMEOUT)
+		#Status of logical domain. This can be None => LM not found or something else	
+		ldom_exists = re.search(re.escape(options["-n"])+"\s+(\w+)",conn.before)
+		if (ldom_exists==None):
+			fail_usage("Failed: You have to enter existing logical domain!")
+		#Test status
+		status=re.search(".*bound",ldom_exists.group(1).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:
+		start_communication(conn,options)
+         	
+		cmd_line="ldm "+(options["-o"]=="on" and "start" or "stop -f")+" \""+options["-n"]+"\""
+            	
+		conn.sendline(cmd_line)
+		    
+		conn.log_expect(options,COMMAND_PROMPT_REG,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",  "identity_file", "test" , "port", "cmd_prompt" ]
+
+    	
+	options = check_input(device_opt, process_input(device_opt))
+
+	## 
+	## Fence agent specific defaults
+	#####
+	if (not options.has_key("-c")):
+		options["-c"] = "\ $"
+	
+
+	options["-x"] = 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/man/Makefile b/fence/man/Makefile
index 803b086..b7e5171 100644
--- a/fence/man/Makefile
+++ b/fence/man/Makefile
@@ -10,6 +10,7 @@ TARGET= fence.8 \
 	fence_gnbd.8 \
 	fence_ifmib.8 \
 	fence_ilo.8 \
+	fence_ldom.8 \
 	fence_manual.8 \
 	fence_mcdata.8 \
 	fence_node.8 \
diff --git a/fence/man/fence_ldom.8 b/fence/man/fence_ldom.8
new file mode 100644
index 0000000..59167c8
--- /dev/null
+++ b/fence/man/fence_ldom.8
@@ -0,0 +1,114 @@
+.TH fence_ldom 8
+
+.SH NAME
+fence_ldom - I/O Fencing agent for Logical Domains (LDoms)
+
+.SH SYNOPSIS
+.B 
+fence_ldom
+[\fIOPTION\fR]...
+
+.SH DESCRIPTION
+fence_ldom is an I/O Fencing agent which can be used with LDoms virtual
+machines. This agent works so, that run ldm command on host machine. So
+ldm must be directly runnable. 
+
+Very useful parameter is -c (or cmd_prompt in stdin mode). This must be
+set to something, what is displayed after successful login to host machine.
+Default string is space on end of string (default for root in bash). But
+(for example) csh use ], so in that case you must use parameter -c with
+argument ']'. Very similar situation is, if you use bash and login to host
+machine with other user than root. Than prompt is $, so again, you must
+use parameter -c. 
+
+fence_ldom accepts options on the command line as well as from stdin.  
+Fenced sends parameters through stdin when it execs the agent.  fence_ldom
+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 LDoms host machine.
+.TP
+\fB-h\fP 
+Print out a help message describing available options, then exit.
+.TP
+\fB-l\fP \fIlogin\fR
+Login name to LDoms host machine.
+.TP
+\fB-o\fP \fIaction\fR
+The action required. Valid values are reboot (default), status, off or on.
+.TP
+\fB-p\fP \fIpassword\fR
+Password for login to LDoms host machine.
+.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-k\fP \fIfilename\fR
+Identity file (private key) for ssh.
+.TP
+\fB-n\fP \fIname\fR
+Name of quest to fence.
+.TP
+\fB-c\fP \fIprompt\fR
+Force command prompt.
+\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_ldom.
+.TP
+\fIipaddr = < hostname | ip >\fR
+IP address or hostname of LDoms host machine.
+.TP
+\fIaction = < param >\fR
+The action required. Valid values are reboot (default), status, off or on.
+.TP
+\fIlogin = < param >\fR
+Login name to LDoms host machine.
+.TP
+\fIpasswd = < param >\fR
+Password for login to LDoms host machine.
+.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
+\fIidentity = < param >\fR
+Identity file (private key) for ssh.
+.TP
+\fIport = < param >\fR
+Name of quest to fence.
+.TP
+\fIcmd_prompt = < param >\fR
+Force command prompt.
+.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)


                 reply	other threads:[~2008-09-25  9:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080925094703.F0094120438@lists.fedorahosted.org \
    --to=honzaf@fedoraproject.org \
    --cc=cluster-cvs-relay@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).