Here’s an outline of the vCO Workflow. I mentioned in the original post it’s not exactly elegant as I should be calling nested workflows so it’s more modular but I had some issues with that I didn’t have a chance to work through yet.
These projects are going to be mostly just proof of concept, so the code will be rough on the first go, deal with it…!
Python running on the Raspberry Pi. Notice I just use CURL to do the rest call. Easy enough, but I should be using a library if doing anything more advanced.
Used default actions to get VM and Host objects from the string of a name.
These actions output an array of VM/Host parameter, so I took a shortcut in not wanting to deal with that, so I just perform the powerOn on the first found object:
This idea simply came from the thought ‘i wonder if it’s possible…’ I’ve always wanted to build something with RFID, and I’ve always wanted to play with a Raspberry Pi, so no time like the present.
The thought here is to simulate swiping your badge at your office in the morning when unlocking the door, and automatically have it wake up your desktop virtual machine so it’s ready for you by the time you need it.
Initial tests with the hardware went well:
I can’t claim credit for the wiring of the rPi and RFID reader. Check out this blog for the exact connections. It’s really easy. The pi cobbler makes it easy to prototype stuff on a breadboard. The logic level converter is so you don’t fry the rPi from the higher voltage the reader needs.
(1) A simple python script loops reading serial data from the RFID reader. (Based on this post.)
(2) When a badge is read, a sound plays and a call over REST is made to vCO to invoke a workflow. The badge ID is passed to the workflow.
The rest of this (but not REST.. ha ha. nerd joke. ok sorry.) is within a vCO Workflow. At the current time it’s more or less one workflow which isn’t super elegant, but I had issues doing certain operations when separating it out. A future revision will make this part better.
(3) The workflow takes the badge ID, looks it up in a SQL DB (i wanted to test doing operations on an external DB too), gets the employee ID, – albeit overkill, I wanted to give it more real world context and functionality. Think of this as an integration with a 3rd party security system, and a HR system or Active Directory.
(4) The employee ID is used to lookup the name of the desktop from another database table.
(5) The workflow does some magic to find what the exact VM object is from the string of just the name.
(6) VM is powered on.
Pretty basic, but this covers an external VCO invocation over the API, external DB CRUD, variable manipulation, and VM power operations.
Here’s the full video overview:
All done for now. The rPi is off mining bitcoins on a shelf until it’s called to duty next. Stay tuned for a new project in a few weeks..
– Clean up the vCO, make it more modular
– Python script reads badges way too fast causing duplicates
– Package up content and post here (workflow + python)
I take really good notes, but I may have missed a site that was helpful, sorry if I missed you!
This page will be the main page where I link to all upcoming projects I will be building. Expect much much more detail here over time….
Background: I travel a good amount in a new role I moved into this year. With the travel, I’ve picked up running again as a way to keep myself sane which is a good thing. I tend to have a flood of thoughts, ideas, and other wacky randomness when the miles add up. This endeavor is a direct product of this attempt at sanity creating more insanity. But the good kind. I think.
What is this: Projects will be posted here as I complete them. They will be varying levels of direct work related-ness. Some will be entirely useful and applicable. Others will just be because I can. All will show off a science and art of what is possible with software (mostly VMware).