Owner's Manual

Programmatic Management | 109
The following example shows how to embed an HTTP get request in Python script.
Figure 10-2. Python Sample with HTTP Get Request that Invokes the REST API
#
!/usr/bin/python
i
mport httplib
c
onn = httplib.HTTPConnection("10.42.51.5")
#
Send HTTP GET request
c
onn.request("GET","/cgi-bin/F10Ping?IpAddress=10.42.0.13")
#
Get response data
r
esponse = conn.getresponse()
#
Display response texts on success or display status
i
f(response.status == 200):
# Handle response data
data = response.read()
print data
e
lse :
# Handle error
print "Operation failed",response.status,response.reason
c
onn.close()