This question cropped up on our discussion forum: Re: How to use RESTful Control API with Python? - enable, disable, or drain node: How can I list the nodes that are draining in a Stingray configuration, much like the 'Draining' page in the UI.
You can get the list of nodes that are draining per-pool from /api/tm/1.0/config/active/pools/poolname; look at the properties->basic->draining value. There's no single action to get a list of all of the nodes that are draining in all pools. The UI reads each pool one at a time and merges the 'draining' lists from each; you will need to do the same.
The following Python code illustrates how you could do this:
#!/usr/bin/python import requests import json url = 'https://stingray:9070/api/tm/1.0/config/active/pools/'; client = requests.Session() client.auth = ('admin', 'admin') client.verify = 0 response = client.get(url) pools = json.loads(response.content) draining = [] for node in pools['children']: response = client.get(url+node['name']) data = json.loads(response.content) draining += data['properties']['basic']['draining'] print "Draining Nodes: " + ", ".join( set( draining ))