Oracle OVM rest api example
If you hate the Oracle OVM CLI and having to use expect scripts you may want to look into the web services API. Note it looks like SOAP will be decommissioned soon so use REST.
$ cat ovm_using_rest.py import requests s=requests.Session() s.auth=('admin','pwd_removed') s.verify=False #disables SSL certificate verification s.headers.update({'Accept': 'application/json', 'Content-Type': 'application/json'}) baseUri='https://ovmm:7002/ovm/core/wsapi/rest' print "\nServer List:" print "##############" r=s.get(baseUri+'/Server') for i in r.json(): # do something with the content print '{:20} {:20}'.format(i['serverRunState'],i['name']) print "\nVM List:" print "########" r=s.get(baseUri+'/Vm') for i in r.json(): # do something with the content print '{:20} {:20}'.format(i['vmRunState'],i['name']) #print '{name} '.format(name=i['name'])
Output:
$ python ovm_using_rest.py Server List: ############## /usr/lib/python2.7/dist-packages/urllib3/connectionpool.py:794: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning) RUNNING ovms2 RUNNING ovms3 RUNNING ovms1 VM List: ######## TEMPLATE EXALYTICS_BASE_LINUX_OEL5_GUEST_VM_TEMPLATE_2.2.0.0.0.el5 TEMPLATE EXALYTICS_BASE_LINUX_OEL6_GUEST_VM_TEMPLATE_2.2.0.0.0.el6 RUNNING OBIEXA3 STOPPED obiexa4 [..] STOPPED EXALYTICS_BASE_LINUX_OEL5_GUEST_VM_TEMPLATE_2.0.1.4.0 TEMPLATE OBIEE12C_TEMPLATE.0 RUNNING OBIEXA01