code: public ManagedEntity findByDnsName(Datacenter datacenter, String dnsName, boolean vmOnly) throws RuntimeFault, RemoteException {
          ManagedObjectReference mor = getVimService().findByDnsName(getMOR(), datacenter == null ? null : datacenter.getMOR(), dnsName, vmOnly);
          return MorUtil.createExactManagedEntity(getServerConnection(), mor);
      }
docs: Find a VM or Host by its DNS name
  
  @param datacenter The datacenter within which it searches. If null is passed, all inventory is searched.
  @param dnsName    DNS name like "dev.eng.vmware.com"
  @param vmOnly     When set true only searches for VM; otherwise only for Host.
  @return A ManagedEntity to either HostSystem or VirtualMachine having the DNS name.
  @throws RemoteException
  @throws RuntimeFault