dchosnek

Useful user labels for blades with PowerTool

Blog Post created by dchosnek on Dec 6, 2013

When a single UCS Manager domain contains a heterogeneous mix of different blade types with different processors and different memory footprints, it can be challenging to find the ideal blade for a given workload. I like to create a custom user label for each blade so that I can easily glance at the equipment tab and see what compute resources are available to me. The user label for each blade is shown in parenthesis as seen in the graphic below. By default, the user label field is blank and nothing is displayed next to the server on the equipment tab.


User label applied to each bladeNo user label (default)
equip_tab_1.pngno_label.png


 

Easy to create a meaningless label

 

It's actually quite easy to set a custom label for all of your blades using PowerTool. Try this:

 

Get-UcsBlade | Set-UcsBlade -UsrLbl "Custom Label" -Force

 

If it were really that easy, I wouldn't need to write a blog about it. If you tried that code, you found that you just gave every blade in your entire environment the same label. What is the point of labeling if everything is going to have the same label? Instead, let's examine how to set a unique label for each blade. We will start with serial number.

 

Get-UcsBlade | % { $_ | Set-UcsBlade -UsrLbl $_.Serial -Force }

 

or a more readable form of the exact same commands:

 

foreach($blade in Get-UcsBlade) {

    $serial = $blade.Serial

    $blade | Set-UcsBlade -UsrLbl $serial -Force

}

 

Now every blade has a unique label, although this isn't a particularly useful label for me since I don't have my blade serial numbers memorized.

 

serial.png

 

Meaningful labels

 

Instead of using serial number as a label, I prefer a label in the format: B200 M3 / E5-2665 / 128GB

 

To get that label, I'll need to collect the blade model name, processor name, and memory footprint. I'll use the same framework I used for setting the label equal to the serial number:

 

foreach($blade in Get-UcsBlade) {

    $model = ($blade | Get-UcsCapability).Name -replace "Cisco UCS ", ""

    $long = $blade | Get-UcsComputeBoard | Get-UcsProcessorUnit -Id 1 | select -ExpandProperty Model

    $cpu = $long | Get-FriendlyProcName

    $mem = $blade.TotalMemory / 1KB

    $custom_label = "$model / $cpu / $mem"

   $blade | Set-UcsBlade -UsrLbl $custom_label -Force

}

 

If you run that code, you will likely get an error because PowerShell doesn't recognize the function "Get-FriendlyProcName". You can read my last blog about generating friendly names for processors and just use the function I've created; or you can grab the one snippet from that function that you actually need and use this code instead:

 

foreach($blade in Get-UcsBlade) {

    $model = ($blade | Get-UcsCapability).Name -replace "Cisco UCS ", ""

    $long = $blade | Get-UcsComputeBoard | Get-UcsProcessorUnit -Id 1 | select -ExpandProperty Model

    if($long -match 'Intel.*?([EXL\-57]+\s*\d{4}L*\b(\sv2)?)')

    {

        $cpu = $Matches[1] -replace '- ', "-"

    }

    else

    {

        $cpu = "unknown"

    }

    $mem = $blade.TotalMemory / 1KB

    $custom_label = "$model / $cpu / $mem"

    $blade | Set-UcsBlade -UsrLbl $custom_label -Force

}

 

That code will combine the model name, CPU name, and memory footprint of each blade to create a very useful user label as shown below.

full_label.png

 

Taking it further

 

Just a few lines of code can provide a very useful user label. What else can you display? How about the model of the mezz card installed? Firmware version(s)? Number and size of disks? MAC addresses? All of these are possible. Taking it a step further, I might only want to display a user label for blades that are available for me to use. If you want to label only blades that are not already in use, take a look at the Association property of each blade.

 

Did you know you can apply a user label to a chassis? You could display number of uplinks, number of power supplies -- or even something as drab as the serial number of the chassis.

 

User labels can be utilized to display information useful to your administrators, and I've just shown you that it is easy to do. Enjoy!

Outcomes