I’m fortunate enough to have a small Intel NUC powering my labbing efforts for both home and work use. When I joined Okta, I decided to set up a separate AD/Firewall VM to keep things apart from my home lab AD I’d been using in the past.
I also decided that I didn’t need these VMs running over night so I thought I’d suspend them after ‘working hours’. So at 9am, I wanted the VMs to resume, and at around 5:30/6, have them suspend.
In this post, we will explore how to use the vCenter API called by a Python script to suspend and resume a set of VMs on a schedule.
When I was passing this via my PHP API wrapper, this was giving me no end of heck. I spent ages looking for how to escape those “”‘s, and after testing with Postman that this worked great like this, for some reason I notice an option in Postman I’d never clicked before.
Just up there by Save on the top right.
Then like an idiot, I realised I just needed to use the ASCII code for “, and I’d have been fine. Copy and pasted this into the function call going to my API wrapper, and we have liftoff.
If you want to be even smarter, you can have Postman generate all the code needed when you have a working call in the app! This would have saved me HOURS in the past if I’d known this.