Quick SimpliVity OmniStack Capacity Script
This is a quick script, SVT-Fed-Capactiy.ps1, I put together using Powershell and the SimpliVity REST API to report available, free, and used capacity information for OmniStack Clusters in a SimpliVity Federation, and the OmniStack hosts in each Cluster.
Get the script here: https://github.com/herseyc/SVT/blob/master/SVT-Fed-Capacity.ps1
Just set a couple of simple configuration variables:
- Line 12-14 – set the OVC mgmt IP (
$ovc
), username to use ($username
), and password ($pass
) - Line 22 – Here you can set what you want to convert the capacity information to, the REST API returns capacity information in Bytes. Just change the variable to one of the ones above the line. This is set to TiB in the script.
- Line 23 – Set the number of decimal places to round the capacity conversion to. It is set to 2 in the script.
The script will output the total capacity of each SimpliVity OmniStack Cluster and the physical capacity of each host in the OmniStack Cluster. It looks a little something like this:
Happy Friday! Enjoy.
Hi Hersey,
I’m interesting to use this host capacity check script. But When I apply to the simplivity 3.7.0 on DL380Gen9. I can’t pass the authen step. I think I key in wrong username. Can you help to look my output.
This is the .ps1 header.
############## Set Variables ##############
$ovc = “172.30.1.24” #OVC Mgmt IP
$username = “administrator@vsphere.local” #vCenter Username
$pass = “P@ssw0rd” #vCenter Password
This is the power shell output.
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At C:\Users\sunya\Documents\SVT-FED-Capa.ps1:56 char:13
+ $response = Invoke-RestMethod -Uri $uri -Headers $headers -Body $body -Method Po …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Unable to Authenticate
PS C:\Users\sunya\Documents>
Regards,
Sunya
Sunya,
Thanks for stopping by.
You will need to update the $username and $pass variables to be the Username (and password) of a vCenter user in your environment. The IP address will be of an OVC, not the vCenter Server.
Hersey
Hi Hershey,
Thank you .. I correct my IP Address setting. and now your script is working well.
Thankyou
Sunya
Hi there Hersey 🙂
This script has proven useful to us internally on many occasions so thought i’d give something back… if you replace the ‘Set Variables’ section with the below, it will prompt for password as secure string without having to enter it into the script:
############## Set Variables ##############
$ovc = “x.x.x.x” #OVC Mgmt IP
$username = Read-host “Please enter the Username to connect to vCenter” #vCenter Username
$VCPass = Read-Host “Please enter the Password for the Username given Above” -AsSecureString #vCenter Password
$bstr1 = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($VCPass)
$pass = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr1)
I need to send this entire report with email . How can I do that please
Does it work on OVC 4.1 version ? I am getting errors when I execute this script. Token is always empty
$uri = “https://” + $ovc + “/api/oauth/token”
$base64 = [Convert]::ToBase64String([System.Text.UTF8Encoding]::UTF8.GetBytes(“simplivity:”))
$body = @{username=”$username”;password=”$pass”;grant_type=”password”}
$headers = @{}
$headers.Add(“Authorization”, “Basic ‘$base64′”)
$response = Invoke-RestMethod -Uri $uri -Headers $headers -Body $body -Method Post
$atoken = $response.access_token