We need to write simple scripts to manipulate the configuration of our load balancers (i.e. merge nodes from pools, enable or disable traffic rules). The load balancer has a SOAP API (defined through a bunch of WSDL files) that is very comprehensive, but using it is quite low level, with a lot of manual error checking and list manipulation. It does not tend to create reusable, reliable code.
I would like to write a Python library to handle interactions with the SOAP interface, but I don't know where to start; all my coding experience is writing one-time monolithic programs for specific tasks. This is normal for small jobs, but it does not help me or my colleagues - every time we invent a wheel with a different number of spokes: ~)
The API already provides methods such as getPoolNames () and getDrainingNodes (), but they are a bit inconvenient to use. Most of them take a list of nodes and return another list, so (say), the development of which includes virtual servers, includes such things:
names = conn.getVirtualServerNames()
enabled = conn.getEnabled(names)
for i in range(0, len(names)):
if (enabled[i]):
print names[i]
conn.setEnabled(['www.example.com'], [0])
While something like this:
lb = LoadBalancer('hostname')
for name in [vs.name for vs in lb.virtualServers() if vs.isEnabled()]:
print name
www = lb.virtualServer('www.example.com').disable()
more Pythonic and (IMHO) easier.
, : , 20- WSDL ( SOAPpy/suds ?) API .
( ), - , . , (, ), , . ? "" ?