vSphere Lifecycle Manager (vLCM) allows users to upload an ESXi component into its depot using the Import Updates operation in the vSphere UI, but deleting an ESXi component from the vLCM depot is currently not possible when using the vSphere UI.
However, using the vLCM REST API we can delete an ESXi component from the vLCM depot with the Settings Depots Offline APIs. To demonstrate these specific vLCM REST APIs, I will be using PowerCLI (Connect-CisServer) but you can also use the vLCM REST API directly via any REST Client.
Step 1 - We first need to find our specific ESXi component and its ID by using the List Depots Offline API. By default, you will find ESXi components that are uploaded by users as well as ESXi components that are managed by vCenter Server such as the vSphere with Tanzu and vSphere HA ESXi components. The easiest way to filter out the managed ESXi components is by looking at the ESXi component owner. In my example, I am filtering by administrator account but you can certainly filter by other users who may have uploaded an ESXi component into vLCM.
$owner = 'administrator[at]vsphere[dot]local' $offlineDepotService = Get-CisService -Name com.vmware.esx.settings.depots.offline $allComponents = $offlineDepotService.list() $results = @() foreach ($component in $allComponents.GetEnumerator()) { if($component.Value.owner.toLower() -eq $owner) { $tmp = [PSCustomObject] @{ ComponentId = $component.Key } $results += $tmp } } $results
As you can see from the output above, there are two ESXi components that match the filter. Ideally, this is the only vLCM API that is required to find the specific ESXi component and its ID, but I found out that the vLCM UI currently does not use the description field from an uploaded ESXi component, which means that the description field is currently left blank and it is impossible to identify the ESXi component that you see in the vSphere UI. I have already filed a feature request to ensure that the vLCM UI will use the description provided by an ESXi component, so that the next step will no longer be required in the future.
Step 2 - With the list of ESXi Component IDs, we now need to use the Get Depots Offline API to check the individual ESXi component to confirm whether that is the ESXi component we wish to delete.
$componentId = "29ABE68C1AE400945FBA10491BA21AB53F9279C3" $offlineDepotContentService = Get-CisService -Name com.vmware.esx.settings.depots.offline.content $componentDetails = $offlineDepotContentService.get($componentId).metadata_bundles $results = @() foreach ($componentDetail in $componentDetails.GetEnumerator()) { foreach ($component in $componentDetail.Value.independent_components.GetEnumerator()) { $tmp = [PSCustomObject] @{ ComponentName = $component.Key ComponentVersion = $component.Value.versions.version ComponentDirectory = $componentDetail.Key ComponentFile = $componentDetail.Value.file_name } $results += $tmp } } $results
As you can see from the output above, the second ESXi component ID is the one we are actually after. In addition to ESXi component name and version, the output also contains two additional fields which might be of interests to those interested in knowing where the ESXi components actually reside within the vCenter Server filesystem. All uploaded ESXi components are stored in a sub-directory under /storage/updatemgr/patch-store/hostupdate and the ComponentFileDirectory provides the name of the sub-directory for that given ESXi component.
In our example, the ESXi component is stored in /storage/updatemgr/patch-store/hostupdate/VMX and the metadata filename which is provided as part of the ComponentFile is called metadata-39.zip. This of course is for informational purposes, you should never manually manipulate the filesystem but instead use the vLCM API as mentioned in this blog post to remove ESXi components that are no longer required.
Step 3 - Lastly, to delete our desired ESXi component, we need to use the Delete Depots Offline API and provide the ESXi component ID.
$componentToDelete = "18EC0E31AA9E1376F099CF2A2528832005D0E961" $offlineDepotService = Get-CisService -Name com.vmware.esx.settings.depots.offline $offlineDepotService.delete($componentToDelete)
Everything went through and I was able to delete the two components. However, they still show under the vLCM Image Depot. Any ideas how to refresh or make them disappear? Thank you and great article.
Same problem for me. Component deleted from the API but is still shown in the web UI.
Maybe it's due to this:
The task-based {@name #delete} {@term operation} removes content of an imported offline depot from vLCM completely. Note: The non task-based {@name #delete} {@term operation} has been deprecated. It deletes only the record of depot from the list of imported offline software depots, instead of removing the depot's content from vLCM.