From: Marek Grac <mgrac@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] fence_ipal: Introduce ipal fence agent
Date: Wed, 23 Apr 2014 11:35:02 +0200 [thread overview]
Message-ID: <53578946.706@redhat.com> (raw)
In-Reply-To: <1397740033-22513-1-git-send-email-andreavb@linux.vnet.ibm.com>
Hi,
Unfortunately, this fence agent can not be accepted without additional
changes. I have no major problem of 'expect' file but fence agent has
to produce at least valid xml metadata, support not only stdin-options
but also command line options. There is a fencing library that provides
a lot
of required features and it should not be difficult to port your python
part to it, you can run your expect file from there too. We alredy use
that approach for amt or ipmi
m,
On 04/17/2014 03:07 PM, Andrea Bucci wrote:
> Based on 2012 code by Gustavo Rahal
> ---
> configure.ac | 1 +
> fence/agents/ipal/Makefile.am | 18 +++++++++++++++
> fence/agents/ipal/fence_ipal | 20 ++++++++++++++++
> fence/agents/ipal/ipal | 51 +++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 90 insertions(+)
> create mode 100644 fence/agents/ipal/Makefile.am
> create mode 100755 fence/agents/ipal/fence_ipal
> create mode 100755 fence/agents/ipal/ipal
>
> diff --git a/configure.ac b/configure.ac
> index c24198c..fc9e117 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -268,6 +268,7 @@ AC_CONFIG_FILES([Makefile
> fence/agents/eps/Makefile
> fence/agents/hpblade/Makefile
> fence/agents/ibmblade/Makefile
> + fence/agents/ipal/Makefile
> fence/agents/ipdu/Makefile
> fence/agents/ifmib/Makefile
> fence/agents/ilo/Makefile
> diff --git a/fence/agents/ipal/Makefile.am b/fence/agents/ipal/Makefile.am
> new file mode 100644
> index 0000000..0a45e8e
> --- /dev/null
> +++ b/fence/agents/ipal/Makefile.am
> @@ -0,0 +1,18 @@
> +MAINTAINERCLEANFILES = Makefile.in
> +
> +TARGET = fence_ipal
> +
> +SYMTARGET = ipal
> +
> +SRC = $(TARGET).py
> +
> +EXTRA_DIST = $(SRC)
> +
> +sbin_SCRIPTS = $(TARGET)
> +bin_SCRIPTS = $(SYMTARGET)
> +
> +include $(top_srcdir)/make/fencebuild.mk
> +include $(top_srcdir)/make/fenceman.mk
> +
> +clean-local: clean-man
> + rm -f $(TARGET) $(SYMTARGET)
> diff --git a/fence/agents/ipal/fence_ipal b/fence/agents/ipal/fence_ipal
> new file mode 100755
> index 0000000..3b073e5
> --- /dev/null
> +++ b/fence/agents/ipal/fence_ipal
> @@ -0,0 +1,20 @@
> +#!/usr/bin/python
> +
> +import sys
> +import os
> +
> +# STDIN format:
> +# "action=$power_mode\nlogin=$power_user\npasswd=$power_pass\nipaddr=$power_address\nport=$power_id"
> +stdin_str = sys.stdin.read()
> +#print "STDIN: " + stdin_str
> +
> +action_kv, login_kv, passwd_kv, ipaddr_kv, port_kv = stdin_str.split()
> +
> +action = action_kv.replace("action=", "")
> +login = login_kv.replace("login=", "")
> +passwd = passwd_kv.replace("passwd=", "")
> +ipaddr = ipaddr_kv.replace("ipaddr=", "")
> +port = port_kv.replace("port=", "")
> +
> +if action == "on":
> + os.system("ipal %s %s %s" % (ipaddr, port, passwd))
> diff --git a/fence/agents/ipal/ipal b/fence/agents/ipal/ipal
> new file mode 100755
> index 0000000..62de7a6
> --- /dev/null
> +++ b/fence/agents/ipal/ipal
> @@ -0,0 +1,51 @@
> +#!/usr/bin/expect
> +
> +#@IMPROVEMENT port to python, as it is the most common programming language in
> +# fence-agents and it removes the need of having two files for this agent
> +
> +if { [ llength $argv ] == 0 || [ llength $argv ] > 4} {
> + send_user "Usage: ipal <host> <outlet-portnumber> <passwd> \[ <toggles> \]\n"
> + exit 1
> +}
> +
> +set host [lindex $argv 0]
> +set outletnumber [lindex $argv 1]
> +set passwd [lindex $argv 2]
> +set toggles 2
> +if { [ llength $argv ] == 4 } {
> + set toggles [ lindex $argv 3 ]
> +}
> +set remain $toggles
> +
> +spawn telnet $host
> +set env(TERM) vt100
> +set timeout 30
> +
> +expect timeout {
> + send_user "failed to contact $host\n"
> + exit
> +} "Password >" {
> + # first password prompt, so just send a return
> + send "\r"
> +}
> +
> +while {1} {
> + expect timeout {
> + send_user "failed to contact $host\n"
> + exit
> + } "Password >" {
> + # second password prompt, so send password
> + send "$passwd\r"
> + } "Enter >" {
> + # reboot prompt
> + if { $remain == 0 } {
> + send_user "\ntoggled outlet $outletnumber $toggles times\n"
> + exit 0
> + }
> + send "$outletnumber\r"
> + set remain [expr { $remain - 1 } ]
> + } eof {
> + send_user "failed to connect to power strip\n"
> + exit
> + }
> +}
prev parent reply other threads:[~2014-04-23 9:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-17 13:07 [Cluster-devel] [PATCH] fence_ipal: Introduce ipal fence agent Andrea Bucci
2014-04-23 9:35 ` Marek Grac [this message]
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=53578946.706@redhat.com \
--to=mgrac@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.