Automating VCF Upgrade - Download Release Bundles
In order to upgrade VMware Cloud Foundation you must first download the upgrade bundles, I recently wrote a blog Automating the Download of VCF Bundles for a Release on this topic which I shared a script vcfBundleDownload.ps1 which can be downloaded from GitHub which we will utilize as part of the procedure here. The script takes a JSON as input where we define the bundle IDs for download but as part of this post I will share a way to automate that part too.
- Part 1 - Generate the bundle download JSON with Bundle IDs
- Part 2 - Download the bundles
VMware Cloud Foundation APIs Used
- GET /v1/bundles
- POST /v1/bundles
- GET /v1/tasks/{id}
- GET /v1/releases
PowerVCF Cmdlets
- Get-VCFBundle
- Request-VCFBundle
- Get-VCFTask
- Get-VCFRelease
PowerShell Scripts
Generate the Bundle Download JSON with Bundle IDs
Procedure
Start Windows PowerShell.
Replace the values in the sample code with values for the instance of VMware Cloud Foundation and run the commands in the PowerShell console.
1$sddcManagerFqdn = "lax-vcf01.lax.rainpole.io"
2$sddcManagerUser = "[email protected]"
3$sddcManagerPass = "VMw@re1!"
4$vcfRelease = "4.5.1.0"
5$jsonFile = "vcf4510Bundles.json"
- Authenticate to the SDDC Manager appliance by running the following command:
1Request-VCFToken -fqdn $sddcManagerFqdn -username $sddcManagerUser -password $sddcManagerPass
- Obtain details from SDDC Manager about the release by running the following command:
1$releases = Get-VCFRelease | Where-Object {$_.version -eq $vcfRelease}
In this step we use the Get-VCFRelease cmdlet to capture the details relating to the release version. We will use this in the next step work out what components are part of the Bill of Materials (BoM).
- Collect the details relating to the BoM by running the following command:
1$bundles = @()
2foreach ($bom in $releases.bom) {
3 $bundles += Get-VCFBundle | Where-Object {$_.components.description -match "Update" -and $_.components.toVersion -eq $bom.version}
4}
In this procedure we are using the Get-VCFBundle cmdlet to request bundle details based on the release.
- Construct the JSON specification file including the bundle ID and product details by running the following command:
1$bundleList = @()
2foreach ($bundle in $bundles) {
3 $bundleId = New-Object -TypeName psobject
4 $bundleId | Add-Member -notepropertyname 'bundleId' -notepropertyvalue $bundle.id
5 $bundleId | Add-Member -notepropertyname 'product' -notepropertyvalue $bundle.components.type
6 $bundleList += $bundleId
7}
8$json = New-Object -TypeName psobject
9$json | Add-Member -notepropertyname 'bundles' -notepropertyvalue $bundleList
- Convert the data to JSON format and output it to a file by running the following command:
1$json | ConvertTo-Json | Out-File $outJson
That completes the process of generating the JSON spec used by the public API for downloading bundles, we are now ready to start the bundle download process.
Download the generateBundleJson.ps1
script from GitHub
.
Download the bundles
Procedure
Start Windows PowerShell.
Replace the values in the sample code with values for the instance of VMware Cloud Foundation and run the commands in the PowerShell console.
1$sddcManagerFqdn = "lax-vcf01.lax.rainpole.io"
2$sddcManagerUser = "[email protected]"
3$sddcManagerPass = "VMw@re1!"
4$jsonFile = "vcf4510Bundles.json"
- Download the bundles by running the following command:
1requestBundleDownload.ps1 -server $sddcManagerFqdn -user $sddcManagerUser -pass $sddcManagerPass -json $jsonFile