Skip to content

Pull Request (Reposted) : Add Support for Offline Catalog Files in OSD Software (Feature/support offline catalog) #284

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
18 changes: 11 additions & 7 deletions Public/Functions/Other/Save-WebFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,17 @@ function Save-WebFile {
else {
Write-Verbose "cURL Source: $SourceUrl"
Write-Verbose "Destination: $DestinationFullName"

if ($host.name -match 'ConsoleHost') {
Invoke-Expression "& curl.exe --insecure --location --output `"$DestinationFullName`" --url `"$SourceUrl`""
}
else {
#PowerShell ISE will display a NativeCommandError, so progress will not be displayed
$Quiet = Invoke-Expression "& curl.exe --insecure --location --output `"$DestinationFullName`" --url `"$SourceUrl`" 2>&1"
$Headers = Invoke-Expression "& curl.exe --head --silent --insecure --location --url `"$SourceUrl`""
if ($Headers[0] -match "200.+OK") {
if ($host.name -match 'ConsoleHost') {
Invoke-Expression "& curl.exe --insecure --location --output `"$DestinationFullName`" --url `"$SourceUrl`""
}
else {
#PowerShell ISE will display a NativeCommandError, so progress will not be displayed
$Quiet = Invoke-Expression "& curl.exe --insecure --location --output `"$DestinationFullName`" --url `"$SourceUrl`" 2>&1"
}
} else {
Write-Warning "Header status: $($headers[0])"
}
}
#=================================================
Expand Down
12 changes: 11 additions & 1 deletion Public/OSDCloudDriverPack/OSDCloud.DriverPack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,17 @@ function Get-OSDCloudDriverPacks {
#>
[CmdletBinding()]
param ()
$Results = Import-Clixml -Path "$(Get-OSDModulePath)\cache\driverpack-catalogs\build-driverpacks.xml"
$DriverCatalogXML = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object {
Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "build-driverpacks.xml" -File -Force -Recurse -ErrorAction Ignore
}
if ($DriverCatalogXML) {
foreach ($Item in $DriverCatalogXML) {
Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)."
$Results = Import-Clixml -Path $Item.FullName
}
} else {
$Results = Import-Clixml -Path "$(Get-OSDModulePath)\cache\driverpack-catalogs\build-driverpacks.xml"
}
$Results
}
function Save-OSDCloudDriverPack {
Expand Down
16 changes: 11 additions & 5 deletions Public/OSDCloudTS/Get-OSDCloudOperatingSystems.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ function Get-OSDCloudOperatingSystems {
[System.String]
$OSArch = 'x64'
)
$FullResults = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystems.json" | ConvertFrom-Json
if ($OSArch -eq 'x64'){
$Results = $FullResults | Where-Object {$_.Architecture -eq "x64"}
$OfflineCatalog = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object {
Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "CloudOperatingSystems.json" -File -Force -Recurse -ErrorAction Ignore
}
elseif ($OSArch -eq "arm64"){
$Results = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystemsARM64.json" | ConvertFrom-Json
if ($OfflineCatalog) {
foreach ($Item in $OfflineCatalog) {
Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)."
$FullResults = Get-Content -Path "$($Item.FullName)" | ConvertFrom-Json -ErrorAction "Stop"
}
$Results = $FullResults | Where-Object {$_.Architecture -eq $OSArch}
} else {
$FullResults = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystems.json" | ConvertFrom-Json
$Results = $FullResults | Where-Object {$_.Architecture -eq $OSArch}
}
$Results
}
16 changes: 13 additions & 3 deletions Public/OSDCloudTS/Get-OSDCloudOperatingSystemsIndexMap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ function Get-OSDCloudOperatingSystemsIndexMap {
$OSArch = 'x64'
)

$indexMapPath = "$(Get-OSDModulePath)\cache\archive-cloudoperatingindexmap\CloudOperatingIndexMap.json"
$Results = Get-Content -Path $indexMapPath | ConvertFrom-Json
$OfflineCatalog = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object {
Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "CloudOperatingIndexMap.json" -File -Force -Recurse -ErrorAction Ignore
}
if ($OfflineCatalog) {
foreach ($Item in $OfflineCatalog) {
Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)."
$indexMapPath = (Get-Item -Path "$($Item.FullName)").FullName
}
} else {
$indexMapPath = "$(Get-OSDCachePath)\archive-cloudoperatingindexmap\CloudOperatingIndexMap.json"
}
$Results = Get-Content -Path $indexMapPath -Encoding UTF8 | ConvertFrom-Json # as of OSD 25.6.10.1 encoding of the json is UTF8
$Results = $Results | Where-Object { $_.Architecture -eq $OSArch }

return $Results
}
}
24 changes: 22 additions & 2 deletions Public/OSDCloudTS/Get-OSDCloudOperatingSystemsIndexes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,30 @@ function Get-OSDCloudOperatingSystemsIndexes {
)

if ($OSArch -eq 'x64') {
$Results = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystemsIndexes.json" | ConvertFrom-Json
$OfflineCatalog = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object {
Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "CloudOperatingSystemsIndexes.json" -File -Force -Recurse -ErrorAction Ignore
}
if ($OfflineCatalog) {
foreach ($Item in $OfflineCatalog) {
Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)."
$Results = Get-Content -Path "$($Item.FullName)" | ConvertFrom-Json -ErrorAction "Stop"
}
} else {
$Results = Get-Content -Path "$(Get-OSDCachePath)\archive-cloudoperatingsystems\CloudOperatingSystemsIndexes.json" | ConvertFrom-Json
}
}
elseif ($OSArch -eq "ARM64") {
$Results = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystemsARM64Indexes.json" | ConvertFrom-Json
$OfflineCatalog = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object {
Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "CloudOperatingSystemsARM64Indexes.json" -File -Force -Recurse -ErrorAction Ignore
}
if ($OfflineCatalog) {
foreach ($Item in $OfflineCatalog) {
Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)."
$Results = Get-Content -Path "$($Item.FullName)" | ConvertFrom-Json -ErrorAction "Stop"
}
} else {
$Results = Get-Content -Path "$(Get-OSDCachePath)\archive-cloudoperatingsystems\CloudOperatingSystemsARM64Indexes.json" | ConvertFrom-Json
}
}

return $Results
Expand Down