Category Archives: Uncategorized

busywork … nothing to see here

Follow my blog with Bloglovin


Script to throttle mass vMotions or svMotions

I wrote the shell of this as new datastores were added to environments and we rearranged VMs, and it got a little better each time until I finally made it a full function when we were going to migrate to new storage arrays in a few separate environments.

It’s purpose is to make sure not too many of my storage vMotions are running at once and impacting other VMs.  It sits in the middle of your script or one-liner pipeline.  It looks at the active tasks and counts how many storage or host vMotions are running.  If more than the throttle limit are running the script sleeps for a bit and checks again.  If less than the limit are running then it exits, passing control to the next action.

You  can configure counting running (s)vMotions at the vCenter or cluster level, the number of (s)vMotions allowed to be running at once, and the sleep interval.

I found the cluster option handy because we have multiple clusters in each vCenter connected to separate storage so the IO load in one cluster doesn’t impact other clusters.  If a host is put into maintenance mode and 20 vMotions are queued in one cluster the storage vMotions in another cluster can keep going.

It’s a bit long to post the code inline so I’m only using the github link.

UCS port license report.

This is simple, but handy.  It’s just some formatting around the PowerTool cmdlet Get-UcsLicense.  Then I either export it to a CSV or leave it on the screen, and I might wrap it in a loop to report on all our UCS FEs.

Below are two snippets.  First, connecting to one UCS and exporting to a CSV file.  And then connecting to several UCSs, filtering on UCSs that are short licenses, and printing to the screen.

Get-UcsLicense | Select-Object Ucs,Scope,Feature,Sku,AbsQuant,DefQuant,UsedQuant,@{n="RemQuant";e={$_.AbsQuant-$_.UsedQuant}},Status,PeerStatus,OperState,GracePeriodUsed | Export-Csv-Path "UCSLicenseReport_$($DefaultUcs | Select-Object -Expand Ucs)_$(Get-Now).csv" -NoTypeInformation

gc UCSs.txt | % {
   Connect-Ucs-Name$_-Credential$ucscred | select ucs,VirtualIpv4Address,username,version | ft-a
   Get-UcsLicense | Select-Object Ucs,Scope,Feature,Sku,AbsQuant,DefQuant,UsedQuant,@{n="RemQuant";e={$_.AbsQuant-$_.UsedQuant}},Status,PeerStatus,OperState,GracePeriodUsed | ? { $_.RemQuant -lt0 } | ft-a

Hope this helps