To track manager status in Python, the API can be queried repeatedly using the managerGet() method to access the Manager object and the managerRunState property value can be tested to determine whether or not the Oracle VM Manager instance has RUNNING runtime status. To keep the script polite, use the time library to sleep between requests. Since this is functionality that may be used repeatedly at different stages in a program, it is better to define it as a function:
import time ... def check_manager_state(client): while True: manager=client.service.managerGet() if manager.managerRunState.upper() == 'RUNNING': break time.sleep(1) return;
In this function, the while True:
statement
creates an infinite loop. The suds library client object is
used to submit a call to the managerGet() method exposed by
the SOAP API. We use an if
statement to test the
managerRunState property to see whether it matches the string
value 'RUNNING'. If a match is found, the infinite loop is
broken and the function can return. If a match is not found,
the time.sleep
statement causes the function to
wait for one second before submitting the next request, so
that requests take place over a sensible period.
Usually, you would insert a call to this function directly after you authenticate, as described in Section 3.5.1, “Authenticating”. You may even incorporate this code into your authentication process, so that it is called whenever an authentication request is made within your application.