VMware Cloud Director
Any stale vApps/vApp templates/media can be identified from the database and then verified in the UI.
1. Note the name of the affected OVDC and the storage policy to-be-removed. The scripts listed in Step 3 and 4 will need these names and have to be replaced accordingly.
2. Connect to the VCD database via SSH or pgAdmin
sudo -u postgres psql vcloud
3. To find the list of vApps or vApp templates referencing the storage policy available on the tenant
SELECT
vapp_vm.name AS vapp_vm_name,
vm_container.name as vapp_name,
vm_container.sg_type as type,
vm.moref as moref,
vapp_vm_sclass_metrics.storage_used_mb
FROM vapp_vm_sclass_metrics
LEFT JOIN vapp_vm ON vapp_vm.id = vapp_vm_sclass_metrics.vapp_vm_id
LEFT JOIN vm_container ON vm_container.sg_id = vapp_vm.vapp_id
left join vm on vm.id = vapp_vm.svm_id
JOIN vdc_logical_resource ON vdc_logical_resource.id = vapp_vm_sclass_metrics.storage_class_lr_id
JOIN org_prov_vdc ON org_prov_vdc.id = vdc_logical_resource.vdc_id
WHERE org_prov_vdc.name = 'Organization VDC Name' AND vdc_logical_resource.name = 'Storage policy to-be-removed';
Note: type column with value 1 would mean it is a normal vApp and value 2 would mean it is a vApp template.
4. To find the list of media items that may still be present in the storage profile to be removed.
SELECT
org_prov_vdc.name AS org_vdc_name,
logical_disk.id AS logical_disk_id,
logical_disk.name AS logical_disk_name,
logical_disk.logical_disk_type,
logical_disk.creation_status AS logical_creation_status,
COALESCE((logical_disk.size_bytes::numeric / 1048576.0), 0::numeric) AS storage_used_mb
FROM logical_disk
LEFT JOIN ldisk_storage_class_join ON logical_disk.id = ldisk_storage_class_join.logical_disk_id
LEFT JOIN ldisk_fo_join ON logical_disk.id = ldisk_fo_join.logical_disk_id
LEFT JOIN vm_disk ON vm_disk.disk_id = ldisk_fo_join.fo_id
LEFT JOIN org_prov_vdc ON org_prov_vdc.id = logical_disk.org_vdc_id
LEFT JOIN vdc_logical_resource ON vdc_logical_resource.id = ldisk_storage_class_join.storage_class_id
where org_prov_vdc.name like '%Organization VDC Name%';
5. For the catalogs in the organizations, verify the Storage Policies settings as per the documentations below:
6. Migrate the VMs/vApps/media identified Steps 3 or 4 OR change the storage policy on them.
Edit the Default Storage Policy of a vApp Template
Edit Virtual Machine Properties in the VMware Cloud Director Tenant Portal
If the UI method(s) does not work, contact VMware Cloud Director Support and note this Article ID (371259) in the problem description.