Skip to content

Commit

Permalink
fix: address path related issues (#182)
Browse files Browse the repository at this point in the history
- Fixed issue #181.
- Updated `CHANGELOG.md` for v2.4.2 release.
- Updated module version to 2.4.2.1000.

Signed-off-by: bhumitra nagar <bnagar@vmware.com>
Signed-off-by: Ryan Johnson <johnsonryan@vmware.com>
Co-authored-by: Ryan Johnson <johnsonryan@vmware.com>
  • Loading branch information
bhumitra and Ryan Johnson authored Oct 18, 2023
1 parent 0969790 commit 86d5288
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 35 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release History

## v2.4.2

> Release Date: 2023-10-18
Bugfix:

- Updated `Start-Create*` and `Invoke-*` functions to address file path generation issues in Linux. [GH-182](https://github.com/vmware/powershell-module-for-vmware-cloud-foundation-reporting/pull/182)

## v2.4.1

> Release Date: 2023-09-25
Expand Down
4 changes: 2 additions & 2 deletions VMware.CloudFoundation.Reporting.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: VMware, Inc.
#
# Generated on: 2023-09-25
# Generated on: 2023-10-18
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = '.\VMware.CloudFoundation.Reporting.psm1'

# Version number of this module.
ModuleVersion = '2.4.1.1000'
ModuleVersion = '2.4.2.1000'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
50 changes: 17 additions & 33 deletions VMware.CloudFoundation.Reporting.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Function Invoke-VcfHealthReport {

if (Test-VCFConnection -server $sddcManagerFqdn) {
if (Test-VCFAuthentication -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass) {
$defaultReport = Start-CreateReportDirectory -path $reportPath -sddcManagerFqdn $sddcManagerFqdn -reportType health # Setup Report Location and Report File
$defaultReport = Start-CreateReportDirectory -path $reportPath -reportType health # Setup Report Location and Report File
if (!(Test-Path -Path $reportPath)) {Write-Warning "Unable to locate report path $reportPath, enter a valid path and try again"; Write-Host ""; Break }
if ($PsBoundParameters.ContainsKey("allDomains")) {
$reportname = $defaultReport.Split('.')[0] + "-" + $sddcManagerFqdn.Split(".")[0] + ".htm"
Expand Down Expand Up @@ -466,7 +466,7 @@ Function Invoke-VcfAlertReport {

if (Test-VCFConnection -server $sddcManagerFqdn) {
if (Test-VCFAuthentication -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass) {
$defaultReport = Start-CreateReportDirectory -path $reportPath -sddcManagerFqdn $sddcManagerFqdn -reportType alert # Setup Report Location and Report File
$defaultReport = Start-CreateReportDirectory -path $reportPath -reportType alert # Setup Report Location and Report File
if (!(Test-Path -Path $reportPath)) {Write-Warning "Unable to locate report path $reportPath, enter a valid path and try again"; Write-Host ""; Break }
if ($PsBoundParameters.ContainsKey("allDomains")) {
$reportname = $defaultReport.Split('.')[0] + "-" + $sddcManagerFqdn.Split(".")[0] + ".htm"
Expand Down Expand Up @@ -588,7 +588,7 @@ Function Invoke-VcfConfigReport {

if (Test-VCFConnection -server $sddcManagerFqdn) {
if (Test-VCFAuthentication -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass) {
$defaultReport = Start-CreateReportDirectory -path $reportPath -sddcManagerFqdn $sddcManagerFqdn -reportType config # Setup Report Location and Report File
$defaultReport = Start-CreateReportDirectory -path $reportPath -reportType config # Setup Report Location and Report File
if (!(Test-Path -Path $reportPath)) {Write-Warning "Unable to locate report path $reportPath, enter a valid path and try again"; Write-Host ""; Break }
if ($PsBoundParameters.ContainsKey("allDomains")) {
$reportname = $defaultReport.Split('.')[0] + "-" + $sddcManagerFqdn.Split(".")[0] + ".htm"
Expand Down Expand Up @@ -704,7 +704,7 @@ Function Invoke-VcfUpgradePrecheck {

if (Test-VCFConnection -server $sddcManagerFqdn) {
if (Test-VCFAuthentication -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass) {
$defaultReport = Start-CreateReportDirectory -path $reportPath -sddcManagerFqdn $sddcManagerFqdn -reportType upgrade # Setup Report Location and Report File
$defaultReport = Start-CreateReportDirectory -path $reportPath -reportType upgrade # Setup Report Location and Report File
if (!(Test-Path -Path $reportPath)) {Write-Warning "Unable to locate report path $reportPath, enter a valid path and try again"; Write-Host ""; Break }
$reportname = $defaultReport.Split('.')[0] + "-" + $workloadDomain + ".htm"
$workflowMessage = "Workload Domain ($workloadDomain)"
Expand Down Expand Up @@ -853,7 +853,7 @@ Function Invoke-VcfOverviewReport {

if (Test-VCFConnection -server $sddcManagerFqdn) {
if (Test-VCFAuthentication -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass) {
$defaultReport = Start-CreateReportDirectory -path $reportPath -sddcManagerFqdn $sddcManagerFqdn -reportType overview # Setup Report Location and Report File
$defaultReport = Start-CreateReportDirectory -path $reportPath -reportType overview # Setup Report Location and Report File
if (!(Test-Path -Path $reportPath)) {Write-Warning "Unable to locate report path $reportPath, enter a valid path and try again"; Write-Host ""; Break }
$reportname = $defaultReport.Split('.')[0] + "-" + $sddcManagerFqdn.Split(".")[0] + ".htm"
$workflowMessage = "VMware Cloud Foundation instance ($sddcManagerFqdn)"
Expand Down Expand Up @@ -1010,11 +1010,7 @@ Function Request-SoSHealthJson {
}

# Set the report destination.
if ($PSEdition -eq "Core" -and ($PSVersionTable.OS).Split(' ')[0] -eq "Linux") {
$reportDestination = Join-Path -Path $reportPath -ChildPath $reportName | Split-Path -NoQualifier -Parent
} else {
$reportDestination = Join-Path -Path $reportPath -ChildPath $reportName
}
$reportDestination = Join-Path -Path $reportPath -ChildPath $reportName

if (Test-VCFConnection -server $server) {
# Create a temporary directory under reportDirectory.
Expand Down Expand Up @@ -9364,23 +9360,22 @@ Export-ModuleMember -Function Show-ReportingOutput
Function Start-CreateReportDirectory {
Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$path,
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$sddcManagerFqdn,
[Parameter (Mandatory = $true)] [ValidateSet("health","alert","config","upgrade","overview")] [String]$reportType
)

$filetimeStamp = Get-Date -Format "MM-dd-yyyy_hh_mm_ss"
if ($reportType -eq "health") { $Global:reportFolder = $path + '\HealthReports\' }
if ($reportType -eq "alert") { $Global:reportFolder = $path + '\AlertReports\' }
if ($reportType -eq "config") { $Global:reportFolder = $path + '\ConfigReports\' }
if ($reportType -eq "upgrade") { $Global:reportFolder = $path + '\UpgradeReports\' }
if ($reportType -eq "overview") { $Global:reportFolder = $path + '\OverviewReports\' }
if ($PSEdition -eq "Core" -and ($PSVersionTable.OS).Split(' ')[0] -eq "Linux") {
$reportFolder = ($reportFolder).split('\') -join '/' | Split-Path -NoQualifier
}
if ($reportType -eq "health") { $Global:reportFolder = Join-Path -Path $path -ChildPath 'HealthReports' }
if ($reportType -eq "alert") { $Global:reportFolder = Join-Path -Path $path -ChildPath 'AlertReports' }
if ($reportType -eq "config") { $Global:reportFolder = Join-Path -Path $path -ChildPath 'ConfigReports' }
if ($reportType -eq "upgrade") { $Global:reportFolder = Join-Path -Path $path -ChildPath 'UpgradeReports' }
if ($reportType -eq "overview") { $Global:reportFolder = Join-Path -Path $path -ChildPath 'OverviewReports' }


if (!(Test-Path -Path $reportFolder)) {
New-Item -Path $reportFolder -ItemType "directory" | Out-Null
}
$reportName = $reportFolder + $filetimeStamp + "-" + $reportType + ".htm"
$filename = $filetimeStamp + "-" + $reportType + ".htm"
$reportName = Join-Path -Path $reportFolder -ChildPath $fileName
$reportName
}
Export-ModuleMember -Function Start-CreateReportDirectory
Expand All @@ -9394,13 +9389,7 @@ Function Start-CreateOutputJsonDirectory {
$filetimeStamp = Get-Date -Format "MM-dd-yyyy_hh_mm_ss"
$Global:jsonFolder = $jsonFolder
$jsonName = $filetimeStamp + "-" + $jsonFileSuffix

if ($PSEdition -eq "Core" -and ($PSVersionTable.OS).Split(' ')[0] -eq "Linux") {
$jsonDestination = Join-Path -Path $jsonFolder -ChildPath $jsonName | Split-Path -NoQualifier -Parent
$jsonFolder = $jsonFolder | Split-Path -NoQualifier -Parent
} else {
$jsonDestination = Join-Path -Path $jsonFolder -ChildPath $jsonName
}
$jsonDestination = Join-Path -Path $jsonFolder -ChildPath $jsonName

if (!(Test-Path -Path $jsonFolder)) {
New-Item -Path $jsonFolder -ItemType "directory" | Out-Null
Expand All @@ -9419,12 +9408,7 @@ Function Start-CreateOutputCsvDirectory {
$Global:csvFolder = $csvFolder
$csvName = $filetimeStamp + "-" + $csvFileSuffix + ".csv"

if ($PSEdition -eq "Core" -and ($PSVersionTable.OS).Split(' ')[0] -eq "Linux") {
$csvDestination = Join-Path -Path $csvFolder -ChildPath $csvName | Split-Path -NoQualifier -Parent
$csvFolder = $csvFolder | Split-Path -NoQualifier -Parent
} else {
$csvDestination = Join-Path -Path $csvFolder -ChildPath $csvName
}
$csvDestination = Join-Path -Path $csvFolder -ChildPath $csvName

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

0 comments on commit 86d5288

Please sign in to comment.