Apr 07

Every once and a while I get too fancy for my own good. :) A customer of mine has lots and lots (well…hundreds really) of Unix hosts that need updates of config files and such. There are lots of tools out there that can do what I need to do, but they all require an install on the nodes themselves. My customer does not want any extra software on these nodes, so to do any kind of automation requires me to upload the program, run it remotely, then remove it. I have a large number of tools to do all that several different ways.

Recently though, I needed to download a large file from each node while running another program on the node at the same time. Normally I would use SCP for the download part, but for reasons that would take too long to explain, that option was not open to me. So for some reason, I was struck with the ideal to just use a custom XMLRPC client/server to do the job. Turns out the code is pretty simple. My customer only has Python on these nodes, so my XMLRPC client is written in Python:

import xmlrpclib
import sys
import platform

port = 80    # Some port that passes through your firewall:  80, 21, 23, 25, etc.

farfname = sys.argv[1]
localfilename = sys.argv[2]
server = sys.argv[3]
#host = platform.uname()[1]
host = platform.node()
farname = host + "-" + farfname

ff = open(localfilename, "r").read()

svr = "http://" + server + ":" + port + "/RPC2"
xmlprxy = xmlrpclib.ServerProxy(svr)

print xmlprxy.xfer(farname, ff)

Continue reading »

SociBook Digg Facebook Google Yahoo Buzz StumbleUpon
Tagged with: