2.6.6.2 Python

As in our previous example, Section 2.6.4, “Discovering Servers”, the session object can be used to submit a POST request, this time containing the serverPool object which is described as a Python dictionary and converted to a JSON string as it is submitted:

...
data = {
            'name': 'MyServerPool',
            'virtualIp': '10.172.77.196',
        }
uri='{base}/ServerPool'.format(base=baseUri)
r=s.post(uri, data=json.dumps(data))
job=r.json()
# wait for the job to complete
sp_id=wait_for_job(job['id']['uri'],s)

As before, the response content returned by Oracle VM Manager, contains a JSON object describing the job that is created to add the server pool. See Track Job Status for more information on how to handle this content. Assuming this server pool is created without any hitch, the wait_for_job function should return the ID for the server pool that has been created, so we populate the sp_id variable with the contents returned by the wait_for_job function. This makes it easier for us to perform other immediate actions, such as setting up clustering.