I’ve been quite quiet since VMworld, sorry! Life has not slowed down at all. Anyway enough about the boring stuff.
First, let me say, the people were GREAT! I’m sure I cannot mention them all, but here are a few: AJ Kuftic, Dave Kalaluhi, Dan Barr, Doug DeFrank. All of these guys were great to hang with and were super welcoming. I cannot thank them enough for their hospitality!
At the TAM meeting, there were a lot of great conversations with wide ranging topics. It was great to be in a room with very smart folks! Not to mention the diversity in skill sets. Its amazing how everyone uses the technology, but we all use it differently. It just proves that we all have so much to learn.
The PGH Little Hack was fun! I’m not sure that anyone accomplished a specific task. But I know that we all walked away with more knowledge! Just like the larger hackathons I think keeping scope small is key. It’s way too easy to get off topic.
Lastly the WPVMUG, these events are great, we get to see presentations from experts in our field with direct access to the presenter. Additionally my favorite part is that new speakers get their time to shine. This time it was Doug DeFrank and boy did he shine. You could tell he was a bit nervous before the start of his presentation, but as soon as it started he blew me away. His passion for his topic was unprecedented, the topic hits home for me, as I got started scripting the same way he described. I’m sure that Ariel will be posting a video, if I find it I will post the link. So thank you Ariel for getting Doug to speak, and Thanks to Doug for delivering a very good presentation. The workflow diagrams were great, but the passion will keep me coming back, I hope I get to see you on stage again soon! Check out his blog here.
Lets get to some Technical stuff…
One of the problems we had with the little Hack (and I could see in future events) is that we did not know what to do. Everyone had some idea’s but we never really ironed the details out. Now I don’t think that every little detail has to exist before you start one of these events, but having a plan or general direction is always nice. One of the constant themes we had over the 2 days was hearing folks say “I want to learn more about the vSphere API’s”. But no one really knew how to get started, or a way to really have it hit home. So I am here to propose the following, at least for folks with a similar skill set to my own….. which consists of quite a bit of PowerShell.
I’ve started a new PowerShell Module called “PowerRestCLI”, which is just a PowerShell wrapper to the vSphere API. Now, I want to be clear: THIS IS NOT A REPLACEMENT FOR POWERCLI! This is not my goal, it is not the purpose of this Module. This is just a tool for folks to learn a new skill. Honestly my goal, whether it be for the Little hacks that involve the VMwareCode community, or if someone just wants to learn a little, is for them to contribute to the Samples.
I have submitted a Pull Request that includes the Module to the vSphere-Automation-sdk-Rest project on the VMware Github site. If the folks in charge do not agree that the samples/module belongs, I will simply support the module on my personal GitHub repository. This is not new information, as I pulled stuff from the following blogs, Luk Dekens (go figure…lol), Chris Wahl (no surprise here) and Chris Bradshaw. I am just extending their work, to hopefully help others in the community.
Here are the skills that I believe folks will learn while contributing:
- Deeper PowerShell skills
- How Rest interfaces work
- GitHub methodologies
- vSphere Rest specific knowledge
I’m sure I am missing something, but these are the things that all the guys were asking about while I was in Pittsburgh.
Here is a peek at the module I started and what it includes:
- Download the module (not available in the PowerShell Gallery yet).
- Edit the ConnectionVariables.ps1 file to update the Name/IP of your vCenter
- Import the Module
- Connect to the vCenter
- Pull the list of VM’s
Yes, I know, its not much. But its a start, and the formats are fairly similar.
Module Name – PowerRestCLI, Go ahead and import it.
Next, connect to your vCenter:
# This will prompt you for UN/PW Connect-rVIServer -vCenter $vCenter # Or specify the UN/PW Connect-rVIServer -vCenter $vCenter -User Administrator@corp.local -Password VMware1! # Or use a Credential already set Connect-rVIServer -vCenter $vCenter -Credential $creds
This command returns:
Name Port User ---- ---- ---- 192.168.2.220 443 email@example.com
Once you are connected its easy to get the list of VM’s!
Notice all of the commands have a lower case ‘r’, to designate this as a “REST” command vs. a normal PowerCLI command. Note, ‘Get-rVM’ does not support filtering yet! Add this to the next little hack!
All of this sounds really cool, but do we get the same information? YES! kinda.
Here is the typical formatted return of PowerCLI’s ‘Get-VM’
Name PowerState Num CPUs MemoryGB ---- ---------- -------- ------- Win_7_Test_vm PoweredOff 1 2.000 Win_10_test_vm PoweredOff 1 4.000 CentOS_6_test_vm PoweredOff 1 2.000 Embedded-vCenter-... PoweredOn 2 10.000
And here is ‘Get-rVM’ output:
name power_state cpu_count memory_size_MiB ---- ----------- --------- --------------- Embedded-vCenter-Server-Appliance POWERED_ON 2 10240 Win_7_Test_vm POWERED_OFF 1 2048 Win_10_test_vm POWERED_OFF 1 4096 CentOS_6_test_vm POWERED_OFF 1 2048
Sorry, wordpress kinda sucks with formatting. Notice any differences?
PowerState(PowerCLI) is different than power_state(PowerRestCLI). CPU/Memory also have differences. Note that in the second example, the full name of the VCSA is displayed by default. These can be overcome with some code, but it is interesting that the returns are slightly different. I’m curious if this is something nice PowerCLI does for us in the background.
It is clear that the information is available, and that is the goal of this module! I hope that it is accepted into the Samples, and that more and more folks can learn how to use the vSphere API through PowerShell. There is also potential that at some point in the future that the vSphere API may have a setting available that PowerCLI does not, Now you have the power to make the change in PowerShell!
Thanks for reading! Hit me up on Twitter if you have any questions! @jpsider