Using PowerShell to automate in the Cisco UCS platform
- select the contributor at the end of the page -
Cisco UCS Platform
The Cisco UCS Platform was introduced in 2009 and is one of the most technically advanced server platforms on the market. Getting into the technical details of the platform is a bit beyond what I'm looking to cover here, but there's quite a bit of information available online.
Cisco UCS emulator
Because we don't all have enterprise-class hardware (or the power to run it) in our IT sandbox, fortunately Cisco provides a “UCS Platform Emulator” which you can install on a desktop-class virtualization product like the free VMware Player.
To get the emulator, simply go to the Cisco download site. A free Cisco ID is required, but is generally not too much trouble to setup. At the time of writing, version “2.1.1aPE3” was available as an .ova file that's just over 500 MB (the .zip version is only slightly smaller).
There's a link on the Petri IT web site that provides an overview of how to get the emulator running, so I won't cover those details here. However, they don't really mention the networking requirements. You'll need to make sure the emulator boots up and has an IP address (it will try DHCP by default) if you want to try to manage it via some of the available tools.
Once you have the emulator installed, you have your own virtual UCS environment. You can't do things like boot an operating system, but there are several other tasks that are actually possible and mimic a real, complete environment.
Cisco UCS PowerTool
Cisco provides the Windows PowerShell functionality for managing their UCS platform as a module. Now, you might think there's maybe a few cmdlets, but there are actually almost 1,700! Cisco has really gone all out to offer a complete automation interface in their UCS Platform.
To get to the PowerTool go to the download page and scroll down a bit to the “download instructions” section. Currently the site has version 1.0.0 and it's a small 8.5 MB download. The installation is really simple as well, so I won't cover it here.
Connecting via the PowerTool
Let's do something useful. In the following image, I'm connecting to the UCS emulator and I'm saving this connection to a variable, or a UCS connection object. Then I'm running a cmdlet to get all the blades on the system, and selecting a few properties (using Format-Table for easier visibility).
A few things to note:
- There's a prompt for my user credentials which is not shown in the above image.
- You should be able to look at the console of the emulator, and get the IP address that you'll need to connect to, especially if it was provided by DHCP.
The above image appears to show another small bug as most of the model strings are not showing properly, but it does show the “UCSB-B200-M3” which is one of the B-Series blade models that is available for the platform. These are the default blades that show up in the emulator.
Tracing a session
Something that I find really cool is how Cisco has added a Windows PowerShell “wizard.” Basically, you can fire up a Windows PowerShell session and start the ConvertTo-UcsCmdlet.
When commands are run from the UCS Manager (UCSM) interface, they will display command-by-command in the Windows PowerShell session, as shown in the following image.
Here, what I've done in UCSM is complete a wizard to create a service profile template. What you see in the image is the Windows PowerShell command that could be used to do the same task. This makes it easy for me to copy, edit, paste and run custom code to automate various tasks.
Unfortunately, this particular version doesn't seem to have full or complete built-in help for Windows PowerShell.
For example, if you try something like “get-help get-ucsblade -examples”, there won't be any actual examples shown on the console. It's not a matter of formatting either because even “get-help get-ucsblade -full” doesn't show any examples either.
Hopefully this is something that Microsoft is looking to address in the future, or maybe it will offer an user guide at the very least.
MMS 2013 session
A few Cisco team members presented at the Microsoft Management Summit 2013 recently. They gave an awesome session covering different Microsoft technologies that support the Cisco UCS platform. The session is available for online and offline viewing.
In the session, they walk through a lot of practical examples using PowerTool. I'm especially excited about a coming feature that they discuss at the 44:40 mark of the MMS video. They are going to offer functionality that can basically parse a UCS backup file and output the entirety of the Windows PowerShell commands that would be used to recreate the current backup file. I think that's an awesome feature not only for DR documentation, but also because of the portability of dumping all the required commands, doing some slight edits, and using that set of commands to maybe setup another test environment.
The video is definitely worth watching for the information that it provides. Also, TrainSignal has an amazing 20-module course on the Cisco UCS platform, and it's definitely worth checking out. The emulator is also used there as well.
Your trial includes access to our course on Implementing Cisco UCS!