Removing stale/ghost Virtual Machine templates from Content Library when standard deletion fails with "Operation Not Supported" or the Option is Grayed Out
search cancel

Removing stale/ghost Virtual Machine templates from Content Library when standard deletion fails with "Operation Not Supported" or the Option is Grayed Out

book

Article ID: 435189

calendar_today

Updated On:

Products

VMware vCenter Server VMware vCenter Server 8.0

Issue/Introduction

  • When attempted to removed Virtual Machine Templates from Content Libraries, Vtemplates may become "ghost" or stale items that cannot be deleted.
  • Attempting to remove these items from the vCenter Server inventory or Content Library UI results in failure.
  • Users may see the following error messages when attempting to delete these Virtual Machine Template from the Content Library
    • A general system error occurred: Operation failed.
    • The operation is not supported on the object.
    • Cannot find library item [UUID] in the storage backing.
  • The option to delete these template is unavailable or grayed out.

Environment

  • VMware vCenter Server 7.x
  • VMware vCenter Server 8.x

Cause

A metadata-inventory mismatch occurs when the physical backing files (.vmtx, .ovf, .vmdk) are removed from the datastore before the deletion is initiated within the Content Library interface. vCenter maintains a database reference in the `cl_libraryitem` table to a null file path. The deletion operation aborts because the storage layer cannot locate the source objects required to complete the task.

Resolution

Note: If the vCenter is apart of Enhanced Linked Mode, then please review VMware vCenter in Enhanced Linked Mode pre-changes snapshot (online or offline) best practice and take offline snapshots of every vCenter node in Enhanced Linked mode.

Preliminary Checks:

  1. Navigate to the Content Library view in the vCenter Web Client.
  2. Right-click the stale template and select Remove from Inventory
  3. If the option is greyed out or the entry persists in the Content Library UI, then take note of the UUID of the stale Template from the list.
    For Example, Windows-Test-Gold is unable to be removed:

Removing the Stale Template

  1.  Log into the vCenter via an SSH session (How to enable SSH service on vCenter Server Appliance) and stop the Content Library, vCenter Server (vpxd and UI) services with the following command:
    service-control --stop vmware-content-library && service-control --stop vpxd && service-control --stop vsphere-ui


  2. Using the following command, make sure the UUID matches what we saw in the vCenter UI and record the UUID:
    /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c "SELECT id, name, libraryid FROM cl_libraryitem;"


  3. Delete the stale template with the following command, be sure to replace YOUR_ITEM_ID with the correct id, if successful the line will return as "DELETE 1":
    /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c "DELETE FROM cl_libraryitem WHERE id = 'YOUR_ITEM_UUID';"

    For Example:
    /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c "DELETE FROM cl_libraryitem WHERE id = 'ad93f0b4-67b4-4b49-b541-0a1189084ab1';"
  4. List the templates again to confirm removal:
    /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c "SELECT id, name, libraryid FROM cl_libraryitem;"


  5. Restart the vCenter services with the following command:
    service-control --start --all


  6. Log back into the vCenter UI and confirm that the template has been removed.

You may need to resynchronize the content library for newer images to appear

  1. Log in to the vSphere Client.
  2. Navigate to the Publisher Content Library.
  3. Right-click the library and select Synchronize to propagate the database changes to all remote subscribed libraries.