From e9be59e1502a41bab9891d96d753102a7dafef0b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 08:40:13 +0200 Subject: Adding upstream version 1.0.12. Signed-off-by: Daniel Baumann --- lib/plugins/stonith/ribcl.py.in | 101 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 lib/plugins/stonith/ribcl.py.in (limited to 'lib/plugins/stonith/ribcl.py.in') diff --git a/lib/plugins/stonith/ribcl.py.in b/lib/plugins/stonith/ribcl.py.in new file mode 100644 index 0000000..14e070c --- /dev/null +++ b/lib/plugins/stonith/ribcl.py.in @@ -0,0 +1,101 @@ +#!@PYTHON@ + + +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +import sys +import socket +from httplib import * +from time import sleep + + +argv = sys.argv + + +try: + host = argv[1].split('.')[0]+'-rm' + cmd = argv[2] +except IndexError: + print "Not enough arguments" + sys.exit(1) + + +login = [ '', + '' ] + + +logout = [ '', '' ] + + +status = [ '', '', + '' ] + + +reset = [ '', '', '' ] + + +off = [ '', '', + '' ] + + +on = [ '', '', + '' ] + + +todo = { 'reset':reset, 'on':on, 'off':off, 'status':status } + + +acmds=[] +try: + if cmd == 'reset' and host.startswith('gfxcl'): + acmds.append(login + todo['off'] + logout) + acmds.append(login + todo['on'] + logout) + else: + acmds.append(login + todo[cmd] + logout) +except KeyError: + print "Invalid command: "+ cmd + sys.exit(1) + + +try: + for cmds in acmds: + + + c=HTTPSConnection(host) + c.send('\r\n') + c.sock.recv(1024) + + + for line in cmds: + c.send(line+'\r\n') + c.sock.recv(1024) + + + c.close() + sleep(1) + + +except socket.gaierror, msg: + print msg + sys.exit(1) +except socket.sslerror, msg: + print msg + sys.exit(1) +except socket.error, msg: + print msg + sys.exit(1) + -- cgit v1.2.3