WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / Automation / How to delete an ESXi component in vSphere Lifecycle Manager (vLCM) depot?

How to delete an ESXi component in vSphere Lifecycle Manager (vLCM) depot?

11.16.2022 by William Lam // 1 Comment

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)

More from my site

  • Is my vSphere Cluster managed by vSphere Lifecycle Manager (vLCM) as a Desired Image or Baseline?
  • How to configure Hardware Compatibility List (HCL) database for vSphere Lifecycle Manager (vLCM) in an air-gapped environment?
  • How to automate checking for new vCenter Server updates in vSphere Lifecycle Manager (vLCM)?
  • Creating custom ESXi images using vSphere Lifecycle Manager (vLCM) UI and PowerCLI cmdlets for vSphere 8
  • Using vSphere Lifecycle Manager (vLCM) to remediate Nested ESXi host with CPU on the host is not supported 

Categories // Automation, ESXi, vSphere 7.0, vSphere 8.0 Tags // vSphere Lifecycle Manager

Comments

  1. edtechlvm says

    03/08/2023 at 11:38 am

    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.

    Reply

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native technologies, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC)

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • How to disable the Efficiency Cores (E-cores) on an Intel NUC? 03/24/2023
  • Changing the default HTTP(s) Reverse Proxy Ports on ESXi 8.0 03/22/2023
  • NFS Multi-Connections in vSphere 8.0 Update 1 03/20/2023
  • Quick Tip - How to download ESXi ISO image for all releases including patch updates? 03/15/2023
  • SSD with multiple NVMe namespaces for VMware Homelab 03/14/2023

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2023

 

Loading Comments...