Infrastructure Adventures


Using vSphere PowerCLI and UCS PowerTool to map out a server environment

Filed under: Compute, Virtualization — Tags: , , , , , , — Joe Keegan @ 6:09 PM

I recently started working in a large vSphere environment that heavily leverages Cisco UCS. This environment had many vSphere Data Centers, Clusters and hosts and it was a daunting task to try and understand how all of that mapped to the physical UCS environment. This seemed like something that could be easily done using VMware’s and Cisco’s PowerShell add-ons and I was quickly able to whip up something pretty quickly.

The key was finding something that I could use to relate VMHost objects with UcsServiceProfile objects. UUID looked like the most obvious and worked like a charm. Here is the script, I hope someone out there finds this helpful.

## DC_Inventory.ps1 by Joe Keegan
## Generates CSV output of VMHost and UCS Service profile information for the purposes of
## relating the virtual environment with the physical environment
## This script must be run from a PowerCLI session that is already connected to your
## VC Servers and UCS Managers

# Generate a list of VMware Data Centers configured in your VCs
$DC_List = Get-Datacenter

# Generates the header line for the data
Write-Host "DataCenter,Cluster,VMHost Name,VMHost Model,ESXi Version,Host Profile,UCS System Name,UCS Service Profile,UCS Server Location"

# Iterates through each of the DCs.
foreach ($DC in $DC_List) {
$DC_Name = $DC.Name

# Gets a lists of clusters included in the DC and iterates through them
$Cluster_List = $DC | get-cluster
foreach ($Cluster in $Cluster_List) {
$Cluster_Name = $Cluster.Name

# Gets a list of Hosts in each clusters and iterates through them
$VMHost_List = $Cluster | get-vmhost
foreach ($VMHost in $VMHost_List) {

# Get Information such as Hostname (As configured in VMware), Model, Version of ESX, Applied Host Profile and UUID
$VMHost_Name = $VMHost.Name
$VMHost_Model = $VMHost.ExtensionData.hardware.SystemInfo.Model
$VMHost_ESXVersion = $VMHost.ExtensionData.Config.Product.FullName
$VMHost_HostProfile = ($VMHost | Get-VMHostProfile).name

# UUID is the attribute used to tie the VMware server object with UCS Service Profile
$VMHost_UUID = $VMHost.ExtensionData.hardware.SystemInfo.Uuid

# Gets the UCS Service Profile object based on the UUID collected from vSphere above
$UCSServer = Get-UcsServiceProfile -Uuid $VMHost_UUID
# Get information on the Service Profile, such as the name of the UCS Manager, Service profile and Location within the UCS
$UCSServer_UCSName = $UCSServer.Ucs
$UCSServer_Pofile = $UCSServer.Name
$UCSServer_Location = $UCSServer.PnDn

# Writes the output in CSV format
Write-Host $DC_Name","$Cluster_Name","$VMHost_Name","$VMHost_Model","$VMHost_ESXVersion","$VMHost_HostProfile","$UCSServer_UCSName","$UCSServer_Pofile","$UCSServer_Location


Intro to Cisco UCS PowerTool

Filed under: Compute — Tags: , , , — Joe Keegan @ 1:25 PM

Intro and Where to Get It

I’ve been playing around with VMware’s vSphere PoweCLI (based of MS PowerShell) for a little while now. I’m not crazy about it being available just on Windows, but I am starting to like PowerShell and I like the fact that other manufacturers are releasing PowerShell module and snap-ins for their products.  The idea of using a single scripting language to interface with all the infrastructure in the data center is a really an awesome concept. So I decided to check out Cisco’s UCS PowerTool.

The first thing to mention is that the PowerTool is very much in beta and I am using the most recent version, I haven’t done a whole lot with the PowerTool, so I haven’t had a chance to come across too many bugs. The biggest bug I have encounter is that the cmdlets seem to ignore the -Confirm:$false flag, so many of the useful commands require you to confirm them. This really prevents the cmdlets from being used in a script and greatly diminishes their use. (Disclaimer: It’s possible there are other ways to prevent cmdlets from asking for confirmation, but I’m still somewhat of a PowerShell newb, and it’s the only way I know how.)

Also it’s a little confusing on where to download it from. If you search for “Cisco UCS PowerTool” the first link brings you to a page about the Toolkit with the URL — This seems like a good place to get it, but you can not download PowerTool from this page, instead you get it from here – – Down at the bottom of the page.

The documentation for the PowerTool is a bit lacking (Hey it’s beta) and the text file available on the same download page is the extent of what is available. The text file mostly includes examples, but for the most part the cmdlets are named pretty well, so it’s pretty easy to find what you are looking for. The get-help for each of the cmdlets contain the bare bones info you need to get by and sometimes there is a bit of trial and error to figure out exactly how something works.

Examples and One-Liners

Here are some examples of using the PowerTool, along with any notes some of this is from the text file.

Connect to UCSM

Connect-Ucs <ip or hostname>

Show Blades in a table sorted by Chassis/Blade showing Availability, Power State and Assigned Service profile

Get-Ucsblade | sort-object dn | ft -Property Dn, Availability, OperPower, AssignedToDn

Show Service Profiles in table sorted by name showing the name, if it’s associated and to what blade

Get-UcsServiceProfile | sort-object name | where-object {$_.Type -eq "instance"} | ft -property Name, AssocState, PnDn

You can replace instance with initial-template or updating-template to show those type of templates instead.

Create a New Service Profile from Template

Add-UcsServiceProfile -Name ServiceProfileName -SrcTemplName ServiceProfileTemplateName

Associate a Service Profile to a blade

Connect-UcsServiceProfile -ServiceProfile ServiceProfileName -Blade ServerID

ServerID looks to be Chassis/Slot

Disassociate a Service Profile from a blade

Disconnect-UcsServiceProfile -ServiceProfile ServiceProfileName

Delete Service Profile

Remove-UcsServiceProfile -ServiceProfile ServiceProfileName

Identifying a Blade

There seems to be (at least?) three different properties that identify the location of a blade: ServerID, DN & RN.

Get-UcsBlade | fl -Property ServerId,Dn,Rn

ServerId : 1/1
Dn       : sys/chassis-1/blade-1
Rn       : blade-1

It looks like ServerID and Dn seem to be the most common properties used to select objects. Some command you can specify -Dn or -ServerID, but others use -Blade (such as Connect-UCSServiceProfile).  It would be ideal if all cmdlets used the same properties to select a blade, but for now you may need to be mindful of which switch to us for each cmdlet.

I hope to start using vSphere PowerCLI and Cisco UCS PowerTool together. I’ll be work on putting together a future post that will hopefully show off some useful things you can do with the two together.




Scaling VMware deployments with Cisco UCS and VMware Auto Deploy

Filed under: Compute, Virtualization — Tags: , , , — Joe Keegan @ 6:25 PM

There has been some well deserved buzz about VMware Auto Deploy and I think Auto Deploy will be a key feature for building VMware based clouds. Auto Deploy particularity shines on UCS and I have some cool ideas on how to use the two products together. But I wanted to start with a quick post on using Auto Deploy with UCS.

This is not a primer on Auto Deploy and I’m going to expect that you know how Auto Deploy works, at least at a high level. Instead I plan to cover some specific topics pertinent to Auto Deploy on UCS.

If you need to come up to speed (or need a refresher) on Auto Deploy I would suggest checking out:

oemstring Pattern Matching

UCS information is made available to Auto Deploy via the oemstring attributes.

If you have watched a system’s console while it is being provisioned using Auto Deploy then you will recognize the above screen shot. Here you can see there are several oemstrings that we can use to match the right Auto Deploy rule.

I’ve looked around and I have not found any documentation on the oemstrings provided by UCS, but from the above I can deduce that they are the following.

$SPI – “Service Profile Instance” i.e. The name of the service profile assigned that that specific blade (or rack server I presume).

$SPT – “Service Profile Template” i.e. The name of the template used to create that specific service profile.

$SYS – “System” i.e. The name of the physical blade associated with the service profile.

This information allows for the creation of complex Auto Deploy rules without the hassle of dealing with MAC/IP addresses, Serial Numbers, etc.

Say for example that I have a Production and a Dev cluster and I wanted to be able to add systems to either cluster by just provisioning a UCS blade from a service profile template.

Using the UCS specific oemstring attributes makes adding Auto Deploy rules for this scenario pretty simple.

New-DeployRule -Name "Prod-AutoDeploy" -Item "ESXi-5.0","HostProfile-ESX-Prod","Prod-Cluster" -Pattern 'oemstring=$SPT:ESX-Prod-Template'
New-DeployRule -Name "Dev-AutoDeploy" -Item "ESXi-5.0","HostProfile-ESX-Dev","Dev-Cluster" -Pattern 'oemstring=$SPT:ESX-Dev-Template'
Add-DeployRule Prod-AutoDeploy
Add-DeployRule Dev-AutoDeploy

The above deploy rules match for the name of the service profile templates using the oemstring=$SPT attribute. Note that single quotes are used around the pattern match so that PowerShell ignores the $ included in the string.

The above oemstring attributes are only available if the server is running with UCS 2.0 firmware. Also make sure that you are using the latest firmware as there is a bug in the earlier firmware that causes an issues with gPXE and DHCP (at least if you are running a windows DHCP server).

Auto Deploy and VM-FEX

If you plan to use Auto Deploy and VM-FEX then you will need to includ the VEM Software package as part of the ESXi boot image. This is done in a similar way to adding the FDM for HA to the boot image.

First you will need to add the software depot with the package. For VM-FEX you’ll just add the URL for you UCSM instance.


Then you add the cisco-vem-v132-esx software package to your image. In the example below I have an existing image profile called ESXi-5.0-FEX which I add the image to.

Add-EsxSoftwarePackage -ImageProfile "ESXi-5.0-FEX" -SoftwarePackage cisco-vem-v132-esx

Then just create a deploy rule using the image profile that includes the VIM software package. In the example below the rule only match servers that have been provisioned using the Service Profile Template ESX-AD-VMFEX. This service profile template has the configuration required to support VM-FEX. See Deploying Cisco UCS VM-FEX for vSphere for more info.

New-DeployRule -name "ESX-VMFEX" -item "ESXi-5.0-FEX","HP-VM-FEX","Cluster-VM-FEX" -Pattern 'oemstring=$SPT:ESX-AD-VMFEX'
Add-DeployRule ESX-VMFEX
Older Posts »

The Silver is the New Black Theme. Blog at


Get every new post delivered to your Inbox.

Join 38 other followers

%d bloggers like this: