2.6.8.2 Python

Adding a server to a server pool.

By searching for the IDs for each server name we wish to add to the server pool, it is straightforward to add a server to the server pool that we created:

...
svrid=get_id_from_name(s,baseUri,'Server','1.example.org')
uri='{base}/ServerPool/{spid}/addServer'.format(base=baseUri,spid=sp_id['value'])
r=s.put(uri,data=json.dumps(svrid)) 
job=r.json()
# wait for the job to complete
wait_for_job(job['id']['uri'],s)

Note that we assume that you have the sp_id variable set, from one of the previous examples. If you do not have this set, you must populate it with the id for the server pool that you are configuring.

Removing a server from a server pool.

Using the same logic as we used to add a server, it is also straightforward to remove a server from the server pool that we created:

...
svrid=get_id_from_name(s,baseUri,'Server','1.example.org')
uri='{base}/ServerPool/{spid}/removeServer'.format(base=baseUri,spid=sp_id['value'])
r=s.put(uri,data=json.dumps(svrid)) 
job=r.json()
# wait for the job to complete
wait_for_job(job['id']['uri'],s)

Note that we assume that you have the sp_id variable set, from one of the previous examples. If you do not have this set, you must populate it with the id for the server pool that you are configuring.