How to manually remove a Content Library from vCenter Server Appliance when the datastore it resided on is no longer accessible or the Content Library has been corrupted
search cancel

How to manually remove a Content Library from vCenter Server Appliance when the datastore it resided on is no longer accessible or the Content Library has been corrupted

book

Article ID: 326242

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

Symptoms - Some or all may apply to the environment:
  • A Content Library cannot be deleted from the vSphere Web UI.

  • When attempting to delete the Content Library using the vSphere Web UI, the task fails.

  • The backing datastore for the Content Library is no longer accessible after the datastore has been unmounted and/or removed from hosts.

  • The Content Library was corrupted from accidental deletion of the Content Library items from disk or due to a corrupted content library item uploaded to the library resulting in new items failing to deploy from the Content Library.



Environment

VMware vCenter Server 8.0.x
VMware vCenter Server 7.0.x
VMware vCenter Server 6.x

Cause

Part of the deletion process for a Content Library is cleaning up the Content Library files which reside on a VMFS datastore.
If this part of the workflow fails, the deletion process can run into an error and the Content Library fails to delete completely. The CL may still show content with size and details, but the data does not exist on disk.

Resolution

Note: The steps below are irreversible. Before you make those changes, please ensure that you have created a fresh backup or snapshot of the vCenter Server. If the vCenter Server is a member of an Enhanced Linked Mode (ELM) replication setup, please keep in mind that you need to create backups or offline snapshots (in powered off state) for all ELM nodes. Similarly, when you need to restore the backup of this vCenter, or roll back to the snapshot, all of the other ELM nodes need to be restored/rolled back as well. For more information, please see https://knowledge.broadcom.com/external/article/313886.

 

To remove the Content Library from vCenter, connect to the vCenter Database using to psql tool in the VCSA:

# /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres


Then:

  1. In psql run the following query to find the ID of the Content Library that it to be deleted (replace <cl_name> with the name of the Content Library):
    # select id,name from cl_library where name = '<cl_name>';
  2. Use the Content Library ID to find the storage ID:
    # select * from cl_library_storage where library_id = '<ID from step 1>';
  3. Using the 2 IDs, delete the Entries for the Content Library:
    # delete from cl_library_storage where library_id = '<ID from step 1>';
    # delete from cl_storage where id = '<storage_id from step 2>';
    # delete from cl_library where name = '<cl_name>';
  4. Exit psql comm and line using '\q'
  5. Restart the vCenter Services and verify the vSphere Web UI no longer lists the deleted Content Library:
    # service-control --stop --all && service-control --start --all