{"id":1026,"date":"2017-01-05T16:36:28","date_gmt":"2017-01-05T22:36:28","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=1026"},"modified":"2017-01-05T16:36:28","modified_gmt":"2017-01-05T22:36:28","slug":"oracle-ovm-rest-api-example","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/oracle-ovm-rest-api-example\/","title":{"rendered":"Oracle OVM rest api example"},"content":{"rendered":"

If you hate the Oracle OVM CLI and having to use expect scripts you may want to look into the web services API. \u00a0Note it looks like SOAP will be decommissioned soon so use REST.<\/p>\n

\r\n$ cat ovm_using_rest.py \r\nimport requests\r\n\r\ns=requests.Session()\r\ns.auth=('admin','pwd_removed')\r\ns.verify=False #disables SSL certificate verification\r\n\r\ns.headers.update({'Accept': 'application\/json', 'Content-Type': 'application\/json'})\r\n\r\nbaseUri='https:\/\/ovmm:7002\/ovm\/core\/wsapi\/rest'\r\n\r\nprint "\\nServer List:"\r\nprint "##############"\r\nr=s.get(baseUri+'\/Server')\r\nfor i in r.json():\r\n  # do something with the content\r\n  print '{:20} {:20}'.format(i['serverRunState'],i['name'])\r\n\r\nprint "\\nVM List:"\r\nprint "########"\r\nr=s.get(baseUri+'\/Vm')\r\nfor i in r.json():\r\n  # do something with the content\r\n  print '{:20} {:20}'.format(i['vmRunState'],i['name'])\r\n  #print '{name} '.format(name=i['name'])\r\n<\/pre>\n

Output:<\/p>\n

\r\n$ python ovm_using_rest.py \r\n\r\nServer List:\r\n##############\r\n\/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\r\n  InsecureRequestWarning)\r\nRUNNING              ovms2            \r\nRUNNING              ovms3             \r\nRUNNING              ovms1             \r\n\r\nVM List:\r\n########\r\nTEMPLATE             EXALYTICS_BASE_LINUX_OEL5_GUEST_VM_TEMPLATE_2.2.0.0.0.el5\r\nTEMPLATE             EXALYTICS_BASE_LINUX_OEL6_GUEST_VM_TEMPLATE_2.2.0.0.0.el6\r\nRUNNING              OBIEXA3           \r\nSTOPPED              obiexa4           \r\n[..]\r\nSTOPPED              EXALYTICS_BASE_LINUX_OEL5_GUEST_VM_TEMPLATE_2.0.1.4.0\r\nTEMPLATE             OBIEE12C_TEMPLATE.0 \r\nRUNNING              OBIEXA01         \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

If you hate the Oracle OVM CLI and having to use expect scripts you may want to look into the<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,13],"tags":[],"class_list":["post-1026","post","type-post","status-publish","format-standard","hentry","category-ovm","category-python"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1026","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=1026"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1026\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=1026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=1026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=1026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}