{"id":1154,"date":"2023-01-28T21:25:30","date_gmt":"2023-01-28T21:25:30","guid":{"rendered":"https:\/\/blog.thomarite.uk\/?p=1154"},"modified":"2023-01-31T23:56:31","modified_gmt":"2023-01-31T23:56:31","slug":"api-scripts-cml-and-vsphere","status":"publish","type":"post","link":"https:\/\/blog.thomarite.uk\/index.php\/2023\/01\/28\/api-scripts-cml-and-vsphere\/","title":{"rendered":"API scripts: CML and Vsphere"},"content":{"rendered":"\n<p>In the last months I have been trying to practice the knowledge from CCNA DevNet and managed to wrote very basic scripts using API.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>CML is a simulation solution from Cisco that actually works (you have to pay and need hardware). There are nice docs out there:<\/p>\n\n\n\n<p><a href=\"https:\/\/developer.cisco.com\/docs\/modeling-labs\/#!sandbox\/cisco-modeling-labs-sandbox\">CML sandbox<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/developer.cisco.com\/codeexchange\/github\/repo\/sttrayno\/CML-Personal-Guide\/\">CML Starting guide + API examples<\/a> (this saved me)<\/p>\n\n\n\n<p><a href=\"https:\/\/developer.cisco.com\/codeexchange\/github\/repo\/kikuta\/CML\">CML simulation lifecycle example<\/a> (havent tried yet)<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/thomarite\/scripts\/blob\/main\/cml-restore.py\">CML<\/a>: I actually struggled in this one regarding how to authenticate&#8230;.. Checking some pages I worked out. I was trying to use the theory from DevNet but no joy. The idea is to restore a lab after you have made many changes. The script log into CML, delete the lab and restore with a provided backup.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Some docs for vsphere api:<\/p>\n\n\n\n<p><a href=\"https:\/\/developer.vmware.com\/apis\/vsphere-automation\/latest\/cis\/api\/session\/post\/\">Vsphere create session<\/a>: (quite useful)<\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/45026210\/vcenter-rest-api-authentication\">vcenter REST API authentication<\/a> <\/p>\n\n\n\n<p><a href=\"https:\/\/www.vgemba.net\/vmware\/VCSA-API-Postman\/\">vcenter API with Postman<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/developer.vmware.com\/samples\/2562\/vsphere-automation-rest-api-postman-resources-and-samples\">Vsphere postman examples<\/a> (need to take a look)<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/thomarite\/scripts\/blob\/main\/vsphere-api.py\">Vsphere<\/a>: This is even simpler&#8230;. at least in this one I didnt struggle with the auth as the documentation was quite clear. But the original goal of restore a VM from a snapshot looks like is not available via API.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the last months I have been trying to practice the knowledge from CCNA DevNet and managed to wrote very basic scripts using API. CML is a simulation solution from Cisco that actually works (you have to pay and need hardware). There are nice docs out there: CML sandbox CML Starting guide + API examples &hellip; <a href=\"https:\/\/blog.thomarite.uk\/index.php\/2023\/01\/28\/api-scripts-cml-and-vsphere\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;API scripts: CML and Vsphere&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-1154","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/1154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/comments?post=1154"}],"version-history":[{"count":2,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/1154\/revisions"}],"predecessor-version":[{"id":1157,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/1154\/revisions\/1157"}],"wp:attachment":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/media?parent=1154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/categories?post=1154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/tags?post=1154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}