All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikola Ciprich <nikola.ciprich@linuxbox.cz>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] fence_netio: new fence-agent for the Koukaam NETIO-230B PDU
Date: Thu, 3 Oct 2013 15:20:36 +0200	[thread overview]
Message-ID: <20131003132036.GC29455@pcnci.linuxbox.cz> (raw)
In-Reply-To: <52495E0A.9010308@redhat.com>

Hi guys,

just wanted to report, it works pretty well with 230CS too.
good job, thanks a lot!

nik


On Mon, Sep 30, 2013 at 01:18:34PM +0200, Marek Grac wrote:
> Hi,
> 
> thanks for patch, I do not have any objections - applied to upstream
> 
> m,
> On 09/28/2013 12:15 PM, Niels de Vos wrote:
> >The Koukaam NETIO-230B is a power distribution unit with four normal
> >(European) sockets. The device has a webui and a telnet interface. Each
> >socket can be given a custom name, which is returned with '-o list'.
> >
> >Link to the device, its specifications and API:
> >- http://www.koukaam.se/kkm/showproduct.php?article_id=1502
> >
> >Signed-off-by: Niels de Vos <ndevos@redhat.com>
> >---
> >  .gitignore                        |    1 +
> >  configure.ac                      |    1 +
> >  fence/agents/netio/Makefile.am    |   17 +++++
> >  fence/agents/netio/fence_netio.py |  119 +++++++++++++++++++++++++++++++++++++
> >  4 files changed, 138 insertions(+), 0 deletions(-)
> >  create mode 100644 fence/agents/netio/Makefile.am
> >  create mode 100755 fence/agents/netio/fence_netio.py
> >
> >diff --git a/.gitignore b/.gitignore
> >index 245592f..0c19556 100644
> >--- a/.gitignore
> >+++ b/.gitignore
> >@@ -59,6 +59,7 @@ fence/agents/lib/fencing_snmp.pyc
> >  fence/agents/lpar/fence_lpar
> >  fence/agents/manual/fence_ack_manual
> >  fence/agents/mcdata/fence_mcdata
> >+fence/agents/netio/fence_netio
> >  fence/agents/node_assassin/fence_na
> >  fence/agents/node_assassin/fence_na.conf
> >  fence/agents/node_assassin/fence_na.lib
> >diff --git a/configure.ac b/configure.ac
> >index 910cab8..6f4baa0 100644
> >--- a/configure.ac
> >+++ b/configure.ac
> >@@ -276,6 +276,7 @@ AC_CONFIG_FILES([Makefile
> >  		 fence/agents/lpar/Makefile
> >  		 fence/agents/manual/Makefile
> >  		 fence/agents/mcdata/Makefile
> >+		 fence/agents/netio/Makefile
> >  		 fence/agents/nss_wrapper/Makefile
> >  		 fence/agents/rackswitch/Makefile
> >  		 fence/agents/ovh/Makefile
> >diff --git a/fence/agents/netio/Makefile.am b/fence/agents/netio/Makefile.am
> >new file mode 100644
> >index 0000000..3e1a1d9
> >--- /dev/null
> >+++ b/fence/agents/netio/Makefile.am
> >@@ -0,0 +1,17 @@
> >+MAINTAINERCLEANFILES	= Makefile.in
> >+
> >+TARGET			= fence_netio
> >+
> >+SRC			= $(TARGET).py
> >+
> >+EXTRA_DIST		= $(SRC)
> >+
> >+sbin_SCRIPTS		= $(TARGET)
> >+
> >+man_MANS		= $(TARGET).8
> >+
> >+include $(top_srcdir)/make/fencebuild.mk
> >+include $(top_srcdir)/make/fenceman.mk
> >+
> >+clean-local: clean-man
> >+	rm -f $(TARGET)
> >diff --git a/fence/agents/netio/fence_netio.py b/fence/agents/netio/fence_netio.py
> >new file mode 100755
> >index 0000000..ffb6e30
> >--- /dev/null
> >+++ b/fence/agents/netio/fence_netio.py
> >@@ -0,0 +1,119 @@
> >+#!/usr/bin/python
> >+
> >+import sys, re, pexpect, exceptions
> >+sys.path.append("@FENCEAGENTSLIBDIR@")
> >+from fencing import *
> >+
> >+#BEGIN_VERSION_GENERATION
> >+RELEASE_VERSION=""
> >+REDHAT_COPYRIGHT=""
> >+BUILD_DATE=""
> >+#END_VERSION_GENERATION
> >+
> >+def get_power_status(conn, options):
> >+	conn.send_eol("port %s" % options["--plug"])
> >+	re_status = re.compile("250 [01imt]")
> >+	conn.log_expect(options, re_status, int(options["--shell-timeout"]))
> >+	status = {
> >+		"0" : "off",
> >+		"1" : "on",
> >+		"i" : "reboot",
> >+		"m" : "manual",
> >+		"t" : "timer"
> >+	}[conn.after.split()[1]]
> >+
> >+	return status
> >+
> >+def set_power_status(conn, options):
> >+	action = {
> >+		"on" : "1",
> >+		"off" : "0",
> >+		"reboot" : "i"
> >+	}[options["--action"]]
> >+
> >+	conn.send_eol("port %s %s" % (options["--plug"], action))
> >+	conn.log_expect(options, "250 OK", int(options["--shell-timeout"]))
> >+
> >+def get_outlet_list(conn, options):
> >+	result = {}
> >+
> >+	try:
> >+		# the NETIO-230B has 4 ports, counting start at 1
> >+		for plug in ["1", "2", "3", "4"]:
> >+			conn.send_eol("port setup %s" % plug)
> >+			conn.log_expect(options, "250 .+", int(options["--shell-timeout"]))
> >+			# the name is enclosed in "", drop those with [1:-1]
> >+			name = conn.after.split()[1][1:-1]
> >+			result[plug] = (name, "unknown")
> >+	except Exception, exn:
> >+		print str(exn)
> >+
> >+	return result
> >+
> >+def main():
> >+	device_opt = [ "ipaddr", "login", "passwd", "port" ]
> >+
> >+	atexit.register(atexit_handler)
> >+
> >+	opt = process_input(device_opt)
> >+
> >+	# set default port for telnet only
> >+	if 0 == opt.has_key("--ipport"):
> >+		opt["--ipport"] = "1234"
> >+
> >+	opt["eol"] = "\r\n"
> >+	options = check_input(device_opt, opt)
> >+
> >+	docs = { }
> >+	docs["shortdesc"] = "I/O Fencing agent for Koukaam NETIO-230B"
> >+	docs["longdesc"] = "fence_netio is an I/O Fencing agent which can be \
> >+used with the Koukaam NETIO-230B Power Distribution Unit. It logs into \
> >+device via telnet and reboots a specified outlet. Lengthy telnet connections \
> >+should be avoided while a GFS cluster is running because the connection will \
> >+block any necessary fencing actions."
> >+	docs["vendorurl"] = "http://www.koukaam.se/"
> >+	show_docs(options, docs)
> >+
> >+	##
> >+	## Operate the fencing device
> >+	## We can not use fence_login(), username and passwd are sent on one line
> >+	####
> >+	try:
> >+		try:
> >+			conn = fspawn(options, TELNET_PATH)
> >+			conn.send("set binary\n")
> >+			conn.send("open %s -%s\n"%(options["--ip"], options["--ipport"]))
> >+		except pexpect.ExceptionPexpect, ex:
> >+			sys.stderr.write(str(ex) + "\n")
> >+			sys.stderr.write("Due to limitations, binary dependencies on fence agents "
> >+			"are not in the spec file and must be installed separately." + "\n")
> >+			sys.exit(EC_GENERIC_ERROR)
> >+
> >+		screen = conn.read_nonblocking(size=100, timeout=int(options["--shell-timeout"]))
> >+		conn.log_expect(options, "100 HELLO .*", int(options["--shell-timeout"]))
> >+		conn.send_eol("login %s %s" % (options["--username"], options["--password"]))
> >+		conn.log_expect(options, "250 OK", int(options["--shell-timeout"]))
> >+	except pexpect.EOF:
> >+		fail(EC_LOGIN_DENIED)
> >+	except pexpect.TIMEOUT:
> >+		fail(EC_LOGIN_DENIED)
> >+	result = fence_action(conn, options, set_power_status, get_power_status, get_outlet_list)
> >+
> >+	##
> >+	## Logout from system
> >+	##
> >+	## In some special unspecified cases it is possible that
> >+	## connection will be closed before we run close(). This is not
> >+	## a problem because everything is checked before.
> >+	######
> >+	try:
> >+		conn.send("quit\n")
> >+		conn.log_expect(options, "110 BYE", int(options["--shell-timeout"]))
> >+		conn.close()
> >+	except:
> >+		pass
> >+
> >+	sys.exit(result)
> >+
> >+if __name__ == "__main__":
> >+	main()
> 

-- 
-------------------------------------
Ing. Nikola CIPRICH
LinuxBox.cz, s.r.o.
28.rijna 168, 709 00 Ostrava

tel.:   +420 591 166 214
fax:    +420 596 621 273
mobil:  +420 777 093 799
www.linuxbox.cz

mobil servis: +420 737 238 656
email servis: servis at linuxbox.cz
-------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20131003/d56a85cf/attachment.sig>

  reply	other threads:[~2013-10-03 13:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-28 10:15 [Cluster-devel] [PATCH] fence_netio: new fence-agent for the Koukaam NETIO-230B PDU Niels de Vos
2013-09-30 11:18 ` Marek Grac
2013-10-03 13:20   ` Nikola Ciprich [this message]
2013-10-03 13:56     ` Niels de Vos

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=20131003132036.GC29455@pcnci.linuxbox.cz \
    --to=nikola.ciprich@linuxbox.cz \
    /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.