Architecting a vCloud Director Solution : vCloud Director Design : 7.7 vApps : 7.7.4 VM Auto Import
   
7.7.4 VM Auto Import
vCloud Director 8.20 provides a VM auto import feature. The system administrator can simply drag any vSphere VM into an Org VDC resource pool and vCloud Director automatically discovers the VM and imports it. The VM can even be in the running state. This enables migration use cases, or allows service providers to easily offer self-service access to their fully managed vSphere only environments by simply connecting them to vCloud Director.
For each imported VM a separate special vApp is created with a Discovered prefix. While these vApps resemble regular vApps, they are not real vCloud Director vApps until they are adopted. The adoption takes place when the VM inside the vApp is somehow reconfigured after being imported to vCloud Director for management.
By default, VM discovery is enabled for every Organization in vCloud Director. It can be disabled in General Settings (UI or API) or with CMT command on VCD cell:
cell-management-tool manage-config -n managed-vapp.discovery.activated -v false
This behavior can be overridden at the Org VDC level with the <VmDiscoveryEnabled> API element.
Differences between a discovered and an adopted vApp are described here.
Discovered vApp:
Looks like a regular vApp
Can have only one VM per discovered vApp
vApp contains API element <autoNature>true</autoNature>
When the imported VM is deleted in VC or VCD, its vApp object is automatically purged
Is owned by the system
Is not subject to Org lease settings
Adopted vApp:
Treated as a regular vCloud Director vApp
Can contain multiple VMs, vApp networks, and so forth
A discovered vApp is adopted when it is reconfigured
Other considerations include the following:
The discovery process runs in the background every 3 minutes
A failed VM import is retried after 60 minutes. This can be changed with the CMT command. The following is an example using 25 seconds:
cell-management-tool manage-config -n managed-vapp.discovery.retry-delay-sec -v 25
The following VMs cannot be imported: Fault Tolerant VMs, VMs with creation/upload process in vCenter Server, templates, vCloud Director shell VMs
VMs must be connected to an Org VDC network
VMs can be running or powered off
VMs do not need to use an Org VDC storage policy. If it resides on an unknown storage policy, it is automatically relocated to the default Org VDC storage policy during the adoption. However, the VM must be in the powered off state.
VMs with IDE controllers must be in powered off state
VM CPU/RAM resources are changed based on Org VDC allocation type
VM resources are not subject to Org VDC allocation restrictions, but are charged against it
The VM name in vCenter Server remains intact until it is adopted and renamed
New vSphere 6.5 guest operating systems are not recognized and are imported as Other (32-bit) OS
By default, the minimal VM age is configured to 1 hour. This means VMs that were freshly reconfigured are skipped for the import. This is to “settle” the VMs first. The interval can however be changed with the following CMT command. In this example, the age set to 60 seconds.
cell-management-tool manage-config -n VM_DISCOVERY_MIN_AGE_SEC -v 60
Related to the minimal age, it is important that all cells and the vCloud database are using the same time configuration. Not only must the time be correct, but the time zone must also be configured identically.