Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add vcf+ subscription cores #87

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 75 additions & 3 deletions VMware.CloudFoundation.Reporting.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -8485,6 +8485,14 @@ Function Request-EsxiOverview {
Request-EsxiOverview -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1!
This example will return an overview of the ESXi hosts managed by the SDDC Manager instance.

.EXAMPLE
Request-EsxiOverview -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -subscription
This example will return an overview of the ESXi hosts managed by the SDDC Manager instance with the number of cores for VCF+ subscription.

.EXAMPLE
Request-EsxiOverview -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -subscription -outputCsv F:\Reporting
This example will return an overview of the ESXi hosts managed by the SDDC Manager instance with the number of cores for VCF+ subscription and save as a CSV file to F:\Reporting.

.EXAMPLE
Request-EsxiOverview -server sfo-vcf01.sfo.rainpole.io -user admin@local -pass VMw@re1!VMw@re1! -anonymized
This example will return an overview of the ESXi hosts managed by the SDDC Manager instance, but will anonymize the output.
Expand All @@ -8494,7 +8502,9 @@ Function Request-EsxiOverview {
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$server,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$user,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$pass,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$anonymized
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$anonymized,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$subscription,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$outputCsv
)

Try {
Expand All @@ -8507,6 +8517,16 @@ Function Request-EsxiOverview {
$allAssignedEsxiHosts = (Get-VCFHost | Where-Object {$_.domain.id -eq $domain.id})
foreach ($assignedEsxiHost in $allAssignedEsxiHosts) {
$customObject = New-Object -TypeName psobject

$sockets = $assignedEsxiHost.cpu.cpuCores.Count
$coresPerSocket = $assignedEsxiHost.cpu.Cores / $sockets

if ($coresPerSocket -le 16) {
$vcfPlusLicenseCount = $sockets * 16
} else {
$vcfPlusLicenseCount = $sockets * $coresPerSocket
}

if ($PsBoundParameters.ContainsKey('anonymized')) {
$customObject | Add-Member -notepropertyname "Domain UUID" -notepropertyvalue $domain.id
$customObject | Add-Member -notepropertyname "Cluster UUID" -notepropertyvalue $cluster.id
Expand All @@ -8518,6 +8538,9 @@ Function Request-EsxiOverview {
$customObject | Add-Member -notepropertyname "CPU Cores" -notepropertyvalue $assignedEsxiHost.cpu.Cores
$customObject | Add-Member -notepropertyname "CPU Cores per Socket" -notepropertyvalue ($assignedEsxiHost.cpu.Cores / $assignedEsxiHost.cpu.cpuCores.Count)
$customObject | Add-Member -notepropertyname "Memory (GB)" -notepropertyvalue ([Math]::round(($assignedEsxiHost.memory.totalCapacityMB) / 1024))
if ($PsBoundParameters.ContainsKey('subscription')) {
$customObject | Add-Member -notepropertyname "VCF+ Subscription Core Count" -notepropertyvalue $vcfPlusLicenseCount
}
$customObject | Add-Member -notepropertyname "Status" -notepropertyvalue $assignedEsxiHost.status
} else {
$customObject | Add-Member -notepropertyname "Domain Name" -notepropertyvalue $domain.name
Expand All @@ -8530,16 +8553,28 @@ Function Request-EsxiOverview {
$customObject | Add-Member -notepropertyname "CPU Cores" -notepropertyvalue $assignedEsxiHost.cpu.Cores
$customObject | Add-Member -notepropertyname "CPU Cores per Socket" -notepropertyvalue ($assignedEsxiHost.cpu.Cores / $assignedEsxiHost.cpu.cpuCores.Count)
$customObject | Add-Member -notepropertyname "Memory (GB)" -notepropertyvalue ([Math]::round(($assignedEsxiHost.memory.totalCapacityMB) / 1024))
if ($PsBoundParameters.ContainsKey('subscription')) {
$customObject | Add-Member -notepropertyname "VCF+ Subscription Core Count" -notepropertyvalue $vcfPlusLicenseCount
}
$customObject | Add-Member -notepropertyname "Status" -notepropertyvalue $assignedEsxiHost.status
}
$allEsxiHostObject += $customObject

}
}
}
$allUnassignedEsxiHosts = (Get-VCFHost | Where-Object {$_.status -eq "UNASSIGNED_USEABLE"})
foreach ($unassignedEsxiHost in $allUnassignedEsxiHosts) {
$customObject = New-Object -TypeName psobject

$sockets = $unassignedEsxiHost.cpu.cpuCores.Count
$coresPerSocket = $unassignedEsxiHost.cpu.Cores / $sockets

if ($coresPerSocket -le 16) {
$vcfPlusLicenseCount = $sockets * 16
} else {
$vcfPlusLicenseCount = $sockets * $coresPerSocket
}

if ($PsBoundParameters.ContainsKey('anonymized')) {
$customObject | Add-Member -NotePropertyName 'Domain UUID' -NotePropertyValue ""
$customObject | Add-Member -notepropertyname "Cluster UUID" -notepropertyvalue ""
Expand All @@ -8551,6 +8586,9 @@ Function Request-EsxiOverview {
$customObject | Add-Member -notepropertyname "CPU Cores" -notepropertyvalue $assignedEsxiHost.cpu.Cores
$customObject | Add-Member -notepropertyname "CPU Cores per Socket" -notepropertyvalue ($assignedEsxiHost.cpu.Cores / $assignedEsxiHost.cpu.cpuCores.Count)
$customObject | Add-Member -notepropertyname "Memory (GB)" -notepropertyvalue ([Math]::round(($unassignedEsxiHost.memory.totalCapacityMB) / 1024))
if ($PsBoundParameters.ContainsKey('subscription')) {
$customObject | Add-Member -notepropertyname "VCF+ Subscription Core Count" -notepropertyvalue $vcfPlusLicenseCount
}
$customObject | Add-Member -notepropertyname "Status" -notepropertyvalue $unassignedEsxiHost.status
} else {
$customObject | Add-Member -notepropertyname "Domain Name" -notepropertyvalue ""
Expand All @@ -8563,11 +8601,22 @@ Function Request-EsxiOverview {
$customObject | Add-Member -notepropertyname "CPU Cores" -notepropertyvalue $assignedEsxiHost.cpu.Cores
$customObject | Add-Member -notepropertyname "CPU Cores per Socket" -notepropertyvalue ($assignedEsxiHost.cpu.Cores / $assignedEsxiHost.cpu.cpuCores.Count)
$customObject | Add-Member -notepropertyname "Memory (GB)" -notepropertyvalue ([Math]::round(($unassignedEsxiHost.memory.totalCapacityMB) / 1024))
if ($PsBoundParameters.ContainsKey('subscription')) {
$customObject | Add-Member -notepropertyname "VCF+ Subscription Core Count" -notepropertyvalue $vcfPlusLicenseCount
}
$customObject | Add-Member -notepropertyname "Status" -notepropertyvalue $unassignedEsxiHost.status
}
$allEsxiHostObject += $customObject
}
$allEsxiHostObject | Sort-Object -Property Status, 'Domain Name', 'Domain UUID', 'Cluster Name', 'Cluster UUID', 'ESXi Host FQDN', 'ESXi Host UUID'

if ($PsBoundParameters.ContainsKey('outputCsv')) {
$csv = Start-CreateOutputCsvDirectory -csvFolder $outputCsv -csvFileSuffix $server
$allEsxiHostObject | ConvertTo-Csv -NoTypeInformation | Out-File $csv
Write-Output "CSV file saved to $csv"
} else {
$allEsxiHostObject | Sort-Object -Property Status, 'Domain Name', 'Domain UUID', 'Cluster Name', 'Cluster UUID', 'ESXi Host FQDN', 'ESXi Host UUID'
}

}
}
}
Expand Down Expand Up @@ -9023,6 +9072,29 @@ Function Start-CreateOutputJsonDirectory {
$jsonDestination
}

Function Start-CreateOutputCsvDirectory {
Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$csvFolder,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$csvFileSuffix
)

$filetimeStamp = Get-Date -Format "MM-dd-yyyy_hh_mm_ss"
$Global:csvFolder = $csvFolder
$csvName = $filetimeStamp + "-" + $csvFileSuffix + ".csv"

if ($PSEdition -eq "Core" -and ($PSVersionTable.OS).Split(' ')[0] -eq "Linux") {
$csvDestination = ($csvDestination = ($csvFolder + "\" + $csvName)).split('\') -join '/' | Split-Path -NoQualifier
$csvFolder = ($csvFolder).split('\') -join '/' | Split-Path -NoQualifier
} else {
$csvDestination = ($csvFolder + "\" + $csvName)
}

if (!(Test-Path -Path $csvFolder)) {
New-Item -Path $csvFolder -ItemType "directory" | Out-Null
}

$csvDestination
}

Function Invoke-SddcCommand {
<#
Expand Down