Symptoms:
VMware Cloud Director 10.x
VMware Cloud Director for Service Provider 10.x
This issue occurs when the VMs being provisioned have null datastore moref values in the VCD database
This issue is resolved by performing the following steps:
1. Take the snapshot for all VCD cell
2. Take the DB backup before proceeding with the below steps
3. SSH to the Primary Cell using Putty or other SSH Client
4. Login to the Postgres database: sudo -u postgres psql vcloud
5. Execute the query below:
***NOTE: This only impacts VMs with NULL dstore_moref values and has no impact on functional VMs***
select 'update vm set dstore_moref = ' || '''' || datastore_inv.moref || '''' || ' where id = ' || '''' || vm.id || '''' || ';' from vm
inner join vapp_vm on vapp_vm.svm_id = vm.id
inner join vm_inv on vm_inv.moref = vm.moref
inner join datastore_inv on datastore_inv.vc_display_name = (substring(vm.location_path,2,(POSITION(']' in vm.location_path))-2))
where vm.dstore_moref is NULL and vm_inv.is_deleted is false;
6. The above query will generate a series of "update" statements that can be executed to update all VMs with a null dstore_moref. An example output is shown below:
update vm set dstore_moref = 'datastore-123' where id = '########-####-####-####-#############';
update vm set dstore_moref = 'datastore-456' where id = '########-####-####-####-#############';
Workaround: