When using the vSphere Replication Plug-in through VMware Aria Automation with a combination of configuration elements, you cannot retrieve the correct remote site object.

Problem

You cannot retrieve the virtual machine, because the incorrect remote site object ( VR:VcRemoteSite) was selected, after being stored in a configuration element. The process fails with the following error:

The object '<VM_ID>' has already been deleted or has not been completely created

Cause

This problem can occur, because the source and remote sites are internally presented as a map within a map. For each pair of source and remote site, there are four relations, which represent each possible direction of a replication:

  • Source site – Source site (a relation within the respective site)
  • Source site – Remote site (direction of the replication between sites)
  • Remote site – Remote site (a relation within the respective site)
  • Remote site – Source site (direction of the replication between sites)

There is one map containing the Source and Remote objects for the local sites. Each of these elements contains another map of the Source and Remote objects for the remote sites. There is a total of four elements for remote sites, but only two of them have unique IDs. The VMware Aria Automation configuration element keeps information only for the ID of the stored object and not the ID of its parent, which can lead to retrieving the incorrect remote site object.

Solution

Select the parent of the remote site and select the correct remote site by using the following script:
for each(var el in localSites) {
    if (el.name == 'SOURCE_SITE_NAME') { 
        var remotesites = el.getVcRemoteSites() 
        for each( var rsite in remotesites){ 
            if (rsite.name == 'REMOTE_SITE_NAME') {
                remoteSiteSelected = rsite; 
            }
        } 
    } 
}