fence_netio: new fence-agent for the Koukaam NETIO-230B PDU
PATCH 1/1 fence_netio: new fence-agent for the Koukaam NETIO-230B PDU
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
--- .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
.gitignore +1 -0
@@ -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
configure.ac +1 -0
@@ -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
fence/agents/netio/Makefile.am new file +17 -0
@@ -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)
fence/agents/netio/fence_netio.py new file +119 -0
119 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 1/1 fence_netio: new fence-agent for the Koukaam NETIO-230B PDU
Hi,
thanks for patch, I do not have any objections - applied to upstream
m,
Quoted 189 lines · Niels de Vos
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=1502Signed-off-by Niels de Vos <[email protected]>--- .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.gitignore +1
-0@@ -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.libconfigure.ac +1
-0@@ -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/Makefilefence/agents/netio/Makefile.am new file +17
-0@@ -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)fence/agents/netio/fence_netio.py new file +119
-0@@ -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()
PATCH 1/1 fence_netio: new fence-agent for the Koukaam NETIO-230B PDU
Hi guys,
just wanted to report, it works pretty well with 230CS too. good job, thanks a lot!
nik
Quoted 196 lines · Marek Grac
Hi,
thanks for patch, I do not have any objections - applied to upstream
m,
Quoted 189 lines · Niels de Vos
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=1502Signed-off-by Niels de Vos <[email protected]>--- .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.gitignore +1
-0@@ -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.libconfigure.ac +1
-0@@ -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/Makefilefence/agents/netio/Makefile.am new file +17
-0@@ -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)fence/agents/netio/fence_netio.py new file +119
-0@@ -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()
Signature · 20 lines
------------------------------------- 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>
PATCH 1/1 fence_netio: new fence-agent for the Koukaam NETIO-230B PDU
Quoted 4 lines · Nikola Ciprich
Hi guys,
just wanted to report, it works pretty well with 230CS too. good job, thanks a lot!
Thanks for the report. It's nice to hear that others can use this as well :)
Niels
Quoted 216 lines
nik
Quoted 196 lines · Marek Grac
Hi,
thanks for patch, I do not have any objections - applied to upstream
m,
Quoted 189 lines · Niels de Vos
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=1502Signed-off-by Niels de Vos <[email protected]>--- .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.gitignore +1
-0@@ -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.libconfigure.ac +1
-0@@ -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/Makefilefence/agents/netio/Makefile.am new file +17
-0@@ -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)fence/agents/netio/fence_netio.py new file +119
-0@@ -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()Signature · 13 lines
------------------------------------- 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 -------------------------------------
Signature · 4 lines
Niels de Vos Sr. Software Maintenance Engineer Support Engineering Group Red Hat Global Support Services