[Linux-HA] Setup Question.
Alain St-Denis
alain.st-denis at ec.gc.ca
Fri Jun 11 12:22:35 MDT 2004
Skipped content of type multipart/alternative-------------- next part --------------
A non-text attachment was scrubbed...
Name: hbaping.tar
Type: application/octet-stream
Size: 20480 bytes
Desc: not available
Url : http://lists.community.tummy.com/pipermail/linux-ha/attachments/20040611/69a17bf6/hbaping-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: riloe.tar
Type: application/octet-stream
Size: 20480 bytes
Desc: not available
Url : http://lists.community.tummy.com/pipermail/linux-ha/attachments/20040611/69a17bf6/riloe-0001.obj
-------------- next part --------------
#!/usr/bin/python2.2
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 = [ '<RIBCL VERSION="1.2">',
'<LOGIN USER_LOGIN="Administrator" PASSWORD="********">' ]
logout = [ '</LOGIN>', '</RIBCL>' ]
status = [ '<SERVER_INFO MODE="read">', '<GET_HOST_POWER_STATUS/>',
'</SERVER_INFO>' ]
reset = [ '<SERVER_INFO MODE="write">', '<RESET_SERVER/>', '</SERVER_INFO>' ]
off = [ '<SERVER_INFO MODE = "write">', '<SET_HOST_POWER HOST_POWER = "N"/>',
'</SERVER_INFO>' ]
on = [ '<SERVER_INFO MODE = "write">', '<SET_HOST_POWER HOST_POWER = "Y"/>',
'</SERVER_INFO>' ]
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('<?xml version="1.0"?>\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)
More information about the Linux-HA
mailing list