Unable to list Orphaned VMs in VMware Cloud Director using cell-management-tool
search cancel

Unable to list Orphaned VMs in VMware Cloud Director using cell-management-tool

book

Article ID: 430853

calendar_today

Updated On:

Products

VMware Cloud Director VMware vSphere ESXi

Issue/Introduction

  • When attempting to list orphaned VMs using the "./cell-management-tool find-orphan-vms --host VCD_IP -u <admin_user> -vc-name <vcenter_name> -vc-password <vcenter_password> --vc-user <vcenter_administrator_user> --output-file -" command in VMware Cloud Director, the operation fails with an unexpected execution exception.

    The error message indicates:

Unexpected error during command execution: Exception(s) during execution (See log file.), Root Cause: Exception(s) during execution (See log file.)
Refer to cell-management-tool.log for more details

  • Error messages similar to the following appear in /opt/vmware/vcloud-director/logs/vcloud-container-debug.log file indicating a  SSL handshake from VCD to vCenter with the following error:

    DEBUG | pool-1-thread-9 | FindOrphanVmsCommand | Exception while processing vdc |
    com.vmware.vim.vmomi.client.exception.SslException: com.vmware.vim.vmomi.core.exception.CertificateValidationException: SSL handshake from 0.0.0.0/0.0.0.0:37
    780 to <VCENTER_FQDN>/##.##.##.##:443 failed in 76 ms
            at com...
    Caused by: com.vmware.vim.vmomi.core.exception.CertificateValidationException: SSL handshake from 0.0.0.0/0.0.0.0:37780 to <VCENTER_FQDN>/##.##.##.##:443 failed in 76 ms

Environment

VMware Cloud Director 10.6.x

Cause

This is a known issue in VMware Cloud Director where the cell-management-tool (CMT) intermittently encounters closed database sessions causing the command execution to fail.

Resolution

Broadcom is aware of this issue and a fix is planned for an upcoming release of VMware Cloud Director. Please subscribe to this KB by following the steps in the article:Subscribe an article for future updates on the resolution.

Workaround:

As a temporary workaround, use the following query to identify VMs that exist in an Org VDC resource pool but are not managed by VMware Cloud Director (equivalent to the find-orphan-vms CMT command):

a. Log in directly or by using an SSH client to the primary appliance console as root.

b. Connect to the Cloud Director database using the below command:

sudo -i -u postgres psql vcloud

c. Run the following query to list the orphaned VMs:


WITH vmi AS (
  SELECT
    vm_inv.moref,
    vm_inv.vc_id,
    org_prov_vdc_rp_view.rp_name   AS res_group_name,
    org_prov_vdc_rp_view.rp_moref  AS res_group_moref
  FROM vm_inv
  JOIN org_prov_vdc_rp_view
    ON vm_inv.resource_pool_moref = org_prov_vdc_rp_view.rp_moref
   AND vm_inv.vc_id               = org_prov_vdc_rp_view.vc_id
  WHERE vm_inv.is_deleted = false
    AND vm_inv.is_vrouter = false
    AND NOT EXISTS (SELECT 1 FROM shadow_vm sv
                   WHERE sv.vc_id = vm_inv.vc_id AND sv.moref = vm_inv.moref)
    AND NOT EXISTS (SELECT 1 FROM multi_vc_vm mvv
                   WHERE mvv.vc_id = vm_inv.vc_id AND mvv.moref = vm_inv.moref)
    AND NOT EXISTS (SELECT 1 FROM disk d
                   WHERE d.vc_id = vm_inv.vc_id AND d.shell_vm_moref = vm_inv.moref)
)
SELECT
  vm_inv.name,
  vmi.res_group_name,
  vm_inv.moref,
  vm_inv.vc_id
FROM vm_inv
JOIN vmi
  ON vmi.moref = vm_inv.moref AND vmi.vc_id = vm_inv.vc_id
WHERE NOT EXISTS (
  SELECT 1 FROM vm
  WHERE vm.moref = vm_inv.moref AND vm.vc_id = vm_inv.vc_id
);